aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-31 01:18:26 +0000
committerAnna Zaks <ganna@apple.com>2012-10-31 01:18:26 +0000
commit3719ed248b7b7e239b1b435dd569b007aaea9d26 (patch)
tree29947ccc4e5285cd90e719efc91eaf1ce4db3395
parente63aedd0cb064fc106636ad856cc0e645e6374ce (diff)
[analyzer]Don't invalidate const arguments when there is no
IdentifierInfo. Ee: C++ copy constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167092 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp2
-rw-r--r--test/Analysis/method-call.cpp11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp
index 31e4cf05d9..b1e2d78183 100644
--- a/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -321,7 +321,7 @@ bool AnyFunctionCall::argumentsMayEscape() const {
const IdentifierInfo *II = D->getIdentifier();
if (!II)
- return true;
+ return false;
// This set of "escaping" APIs is
diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp
index cfb6cd55ad..1a2fedda33 100644
--- a/test/Analysis/method-call.cpp
+++ b/test/Analysis/method-call.cpp
@@ -9,6 +9,10 @@ struct A {
int getx() const { return x; }
};
+struct B{
+ int x;
+};
+
void testNullObject(A *a) {
clang_analyzer_eval(a); // expected-warning{{UNKNOWN}}
(void)a->getx(); // assume we know what we're doing
@@ -34,3 +38,10 @@ void f4() {
A x = 3;
clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}}
}
+
+void checkThatCopyConstructorDoesNotInvalidateObjectBeingCopied() {
+ B t;
+ t.x = 0;
+ B t2(t);
+ clang_analyzer_eval(t.x == 0); // expected-warning{{TRUE}}
+}