]> granicus.if.org Git - clang/commitdiff
Teach more of the static analyzer about ObjCQualifiedIdType.
authorTed Kremenek <kremenek@apple.com>
Wed, 30 Apr 2008 20:17:27 +0000 (20:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 30 Apr 2008 20:17:27 +0000 (20:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50494 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRExprEngine.h
lib/Analysis/BasicObjCFoundationChecks.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/GRSimpleVals.cpp

index 7005263033ab8e70e1f7c63918e916ea9accd9bf..127726ac06c52e60ffbc089e5b4952db245d74e1 100644 (file)
@@ -20,6 +20,7 @@
 #include "clang/Analysis/PathSensitive/ValueState.h"
 #include "clang/Analysis/PathSensitive/GRSimpleAPICheck.h"
 #include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/AST/Type.h"
 
 namespace clang {  
   
@@ -636,4 +637,17 @@ protected:
 };
 } // end clang namespace
 
+
+//===----------------------------------------------------------------------===//
+// Utility
+//===----------------------------------------------------------------------===//
+
+namespace clang {
+  
+static inline bool IsPointerType(QualType T) {
+  return T->isPointerType() || T->isObjCQualifiedIdType();
+}
+  
+} // end clang namespace
+
 #endif
index 98c7e28b740f0e3c28f7ef196761bc9b326c11ca..d2a3d08b8e3eff9c6a0e5c4cf6e42c4b1a36cd9e 100644 (file)
@@ -40,10 +40,7 @@ static ObjCInterfaceType* GetReceiverType(ObjCMessageExpr* ME) {
   QualType X = Receiver->getType();
   Type* TP = X.getTypePtr();
   
-  // FIXME: Why can this not be a pointer type?
-  //  assert (TP->isPointerType());
-  if (!TP->isPointerType())
-    return NULL;
+  assert (IsPointerType(X));
   
   const PointerType* T = TP->getAsPointerType();
   
index 08bad5b155fc16806d1cca7a9fbd66fa7047bde2..9ed4f1db2934115c156ae325db922e9d48d11680 100644 (file)
@@ -335,7 +335,8 @@ CFRefSummaryManager::getUnaryCFSummary(FunctionTypeProto* FT, CFUnaryFunc func)
   if (strcmp("CFTypeRef", TDName) != 0)
     return NULL;
   
-  assert (ArgT->isPointerType() || ArgT->isObjCQualifiedIdType());
+  if (!ArgT->isPointerType())
+    return NULL;
 
   QualType RetTy = FT->getResultType();
   
index 22205c06e0d76704063a54daa09691e681732b09..80e9af319000d4e312084c8d83f33849e432dcaf 100644 (file)
@@ -28,10 +28,6 @@ using llvm::dyn_cast;
 using llvm::cast;
 using llvm::APSInt;
 
-static inline bool IsPointerType(QualType T) {
-  return T->isPointerType() || T->isObjCQualifiedIdType();
-}
-
 //===----------------------------------------------------------------------===//
 // Engine construction and deletion.
 //===----------------------------------------------------------------------===//
index bb6ea5d5603963a91b56cc9a9a5230cd9276e680..b496f2644337ea037f03c0c1e26cf5daace68ab3 100644 (file)
@@ -20,6 +20,7 @@
 #include "clang/Analysis/PathSensitive/ValueState.h"
 #include "clang/Analysis/PathSensitive/BugReporter.h"
 #include "clang/Analysis/LocalCheckers.h"
+#include "clang/Analysis/PathSensitive/GRExprEngine.h"
 #include "llvm/Support/Compiler.h"
 #include <sstream>
 
@@ -306,11 +307,10 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, NonLVal X, QualType T) {
   BasicValueFactory& BasicVals = Eng.getBasicVals();
   
   llvm::APSInt V = cast<nonlval::ConcreteInt>(X).getValue();
-  V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType() 
-                  || T->isObjCQualifiedIdType());
+  V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
   V.extOrTrunc(Eng.getContext().getTypeSize(T));
   
-  if (T->isPointerType())
+  if (IsPointerType(T))
     return lval::ConcreteInt(BasicVals.getValue(V));
   else
     return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -320,7 +320,7 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, NonLVal X, QualType T) {
 
 RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
   
-  if (T->isPointerLikeType() || T->isObjCQualifiedIdType())
+  if (IsPointerType(T))
     return X;
   
   assert (T->isIntegerType());
@@ -331,7 +331,7 @@ RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
   BasicValueFactory& BasicVals = Eng.getBasicVals();
   
   llvm::APSInt V = cast<lval::ConcreteInt>(X).getValue();
-  V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType());
+  V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
   V.extOrTrunc(Eng.getContext().getTypeSize(T));
 
   return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -594,7 +594,7 @@ void GRSimpleVals::EvalCall(ExplodedNodeSet<ValueState>& Dst,
     unsigned Count = Builder.getCurrentBlockCount();
     SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count);
         
-    RVal X = CE->getType()->isPointerType() 
+    RVal X = IsPointerType(CE->getType())
              ? cast<RVal>(lval::SymbolVal(Sym)) 
              : cast<RVal>(nonlval::SymbolVal(Sym));