diff options
author | Jordan Rose <jordan_rose@apple.com> | 2014-01-13 17:59:19 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2014-01-13 17:59:19 +0000 |
commit | c9176072e6aae5a7a1a1b17506fe9c35b3399787 (patch) | |
tree | cda6b2b334ed5debc521e3688289a26405731d3d /clang/lib/Analysis/AnalysisDeclContext.cpp | |
parent | 54f6bd59f57150234f5d99d564c57a5c628e7ed6 (diff) | |
download | llvm-c9176072e6aae5a7a1a1b17506fe9c35b3399787.zip llvm-c9176072e6aae5a7a1a1b17506fe9c35b3399787.tar.gz llvm-c9176072e6aae5a7a1a1b17506fe9c35b3399787.tar.bz2 |
[analyzer] Add a CFG node for the allocator call in a C++ 'new' expression.
In an expression like "new (a, b) Foo(x, y)", two things happen:
- Memory is allocated by calling a function named 'operator new'.
- The memory is initialized using the constructor for 'Foo'.
Currently the analyzer only models the second event, though it has special
cases for both the default and placement forms of operator new. This patch
is the first step towards properly modeling both events: it changes the CFG
so that the above expression now generates the following elements.
1. a
2. b
3. (CFGNewAllocator)
4. x
5. y
6. Foo::Foo
The analyzer currently ignores the CFGNewAllocator element, but the next
step is to treat that as a call like any other.
The CFGNewAllocator element is not added to the CFG for analysis-based
warnings, since none of them take advantage of it yet.
llvm-svn: 199123
Diffstat (limited to 'clang/lib/Analysis/AnalysisDeclContext.cpp')
-rw-r--r-- | clang/lib/Analysis/AnalysisDeclContext.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 79918a3..5a9b107 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -68,7 +68,8 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, bool addInitializers, bool addTemporaryDtors, bool synthesizeBodies, - bool addStaticInitBranch) + bool addStaticInitBranch, + bool addCXXNewAllocator) : SynthesizeBodies(synthesizeBodies) { cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG; @@ -76,6 +77,7 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, cfgBuildOptions.AddInitializers = addInitializers; cfgBuildOptions.AddTemporaryDtors = addTemporaryDtors; cfgBuildOptions.AddStaticInitBranches = addStaticInitBranch; + cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator; } void AnalysisDeclContextManager::clear() { |