[MC] Change "unexpected tokens" to "expected newline" and remove unneeded "in .xxx directive"

This commit is contained in:
Fangrui Song 2021-06-02 16:08:05 -07:00
parent 60ce8babf7
commit c980d93d91
2 changed files with 18 additions and 23 deletions

View File

@ -4776,20 +4776,18 @@ bool X86AsmParser::parseDirectiveFPOProc(SMLoc L) {
return true;
if (!isUIntN(32, ParamsSize))
return Parser.TokError("parameters size out of range");
if (Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_proc' directive");
if (parseEOL())
return true;
MCSymbol *ProcSym = getContext().getOrCreateSymbol(ProcName);
return getTargetStreamer().emitFPOProc(ProcSym, ParamsSize, L);
}
// .cv_fpo_setframe ebp
bool X86AsmParser::parseDirectiveFPOSetFrame(SMLoc L) {
MCAsmParser &Parser = getParser();
unsigned Reg;
SMLoc DummyLoc;
if (ParseRegister(Reg, DummyLoc, DummyLoc) ||
Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_setframe' directive");
if (ParseRegister(Reg, DummyLoc, DummyLoc) || parseEOL())
return true;
return getTargetStreamer().emitFPOSetFrame(Reg, L);
}
@ -4798,9 +4796,8 @@ bool X86AsmParser::parseDirectiveFPOPushReg(SMLoc L) {
MCAsmParser &Parser = getParser();
unsigned Reg;
SMLoc DummyLoc;
if (ParseRegister(Reg, DummyLoc, DummyLoc) ||
Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_pushreg' directive");
if (ParseRegister(Reg, DummyLoc, DummyLoc) || parseEOL())
return true;
return getTargetStreamer().emitFPOPushReg(Reg, L);
}
@ -4808,9 +4805,8 @@ bool X86AsmParser::parseDirectiveFPOPushReg(SMLoc L) {
bool X86AsmParser::parseDirectiveFPOStackAlloc(SMLoc L) {
MCAsmParser &Parser = getParser();
int64_t Offset;
if (Parser.parseIntToken(Offset, "expected offset") ||
Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_stackalloc' directive");
if (Parser.parseIntToken(Offset, "expected offset") || parseEOL())
return true;
return getTargetStreamer().emitFPOStackAlloc(Offset, L);
}
@ -4818,25 +4814,24 @@ bool X86AsmParser::parseDirectiveFPOStackAlloc(SMLoc L) {
bool X86AsmParser::parseDirectiveFPOStackAlign(SMLoc L) {
MCAsmParser &Parser = getParser();
int64_t Offset;
if (Parser.parseIntToken(Offset, "expected offset") ||
Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_stackalign' directive");
if (Parser.parseIntToken(Offset, "expected offset") || parseEOL())
return true;
return getTargetStreamer().emitFPOStackAlign(Offset, L);
}
// .cv_fpo_endprologue
bool X86AsmParser::parseDirectiveFPOEndPrologue(SMLoc L) {
MCAsmParser &Parser = getParser();
if (Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_endprologue' directive");
if (Parser.parseEOL())
return true;
return getTargetStreamer().emitFPOEndPrologue(L);
}
// .cv_fpo_endproc
bool X86AsmParser::parseDirectiveFPOEndProc(SMLoc L) {
MCAsmParser &Parser = getParser();
if (Parser.parseEOL("unexpected tokens"))
return addErrorSuffix(" in '.cv_fpo_endproc' directive");
if (Parser.parseEOL())
return true;
return getTargetStreamer().emitFPOEndProc(L);
}

View File

@ -9,7 +9,7 @@ _foo:
.cv_fpo_proc _foo extra
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: expected parameter byte count
.cv_fpo_proc _foo 4 extra
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: unexpected tokens
# CHECK: :[[#@LINE-1]]:22: error: expected newline
.cv_fpo_proc _foo 4
pushl %ebp
@ -21,17 +21,17 @@ _foo:
.cv_fpo_stackalloc asdf
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: expected offset
.cv_fpo_stackalloc 20 asdf
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: unexpected tokens
# CHECK: :[[#@LINE-1]]:24: error: expected newline
.cv_fpo_stackalloc 20
.cv_fpo_endprologue asdf
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: unexpected tokens
# CHECK: :[[#@LINE-1]]:22: error: expected newline
.cv_fpo_endprologue
addl $20, %esp
popl %ebp
retl
.cv_fpo_endproc asdf
# CHECK: :[[#@LINE-1]]:{{[0-9]+}}: error: unexpected tokens
# CHECK: :[[#@LINE-1]]:18: error: expected newline
.cv_fpo_endproc
.section .debug$S,"dr"