summaryrefslogtreecommitdiff
path: root/lib/Support/SourceMgr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-02 23:08:13 +0000
committerChris Lattner <sabre@nondot.org>2009-07-02 23:08:13 +0000
commiteeb4a84ac8d91fb1d5a7c484a1c7047409faee30 (patch)
treea74754636cc687794c2d224169dec37702cc34be /lib/Support/SourceMgr.cpp
parent92bcb426c3e4503c99324afd4ed0a73521711a56 (diff)
switch the .ll parser to use SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SourceMgr.cpp')
-rw-r--r--lib/Support/SourceMgr.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp
index 123531e21db..6b0d55c19f2 100644
--- a/lib/Support/SourceMgr.cpp
+++ b/lib/Support/SourceMgr.cpp
@@ -90,17 +90,19 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const {
}
-void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
- const char *Type) const {
- raw_ostream &OS = errs();
+/// GetMessage - Return an SMDiagnostic at the specified location with the
+/// specified string.
+///
+/// @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,
+ const char *Type) const {
// First thing to do: find the current buffer containing the specified
// location.
int CurBuf = FindBufferContainingLoc(Loc);
assert(CurBuf != -1 && "Invalid or unspecified location!");
- PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
-
MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
@@ -122,12 +124,21 @@ void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
}
PrintedMsg += Msg;
-
// Print out the line.
- SMDiagnostic(CurMB->getBufferIdentifier(), FindLineNumber(Loc, CurBuf),
- Loc.getPointer()-LineStart, PrintedMsg,
- std::string(LineStart, LineEnd)).Print(0, OS);
-
+ return SMDiagnostic(CurMB->getBufferIdentifier(), FindLineNumber(Loc, CurBuf),
+ Loc.getPointer()-LineStart, PrintedMsg,
+ std::string(LineStart, LineEnd));
+}
+
+void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
+ const char *Type) const {
+ raw_ostream &OS = errs();
+
+ int CurBuf = FindBufferContainingLoc(Loc);
+ assert(CurBuf != -1 && "Invalid or unspecified location!");
+ PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
+
+ GetMessage(Loc, Msg, Type).Print(0, OS);
}
//===----------------------------------------------------------------------===//