namespace clang {
template <typename ITERATOR>
-static inline const PostStmt& GetLocation(ITERATOR I) {
- return cast<PostStmt>((*I)->getLocation());
+static inline ProgramPoint GetLocation(ITERATOR I) {
+ return (*I)->getLocation();
}
template <>
-inline const PostStmt& GetLocation(GRExprEngine::undef_arg_iterator I) {
- return cast<PostStmt>(I->first->getLocation());
+inline ProgramPoint GetLocation(GRExprEngine::undef_arg_iterator I) {
+ return I->first->getLocation();
+}
+
+static inline Stmt* GetStmt(const ProgramPoint& P) {
+ if (const PostStmt* PS = dyn_cast<PostStmt>(&P)) {
+ return PS->getStmt();
+ }
+ else if (const BlockEdge* BE = dyn_cast<BlockEdge>(&P)) {
+ return BE->getSrc()->getTerminator();
+ }
+
+ assert (false && "Unsupported ProgramPoint.");
+ return NULL;
}
template <typename ITERATOR>
static void EmitDiag(Diagnostic& Diag, SourceManager& SrcMgr,
unsigned ErrorDiag, ITERATOR I) {
- Expr* Exp = cast<Expr>(GetLocation(I).getStmt());
- cast<Expr>(GetLocation(I).getStmt());
- Diag.Report(FullSourceLoc(Exp->getExprLoc(), SrcMgr), ErrorDiag);
+ Stmt* S = GetStmt(GetLocation(I));
+ Diag.Report(FullSourceLoc(S->getLocStart(), SrcMgr), ErrorDiag);
}
static void EmitDiag(Diagnostic& Diag, SourceManager& SrcMgr,
unsigned ErrorDiag, GRExprEngine::undef_arg_iterator I) {
- Expr* E1 = cast<Expr>(GetLocation(I).getStmt());
+ Stmt* S1 = GetStmt(GetLocation(I));
Expr* E2 = cast<Expr>(I->second);
- SourceLocation Loc = E1->getExprLoc();
+ SourceLocation Loc = S1->getLocStart();
SourceRange R = E2->getSourceRange();
Diag.Report(FullSourceLoc(Loc, SrcMgr), ErrorDiag, 0, 0, &R, 1);
}
CheckerState->undef_arg_begin(),
CheckerState->undef_arg_end(),
"Pass-by-value argument in function or message expression is undefined.");
+
+ EmitWarning(Diag, SrcMgr,
+ CheckerState->undef_branches_begin(),
+ CheckerState->undef_branches_end(),
+ "Branch condition evaluates to an uninitialized value.");
#ifndef NDEBUG
if (Visualize) CheckerState->ViewGraph(TrimGraph);
BasicValueFactory& BasicVals = Eng.getBasicVals();
llvm::APSInt V = cast<nonlval::ConcreteInt>(X).getValue();
- V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType());
+ V.setIsUnsigned(T->isUnsignedIntegerType() || T->isPointerType()
+ || T->isObjCQualifiedIdType());
V.extOrTrunc(Eng.getContext().getTypeSize(T));
if (T->isPointerType())
RVal GRSimpleVals::EvalCast(GRExprEngine& Eng, LVal X, QualType T) {
- if (T->isPointerType() || T->isReferenceType())
+ if (T->isPointerType() || T->isReferenceType() || T->isObjCQualifiedIdType())
return X;
assert (T->isIntegerType());
if (!MD->getBody())
return;
+
+ if (FName.size() > 0 && FName != MD->getSelector().getName())
+ return;
if (printFuncDeclStart()) {
DeclPrinter().PrintObjCMethodDecl(MD);
void GRSimpleValsVisitor::VisitCFG(CFG& C, Decl& CD) {
SourceLocation Loc = CD.getLocation();
-
+
if (!Loc.isFileID() ||
Loc.getFileID() != Ctx->getSourceManager().getMainFileID())
return;
-
+
if (!Visualize) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(&CD)) {
<< ' ';
}
else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(&CD)) {
- llvm::cerr << "ANALYZE (ObjC Method): "
- << MD->getSelector().getName() << ' '
+ llvm::cerr << "ANALYZE (ObjC Method): '"
+ << MD->getSelector().getName() << "' "
<< Ctx->getSourceManager().getSourceName(MD->getLocation())
<< ' ';
}