[llvm-commits] [llvm] r74489 - in /llvm/trunk: include/llvm/Support/SourceMgr.h lib/Support/SourceMgr.cpp tools/llvm-mc/AsmLexer.cpp tools/llvm-mc/AsmLexer.h tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h tools/llvm-mc/llvm-mc.cpp utils/TableGen/TGLexer.cpp utils/TableGen/TableGen.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jun 29 17:49:23 PDT 2009
Author: ddunbar
Date: Mon Jun 29 19:49:23 2009
New Revision: 74489
URL: http://llvm.org/viewvc/llvm-project?rev=74489&view=rev
Log:
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): ...
Modified:
llvm/trunk/include/llvm/Support/SourceMgr.h
llvm/trunk/lib/Support/SourceMgr.cpp
llvm/trunk/tools/llvm-mc/AsmLexer.cpp
llvm/trunk/tools/llvm-mc/AsmLexer.h
llvm/trunk/tools/llvm-mc/AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmParser.h
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
llvm/trunk/utils/TableGen/TGLexer.cpp
llvm/trunk/utils/TableGen/TableGen.cpp
Modified: llvm/trunk/include/llvm/Support/SourceMgr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/SourceMgr.h (original)
+++ llvm/trunk/include/llvm/Support/SourceMgr.h Mon Jun 29 19:49:23 2009
@@ -111,7 +111,10 @@
/// 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;
Modified: llvm/trunk/lib/Support/SourceMgr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SourceMgr.cpp (original)
+++ llvm/trunk/lib/Support/SourceMgr.cpp Mon Jun 29 19:49:23 2009
@@ -90,7 +90,8 @@
}
-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 @@
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.
Modified: llvm/trunk/tools/llvm-mc/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.cpp Mon Jun 29 19:49:23 2009
@@ -42,14 +42,15 @@
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;
}
Modified: llvm/trunk/tools/llvm-mc/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.h Mon Jun 29 19:49:23 2009
@@ -97,7 +97,7 @@
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();
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Mon Jun 29 19:49:23 2009
@@ -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 @@
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 @@
// 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;
}
}
Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Mon Jun 29 19:49:23 2009
@@ -39,7 +39,8 @@
private:
bool ParseStatement();
-
+
+ void Warning(SMLoc L, const char *Msg);
bool Error(SMLoc L, const char *Msg);
bool TokError(const char *Msg);
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Mon Jun 29 19:49:23 2009
@@ -80,7 +80,7 @@
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:
Modified: llvm/trunk/utils/TableGen/TGLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGLexer.cpp (original)
+++ llvm/trunk/utils/TableGen/TGLexer.cpp Mon Jun 29 19:49:23 2009
@@ -44,11 +44,11 @@
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");
}
Modified: llvm/trunk/utils/TableGen/TableGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=74489&r1=74488&r2=74489&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TableGen.cpp (original)
+++ llvm/trunk/utils/TableGen/TableGen.cpp Mon Jun 29 19:49:23 2009
@@ -127,7 +127,7 @@
static SourceMgr SrcMgr;
void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
- SrcMgr.PrintMessage(ErrorLoc, Msg);
+ SrcMgr.PrintMessage(ErrorLoc, Msg, "error");
}
More information about the llvm-commits
mailing list