diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-21 00:09:11 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-21 00:09:11 +0000 |
commit | a43df9539644bf1c258e12710cd69d79b0b078cd (patch) | |
tree | 1c77ba3f0325a80410c1568dc939c1306e80491a /include/clang/Analysis/AnalysisContext.h | |
parent | 445895a97ae3f1d7bad3480839d31ed3ebcc9c83 (diff) |
Implement faux-body-synthesis of well-known functions in the static analyzer when
their implementations are unavailable. Start by simulating dispatch_sync().
This change is largely a bunch of plumbing around something very simple. We
use AnalysisDeclContext to conjure up a fake function body (using the
current ASTContext) when one does not exist. This is controlled
under the analyzer-config option "faux-bodies", which is off by default.
The plumbing in this patch is largely to pass the necessary machinery
around. CallEvent needs the AnalysisDeclContextManager to get
the function definition, as one may get conjured up lazily.
BugReporter and PathDiagnosticLocation needed to be relaxed to handle
invalid locations, as the conjured body has no real source locations.
We do some primitive recovery in diagnostic generation to generate
some reasonable locations (for arrows and events), but it can be
improved.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/AnalysisContext.h')
-rw-r--r-- | include/clang/Analysis/AnalysisContext.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index 45dd24718a..0185e8b69a 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/include/clang/Analysis/AnalysisContext.h @@ -376,12 +376,17 @@ class AnalysisDeclContextManager { ContextMap Contexts; LocationContextManager LocContexts; CFG::BuildOptions cfgBuildOptions; + + /// Flag to indicate whether or not bodies should be synthesized + /// for well-known functions. + bool SynthesizeBodies; public: AnalysisDeclContextManager(bool useUnoptimizedCFG = false, bool addImplicitDtors = false, bool addInitializers = false, - bool addTemporaryDtors = false); + bool addTemporaryDtors = false, + bool synthesizeBodies = false); ~AnalysisDeclContextManager(); @@ -394,6 +399,10 @@ public: CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; } + + /// Return true if faux bodies should be synthesized for well-known + /// functions. + bool synthesizeBodies() const { return SynthesizeBodies; } const StackFrameContext *getStackFrame(AnalysisDeclContext *Ctx, LocationContext const *Parent, |