[PATCH] D102273: [analyzer] LoopUnrolling: fix crash when a loop counter is captured in a lambda by reference

Abbas Sabra via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 14 07:31:52 PDT 2021


AbbasSabra added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:185-186
+      return FD->getType()->isReferenceType();
+    } else {
+      assert(false && "Unknown captured variable");
+    }
----------------
vsavchenko wrote:
> But actually, it's a bit different with this one. I don't know exact details and rules how clang sema fills in the class for lambda.
> According to [[ https://en.cppreference.com/w/cpp/language/lambda | cppreference ]]:
> > For the entities that are captured by reference (with the default capture [&] or when using the character &, e.g. [&a, &b, &c]), it is unspecified if additional data members are declared in the closure type
> 
> It can be pretty much specified in clang, that's true, but it looks like in `DeadStoreChecker` we have a very similar situation and we do not assume that captured variable always have a corresponding field.
Yes, I based this on the fact that DeadStoreChecker considers it possible, but I have never faced a case where it does not have a corresponding field.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102273/new/

https://reviews.llvm.org/D102273



More information about the cfe-commits mailing list