[llvm-commits] [llvm] r108176 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h include/llvm/MC/MCParser/MCAsmParser.h lib/MC/MCParser/AsmParser.cpp

Daniel Dunbar daniel at zuster.org
Mon Jul 12 12:08:25 PDT 2010


Author: ddunbar
Date: Mon Jul 12 14:08:25 2010
New Revision: 108176

URL: http://llvm.org/viewvc/llvm-project?rev=108176&view=rev
Log:
MC/AsmParser: Move .lsym parsing to Darwin specific parser.

Modified:
    llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
    llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmParser.h?rev=108176&r1=108175&r2=108176&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmParser.h Mon Jul 12 14:08:25 2010
@@ -138,7 +138,6 @@
   bool ParseDirectiveSymbolAttribute(MCSymbolAttr Attr);
   bool ParseDirectiveELFType(); // ELF specific ".type"
   bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
-  bool ParseDirectiveDarwinLsym(); // Darwin specific ".lsym"
 
   bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
   bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"

Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h?rev=108176&r1=108175&r2=108176&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h Mon Jul 12 14:08:25 2010
@@ -73,6 +73,10 @@
   /// \brief Report an error at the current lexer location.
   bool TokError(const char *Msg);
 
+  /// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
+  /// and set \arg Res to the identifier contents.
+  virtual bool ParseIdentifier(StringRef &Res) = 0;
+
   /// ParseExpression - Parse an arbitrary expression.
   ///
   /// @param Res - The value of the expression. The result is undefined

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=108176&r1=108175&r2=108176&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Jul 12 14:08:25 2010
@@ -66,6 +66,8 @@
     // Call the base implementation.
     this->MCAsmParserExtension::Initialize(Parser);
 
+    Parser.AddDirectiveHandler(this, ".lsym", MCAsmParser::DirectiveHandler(
+                                 &DarwinAsmParser::ParseDirectiveLsym));
     Parser.AddDirectiveHandler(this, ".subsections_via_symbols",
                                MCAsmParser::DirectiveHandler(
                         &DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols));
@@ -81,10 +83,11 @@
                              &DarwinAsmParser::ParseDirectiveSecureLogReset));
   }
 
-  bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
   bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
-  bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
+  bool ParseDirectiveLsym(StringRef, SMLoc);
   bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
+  bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
+  bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
 };
 
 }
@@ -836,8 +839,6 @@
       return ParseDirectiveDarwinZerofill();
     if (IDVal == ".desc")
       return ParseDirectiveDarwinSymbolDesc();
-    if (IDVal == ".lsym")
-      return ParseDirectiveDarwinLsym();
     if (IDVal == ".tbss")
       return ParseDirectiveDarwinTBSS();
 
@@ -1717,20 +1718,20 @@
 
 /// ParseDirectiveLsym
 ///  ::= .lsym identifier , expression
-bool AsmParser::ParseDirectiveDarwinLsym() {
+bool DarwinAsmParser::ParseDirectiveLsym(StringRef, SMLoc) {
   StringRef Name;
-  if (ParseIdentifier(Name))
+  if (getParser().ParseIdentifier(Name))
     return TokError("expected identifier in directive");
   
   // Handle the identifier as the key symbol.
-  MCSymbol *Sym = CreateSymbol(Name);
+  MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
 
   if (getLexer().isNot(AsmToken::Comma))
     return TokError("unexpected token in '.lsym' directive");
   Lex();
 
   const MCExpr *Value;
-  if (ParseExpression(Value))
+  if (getParser().ParseExpression(Value))
     return true;
 
   if (getLexer().isNot(AsmToken::EndOfStatement))





More information about the llvm-commits mailing list