aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-10 23:56:07 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-10 23:56:07 +0000
commit297308eda369de400e6ea7057dffeadd9f92e385 (patch)
tree7aa6bcb8b75e986d40c746ea61459520786200ca /lib/Analysis/BugReporter.cpp
parentc5840c0e6443085bfc5bb78e01afc1d420c72f44 (diff)
BugReporter: Use llvm::raw_string_stream instead of std::ostringstream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64259 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r--lib/Analysis/BugReporter.cpp54
1 files changed, 25 insertions, 29 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index 7a49112183..cf1d1b774d 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -24,7 +24,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
-#include <sstream>
using namespace clang;
@@ -75,27 +74,26 @@ static inline Stmt* GetStmt(const ExplodedNode<GRState>* N) {
return isa<BlockEntrance>(ProgP) ? GetLastStmt(N) : GetStmt(ProgP);
}
-static void ExecutionContinues(std::ostringstream& os, SourceManager& SMgr,
- const Stmt* S) {
-
+static void ExecutionContinues(llvm::raw_string_ostream& os,
+ SourceManager& SMgr,
+ const Stmt* S) {
if (!S)
return;
// Slow, but probably doesn't matter.
- if (os.str().empty())
- os << ' ';
+ if (os.str().empty()) os << ' ';
os << "Execution continues on line "
- << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
+ << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
}
-static inline void ExecutionContinues(std::ostringstream& os,
+static inline void ExecutionContinues(llvm::raw_string_ostream& os,
SourceManager& SMgr,
const ExplodedNode<GRState>* N) {
ExecutionContinues(os, SMgr, GetStmt(N->getLocation()));
}
-static inline void ExecutionContinues(std::ostringstream& os,
+static inline void ExecutionContinues(llvm::raw_string_ostream& os,
SourceManager& SMgr,
const CFGBlock* B) {
ExecutionContinues(os, SMgr, GetStmt(B));
@@ -603,7 +601,8 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
if (!S)
continue;
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
os << "Control jumps to line "
<< SMgr.getInstantiationLineNumber(S->getLocStart()) << ".\n";
@@ -612,11 +611,10 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
break;
}
- case Stmt::SwitchStmtClass: {
-
+ case Stmt::SwitchStmtClass: {
// Figure out what case arm we took.
-
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
if (Stmt* S = Dst->getLabel())
switch (S->getStmtClass()) {
@@ -663,9 +661,8 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
continue;
}
- llvm::raw_os_ostream OS(os);
- OS << V;
- }
+ os << V;
+ }
os << ":' at line "
<< SMgr.getInstantiationLineNumber(S->getLocStart()) << ".\n";
@@ -684,15 +681,16 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
case Stmt::BreakStmtClass:
case Stmt::ContinueStmtClass: {
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
ExecutionContinues(os, SMgr, LastNode);
PD.push_front(new PathDiagnosticPiece(L, os.str()));
break;
}
case Stmt::ConditionalOperatorClass: {
-
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
os << "'?' condition evaluates to ";
if (*(Src->succ_begin()+1) == Dst)
@@ -700,16 +698,15 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
else
os << "true.";
- PD.push_front(new PathDiagnosticPiece(L, os.str()));
-
+ PD.push_front(new PathDiagnosticPiece(L, os.str()));
break;
}
case Stmt::DoStmtClass: {
if (*(Src->succ_begin()) == Dst) {
-
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
os << "Loop condition is true. ";
ExecutionContinues(os, SMgr, Dst);
@@ -727,12 +724,12 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
case Stmt::ForStmtClass: {
if (*(Src->succ_begin()+1) == Dst) {
-
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
os << "Loop condition is false. ";
ExecutionContinues(os, SMgr, Dst);
-
+
PD.push_front(new PathDiagnosticPiece(L, os.str()));
}
else
@@ -742,8 +739,7 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
break;
}
- case Stmt::IfStmtClass: {
-
+ case Stmt::IfStmtClass: {
if (*(Src->succ_begin()+1) == Dst)
PD.push_front(new PathDiagnosticPiece(L, "Taking false branch."));
else