[PATCH] D80171: [analyzer] LoopUnrolling: fix crash when a parameter is a loop counter

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 20 01:02:54 PDT 2020


vsavchenko added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp:167
 
+  const bool isParm = VD->getKind() == Decl::ParmVar;
+  // Reference parameters are assumed as escaped variables.
----------------
`getKind` function is only an implementation detail for `isa`/`cast`/`dan_cast` functions ([[ https://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates | docs ]]).  So, this condition would be better in the following form: `isa<ParmVarDecl>(VD)`.

NOTE: One good motivation here is that //maybe// in the future there will be some sort of new type of function parameters and it will be derived from `ParmVarDecl`.  In this situation, direct comparison with the kind of node will not work and probably won't be fixed by developers who introduced the new node, but `isa` approach will stay correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80171





More information about the cfe-commits mailing list