[cfe-commits] r138757 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp test/Analysis/keychainAPI.m

Anna Zaks ganna at apple.com
Mon Aug 29 13:05:54 PDT 2011


Author: zaks
Date: Mon Aug 29 15:05:54 2011
New Revision: 138757

URL: http://llvm.org/viewvc/llvm-project?rev=138757&view=rev
Log:
Fix bug 10797: Crash: "cast<Ty>() argument of incompatible type!" assert when analyzing ICU. 

Patch by Jean-Daniel Dupas. Thanks for spotting and fixing!

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
    cfe/trunk/test/Analysis/keychainAPI.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=138757&r1=138756&r2=138757&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Mon Aug 29 15:05:54 2011
@@ -201,9 +201,11 @@
   if (!isa<SymbolicRegion>(R)) {
     // Implicit casts (ex: void* -> char*) can turn Symbolic region into element
     // region, if that is the case, get the underlining region.
-    if (const ElementRegion *ER = dyn_cast<ElementRegion>(R))
+    if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
       R = ER->getAsArrayOffset().getRegion();
-    else
+      if (!isa<SymbolicRegion>(R))
+        return 0;
+    } else
       return 0;
   }
   return cast<SymbolicRegion>(R)->getSymbol();

Modified: cfe/trunk/test/Analysis/keychainAPI.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/keychainAPI.m?rev=138757&r1=138756&r2=138757&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/keychainAPI.m (original)
+++ cfe/trunk/test/Analysis/keychainAPI.m Mon Aug 29 15:05:54 2011
@@ -304,3 +304,9 @@
     CFRelease(userStr);
   }
 }
+
+//Example from bug 10797.
+__inline__ static
+const char *__WBASLLevelString(int level) {
+  return "foo";
+}





More information about the cfe-commits mailing list