[cfe-commits] r167092 - in /cfe/trunk: lib/StaticAnalyzer/Core/CallEvent.cpp test/Analysis/method-call.cpp
Anna Zaks
ganna at apple.com
Tue Oct 30 18:18:26 PDT 2012
Author: zaks
Date: Tue Oct 30 20:18:26 2012
New Revision: 167092
URL: http://llvm.org/viewvc/llvm-project?rev=167092&view=rev
Log:
[analyzer]Don't invalidate const arguments when there is no
IdentifierInfo.
Ee: C++ copy constructors.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/method-call.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=167092&r1=167091&r2=167092&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Tue Oct 30 20:18:26 2012
@@ -321,7 +321,7 @@
const IdentifierInfo *II = D->getIdentifier();
if (!II)
- return true;
+ return false;
// This set of "escaping" APIs is
Modified: cfe/trunk/test/Analysis/method-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/method-call.cpp?rev=167092&r1=167091&r2=167092&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/method-call.cpp (original)
+++ cfe/trunk/test/Analysis/method-call.cpp Tue Oct 30 20:18:26 2012
@@ -9,6 +9,10 @@
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 @@
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}}
+}
More information about the cfe-commits
mailing list