diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-07 18:36:17 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-07 18:36:17 +0000 |
commit | 3c2713accf266a4ed5e8e564ce3874dd959c3a58 (patch) | |
tree | 7fa4a3aabf419da0fba89d07f7773e4fff837b87 /clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | |
parent | b759ede963b24e59136ce384839412361b4b564a (diff) | |
download | bcm5719-llvm-3c2713accf266a4ed5e8e564ce3874dd959c3a58.tar.gz bcm5719-llvm-3c2713accf266a4ed5e8e564ce3874dd959c3a58.zip |
[analyzer] Don't use the address of a temporary CFGElement.
GCC destroys temporary objects more aggressively than clang, so this
results in incorrect behavior when compiling GCC Release builds.
We could avoid this issue under C++11 by preventing getAs from being
called when 'this' is an rvalue:
template<class ElemTy> const ElemTy *getAs() const & { ... }
template<class ElemTy> const ElemTy *getAs() const && = delete;
Unfortunately, we do not have compatibility macros for this behavior yet.
This will hopefully fix PR13760 and PR13762.
llvm-svn: 163402
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CoreEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CoreEngine.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp index 8b7eeef470c..84d2cc65459 100644 --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -514,7 +514,8 @@ void CoreEngine::enqueueStmtNode(ExplodedNode *N, return; } - const CFGStmt *CS = (*Block)[Idx].getAs<CFGStmt>(); + CFGElement Elem = (*Block)[Idx]; + const CFGStmt *CS = Elem.getAs<CFGStmt>(); const Stmt *St = CS ? CS->getStmt() : 0; PostStmt Loc(St, N->getLocationContext()); |