[analyzer] Shorten the stack hint diagnostic.
Do not display the standard "Returning from 'foo'", when a stack hint is
available.
llvm-svn: 152964
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 2926fd5..133482f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -254,7 +254,7 @@
SmallString<200> buf;
llvm::raw_svector_ostream os(buf);
- os << "; reallocation of ";
+ os << "Reallocation of ";
// Printed parameters start at 1, not 0.
printOrdinal(++ArgIndex, os);
os << " parameter failed";
@@ -263,7 +263,7 @@
}
virtual std::string getMessageForReturn(const CallExpr *CallExpr) {
- return "; reallocation of returned value failed";
+ return "Reallocation of returned value failed";
}
};
};
@@ -1292,15 +1292,17 @@
if (Mode == Normal) {
if (isAllocated(RS, RSPrev, S)) {
Msg = "Memory is allocated";
- StackHint = new StackHintGeneratorForSymbol(Sym, "; allocated memory");
+ StackHint = new StackHintGeneratorForSymbol(Sym,
+ "Returned allocated memory");
} else if (isReleased(RS, RSPrev, S)) {
Msg = "Memory is released";
- StackHint = new StackHintGeneratorForSymbol(Sym, "; released memory");
+ StackHint = new StackHintGeneratorForSymbol(Sym,
+ "Returned released memory");
} else if (isReallocFailedCheck(RS, RSPrev, S)) {
Mode = ReallocationFailed;
Msg = "Reallocation failed";
StackHint = new StackHintGeneratorForReallocationFailed(Sym,
- "; reallocation failed");
+ "Reallocation failed");
}
// We are in a special mode if a reallocation failed later in the path.
@@ -1320,7 +1322,8 @@
if (!(FunName.equals("realloc") || FunName.equals("reallocf")))
return 0;
Msg = "Attempt to reallocate memory";
- StackHint = new StackHintGeneratorForSymbol(Sym, "; reallocated memory");
+ StackHint = new StackHintGeneratorForSymbol(Sym,
+ "Returned reallocated memory");
Mode = Normal;
}
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index 2a2b9c6..989553e 100644
--- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -568,12 +568,12 @@
return 0;
SmallString<256> buf;
llvm::raw_svector_ostream Out(buf);
- if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(Callee))
+ if (!CallStackMessage.empty())
+ Out << CallStackMessage;
+ else if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(Callee))
Out << "Returning from '" << *ND << "'";
else
Out << "Returning to caller";
- if (!CallStackMessage.empty())
- Out << CallStackMessage;
return new PathDiagnosticEventPiece(callReturn, Out.str());
}