Skip to content

Commit

Permalink
[analyzer]Don't invalidate const arguments when there is no
Browse files Browse the repository at this point in the history
IdentifierInfo.

Ee: C++ copy constructors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167092 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AnnaZaks committed Oct 31, 2012
1 parent e63aedd commit 3719ed2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/StaticAnalyzer/Core/CallEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions test/Analysis/method-call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
}

0 comments on commit 3719ed2

Please sign in to comment.