diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-09-27 17:42:11 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-09-27 17:42:11 +0000 |
commit | d1e1703c39742f3c9fc3d27a442ff59bbdbfb5aa (patch) | |
tree | 05de677aa6d5ca6f002a1bf0d8662e20fd83a93d /lib/Support/SourceMgr.cpp | |
parent | a8bd1ff8c5e77429dd19257b8039a9abca59e6f1 (diff) |
Push twines deeper into SourceMgr's error handling methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SourceMgr.cpp')
-rw-r--r-- | lib/Support/SourceMgr.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index da5681c5bc..3800753ecd 100644 --- a/lib/Support/SourceMgr.cpp +++ b/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) { |