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 | b5204ee30229c76f8a0be48800508483737ceb5a (patch) | |
tree | e41d66e6b403f71f2381e0cc99e3dae0c5bee40f /lib/StaticAnalyzer/Core/CoreEngine.cpp | |
parent | 0b4db3e08a201c35f0011489bd5cd5d39bbe54fb (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/CoreEngine.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/CoreEngine.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp index 8b7eeef470..84d2cc6545 100644 --- a/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/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()); |