[llvm-commits] [llvm] r78637 - in /llvm/trunk: test/MC/AsmParser/directive_darwin_section.s tools/llvm-mc/AsmParser.cpp

Daniel Dunbar daniel at zuster.org
Mon Aug 10 20:42:35 PDT 2009


Author: ddunbar
Date: Mon Aug 10 22:42:33 2009
New Revision: 78637

URL: http://llvm.org/viewvc/llvm-project?rev=78637&view=rev
Log:
llvm-mc: Fix darwin .section parsing. It was skipping the section name and a ','
(and outputting a diagnostic pointing at the wrong place), all of which lead to
much confusion.

Added:
    llvm/trunk/test/MC/AsmParser/directive_darwin_section.s
Modified:
    llvm/trunk/tools/llvm-mc/AsmParser.cpp

Added: llvm/trunk/test/MC/AsmParser/directive_darwin_section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_darwin_section.s?rev=78637&view=auto

==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_darwin_section.s (added)
+++ llvm/trunk/test/MC/AsmParser/directive_darwin_section.s Mon Aug 10 22:42:33 2009
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s
+
+# CHECK: .section __DWARF,__debug_frame,regular,debug
+	.section	__DWARF,__debug_frame,regular,debug

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

==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Mon Aug 10 22:42:33 2009
@@ -688,14 +688,24 @@
 /// FIXME: This should actually parse out the segment, section, attributes and
 /// sizeof_stub fields.
 bool AsmParser::ParseDirectiveDarwinSection() {
+  SMLoc Loc = Lexer.getLoc();
+
   StringRef SectionName;
+  if (ParseIdentifier(SectionName))
+    return Error(Loc, "expected identifier after '.section' directive");
+
+  // Verify there is a following comma.
+  if (!Lexer.is(AsmToken::Comma))
+    return TokError("unexpected token in '.section' directive");
 
-  if (Lexer.isNot(AsmToken::Identifier))
-    return TokError("expected identifier after '.section' directive");
-  
   std::string SectionSpec = SectionName;
+  SectionSpec += ",";
+
+  // Add all the tokens until the end of the line, ParseSectionSpecifier will
+  // handle this.
   StringRef EOL = Lexer.LexUntilEndOfStatement();
   SectionSpec.append(EOL.begin(), EOL.end());
+
   Lexer.Lex();
   if (Lexer.isNot(AsmToken::EndOfStatement))
     return TokError("unexpected token in '.section' directive");
@@ -709,7 +719,7 @@
                                           TAA, StubSize);
   
   if (!ErrorStr.empty())
-    return TokError(ErrorStr.c_str());
+    return Error(Loc, ErrorStr.c_str());
   
   // FIXME: CACHE THESE.
   





More information about the llvm-commits mailing list