From: Anna Zaks Date: Wed, 31 Oct 2012 01:18:26 +0000 (+0000) Subject: [analyzer]Don't invalidate const arguments when there is no X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7bd0674dea1ee3625d97bf64f6a31760af221f4a;p=platform%2Fupstream%2Fllvm.git [analyzer]Don't invalidate const arguments when there is no IdentifierInfo. Ee: C++ copy constructors. llvm-svn: 167092 --- diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index 31e4cf05..b1e2d78 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/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/clang/test/Analysis/method-call.cpp b/clang/test/Analysis/method-call.cpp index cfb6cd5..1a2fedd 100644 --- a/clang/test/Analysis/method-call.cpp +++ b/clang/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}} +}