#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 {
};
} // end clang namespace
+
+//===----------------------------------------------------------------------===//
+// Utility
+//===----------------------------------------------------------------------===//
+
+namespace clang {
+
+static inline bool IsPointerType(QualType T) {
+ return T->isPointerType() || T->isObjCQualifiedIdType();
+}
+
+} // end clang namespace
+
#endif
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();
using llvm::cast;
using llvm::APSInt;
-static inline bool IsPointerType(QualType T) {
- return T->isPointerType() || T->isObjCQualifiedIdType();
-}
-
//===----------------------------------------------------------------------===//
// Engine construction and deletion.
//===----------------------------------------------------------------------===//
#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>
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));
RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
- if (T->isPointerLikeType() || T->isObjCQualifiedIdType())
+ if (IsPointerType(T))
return X;
assert (T->isIntegerType());
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));
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));