summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/GRExprEngineInternalChecks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r--clang/lib/Analysis/GRExprEngineInternalChecks.cpp17
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);
}
OpenPOWER on IntegriCloud