llvm-project/clang/unittests/Analysis
Sam Estep 300fbf56f8 [clang][dataflow] Analyze calls to in-TU functions
This patch adds initial support for context-sensitive analysis of simple functions whose definition is available in the translation unit, guarded by the `ContextSensitive` flag in the new `TransferOptions` struct. When this option is true, the `VisitCallExpr` case in the builtin transfer function has a fallthrough case which checks for a direct callee with a body. In that case, it constructs a CFG from that callee body, uses the new `pushCall` method on the `Environment` to make an environment to analyze the callee, and then calls `runDataflowAnalysis` with a `NoopAnalysis` (disabling context-sensitive analysis on that sub-analysis, to avoid problems with recursion). After the sub-analysis completes, the `Environment` from its exit block is simply assigned back to the environment at the callsite.

The `pushCall` method (which currently only supports non-method functions with some restrictions) maps the `SourceLocation`s for all the parameters to the existing source locations for the corresponding arguments from the callsite.

This patch adds a few tests to check that this context-sensitive analysis works on simple functions. More sophisticated functionality will be added later; the most important next step is to explicitly model context in some fields of the `DataflowAnalysisContext` class, as mentioned in a `FIXME` comment in the `pushCall` implementation.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D130306
2022-07-26 17:54:27 +00:00
..
FlowSensitive [clang][dataflow] Analyze calls to in-TU functions 2022-07-26 17:54:27 +00:00
CFGBuildResult.h
CFGDominatorTree.cpp [NFC][Clang][test] Inclusive language: Remove and rephrase uses of sanity test/check in clang/test 2021-11-24 14:03:49 -05:00
CFGTest.cpp
CMakeLists.txt [Testing] Drop clangTesting from clang's public library interface 2022-04-20 13:28:44 +02:00
CloneDetectionTest.cpp
ExprMutationAnalyzerTest.cpp [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables 2022-07-24 19:37:54 +02:00
MacroExpansionContextTest.cpp [clang] Use value instead of getValue (NFC) 2022-07-13 23:39:33 -07:00