Skip to content

Commit 8c258f4

Browse files
committed
Addressreview notes
1 parent 52499a2 commit 8c258f4

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ struct TransferFunctions : public StmtVisitor<TransferFunctions> {
480480
}
481481
Visit(Obj);
482482
}
483+
VisitCallExpr(CE);
483484
}
484485

485486
void VisitLambdaExpr(LambdaExpr *LE) {
@@ -495,12 +496,11 @@ struct TransferFunctions : public StmtVisitor<TransferFunctions> {
495496
Visit(MTE->getSubExpr());
496497
}
497498

498-
void VisitExprWithCleanups(FullExpr *FE) {
499-
Visit(FE->getSubExpr());
500-
}
499+
void VisitExprWithCleanups(FullExpr *FE) { Visit(FE->getSubExpr()); }
501500

502501
void VisitCXXConstructExpr(CXXConstructExpr *CE) {
503-
Visit(CE->getArg(0));
502+
if (CE->getNumArgs() > 0)
503+
Visit(CE->getArg(0));
504504
}
505505
};
506506
} // namespace

clang/test/SemaCXX/noreturn-vars.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,49 @@ extern void abc_02(func_type *);
226226
func_ptr();
227227
} // expected-warning {{function declared 'noreturn' should not return}}
228228

229-
[[noreturn]] void test_lambda() {
229+
[[noreturn]] void test_lambda_capture_ref() {
230230
func_type func_ptr = noret;
231231
[&func_ptr]() { func_ptr = ordinary; } ();
232232
func_ptr();
233233
} // expected-warning {{function declared 'noreturn' should not return}}
234234

235-
[[noreturn]] void test_lambda_var(int x) {
235+
[[noreturn]] void test_lambda_var_capture_ref() {
236236
func_type func_ptr = noret;
237-
auto LF = [&](){func_ptr = ordinary;};
237+
auto LF = [&func_ptr](){func_ptr = ordinary; };
238238
LF();
239239
func_ptr();
240240
} // expected-warning {{function declared 'noreturn' should not return}}
241+
242+
[[noreturn]] void test_lambda_capture_ref_all() {
243+
func_type func_ptr = noret;
244+
[&]() { func_ptr = ordinary; } ();
245+
func_ptr();
246+
} // expected-warning {{function declared 'noreturn' should not return}}
247+
248+
[[noreturn]] void test_lambda_var_capture_ref_all() {
249+
func_type func_ptr = noret;
250+
auto LF = [&](){func_ptr = ordinary; };
251+
LF();
252+
func_ptr();
253+
} // expected-warning {{function declared 'noreturn' should not return}}
254+
255+
[[noreturn]] void lambda_capture_by_value() {
256+
func_type func_ptr = noret;
257+
auto LF = [func_ptr](){ return func_ptr; };
258+
LF();
259+
func_ptr();
260+
}
261+
262+
[[noreturn]] void lambda_pass_by_ref() {
263+
func_type func_ptr = noret;
264+
auto LF = [](func_type &fptr){ fptr = ordinary; };
265+
LF(func_ptr);
266+
func_ptr();
267+
} // expected-warning {{function declared 'noreturn' should not return}}
268+
269+
[[noreturn]] void lambda_pass_by_value() {
270+
func_type func_ptr = noret;
271+
auto LF = [](func_type fptr){ fptr = ordinary; };
272+
LF(func_ptr);
273+
func_ptr();
274+
}

0 commit comments

Comments
 (0)