summaryrefslogtreecommitdiff
path: root/tools/llvm-mc/AsmParser.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-11 03:42:33 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-11 03:42:33 +0000
commitace63127bc7501d4d7707f744cdae09894342aa9 (patch)
treec8ae97464c17bc0e1fff0a911b3c97608073adaa /tools/llvm-mc/AsmParser.cpp
parentea6408f8cd17b065e414611e01a7133d118429e9 (diff)
downloadllvm-ace63127bc7501d4d7707f744cdae09894342aa9.tar.gz
llvm-ace63127bc7501d4d7707f744cdae09894342aa9.tar.bz2
llvm-ace63127bc7501d4d7707f744cdae09894342aa9.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc/AsmParser.cpp')
-rw-r--r--tools/llvm-mc/AsmParser.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 09ca3f2ef1..b4fdd83f7b 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/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.