2013-12-10 03:04:43 +08:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
Support
|
|
|
|
)
|
|
|
|
|
2008-10-26 08:56:18 +08:00
|
|
|
add_clang_library(clangAnalysis
|
2011-10-24 09:32:45 +08:00
|
|
|
AnalysisDeclContext.cpp
|
2012-09-21 08:09:11 +08:00
|
|
|
BodyFarm.cpp
|
2009-07-17 02:13:04 +08:00
|
|
|
CFG.cpp
|
2011-02-23 09:51:59 +08:00
|
|
|
CFGReachabilityAnalysis.cpp
|
2010-08-05 02:23:15 +08:00
|
|
|
CFGStmtMap.cpp
|
2012-09-13 08:21:31 +08:00
|
|
|
CallGraph.cpp
|
2010-12-17 13:21:58 +08:00
|
|
|
CocoaConventions.cpp
|
2013-08-13 05:20:55 +08:00
|
|
|
Consumed.cpp
|
Add support for the static analyzer to synthesize function implementations from external model files.
Currently the analyzer lazily models some functions using 'BodyFarm',
which constructs a fake function implementation that the analyzer
can simulate that approximates the semantics of the function when
it is called. BodyFarm does this by constructing the AST for
such definitions on-the-fly. One strength of BodyFarm
is that all symbols and types referenced by synthesized function
bodies are contextual adapted to the containing translation unit.
The downside is that these ASTs are hardcoded in Clang's own
source code.
A more scalable model is to allow these models to be defined as source
code in separate "model" files and have the analyzer use those
definitions lazily when a function body is needed. Among other things,
it will allow more customization of the analyzer for specific APIs
and platforms.
This patch provides the initial infrastructure for this feature.
It extends BodyFarm to use an abstract API 'CodeInjector' that can be
used to synthesize function bodies. That 'CodeInjector' is
implemented using a new 'ModelInjector' in libFrontend, which lazily
parses a model file and injects the ASTs into the current translation
unit.
Models are currently found by specifying a 'model-path' as an
analyzer option; if no path is specified the CodeInjector is not
used, thus defaulting to the current behavior in the analyzer.
Models currently contain a single function definition, and can
be found by finding the file <function name>.model. This is an
initial starting point for something more rich, but it bootstraps
this feature for future evolution.
This patch was contributed by Gábor Horváth as part of his
Google Summer of Code project.
Some notes:
- This introduces the notion of a "model file" into
FrontendAction and the Preprocessor. This nomenclature
is specific to the static analyzer, but possibly could be
generalized. Essentially these are sources pulled in
exogenously from the principal translation.
Preprocessor gets a 'InitializeForModelFile' and
'FinalizeForModelFile' which could possibly be hoisted out
of Preprocessor if Preprocessor exposed a new API to
change the PragmaHandlers and some other internal pieces. This
can be revisited.
FrontendAction gets a 'isModelParsingAction()' predicate function
used to allow a new FrontendAction to recycle the Preprocessor
and ASTContext. This name could probably be made something
more general (i.e., not tied to 'model files') at the expense
of losing the intent of why it exists. This can be revisited.
- This is a moderate sized patch; it has gone through some amount of
offline code review. Most of the changes to the non-analyzer
parts are fairly small, and would make little sense without
the analyzer changes.
- Most of the analyzer changes are plumbing, with the interesting
behavior being introduced by ModelInjector.cpp and
ModelConsumer.cpp.
- The new functionality introduced by this change is off-by-default.
It requires an analyzer config option to enable.
llvm-svn: 216550
2014-08-27 23:14:15 +08:00
|
|
|
CodeInjector.cpp
|
2011-12-20 16:42:15 +08:00
|
|
|
Dominators.cpp
|
2010-07-16 10:11:22 +08:00
|
|
|
FormatString.cpp
|
2008-10-26 08:56:18 +08:00
|
|
|
LiveVariables.cpp
|
2012-09-13 08:21:31 +08:00
|
|
|
ObjCNoReturn.cpp
|
2011-10-22 10:14:23 +08:00
|
|
|
PostOrderCFGView.cpp
|
2010-01-28 07:43:25 +08:00
|
|
|
PrintfFormatString.cpp
|
2011-08-13 07:04:46 +08:00
|
|
|
ProgramPoint.cpp
|
2010-08-24 03:51:57 +08:00
|
|
|
PseudoConstantAnalysis.cpp
|
2010-02-23 10:39:16 +08:00
|
|
|
ReachableCode.cpp
|
2010-07-16 10:11:22 +08:00
|
|
|
ScanfFormatString.cpp
|
2011-09-10 00:11:56 +08:00
|
|
|
ThreadSafety.cpp
|
2014-05-10 02:26:23 +08:00
|
|
|
ThreadSafetyCommon.cpp
|
|
|
|
ThreadSafetyLogical.cpp
|
2014-05-15 08:50:36 +08:00
|
|
|
ThreadSafetyTIL.cpp
|
2011-03-15 11:17:07 +08:00
|
|
|
UninitializedValues.cpp
|
2009-03-17 07:06:59 +08:00
|
|
|
|
2014-02-26 14:41:29 +08:00
|
|
|
LINK_LIBS
|
2012-06-21 09:30:21 +08:00
|
|
|
clangAST
|
2014-07-14 12:59:27 +08:00
|
|
|
clangBasic
|
2014-07-14 13:01:53 +08:00
|
|
|
clangLex
|
2012-06-21 09:30:21 +08:00
|
|
|
)
|