[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 20 09:10:57 PDT 2021


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1649-1653
+  // NOTE: `VD` is always non-null if `Init` is non-null, so we can check for
+  // null only one of them.
+  const Expr *Init = VD->getAnyInitializer(VD);
   if (!Init)
     return None;
----------------
Wait. But if `VD` is null, you get a null-dereference.
But you already dereferenced `VD` multiple times, so it cannot be null.

Oh, but the `getAnyInitializer()` will overwrite it! That's a surprise.
TBH I would rather pass a fresh uninitialized pointer if you really need the exact decl which actually provided the initialized expression to make this behavior explicit.

That way, with a properly chosen name you could spare the NOTE comment as well.


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

https://reviews.llvm.org/D111542



More information about the cfe-commits mailing list