aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser/ELFAsmParser.cpp
diff options
context:
space:
mode:
authorNirav Dave <niravd@google.com>2016-07-18 15:24:03 +0000
committerNirav Dave <niravd@google.com>2016-07-18 15:24:03 +0000
commita645433c5fac7910c199e8bd381942f2b6f0c0d5 (patch)
tree23dd61712189ef3db0462e6333255ff037e17334 /llvm/lib/MC/MCParser/ELFAsmParser.cpp
parent393b37937b4edc1388bdef88469f5fe9ff8003dd (diff)
downloadllvm-a645433c5fac7910c199e8bd381942f2b6f0c0d5.zip
llvm-a645433c5fac7910c199e8bd381942f2b6f0c0d5.tar.gz
llvm-a645433c5fac7910c199e8bd381942f2b6f0c0d5.tar.bz2
[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 llvm-svn: 275795
Diffstat (limited to 'llvm/lib/MC/MCParser/ELFAsmParser.cpp')
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index 533ae1f..47d19a8 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -212,6 +212,7 @@ bool ELFAsmParser::ParseDirectiveSize(StringRef, SMLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
+ Lex();
getStreamer().emitELFSize(Sym, Expr);
return false;
@@ -478,6 +479,7 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
EndStmt:
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
+ Lex();
unsigned Type = ELF::SHT_PROGBITS;
@@ -629,6 +631,10 @@ bool ELFAsmParser::ParseDirectiveIdent(StringRef, SMLoc) {
Lex();
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return TokError("unexpected token in '.ident' directive");
+ Lex();
+
getStreamer().EmitIdent(Data);
return false;
}
@@ -727,6 +733,8 @@ bool ELFAsmParser::ParseDirectiveSubsection(StringRef, SMLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
+ Lex();
+
getStreamer().SubSection(Subsection);
return false;
}