[llvm-commits] [llvm] r94047 - in /llvm/trunk/tools/llvm-mc: AsmLexer.cpp AsmLexer.h AsmParser.cpp AsmParser.h llvm-mc.cpp

Sean Callanan scallanan at apple.com
Wed Jan 20 15:19:55 PST 2010


Author: spyffe
Date: Wed Jan 20 17:19:55 2010
New Revision: 94047

URL: http://llvm.org/viewvc/llvm-project?rev=94047&view=rev
Log:
Changed the AsmParser to handle error messages itself
rather than passing them off to the AsmLexer to handle.
This means the AsmLexer no longer requires a SourceMgr
to do error handling.

Modified:
    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

Modified: llvm/trunk/tools/llvm-mc/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.cpp?rev=94047&r1=94046&r2=94047&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.cpp Wed Jan 20 17:19:55 2010
@@ -36,11 +36,6 @@
   return SMLoc::getFromPointer(TokStart);
 }
 
-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 AsmToken::Error.
 AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {

Modified: llvm/trunk/tools/llvm-mc/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=94047&r1=94046&r2=94047&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.h Wed Jan 20 17:19:55 2010
@@ -61,8 +61,6 @@
   /// EnterIncludeFile - Enter the specified file. This returns true on failure.
   bool EnterIncludeFile(const std::string &Filename);
   
-  void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
-
   const MCAsmInfo &getMAI() const { return MAI; }
 
 private:

Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=94047&r1=94046&r2=94047&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Wed Jan 20 17:19:55 2010
@@ -87,24 +87,29 @@
 }
 
 void AsmParser::Warning(SMLoc L, const Twine &Msg) {
-  Lexer.PrintMessage(L, Msg.str(), "warning");
+  PrintMessage(L, Msg.str(), "warning");
 }
 
 bool AsmParser::Error(SMLoc L, const Twine &Msg) {
-  Lexer.PrintMessage(L, Msg.str(), "error");
+  PrintMessage(L, Msg.str(), "error");
   return true;
 }
 
 bool AsmParser::TokError(const char *Msg) {
-  Lexer.PrintMessage(Lexer.getLoc(), Msg, "error");
+  PrintMessage(Lexer.getLoc(), Msg, "error");
   return true;
 }
 
+void AsmParser::PrintMessage(SMLoc Loc, const std::string &Msg, 
+                             const char *Type) const {
+  SrcMgr.PrintMessage(Loc, Msg, Type);
+}
+
 const AsmToken &AsmParser::Lex() {
   const AsmToken &tok = Lexer.Lex();
   
   if (tok.is(AsmToken::Error))
-    Lexer.PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error");
+    PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error");
   
   return tok;
 }
@@ -1518,9 +1523,9 @@
   // Attempt to switch the lexer to the included file before consuming the end
   // of statement to avoid losing it when we switch.
   if (Lexer.EnterIncludeFile(Filename)) {
-    Lexer.PrintMessage(IncludeLoc,
-                       "Could not find include file '" + Filename + "'",
-                       "error");
+    PrintMessage(IncludeLoc,
+                 "Could not find include file '" + Filename + "'",
+                 "error");
     return true;
   }
 

Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=94047&r1=94046&r2=94047&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Wed Jan 20 17:19:55 2010
@@ -105,6 +105,8 @@
 
   bool TokError(const char *Msg);
   
+  void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
+  
   bool ParseConditionalAssemblyDirectives(StringRef Directive,
                                           SMLoc DirectiveLoc);
   void EatToEndOfStatement();

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=94047&r1=94046&r2=94047&view=diff

==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed Jan 20 17:19:55 2010
@@ -141,7 +141,7 @@
   while (Lexer.Lex().isNot(AsmToken::Eof)) {
     switch (Lexer.getKind()) {
     default:
-      Lexer.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
+      SrcMgr.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
       Error = true;
       break;
     case AsmToken::Error:





More information about the llvm-commits mailing list