[cfe-commits] r54219 - /cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
Ted Kremenek
kremenek at apple.com
Wed Jul 30 10:49:12 PDT 2008
Author: kremenek
Date: Wed Jul 30 12:49:12 2008
New Revision: 54219
URL: http://llvm.org/viewvc/llvm-project?rev=54219&view=rev
Log:
Add range highlighting for path-sensitive return-of-stack-address check.
Modified:
cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp?rev=54219&r1=54218&r2=54219&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp Wed Jul 30 12:49:12 2008
@@ -181,7 +181,21 @@
"Address of stack-allocated variable returned.") {}
virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) {
- Emit(BR, Eng.ret_stackaddr_begin(), Eng.ret_stackaddr_end());
+ for (GRExprEngine::ret_stackaddr_iterator I=Eng.ret_stackaddr_begin(),
+ End = Eng.ret_stackaddr_end(); I!=End; ++I) {
+
+ // Generate a report for this bug.
+ RangedBugReport report(*this, *I);
+
+ ExplodedNode<ValueState>* N = *I;
+ Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
+ Expr* E = cast<ReturnStmt>(S)->getRetValue();
+ assert (E && "Return expression cannot be NULL");
+ report.addRange(E->getSourceRange());
+
+ // Emit the warning.
+ BR.EmitWarning(report);
+ }
}
};
@@ -193,12 +207,11 @@
FindUndefExpr(ValueStateManager& V, const ValueState* S) : VM(V), St(S) {}
- Expr* FindExpr(Expr* Ex) {
-
+ Expr* FindExpr(Expr* Ex) {
if (!MatchesCriteria(Ex))
- return 0;
+ return 0;
- for (Stmt::child_iterator I=Ex->child_begin(), E=Ex->child_end(); I!=E; ++I)
+ for (Stmt::child_iterator I=Ex->child_begin(), E=Ex->child_end();I!=E;++I)
if (Expr* ExI = dyn_cast_or_null<Expr>(*I)) {
Expr* E2 = FindExpr(ExI);
if (E2) return E2;
More information about the cfe-commits
mailing list