mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
[analyzer] C++ initializers may require cleanups; look through these.
When the analyzer sees an initializer, it checks if the initializer contains a CXXConstructExpr. If so, it trusts that the CXXConstructExpr does the necessary work to initialize the object, and performs no further initialization. This patch looks through any implicit wrapping expressions like ExprWithCleanups to find the CXXConstructExpr inside. Fixes PR15070. llvm-svn: 173557
This commit is contained in:
parent
9c67267a7b
commit
9853371f24
@ -404,7 +404,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init,
|
||||
if (BMI->isAnyMemberInitializer()) {
|
||||
// Constructors build the object directly in the field,
|
||||
// but non-objects must be copied in from the initializer.
|
||||
const Expr *Init = BMI->getInit();
|
||||
const Expr *Init = BMI->getInit()->IgnoreImplicit();
|
||||
if (!isa<CXXConstructExpr>(Init)) {
|
||||
SVal FieldLoc;
|
||||
if (BMI->isIndirectMemberInitializer())
|
||||
|
@ -80,3 +80,33 @@ class StringWrapper {
|
||||
public:
|
||||
StringWrapper(const char *input) : str(strdup(input)) {} // no-warning
|
||||
};
|
||||
|
||||
|
||||
// PR15070 - Constructing a type containing a non-POD array mistakenly
|
||||
// tried to perform a bind instead of relying on the CXXConstructExpr,
|
||||
// which caused a cast<> failure in RegionStore.
|
||||
namespace DefaultConstructorWithCleanups {
|
||||
class Element {
|
||||
public:
|
||||
int value;
|
||||
|
||||
class Helper {
|
||||
public:
|
||||
~Helper();
|
||||
};
|
||||
Element(Helper h = Helper());
|
||||
};
|
||||
class Wrapper {
|
||||
public:
|
||||
Element arr[2];
|
||||
|
||||
Wrapper();
|
||||
};
|
||||
|
||||
Wrapper::Wrapper() /* initializers synthesized */ {}
|
||||
|
||||
int test() {
|
||||
Wrapper w;
|
||||
return w.arr[0].value; // no-warning
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user