diff options
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/DereferenceChecker.cpp | 26 | ||||
-rw-r--r-- | lib/Analysis/NSErrorChecker.cpp | 5 |
2 files changed, 27 insertions, 4 deletions
diff --git a/lib/Analysis/DereferenceChecker.cpp b/lib/Analysis/DereferenceChecker.cpp index 4c4091cbc2..4a9312377a 100644 --- a/lib/Analysis/DereferenceChecker.cpp +++ b/lib/Analysis/DereferenceChecker.cpp @@ -90,11 +90,31 @@ void DereferenceChecker::VisitLocation(CheckerContext &C, const Stmt *S, // We know that 'location' cannot be non-null. This is what // we call an "explicit" null dereference. if (!BT_null) - BT_null = new BuiltinBug("Null pointer dereference", - "Dereference of null pointer"); + BT_null = new BuiltinBug("Dereference of null pointer"); + + llvm::SmallString<100> buf; + + switch (S->getStmtClass()) { + case Stmt::UnaryOperatorClass: { + const UnaryOperator *U = cast<UnaryOperator>(S); + const Expr *SU = U->getSubExpr()->IgnoreParens(); + if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(SU)) { + if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { + llvm::raw_svector_ostream os(buf); + os << "Dereference of null pointer loaded from variable '" + << VD->getName() << '\''; + } + } + } + default: + break; + } EnhancedBugReport *report = - new EnhancedBugReport(*BT_null, BT_null->getDescription(), N); + new EnhancedBugReport(*BT_null, + buf.empty() ? BT_null->getDescription():buf.str(), + N); + report->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, bugreporter::GetDerefExpr(N)); diff --git a/lib/Analysis/NSErrorChecker.cpp b/lib/Analysis/NSErrorChecker.cpp index 93b617b115..9a8d02215e 100644 --- a/lib/Analysis/NSErrorChecker.cpp +++ b/lib/Analysis/NSErrorChecker.cpp @@ -114,10 +114,13 @@ void NSErrorChecker::EmitRetTyWarning(BugReporter& BR, const Decl& CodeDecl) { os << " should have a non-void return value to indicate whether or not an " "error occurred"; + // FIXME: Remove when we migrate EmitBasicReport to StringRef. + std::string cat = getCategory().str(); + BR.EmitBasicReport(isNSErrorWarning ? "Bad return type when passing NSError**" : "Bad return type when passing CFError*", - getCategory().c_str(), os.str().c_str(), + cat.c_str(), os.str().c_str(), CodeDecl.getLocation()); } |