aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngineInternalChecks.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-29 21:58:13 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-29 21:58:13 +0000
commitd49967f8764135ae65658e354b6d38e3637c9de3 (patch)
treed1845d72b378da782b4cf5da22a0880841c301cc /lib/Analysis/GRExprEngineInternalChecks.cpp
parent6e5201b71dcf5e98d2ac4e14bebf5b4080120bb6 (diff)
BugReporter/PathDiagnostics:
- Add an (optional) short description for BugReports for clients that want to distinguish between long and short descriptions for bugs - Make the bug report for VLA less obscene for Plist diagnostics by using the short description git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r--lib/Analysis/GRExprEngineInternalChecks.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp
index 1b03149204..a40eff8fc4 100644
--- a/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -405,12 +405,23 @@ public:
"variable-length array (VLA) '"
<< VD->getNameAsString() << "' evaluates to ";
- if (Eng.getStateManager().GetSVal(N->getState(), SizeExpr).isUndef())
+ bool isUndefined = Eng.getStateManager().GetSVal(N->getState(),
+ SizeExpr).isUndef();
+
+ if (isUndefined)
os << "an undefined or garbage value.";
else
os << "0. VLAs with no elements have undefined behavior.";
-
- RangedBugReport *report = new RangedBugReport(*this, os.str().c_str(), N);
+
+ std::string shortBuf;
+ llvm::raw_string_ostream os_short(shortBuf);
+ os_short << "Variable-length array '" << VD->getNameAsString() << "' "
+ << (isUndefined ? " garbage value for array size"
+ : " has zero elements (undefined behavior)");
+
+ RangedBugReport *report = new RangedBugReport(*this,
+ os_short.str().c_str(),
+ os.str().c_str(), N);
report->addRange(SizeExpr->getSourceRange());
BR.EmitReport(report);
}