rename SourceMgr::PrintError to PrintMessage.
authorChris Lattner <sabre@nondot.org>
Sun, 21 Jun 2009 21:22:11 +0000 (21:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 21 Jun 2009 21:22:11 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73861 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 53e7dd8dfbc24b0c9d1f448846361a7a3efe0f0b..25775cb74419d514201fa16d43071a11e83e747e 100644 (file)
@@ -107,10 +107,9 @@ public:
   /// specified file.  This is not a fast method.
   unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
   
-  
-  /// PrintError - Emit an error message about the specified location with the
+  /// PrintMessage - Emit a message about the specified location with the
   /// specified string.
-  void PrintError(SMLoc ErrorLoc, const std::string &Msg) const;
+  void PrintMessage(SMLoc Loc, const std::string &Msg) const;
   
 private:
   void PrintIncludeStack(SMLoc IncludeLoc) const;
index 5460cb3824d5fbeba8920363c8abe73bec4dcf2d..d789f1010be2d15cebef23aa07d0e7439b2541db 100644 (file)
@@ -90,12 +90,12 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const {
 }
 
 
-void SourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const {
+void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg) const {
   raw_ostream &OS = errs();
   
   // First thing to do: find the current buffer containing the specified
   // location.
-  int CurBuf = FindBufferContainingLoc(ErrorLoc);
+  int CurBuf = FindBufferContainingLoc(Loc);
   assert(CurBuf != -1 && "Invalid or unspecified location!");
   
   PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
@@ -104,24 +104,24 @@ void SourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const {
   
   
   OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
-     << FindLineNumber(ErrorLoc, CurBuf) << ": ";
+     << FindLineNumber(Loc, CurBuf) << ": ";
   
   OS << Msg << "\n";
   
   // Scan backward to find the start of the line.
-  const char *LineStart = ErrorLoc.getPointer();
+  const char *LineStart = Loc.getPointer();
   while (LineStart != CurMB->getBufferStart() && 
          LineStart[-1] != '\n' && LineStart[-1] != '\r')
     --LineStart;
   // Get the end of the line.
-  const char *LineEnd = ErrorLoc.getPointer();
+  const char *LineEnd = Loc.getPointer();
   while (LineEnd != CurMB->getBufferEnd() && 
          LineEnd[0] != '\n' && LineEnd[0] != '\r')
     ++LineEnd;
   // Print out the line.
   OS << std::string(LineStart, LineEnd) << "\n";
   // Print out spaces before the caret.
-  for (const char *Pos = LineStart; Pos != ErrorLoc.getPointer(); ++Pos)
+  for (const char *Pos = LineStart; Pos != Loc.getPointer(); ++Pos)
     OS << (*Pos == '\t' ? '\t' : ' ');
   OS << "^\n";
 }
index cf6a4a8c124c234db8a48f73dbd7390fbf1bfc4c..740215b683e92897ef9227b4c01d9d8dec3b1cbd 100644 (file)
@@ -29,18 +29,14 @@ SMLoc AsmLexer::getLoc() const {
   return SMLoc::getFromPointer(TokStart);
 }
 
-void AsmLexer::PrintError(const char *Loc, const std::string &Msg) const {
-  SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg);
-}
-
-void AsmLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
-  SrcMgr.PrintError(Loc, Msg);
+void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg) const {
+  SrcMgr.PrintMessage(Loc, Msg);
 }
 
 /// 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) {
-  PrintError(Loc, Msg);
+  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
   return asmtok::Error;
 }
 
@@ -203,10 +199,8 @@ asmtok::TokKind AsmLexer::LexQuote() {
       CurChar = getNextChar();
     }
     
-    if (CurChar == EOF) {
-      PrintError(TokStart, "unterminated string constant");
-      return asmtok::Eof;
-    }
+    if (CurChar == EOF)
+      return ReturnError(TokStart, "unterminated string constant");
 
     CurChar = getNextChar();
   }
index c668e8639cdc5b81a8e6fd8e8af69ae3e51e9040..bad2cb931b954eebad997c835655d594c6dfb9ec 100644 (file)
@@ -89,8 +89,7 @@ public:
   
   SMLoc getLoc() const;
   
-  void PrintError(const char *Loc, const std::string &Msg) const;
-  void PrintError(SMLoc Loc, const std::string &Msg) const;
+  void PrintMessage(SMLoc Loc, const std::string &Msg) const;
   
 private:
   int getNextChar();
index 9c0b4abb076b057ed1c03d3098871403d9463fbc..1940d7618949feadc9992dfb0e60d0d027fea648 100644 (file)
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
+bool AsmParser::Error(SMLoc L, const char *Msg) {
+  Lexer.PrintMessage(L, Msg);
+  return true;
+}
+
+bool AsmParser::TokError(const char *Msg) {
+  Lexer.PrintMessage(Lexer.getLoc(), Msg);
+  return true;
+}
+
+
 bool AsmParser::Run() {
   // Prime the lexer.
   Lexer.Lex();
@@ -34,8 +45,7 @@ bool AsmParser::Run() {
 bool AsmParser::ParseStatement() {
   switch (Lexer.getKind()) {
   default:
-    Lexer.PrintError(Lexer.getLoc(), "unexpected token at start of statement");
-    return true;
+    return TokError("unexpected token at start of statement");
   case asmtok::EndOfStatement:
     Lexer.Lex();
     return false;
index 5e1f6c65627fdd9a6555c801de7d12b3e4cdf6e0..66e1a9b42f5b20f7e694c8cbf65f3434a52d2eb6 100644 (file)
@@ -30,6 +30,8 @@ public:
 private:
   bool ParseStatement();
   
+  bool Error(SMLoc L, const char *Msg);
+  bool TokError(const char *Msg);
 };
 
 } // end namespace llvm
index 0acd78ea41d87cad00f7e5487996c33fa9e4d012..7d0c571c723c29f7a514f45bc278972d9868a108 100644 (file)
@@ -77,7 +77,7 @@ static int AsLexInput(const char *ProgName) {
   while (Tok != asmtok::Eof) {
     switch (Tok) {
     default:
-      Lexer.PrintError(Lexer.getLoc(), "driver: unknown token");
+      Lexer.PrintMessage(Lexer.getLoc(), "driver: unknown token");
       Error = true;
       break;
     case asmtok::Error:
index 976c123f5a81c522f8df306ed56b424dc0b4860c..6fe8d821e5f302821b593fbefd435aa6134f8014 100644 (file)
@@ -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.PrintError(SMLoc::getFromPointer(Loc), Msg);
+  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
 }
 
 void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
-  SrcMgr.PrintError(Loc, Msg);
+  SrcMgr.PrintMessage(Loc, Msg);
 }
 
 
index cb83cf3b4b81a520ca84a96802c4769f657b429c..038cde2cb7805acf2858d9c5d829e443c467a3bc 100644 (file)
@@ -127,7 +127,7 @@ RecordKeeper llvm::Records;
 static SourceMgr SrcMgr;
 
 void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
-  SrcMgr.PrintError(ErrorLoc, Msg);
+  SrcMgr.PrintMessage(ErrorLoc, Msg);
 }