[analyzer] Inline constructors for any object with a trivial destructor.
This allows us to better reason about status objects, like Clang's own
llvm::Optional (when its contents are trivially destructible), which are
often intended to be passed around by value.
We still don't inline constructors for temporaries in the general case.
<rdar://problem/11986434>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162681 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/base-init.cpp b/test/Analysis/base-init.cpp
index e63d508..b8d0689 100644
--- a/test/Analysis/base-init.cpp
+++ b/test/Analysis/base-init.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -verify %s
-// XFAIL: *
void clang_analyzer_eval(bool);
diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp
index 9120627..65bd515 100644
--- a/test/Analysis/method-call.cpp
+++ b/test/Analysis/method-call.cpp
@@ -15,23 +15,22 @@
clang_analyzer_eval(a); // expected-warning{{TRUE}}
}
-
-// FIXME: These require constructor inlining to be enabled.
-
void f1() {
A x(3);
- // should be TRUE
- clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
void f2() {
const A &x = A(3);
- // should be TRUE
- clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
void f3() {
const A &x = (A)3;
- // should be TRUE
- clang_analyzer_eval(x.getx() == 3); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
+}
+
+void f4() {
+ A x = 3;
+ clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp
index fb77de2..fdd16da 100644
--- a/test/Analysis/new.cpp
+++ b/test/Analysis/new.cpp
@@ -74,6 +74,18 @@
}
+struct PtrWrapper {
+ int *x;
+
+ PtrWrapper(int *input) : x(input) {}
+};
+
+PtrWrapper *testNewInvalidation() {
+ // Ensure that we don't consider this a leak.
+ return new PtrWrapper(static_cast<int *>(malloc(4)));
+}
+
+
//--------------------------------
// Incorrectly-modelled behavior
//--------------------------------