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.

llvm-svn: 78637
This commit is contained in:
Daniel Dunbar 2009-08-11 03:42:33 +00:00
parent bb98db2d21
commit 9af747b421
2 changed files with 19 additions and 5 deletions

View File

@ -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

View File

@ -688,14 +688,24 @@ bool AsmParser::ParseDirectiveSet() {
/// FIXME: This should actually parse out the segment, section, attributes and
/// sizeof_stub fields.
bool AsmParser::ParseDirectiveDarwinSection() {
StringRef SectionName;
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 @@ bool AsmParser::ParseDirectiveDarwinSection() {
TAA, StubSize);
if (!ErrorStr.empty())
return TokError(ErrorStr.c_str());
return Error(Loc, ErrorStr.c_str());
// FIXME: CACHE THESE.