[clang][dataflow] Fix 2 bugs in `MemberExpr` interpretation.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Mon, 9 Jan 2023 22:54:53 +0000 (22:54 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 10 Jan 2023 15:48:00 +0000 (15:48 +0000)
commit3ce03c42dbb46531968c527d80c0243c2db7bc0e
tree37cd99536da16e65e0530e87650605821f23ba97
parent03b83cd703d403cdfd6f0082423f99aae08d3606
[clang][dataflow] Fix 2 bugs in `MemberExpr` interpretation.

There were two (small) bugs causing crashes in the analysis.  This patch fixes both of them.

1. An enum value was accessed as a class member. Now, the engine gracefully
ignores such member expressions.

2. Field access in `MemberExpr` of struct/class-typed global variables. Analysis
didn't interpret fields of global vars, because the vars were initialized before
the fields were added to the "allowlist". Now, the allowlist is set _before_
init of globals.

Differential Revision: https://reviews.llvm.org/D141384
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp