mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[MC] Add MCAsmParser::parseComma to improve diagnostics
llvm-mc will error "expected comma" instead of "unexpected token".
This commit is contained in:
parent
3389648c5f
commit
c70d7b131b
@ -260,6 +260,7 @@ public:
|
|||||||
/// success.
|
/// success.
|
||||||
bool parseOptionalToken(AsmToken::TokenKind T);
|
bool parseOptionalToken(AsmToken::TokenKind T);
|
||||||
|
|
||||||
|
bool parseComma() { return parseToken(AsmToken::Comma, "expected comma"); }
|
||||||
bool parseEOL();
|
bool parseEOL();
|
||||||
bool parseEOL(const Twine &ErrMsg);
|
bool parseEOL(const Twine &ErrMsg);
|
||||||
|
|
||||||
|
@ -2942,8 +2942,8 @@ bool AsmParser::parseIdentifier(StringRef &Res) {
|
|||||||
/// ::= .set identifier ',' expression
|
/// ::= .set identifier ',' expression
|
||||||
bool AsmParser::parseDirectiveSet(StringRef IDVal, bool allow_redef) {
|
bool AsmParser::parseDirectiveSet(StringRef IDVal, bool allow_redef) {
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
if (check(parseIdentifier(Name), "expected identifier") ||
|
if (check(parseIdentifier(Name), "expected identifier") || parseComma() ||
|
||||||
parseToken(AsmToken::Comma) || parseAssignment(Name, allow_redef, true))
|
parseAssignment(Name, allow_redef, true))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -3071,7 +3071,7 @@ bool AsmParser::parseDirectiveReloc(SMLoc DirectiveLoc) {
|
|||||||
|
|
||||||
if (parseExpression(Offset))
|
if (parseExpression(Offset))
|
||||||
return true;
|
return true;
|
||||||
if (parseToken(AsmToken::Comma, "expected comma") ||
|
if (parseComma() ||
|
||||||
check(getTok().isNot(AsmToken::Identifier), "expected relocation name"))
|
check(getTok().isNot(AsmToken::Identifier), "expected relocation name"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -3425,9 +3425,7 @@ bool AsmParser::parseDirectiveFile(SMLoc DirectiveLoc) {
|
|||||||
|
|
||||||
// Usually the directory and filename together, otherwise just the directory.
|
// Usually the directory and filename together, otherwise just the directory.
|
||||||
// Allow the strings to have escaped octal character sequence.
|
// Allow the strings to have escaped octal character sequence.
|
||||||
if (check(getTok().isNot(AsmToken::String),
|
if (parseEscapedString(Path))
|
||||||
"unexpected token in '.file' directive") ||
|
|
||||||
parseEscapedString(Path))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
StringRef Directory;
|
StringRef Directory;
|
||||||
@ -3859,14 +3857,12 @@ bool AsmParser::parseDirectiveCVLinetable() {
|
|||||||
int64_t FunctionId;
|
int64_t FunctionId;
|
||||||
StringRef FnStartName, FnEndName;
|
StringRef FnStartName, FnEndName;
|
||||||
SMLoc Loc = getTok().getLoc();
|
SMLoc Loc = getTok().getLoc();
|
||||||
if (parseCVFunctionId(FunctionId, ".cv_linetable") ||
|
if (parseCVFunctionId(FunctionId, ".cv_linetable") || parseComma() ||
|
||||||
parseToken(AsmToken::Comma,
|
parseTokenLoc(Loc) ||
|
||||||
"unexpected token in '.cv_linetable' directive") ||
|
check(parseIdentifier(FnStartName), Loc,
|
||||||
parseTokenLoc(Loc) || check(parseIdentifier(FnStartName), Loc,
|
|
||||||
"expected identifier in directive") ||
|
"expected identifier in directive") ||
|
||||||
parseToken(AsmToken::Comma,
|
parseComma() || parseTokenLoc(Loc) ||
|
||||||
"unexpected token in '.cv_linetable' directive") ||
|
check(parseIdentifier(FnEndName), Loc,
|
||||||
parseTokenLoc(Loc) || check(parseIdentifier(FnEndName), Loc,
|
|
||||||
"expected identifier in directive"))
|
"expected identifier in directive"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4100,7 +4096,7 @@ bool AsmParser::parseDirectiveCFISections() {
|
|||||||
Debug = true;
|
Debug = true;
|
||||||
if (parseOptionalToken(AsmToken::EndOfStatement))
|
if (parseOptionalToken(AsmToken::EndOfStatement))
|
||||||
break;
|
break;
|
||||||
if (parseToken(AsmToken::Comma))
|
if (parseComma())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4156,8 +4152,7 @@ bool AsmParser::parseRegisterOrRegisterNumber(int64_t &Register,
|
|||||||
/// ::= .cfi_def_cfa register, offset
|
/// ::= .cfi_def_cfa register, offset
|
||||||
bool AsmParser::parseDirectiveCFIDefCfa(SMLoc DirectiveLoc) {
|
bool AsmParser::parseDirectiveCFIDefCfa(SMLoc DirectiveLoc) {
|
||||||
int64_t Register = 0, Offset = 0;
|
int64_t Register = 0, Offset = 0;
|
||||||
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) ||
|
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) || parseComma() ||
|
||||||
parseToken(AsmToken::Comma, "unexpected token in directive") ||
|
|
||||||
parseAbsoluteExpression(Offset) || parseEOL())
|
parseAbsoluteExpression(Offset) || parseEOL())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4180,8 +4175,7 @@ bool AsmParser::parseDirectiveCFIDefCfaOffset() {
|
|||||||
/// ::= .cfi_register register, register
|
/// ::= .cfi_register register, register
|
||||||
bool AsmParser::parseDirectiveCFIRegister(SMLoc DirectiveLoc) {
|
bool AsmParser::parseDirectiveCFIRegister(SMLoc DirectiveLoc) {
|
||||||
int64_t Register1 = 0, Register2 = 0;
|
int64_t Register1 = 0, Register2 = 0;
|
||||||
if (parseRegisterOrRegisterNumber(Register1, DirectiveLoc) ||
|
if (parseRegisterOrRegisterNumber(Register1, DirectiveLoc) || parseComma() ||
|
||||||
parseToken(AsmToken::Comma, "unexpected token in directive") ||
|
|
||||||
parseRegisterOrRegisterNumber(Register2, DirectiveLoc) || parseEOL())
|
parseRegisterOrRegisterNumber(Register2, DirectiveLoc) || parseEOL())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4226,8 +4220,7 @@ bool AsmParser::parseDirectiveCFIOffset(SMLoc DirectiveLoc) {
|
|||||||
int64_t Register = 0;
|
int64_t Register = 0;
|
||||||
int64_t Offset = 0;
|
int64_t Offset = 0;
|
||||||
|
|
||||||
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) ||
|
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) || parseComma() ||
|
||||||
parseToken(AsmToken::Comma, "unexpected token in directive") ||
|
|
||||||
parseAbsoluteExpression(Offset) || parseEOL())
|
parseAbsoluteExpression(Offset) || parseEOL())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4240,8 +4233,7 @@ bool AsmParser::parseDirectiveCFIOffset(SMLoc DirectiveLoc) {
|
|||||||
bool AsmParser::parseDirectiveCFIRelOffset(SMLoc DirectiveLoc) {
|
bool AsmParser::parseDirectiveCFIRelOffset(SMLoc DirectiveLoc) {
|
||||||
int64_t Register = 0, Offset = 0;
|
int64_t Register = 0, Offset = 0;
|
||||||
|
|
||||||
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) ||
|
if (parseRegisterOrRegisterNumber(Register, DirectiveLoc) || parseComma() ||
|
||||||
parseToken(AsmToken::Comma, "unexpected token in directive") ||
|
|
||||||
parseAbsoluteExpression(Offset) || parseEOL())
|
parseAbsoluteExpression(Offset) || parseEOL())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -4284,7 +4276,7 @@ bool AsmParser::parseDirectiveCFIPersonalityOrLsda(bool IsPersonality) {
|
|||||||
|
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
if (check(!isValidEncoding(Encoding), "unsupported encoding.") ||
|
if (check(!isValidEncoding(Encoding), "unsupported encoding.") ||
|
||||||
parseToken(AsmToken::Comma, "unexpected token in directive") ||
|
parseComma() ||
|
||||||
check(parseIdentifier(Name), "expected identifier in directive") ||
|
check(parseIdentifier(Name), "expected identifier in directive") ||
|
||||||
parseEOL())
|
parseEOL())
|
||||||
return true;
|
return true;
|
||||||
@ -4791,8 +4783,7 @@ bool AsmParser::parseDirectiveDCB(StringRef IDVal, unsigned Size) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseToken(AsmToken::Comma,
|
if (parseComma())
|
||||||
"unexpected token in '" + Twine(IDVal) + "' directive"))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const MCExpr *Value;
|
const MCExpr *Value;
|
||||||
@ -4829,8 +4820,7 @@ bool AsmParser::parseDirectiveRealDCB(StringRef IDVal, const fltSemantics &Seman
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseToken(AsmToken::Comma,
|
if (parseComma())
|
||||||
"unexpected token in '" + Twine(IDVal) + "' directive"))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
APInt AsInt;
|
APInt AsInt;
|
||||||
@ -4924,9 +4914,8 @@ bool AsmParser::parseDirectiveComm(bool IsLocal) {
|
|||||||
// Handle the identifier as the key symbol.
|
// Handle the identifier as the key symbol.
|
||||||
MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
|
MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (parseComma())
|
||||||
return TokError("unexpected token in directive");
|
return true;
|
||||||
Lex();
|
|
||||||
|
|
||||||
int64_t Size;
|
int64_t Size;
|
||||||
SMLoc SizeLoc = getLexer().getLoc();
|
SMLoc SizeLoc = getLexer().getLoc();
|
||||||
@ -5139,7 +5128,7 @@ bool AsmParser::parseDirectiveIfc(SMLoc DirectiveLoc, bool ExpectEqual) {
|
|||||||
} else {
|
} else {
|
||||||
StringRef Str1 = parseStringToComma();
|
StringRef Str1 = parseStringToComma();
|
||||||
|
|
||||||
if (parseToken(AsmToken::Comma, "unexpected token in '.ifc' directive"))
|
if (parseComma())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
StringRef Str2 = parseStringToEndOfStatement();
|
StringRef Str2 = parseStringToEndOfStatement();
|
||||||
@ -5628,8 +5617,7 @@ bool AsmParser::parseDirectiveIrp(SMLoc DirectiveLoc) {
|
|||||||
MCAsmMacroArguments A;
|
MCAsmMacroArguments A;
|
||||||
if (check(parseIdentifier(Parameter.Name),
|
if (check(parseIdentifier(Parameter.Name),
|
||||||
"expected identifier in '.irp' directive") ||
|
"expected identifier in '.irp' directive") ||
|
||||||
parseToken(AsmToken::Comma, "expected comma in '.irp' directive") ||
|
parseComma() || parseMacroArguments(nullptr, A) || parseEOL())
|
||||||
parseMacroArguments(nullptr, A) || parseEOL())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Lex the irp definition.
|
// Lex the irp definition.
|
||||||
@ -5662,8 +5650,7 @@ bool AsmParser::parseDirectiveIrpc(SMLoc DirectiveLoc) {
|
|||||||
|
|
||||||
if (check(parseIdentifier(Parameter.Name),
|
if (check(parseIdentifier(Parameter.Name),
|
||||||
"expected identifier in '.irpc' directive") ||
|
"expected identifier in '.irpc' directive") ||
|
||||||
parseToken(AsmToken::Comma, "expected comma in '.irpc' directive") ||
|
parseComma() || parseMacroArguments(nullptr, A))
|
||||||
parseMacroArguments(nullptr, A))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (A.size() != 1 || A.front().size() != 1)
|
if (A.size() != 1 || A.front().size() != 1)
|
||||||
|
@ -49,7 +49,7 @@ TEST6:
|
|||||||
# ERR: :[[#@LINE+1]]:6: warning: '.dcb' directive with negative repeat count has no effect
|
# ERR: :[[#@LINE+1]]:6: warning: '.dcb' directive with negative repeat count has no effect
|
||||||
.dcb -1, 2
|
.dcb -1, 2
|
||||||
|
|
||||||
# ERR: :[[#@LINE+1]]:8: error: unexpected token in '.dcb' directive
|
# ERR: :[[#@LINE+1]]:8: error: expected comma
|
||||||
.dcb 1 2
|
.dcb 1 2
|
||||||
|
|
||||||
# ERR: :[[#@LINE+1]]:11: error: expected newline
|
# ERR: :[[#@LINE+1]]:11: error: expected newline
|
||||||
|
@ -446,9 +446,9 @@ f37:
|
|||||||
.ifdef ERR
|
.ifdef ERR
|
||||||
// ERR: [[#@LINE+1]]:15: error: expected .eh_frame or .debug_frame
|
// ERR: [[#@LINE+1]]:15: error: expected .eh_frame or .debug_frame
|
||||||
.cfi_sections $
|
.cfi_sections $
|
||||||
// ERR: [[#@LINE+1]]:28: error: unexpected token
|
// ERR: [[#@LINE+1]]:28: error: expected comma
|
||||||
.cfi_sections .debug_frame $
|
.cfi_sections .debug_frame $
|
||||||
// ERR: [[#@LINE+1]]:39: error: unexpected token
|
// ERR: [[#@LINE+1]]:39: error: expected comma
|
||||||
.cfi_sections .debug_frame, .eh_frame $
|
.cfi_sections .debug_frame, .eh_frame $
|
||||||
|
|
||||||
// ERR: [[#@LINE+1]]:16: error: unexpected token
|
// ERR: [[#@LINE+1]]:16: error: unexpected token
|
||||||
|
Loading…
Reference in New Issue
Block a user