summaryrefslogtreecommitdiff
path: root/include/llvm/Support/SourceMgr.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-10-16 04:47:35 +0000
committerChris Lattner <sabre@nondot.org>2011-10-16 04:47:35 +0000
commitd8b7aa26134d2abee777f745c32005e63dea2455 (patch)
treeedc5453a63624cef371ed386f811fb2651024d33 /include/llvm/Support/SourceMgr.h
parent17730847d59c919d97f097d46a3fcba1888e5300 (diff)
downloadllvm-d8b7aa26134d2abee777f745c32005e63dea2455.tar.gz
llvm-d8b7aa26134d2abee777f745c32005e63dea2455.tar.bz2
llvm-d8b7aa26134d2abee777f745c32005e63dea2455.tar.xz
Enhance llvm::SourceMgr to support diagnostic ranges, the same way clang does. Enhance
the X86 asmparser to produce ranges in the one case that was annoying me, for example: test.s:10:15: error: invalid operand for instruction movl 0(%rax), 0(%edx) ^~~~~~~ It should be straight-forward to enhance filecheck, tblgen, and/or the .ll parser to use ranges where appropriate if someone is interested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142106 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/SourceMgr.h')
-rw-r--r--include/llvm/Support/SourceMgr.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h
index 92ec891699..17d1df5aa7 100644
--- a/include/llvm/Support/SourceMgr.h
+++ b/include/llvm/Support/SourceMgr.h
@@ -17,10 +17,8 @@
#define SUPPORT_SOURCEMGR_H
#include "llvm/Support/SMLoc.h"
-
+#include "llvm/ADT/ArrayRef.h"
#include <string>
-#include <vector>
-#include <cassert>
namespace llvm {
class MemoryBuffer;
@@ -125,6 +123,7 @@ public:
/// prefixed to the message.
/// @param ShowLine - Should the diagnostic show the source line.
void PrintMessage(SMLoc Loc, const Twine &Msg, const char *Type,
+ ArrayRef<SMRange> Ranges = ArrayRef<SMRange>(),
bool ShowLine = true) const;
@@ -136,6 +135,7 @@ public:
/// @param ShowLine - Should the diagnostic show the source line.
SMDiagnostic GetMessage(SMLoc Loc,
const Twine &Msg, const char *Type,
+ ArrayRef<SMRange> Ranges = ArrayRef<SMRange>(),
bool ShowLine = true) const;
/// PrintIncludeStack - Prints the names of included files and the line of the
@@ -157,6 +157,7 @@ class SMDiagnostic {
int LineNo, ColumnNo;
std::string Message, LineContents;
unsigned ShowLine : 1;
+ std::vector<std::pair<unsigned, unsigned> > Ranges;
public:
// Null diagnostic.
@@ -170,9 +171,7 @@ public:
SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN,
int Line, int Col,
const std::string &Msg, const std::string &LineStr,
- bool showline = true)
- : SM(&sm), Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Message(Msg),
- LineContents(LineStr), ShowLine(showline) {}
+ ArrayRef<std::pair<unsigned,unsigned> > Ranges, bool showline);
const SourceMgr *getSourceMgr() const { return SM; }
SMLoc getLoc() const { return Loc; }
@@ -182,8 +181,10 @@ public:
const std::string &getMessage() const { return Message; }
const std::string &getLineContents() const { return LineContents; }
bool getShowLine() const { return ShowLine; }
-
- void Print(const char *ProgName, raw_ostream &S) const;
+ const std::vector<std::pair<unsigned, unsigned> > &getRanges() const {
+ return Ranges;
+ }
+ void print(const char *ProgName, raw_ostream &S) const;
};
} // end llvm namespace