Skip to content

Commit 6b07c41

Browse files
committed
Adding fixme tests for implicit this parameter
1 parent 4070e29 commit 6b07c41

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

clang/lib/Analysis/LifetimeSafety/Checker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LifetimeChecker {
6969
else if (const auto *OEF = F->getAs<OriginEscapesFact>())
7070
checkAnnotations(OEF);
7171
issuePendingWarnings();
72-
issueAnnotationWarnings();
72+
suggestAnnotations();
7373
}
7474

7575
/// Checks if an escaping origin holds a placeholder loan, indicating a
@@ -154,7 +154,7 @@ class LifetimeChecker {
154154
}
155155
}
156156

157-
void issueAnnotationWarnings() {
157+
void suggestAnnotations() {
158158
if (!Reporter)
159159
return;
160160
for (const auto &[PVD, EscapeExpr] : AnnotationWarningsMap)

clang/test/Sema/warn-lifetime-safety-suggestions.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,31 @@ View reassigned_to_another_parameter (
6464
return a; // expected-note {{param returned here}}
6565
}
6666

67+
struct ReturnsSelf {
68+
const ReturnsSelf& get() const {
69+
return *this;
70+
}
71+
};
72+
73+
struct ViewProvider {
74+
MyObj data;
75+
View getView() const {
76+
return data;
77+
}
78+
};
79+
80+
// FIXME: Fails to generate lifetime suggestions for the implicit 'this' parameter, as this feature is not yet implemented.
81+
void test_get_on_temporary() {
82+
const ReturnsSelf& s_ref = ReturnsSelf().get();
83+
(void)s_ref;
84+
}
85+
86+
// FIXME: Fails to generate lifetime suggestions for the implicit 'this' parameter, as this feature is not yet implemented.
87+
void test_getView_on_temporary() {
88+
View sv = ViewProvider{1}.getView();
89+
(void)sv;
90+
}
91+
6792
//===----------------------------------------------------------------------===//
6893
// Negative Test Cases
6994
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)