diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-29 21:58:13 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-29 21:58:13 +0000 |
commit | 47187c6ad22b5498459b3a0562443feeed260887 (patch) | |
tree | 2b61d3f4d17112fbd6a2795159c82c9a9648fbda /clang/lib/Analysis/GRExprEngineInternalChecks.cpp | |
parent | bff0167a0bb6b60f1002d420c03242e97707ca21 (diff) | |
download | bcm5719-llvm-47187c6ad22b5498459b3a0562443feeed260887.tar.gz bcm5719-llvm-47187c6ad22b5498459b3a0562443feeed260887.zip |
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
llvm-svn: 70415
Diffstat (limited to 'clang/lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngineInternalChecks.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp index 1b031492041..a40eff8fc42 100644 --- a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/clang/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); } |