]> granicus.if.org Git - clang/commitdiff
[analyzer] Weaken assertion to account for pointer-to-integer casts.
authorJordan Rose <jordan_rose@apple.com>
Thu, 25 Jul 2013 17:22:02 +0000 (17:22 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 25 Jul 2013 17:22:02 +0000 (17:22 +0000)
PR16690

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

lib/StaticAnalyzer/Core/SValBuilder.cpp
test/Analysis/casts.m

index 1992abbf4c3e6bb0ed613474cd4293c2ba16af02..6df8a901f42079a64435a93496aaf432ac4e7a01 100644 (file)
@@ -412,7 +412,7 @@ SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
       return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
     }
 
-    assert(val.getAs<Loc>());
+    assert(val.getAs<Loc>() || val.getAs<nonloc::LocAsInteger>());
     return makeTruthVal(true, castTy);
   }
 
index 1a78940eee25e7577f9e4ca4cbab039002e2da86..895c8119c18022a201d0c1a4198fcbaaa231ef14 100644 (file)
@@ -1,9 +1,7 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
 // expected-no-diagnostics
 
-// Test function pointer casts.  Currently we track function addresses using
-// loc::FunctionVal.  Because casts can be arbitrary, do we need to model
-// functions with regions?
+// Test function pointer casts.
 typedef void* (*MyFuncTest1)(void);
 
 MyFuncTest1 test1_aux(void);
@@ -14,8 +12,7 @@ void test1(void) {
   if (p != ((void*) 0)) x = (*p)();
 }
 
-// Test casts from void* to function pointers.  Same issue as above:
-// should we eventually model function pointers using regions?
+// Test casts from void* to function pointers.
 void* test2(void *p) {
   MyFuncTest1 fp = (MyFuncTest1) p;
   return (*fp)();
@@ -41,3 +38,9 @@ adium_media_ready_cb(RDR10087620 *InObj)
 {
   InObj.elem |= EEOne;
 }
+
+
+// PR16690
+_Bool testLocAsIntegerToBool() {
+  return (long long)&testLocAsIntegerToBool;
+}