summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-30 00:49:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-30 00:49:23 +0000
commitc9dc78ae4075af8f081b90edc7f372ca5b513b21 (patch)
tree574ed24e0d22a15ba2816f697235877a2d9cbf84
parent8e66e0bab4c14b79ae7dcff7a447c5d3f6a4eae4 (diff)
downloadbcm5719-llvm-c9dc78ae4075af8f081b90edc7f372ca5b513b21.tar.gz
bcm5719-llvm-c9dc78ae4075af8f081b90edc7f372ca5b513b21.zip
Normalize SourceMgr messages.
- Don't print "Parsing" in front of every message. - Take additional "type" argument which is prepended to the message (with ": ") if given. - Update clients to print errors (warnings) as: <filename>:<line number>: error(warning): ... llvm-svn: 74489
-rw-r--r--llvm/include/llvm/Support/SourceMgr.h5
-rw-r--r--llvm/lib/Support/SourceMgr.cpp10
-rw-r--r--llvm/tools/llvm-mc/AsmLexer.cpp7
-rw-r--r--llvm/tools/llvm-mc/AsmLexer.h2
-rw-r--r--llvm/tools/llvm-mc/AsmParser.cpp18
-rw-r--r--llvm/tools/llvm-mc/AsmParser.h3
-rw-r--r--llvm/tools/llvm-mc/llvm-mc.cpp2
-rw-r--r--llvm/utils/TableGen/TGLexer.cpp4
-rw-r--r--llvm/utils/TableGen/TableGen.cpp2
9 files changed, 33 insertions, 20 deletions
diff --git a/llvm/include/llvm/Support/SourceMgr.h b/llvm/include/llvm/Support/SourceMgr.h
index 4170c8d6dc6..23044a8bd03 100644
--- a/llvm/include/llvm/Support/SourceMgr.h
+++ b/llvm/include/llvm/Support/SourceMgr.h
@@ -111,7 +111,10 @@ public:
/// PrintMessage - Emit a message about the specified location with the
/// specified string.
- void PrintMessage(SMLoc Loc, const std::string &Msg) const;
+ ///
+ /// @param Type - If non-null, the kind of message (e.g., "error") which is
+ /// prefixed to the message.
+ void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
private:
void PrintIncludeStack(SMLoc IncludeLoc) const;
diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp
index d789f1010be..6232265cb3b 100644
--- a/llvm/lib/Support/SourceMgr.cpp
+++ b/llvm/lib/Support/SourceMgr.cpp
@@ -90,7 +90,8 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const {
}
-void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg) const {
+void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
+ const char *Type) const {
raw_ostream &OS = errs();
// First thing to do: find the current buffer containing the specified
@@ -103,9 +104,12 @@ void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg) const {
MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
- OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
+ OS << CurMB->getBufferIdentifier() << ":"
<< FindLineNumber(Loc, CurBuf) << ": ";
-
+
+ if (Type)
+ OS << Type << ": ";
+
OS << Msg << "\n";
// Scan backward to find the start of the line.
diff --git a/llvm/tools/llvm-mc/AsmLexer.cpp b/llvm/tools/llvm-mc/AsmLexer.cpp
index 931f3b2ee0d..7b744fbde65 100644
--- a/llvm/tools/llvm-mc/AsmLexer.cpp
+++ b/llvm/tools/llvm-mc/AsmLexer.cpp
@@ -42,14 +42,15 @@ SMLoc AsmLexer::getLoc() const {
return SMLoc::getFromPointer(TokStart);
}
-void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg) const {
- SrcMgr.PrintMessage(Loc, Msg);
+void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg,
+ const char *Type) const {
+ SrcMgr.PrintMessage(Loc, Msg, Type);
}
/// ReturnError - Set the error to the specified string at the specified
/// location. This is defined to always return asmtok::Error.
asmtok::TokKind AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
- SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
+ SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error");
return asmtok::Error;
}
diff --git a/llvm/tools/llvm-mc/AsmLexer.h b/llvm/tools/llvm-mc/AsmLexer.h
index 5d0002d4d85..6360b1280ce 100644
--- a/llvm/tools/llvm-mc/AsmLexer.h
+++ b/llvm/tools/llvm-mc/AsmLexer.h
@@ -97,7 +97,7 @@ public:
SMLoc getLoc() const;
- void PrintMessage(SMLoc Loc, const std::string &Msg) const;
+ void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
private:
int getNextChar();
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp
index 9a71139873d..9414f9918c6 100644
--- a/llvm/tools/llvm-mc/AsmParser.cpp
+++ b/llvm/tools/llvm-mc/AsmParser.cpp
@@ -22,13 +22,17 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+void AsmParser::Warning(SMLoc L, const char *Msg) {
+ Lexer.PrintMessage(L, Msg, "warning");
+}
+
bool AsmParser::Error(SMLoc L, const char *Msg) {
- Lexer.PrintMessage(L, Msg);
+ Lexer.PrintMessage(L, Msg, "error");
return true;
}
bool AsmParser::TokError(const char *Msg) {
- Lexer.PrintMessage(Lexer.getLoc(), Msg);
+ Lexer.PrintMessage(Lexer.getLoc(), Msg, "error");
return true;
}
@@ -482,7 +486,7 @@ bool AsmParser::ParseStatement() {
if (!strcmp(IDVal, ".weak_reference"))
return ParseDirectiveSymbolAttribute(MCStreamer::WeakReference);
- Lexer.PrintMessage(IDLoc, "warning: ignoring directive for now");
+ Warning(IDLoc, "ignoring directive for now");
EatToEndOfStatement();
return false;
}
@@ -810,14 +814,14 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
// Diagnose non-sensical max bytes to fill.
if (MaxBytesLoc.isValid()) {
if (MaxBytesToFill < 1) {
- Lexer.PrintMessage(MaxBytesLoc, "warning: alignment directive can never "
- "be satisfied in this many bytes, ignoring");
+ Warning(MaxBytesLoc, "alignment directive can never be satisfied in this "
+ "many bytes, ignoring");
return false;
}
if (MaxBytesToFill >= Alignment) {
- Lexer.PrintMessage(MaxBytesLoc, "warning: maximum bytes expression "
- "exceeds alignment and has no effect");
+ Warning(MaxBytesLoc, "maximum bytes expression exceeds alignment and "
+ "has no effect");
MaxBytesToFill = 0;
}
}
diff --git a/llvm/tools/llvm-mc/AsmParser.h b/llvm/tools/llvm-mc/AsmParser.h
index f5e372ccd25..8cd40eb4d4f 100644
--- a/llvm/tools/llvm-mc/AsmParser.h
+++ b/llvm/tools/llvm-mc/AsmParser.h
@@ -39,7 +39,8 @@ public:
private:
bool ParseStatement();
-
+
+ void Warning(SMLoc L, const char *Msg);
bool Error(SMLoc L, const char *Msg);
bool TokError(const char *Msg);
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 4100cb14de1..e26d79d6c90 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -80,7 +80,7 @@ static int AsLexInput(const char *ProgName) {
while (Tok != asmtok::Eof) {
switch (Tok) {
default:
- Lexer.PrintMessage(Lexer.getLoc(), "driver: unknown token");
+ Lexer.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
Error = true;
break;
case asmtok::Error:
diff --git a/llvm/utils/TableGen/TGLexer.cpp b/llvm/utils/TableGen/TGLexer.cpp
index 6fe8d821e5f..04bbf381520 100644
--- a/llvm/utils/TableGen/TGLexer.cpp
+++ b/llvm/utils/TableGen/TGLexer.cpp
@@ -44,11 +44,11 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
- SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
+ SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error");
}
void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
- SrcMgr.PrintMessage(Loc, Msg);
+ SrcMgr.PrintMessage(Loc, Msg, "error");
}
diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/TableGen.cpp
index 038cde2cb78..fb80302c1e8 100644
--- a/llvm/utils/TableGen/TableGen.cpp
+++ b/llvm/utils/TableGen/TableGen.cpp
@@ -127,7 +127,7 @@ RecordKeeper llvm::Records;
static SourceMgr SrcMgr;
void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
- SrcMgr.PrintMessage(ErrorLoc, Msg);
+ SrcMgr.PrintMessage(ErrorLoc, Msg, "error");
}
OpenPOWER on IntegriCloud