mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 13:06:09 +00:00

Inline them if possible - a separate flag is added to control this. The whole thing is under the cfg-temporary-dtors flag, off by default so far. Temporary destructors are called at the end of full-expression. If the temporary is lifetime-extended, automatic destructors kick in instead, which are not addressed in this patch, and normally already work well modulo the overally broken support for lifetime extension. The patch operates by attaching the this-region to the CXXBindTemporaryExpr in the program state, and then recalling it during destruction that was triggered by that CXXBindTemporaryExpr. It has become possible because CXXBindTemporaryExpr is part of the construction context since r325210. Differential revision: https://reviews.llvm.org/D43104 llvm-svn: 325282
23 lines
588 B
C++
23 lines
588 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=false -verify %s
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -DINLINE -verify %s
|
|
|
|
void clang_analyzer_eval(bool);
|
|
|
|
struct S {
|
|
int &x;
|
|
|
|
S(int &x) : x(x) { ++x; }
|
|
~S() { --x; }
|
|
};
|
|
|
|
void foo() {
|
|
int x = 0;
|
|
S(x).x += 1;
|
|
clang_analyzer_eval(x == 1);
|
|
#ifdef INLINE
|
|
// expected-warning@-2{{TRUE}}
|
|
#else
|
|
// expected-warning@-4{{UNKNOWN}}
|
|
#endif
|
|
}
|