[PATCH] D77809: [Analyzer] Include typedef statements in CFG build.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 00:10:32 PDT 2020


balazske marked an inline comment as done.
balazske added inline comments.


================
Comment at: clang/lib/Analysis/CFG.cpp:2855
+
   VarDecl *VD = dyn_cast<VarDecl>(DS->getSingleDecl());
 
----------------
Szelethus wrote:
> How about `using`? How about some other shenanigans that obscure the size of the VLA? Can't we just retrieve the size from `VariableArrayType::getSizeExpr` after seeing this `VarDecl`, and add that to the block?
The current code does that, it gets the size with `getSizeExpr` and adds it. The loop is needed to support multiple array dimensions.

To support every other type that can contain VLA a similar code is needed as in `CodeGenFunction::EmitVariablyModifiedType` (go over the type chain and look not only for `VariableArrayType`). The current code works only if there is typedef (or type alias) with a plain VLA, maybe embedded into another.
If support for every other case is needed, it is a change on its own because the code that generates CFG for VLA declaration is wrong too (later in the same function, the new code is copied from that). For example `void (*vla)(int[x]);` does not work now (`x` is not included in CFG). This is better to do in a later patch, for now this more restricted functionality is better than nothing (it is not wrong, only do not support all, probably seldom used, cases).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77809





More information about the cfe-commits mailing list