]> granicus.if.org Git - clang/commitdiff
[analyzer] Pointers-to-members are (currently) Locs, not NonLocs.
authorJordan Rose <jordan_rose@apple.com>
Tue, 2 Jul 2013 16:50:24 +0000 (16:50 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 2 Jul 2013 16:50:24 +0000 (16:50 +0000)
While we don't model pointers-to-members besides "null" and "non-null",
we were using Loc symbols for valid pointers and NonLoc integers for the
null case. This hit the assert committed in r185401.

Fixed by using a true (Loc) null for null member pointers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185444 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngineC.cpp
test/Analysis/pointer-to-member.cpp

index e9dda5ceeab7eb10e7376572c0c4ad83a8972676..888963359b4dd5c191bf83c2d235d24d9fc0978c 100644 (file)
@@ -371,7 +371,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
       }
       case CK_NullToMemberPointer: {
         // FIXME: For now, member pointers are represented by void *.
-        SVal V = svalBuilder.makeIntValWithPtrWidth(0, true);
+        SVal V = svalBuilder.makeNull();
         state = state->BindExpr(CastE, LCtx, V);
         Bldr.generateNode(CastE, Pred, state);
         continue;
index c9150e8ca5946a3ab713bd9372285f89d42aba01..37d04399b7b791a6ae9093e071c2b108e09dea5a 100644 (file)
@@ -33,6 +33,7 @@ void testConditionalUse() {
 
 void testComparison() {
   clang_analyzer_eval(&A::getPtr == &A::getPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(&A::getPtr == 0); // expected-warning{{FALSE}}
 
   // FIXME: Should be TRUE.
   clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{UNKNOWN}}