[cfe-commits] r50494 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/BasicObjCFoundationChecks.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/GRSimpleVals.cpp
Ted Kremenek
kremenek at apple.com
Wed Apr 30 13:17:28 PDT 2008
Author: kremenek
Date: Wed Apr 30 15:17:27 2008
New Revision: 50494
URL: http://llvm.org/viewvc/llvm-project?rev=50494&view=rev
Log:
Teach more of the static analyzer about ObjCQualifiedIdType.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/lib/Analysis/GRSimpleVals.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Wed Apr 30 15:17:27 2008
@@ -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 @@
};
} // end clang namespace
+
+//===----------------------------------------------------------------------===//
+// Utility
+//===----------------------------------------------------------------------===//
+
+namespace clang {
+
+static inline bool IsPointerType(QualType T) {
+ return T->isPointerType() || T->isObjCQualifiedIdType();
+}
+
+} // end clang namespace
+
#endif
Modified: cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicObjCFoundationChecks.cpp Wed Apr 30 15:17:27 2008
@@ -40,10 +40,7 @@
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();
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Wed Apr 30 15:17:27 2008
@@ -335,7 +335,8 @@
if (strcmp("CFTypeRef", TDName) != 0)
return NULL;
- assert (ArgT->isPointerType() || ArgT->isObjCQualifiedIdType());
+ if (!ArgT->isPointerType())
+ return NULL;
QualType RetTy = FT->getResultType();
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Apr 30 15:17:27 2008
@@ -28,10 +28,6 @@
using llvm::cast;
using llvm::APSInt;
-static inline bool IsPointerType(QualType T) {
- return T->isPointerType() || T->isObjCQualifiedIdType();
-}
-
//===----------------------------------------------------------------------===//
// Engine construction and deletion.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Analysis/GRSimpleVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRSimpleVals.cpp?rev=50494&r1=50493&r2=50494&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Wed Apr 30 15:17:27 2008
@@ -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 @@
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, LVal X, QualType T) {
- if (T->isPointerLikeType() || T->isObjCQualifiedIdType())
+ if (IsPointerType(T))
return X;
assert (T->isIntegerType());
@@ -331,7 +331,7 @@
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 @@
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));
More information about the cfe-commits
mailing list