MC/AsmParser: Move .lsym parsing to Darwin specific parser.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 12 Jul 2010 19:08:25 +0000 (19:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 12 Jul 2010 19:08:25 +0000 (19:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108176 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/AsmParser.h
include/llvm/MC/MCParser/MCAsmParser.h
lib/MC/MCParser/AsmParser.cpp

index 4e89b995ad3bb3507f116cb44931c1374925707a..3e897b38338be0228e40284dea41970fc3bcb3df 100644 (file)
@@ -138,7 +138,6 @@ private:
   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"
index da9b6f228d93a7b572cfb7691558f30cff7abc8d..d0ccd0f617484c518e40b8fe5a2253414c9b5775 100644 (file)
@@ -73,6 +73,10 @@ public:
   /// \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
index 3a1cfc41a478521153e86aa5827bf7110ebebc45..e976c0a0b74708c2739989fe4b4d4cc93ee0dd88 100644 (file)
@@ -66,6 +66,8 @@ public:
     // 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 @@ public:
                              &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 @@ bool AsmParser::ParseStatement() {
       return ParseDirectiveDarwinZerofill();
     if (IDVal == ".desc")
       return ParseDirectiveDarwinSymbolDesc();
-    if (IDVal == ".lsym")
-      return ParseDirectiveDarwinLsym();
     if (IDVal == ".tbss")
       return ParseDirectiveDarwinTBSS();
 
@@ -1717,20 +1718,20 @@ bool AsmParser::ParseDirectiveAbort() {
 
 /// 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))