From 9af747b4211bebc673d01cce7e276007ec05d0f6 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 11 Aug 2009 03:42:33 +0000 Subject: 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 --- llvm/tools/llvm-mc/AsmParser.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-mc/AsmParser.cpp') 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. -- cgit v1.2.3