mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-11 21:57:55 +00:00
[MC] Cleanup Error Handling in AsmParser
Add parseToken and compatriot functions to stitch error checks in straight linear code. As part of this fix some erronous handling of directives where the EndOfStatement token either was not checked or Lexed on termination. Reviewers: rnk, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22312 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
56af121d06
commit
5646cdbe39
@ -428,7 +428,7 @@ void MCAsmStreamer::EmitLinkerOptions(ArrayRef<std::string> Options) {
|
|||||||
ie = Options.end(); it != ie; ++it) {
|
ie = Options.end(); it != ie; ++it) {
|
||||||
OS << ", " << '"' << *it << '"';
|
OS << ", " << '"' << *it << '"';
|
||||||
}
|
}
|
||||||
OS << "\n";
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitDataRegion(MCDataRegionType Kind) {
|
void MCAsmStreamer::EmitDataRegion(MCDataRegionType Kind) {
|
||||||
@ -614,7 +614,7 @@ void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
|||||||
Symbol->print(OS, MAI);
|
Symbol->print(OS, MAI);
|
||||||
OS << ", ";
|
OS << ", ";
|
||||||
Value->print(OS, MAI);
|
Value->print(OS, MAI);
|
||||||
OS << '\n';
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
@ -1243,10 +1243,10 @@ void MCAsmStreamer::EmitCFIEscape(StringRef Values) {
|
|||||||
|
|
||||||
void MCAsmStreamer::EmitCFIGnuArgsSize(int64_t Size) {
|
void MCAsmStreamer::EmitCFIGnuArgsSize(int64_t Size) {
|
||||||
MCStreamer::EmitCFIGnuArgsSize(Size);
|
MCStreamer::EmitCFIGnuArgsSize(Size);
|
||||||
|
|
||||||
uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
|
uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
|
||||||
unsigned Len = encodeULEB128(Size, Buffer + 1) + 1;
|
unsigned Len = encodeULEB128(Size, Buffer + 1) + 1;
|
||||||
|
|
||||||
PrintCFIEscape(OS, StringRef((const char *)&Buffer[0], Len));
|
PrintCFIEscape(OS, StringRef((const char *)&Buffer[0], Len));
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -537,7 +537,6 @@ bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
|
|||||||
|
|
||||||
Args.push_back(Data);
|
Args.push_back(Data);
|
||||||
|
|
||||||
Lex();
|
|
||||||
if (getLexer().is(AsmToken::EndOfStatement))
|
if (getLexer().is(AsmToken::EndOfStatement))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -212,6 +212,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
|
|||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
Lex();
|
||||||
|
|
||||||
getStreamer().emitELFSize(Sym, Expr);
|
getStreamer().emitELFSize(Sym, Expr);
|
||||||
return false;
|
return false;
|
||||||
@ -478,6 +479,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
|
|||||||
EndStmt:
|
EndStmt:
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
Lex();
|
||||||
|
|
||||||
unsigned Type = ELF::SHT_PROGBITS;
|
unsigned Type = ELF::SHT_PROGBITS;
|
||||||
|
|
||||||
@ -629,6 +631,10 @@ bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
|
|||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
|
return TokError("unexpected token in '.ident' directive");
|
||||||
|
Lex();
|
||||||
|
|
||||||
getStreamer().EmitIdent(Data);
|
getStreamer().EmitIdent(Data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -727,6 +733,8 @@ bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
|
|||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
|
||||||
|
Lex();
|
||||||
|
|
||||||
getStreamer().SubSection(Subsection);
|
getStreamer().SubSection(Subsection);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,5 @@ foo: #Comment here
|
|||||||
## WHOLE LINE COMMENT
|
## WHOLE LINE COMMENT
|
||||||
cmpl $196, %eax ## EOL COMMENT
|
cmpl $196, %eax ## EOL COMMENT
|
||||||
#endif
|
#endif
|
||||||
|
.ident "clang version 3.9.0"
|
||||||
|
.section ".note.GNU-stack","",@progbits
|
||||||
|
Loading…
Reference in New Issue
Block a user