[analyzer]Don't invalidate const arguments when there is no
authorAnna Zaks <ganna@apple.com>
Wed, 31 Oct 2012 01:18:26 +0000 (01:18 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 31 Oct 2012 01:18:26 +0000 (01:18 +0000)
IdentifierInfo.

Ee: C++ copy constructors.
llvm-svn: 167092

clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/test/Analysis/method-call.cpp

index 31e4cf0..b1e2d78 100644 (file)
@@ -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 
 
index cfb6cd5..1a2fedd 100644 (file)
@@ -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}}
+}