diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-08-11 03:42:33 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-11 03:42:33 +0000 |
| commit | 9af747b4211bebc673d01cce7e276007ec05d0f6 (patch) | |
| tree | 0cded69466515a67cb69d9a82e1b6acefacb6b7b /llvm/tools/llvm-mc/AsmParser.cpp | |
| parent | bb98db2d21e80c697a8f9da58a12337fc790a8e0 (diff) | |
| download | bcm5719-llvm-9af747b4211bebc673d01cce7e276007ec05d0f6.tar.gz bcm5719-llvm-9af747b4211bebc673d01cce7e276007ec05d0f6.zip | |
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
Diffstat (limited to 'llvm/tools/llvm-mc/AsmParser.cpp')
| -rw-r--r-- | llvm/tools/llvm-mc/AsmParser.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp index 09ca3f2ef16..b4fdd83f7bb 100644 --- a/llvm/tools/llvm-mc/AsmParser.cpp +++ b/llvm/tools/llvm-mc/AsmParser.cpp @@ -688,14 +688,24 @@ bool AsmParser::ParseDirectiveSet() { /// 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 @@ bool AsmParser::ParseDirectiveDarwinSection() { TAA, StubSize); if (!ErrorStr.empty()) - return TokError(ErrorStr.c_str()); + return Error(Loc, ErrorStr.c_str()); // FIXME: CACHE THESE. |

