ARM asm parser should be more lenient w/ .thumb_func directive.

Rather than require the symbol to be explicitly an argument of the directive,
allow it to look ahead and grab the symbol from the next non-whitespace
line.

rdar://10611140

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147100 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2011-12-21 22:30:16 +00:00
parent 483716015f
commit de4d83943a

View File

@ -6421,23 +6421,32 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
const MCAsmInfo &MAI = getParser().getStreamer().getContext().getAsmInfo(); const MCAsmInfo &MAI = getParser().getStreamer().getContext().getAsmInfo();
bool isMachO = MAI.hasSubsectionsViaSymbols(); bool isMachO = MAI.hasSubsectionsViaSymbols();
StringRef Name; StringRef Name;
bool needFuncName = true;
// Darwin asm has function name after .thumb_func direction // Darwin asm has (optionally) function name after .thumb_func direction
// ELF doesn't // ELF doesn't
if (isMachO) { if (isMachO) {
const AsmToken &Tok = Parser.getTok(); const AsmToken &Tok = Parser.getTok();
if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) if (Tok.isNot(AsmToken::EndOfStatement)) {
return Error(L, "unexpected token in .thumb_func directive"); if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String))
Name = Tok.getIdentifier(); return Error(L, "unexpected token in .thumb_func directive");
Parser.Lex(); // Consume the identifier token. Name = Tok.getIdentifier();
Parser.Lex(); // Consume the identifier token.
needFuncName = false;
}
} }
if (getLexer().isNot(AsmToken::EndOfStatement)) if (getLexer().isNot(AsmToken::EndOfStatement))
return Error(L, "unexpected token in directive"); return Error(L, "unexpected token in directive");
Parser.Lex();
// Eat the end of statement and any blank lines that follow.
while (getLexer().is(AsmToken::EndOfStatement))
Parser.Lex();
// FIXME: assuming function name will be the line following .thumb_func // FIXME: assuming function name will be the line following .thumb_func
if (!isMachO) { // We really should be checking the next symbol definition even if there's
// stuff in between.
if (needFuncName) {
Name = Parser.getTok().getIdentifier(); Name = Parser.getTok().getIdentifier();
} }