File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,8 @@ Improvements to Clang's diagnostics
371371
372372 - An error is now emitted when a ``musttail `` call is made to a function marked with the ``not_tail_called `` attribute. (#GH133509).
373373
374+ - The ``-Wloop-analysis `` warning now handles variable modifications inside lambda expressions (#GH132038).
375+
374376Improvements to Clang's time-trace
375377----------------------------------
376378
Original file line number Diff line number Diff line change @@ -2002,9 +2002,26 @@ namespace {
20022002 }
20032003
20042004 void VisitDeclRefExpr (DeclRefExpr *E) {
2005- if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl ()))
2005+ if (VarDecl *VD = dyn_cast<VarDecl>(E->getDecl ())) {
20062006 if (Decls.count (VD))
20072007 FoundDecl = true ;
2008+ } else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(E->getDecl ());
2009+ MD && isLambdaCallOperator (MD)) {
2010+ for (const auto &Capture : MD->getParent ()->captures ()) {
2011+ if (!Capture.capturesVariable ())
2012+ continue ;
2013+
2014+ if (VarDecl *VD = dyn_cast<VarDecl>(Capture.getCapturedVar ())) {
2015+ if (Decls.count (VD))
2016+ FoundDecl = true ;
2017+ }
2018+ }
2019+ }
2020+ }
2021+
2022+ void VisitCXXOperatorCallExpr (CXXOperatorCallExpr *E) {
2023+ if (Expr *Callee = E->getCallee ())
2024+ Visit (E->getCallee ());
20082025 }
20092026
20102027 void VisitPseudoObjectExpr (PseudoObjectExpr *POE) {
@@ -2021,7 +2038,7 @@ namespace {
20212038
20222039 bool FoundDeclInUse () { return FoundDecl; }
20232040
2024- }; // end class DeclMatcher
2041+ }; // end class DeclMatcher
20252042
20262043 void CheckForLoopConditionalStatement (Sema &S, Expr *Second,
20272044 Expr *Third, Stmt *Body) {
Original file line number Diff line number Diff line change @@ -299,3 +299,18 @@ void test10() {
299299 for (auto [i, j, k] = arr; i < a; ++i) { }
300300 for (auto [i, j, k] = arr; i < a; ++arr[0 ]) { }
301301};
302+
303+ extern void foo (int );
304+ void test11 () {
305+ int a = 0 ;
306+ auto incr_a = [&a]() { ++a; };
307+
308+ for (int b = 10 ; a <= b; incr_a ())
309+ foo (a);
310+
311+ for (int b = 10 ; a <= b;)
312+ incr_a ();
313+
314+ for (int b = 10 ; a <= b; [&a]() { ++a; }()) { }
315+ for (int b = 10 ; a <= b; [&a]() { }()) { }
316+ }
You can’t perform that action at this time.
0 commit comments