summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/SourceMgr.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-09-27 17:42:11 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-09-27 17:42:11 +0000
commitc758311025805d901b11695aa04148f2da3f307f (patch)
tree432f0f802e6154a89baab92a4588b7ee4420d43d /llvm/lib/Support/SourceMgr.cpp
parent23cb3716df6c15a895a3aa690f21db903cd0b9bd (diff)
downloadbcm5719-llvm-c758311025805d901b11695aa04148f2da3f307f.tar.gz
bcm5719-llvm-c758311025805d901b11695aa04148f2da3f307f.zip
Push twines deeper into SourceMgr's error handling methods.
llvm-svn: 114847
Diffstat (limited to 'llvm/lib/Support/SourceMgr.cpp')
-rw-r--r--llvm/lib/Support/SourceMgr.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp
index da5681c5bc0..3800753ecdc 100644
--- a/llvm/lib/Support/SourceMgr.cpp
+++ b/llvm/lib/Support/SourceMgr.cpp
@@ -13,6 +13,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/Twine.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
@@ -135,7 +136,7 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const {
///
/// @param Type - If non-null, the kind of message (e.g., "error") which is
/// prefixed to the message.
-SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
+SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const Twine &Msg,
const char *Type, bool ShowLine) const {
// First thing to do: find the current buffer containing the specified
@@ -162,19 +163,18 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
}
std::string PrintedMsg;
- if (Type) {
- PrintedMsg = Type;
- PrintedMsg += ": ";
- }
- PrintedMsg += Msg;
+ raw_string_ostream OS(PrintedMsg);
+ if (Type)
+ OS << Type << ": ";
+ OS << Msg;
return SMDiagnostic(*this, Loc,
CurMB->getBufferIdentifier(), FindLineNumber(Loc, CurBuf),
- Loc.getPointer()-LineStart, PrintedMsg,
+ Loc.getPointer()-LineStart, OS.str(),
LineStr, ShowLine);
}
-void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
+void SourceMgr::PrintMessage(SMLoc Loc, const Twine &Msg,
const char *Type, bool ShowLine) const {
// Report the message with the diagnostic handler if present.
if (DiagHandler) {
OpenPOWER on IntegriCloud