[llvm] e416515 - MC: Use parseEOL
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 28 00:52:39 PDT 2023
Author: Fangrui Song
Date: 2023-04-28T00:52:33-07:00
New Revision: e416515115337648ae6e694db22fe4d8196e6155
URL: https://github.com/llvm/llvm-project/commit/e416515115337648ae6e694db22fe4d8196e6155
DIFF: https://github.com/llvm/llvm-project/commit/e416515115337648ae6e694db22fe4d8196e6155.diff
LOG: MC: Use parseEOL
The diagnostics have changed from "unexpected token" to clearer "expected newline"
Added:
Modified:
llvm/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/MC/ARM/directive_parsing.s
llvm/test/MC/MachO/ARM/build-version-diagnostics.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index 67311f1608f55..7c390041b3698 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -1130,7 +1130,7 @@ bool DarwinAsmParser::parseVersionMin(StringRef Directive, SMLoc Loc,
if (isSDKVersionToken(getLexer().getTok()) && parseSDKVersion(SDKVersion))
return true;
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(Twine(" in '") + Directive + "' directive");
Triple::OSType ExpectedOS = getOSTypeFromMCVM(Type);
@@ -1191,7 +1191,7 @@ bool DarwinAsmParser::parseBuildVersion(StringRef Directive, SMLoc Loc) {
if (isSDKVersionToken(getLexer().getTok()) && parseSDKVersion(SDKVersion))
return true;
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in '.build_version' directive");
Triple::OSType ExpectedOS
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 211a10eba792a..d522b77c25874 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -4537,7 +4537,7 @@ bool MasmParser::parseDirectiveStruct(StringRef Directive,
"' directive; expected none or NONUNIQUE");
}
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in '" + Twine(Directive) + "' directive");
StructInProgress.emplace_back(Name, DirKind == DK_UNION, AlignmentValue);
@@ -4559,7 +4559,7 @@ bool MasmParser::parseDirectiveNestedStruct(StringRef Directive,
Name = getTok().getIdentifier();
parseToken(AsmToken::Identifier);
}
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in '" + Twine(Directive) + "' directive");
// Reserve space to ensure Alignment doesn't get invalidated when
@@ -4585,7 +4585,7 @@ bool MasmParser::parseDirectiveEnds(StringRef Name, SMLoc NameLoc) {
Structure.Size, std::min(Structure.Alignment, Structure.AlignmentSize));
Structs[Name.lower()] = Structure;
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in ENDS directive");
return false;
@@ -4597,7 +4597,7 @@ bool MasmParser::parseDirectiveNestedEnds() {
if (StructInProgress.size() == 1)
return TokError("missing name in top-level ENDS directive");
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in nested ENDS directive");
StructInfo Structure = StructInProgress.pop_back_val();
@@ -4669,7 +4669,7 @@ bool MasmParser::parseDirectiveOrg() {
SMLoc OffsetLoc = Lexer.getLoc();
if (checkForValidSection() || parseExpression(Offset))
return true;
- if (parseToken(AsmToken::EndOfStatement))
+ if (parseEOL())
return addErrorSuffix(" in 'org' directive");
if (StructInProgress.empty()) {
@@ -4738,10 +4738,9 @@ bool MasmParser::parseDirectiveAlign() {
if (getTok().is(AsmToken::EndOfStatement)) {
return Warning(AlignmentLoc,
"align directive with no operand is ignored") &&
- parseToken(AsmToken::EndOfStatement);
+ parseEOL();
}
- if (parseAbsoluteExpression(Alignment) ||
- parseToken(AsmToken::EndOfStatement))
+ if (parseAbsoluteExpression(Alignment) || parseEOL())
return addErrorSuffix(" in align directive");
// Always emit an alignment here even if we throw an error.
@@ -4764,7 +4763,7 @@ bool MasmParser::parseDirectiveAlign() {
/// parseDirectiveEven
/// ::= even
bool MasmParser::parseDirectiveEven() {
- if (parseToken(AsmToken::EndOfStatement) || emitAlignTo(2))
+ if (parseEOL() || emitAlignTo(2))
return addErrorSuffix(" in even directive");
return false;
@@ -5482,7 +5481,7 @@ bool MasmParser::parseDirectiveCFIStartProc() {
if (!parseOptionalToken(AsmToken::EndOfStatement)) {
if (check(parseIdentifier(Simple) || Simple != "simple",
"unexpected token") ||
- parseToken(AsmToken::EndOfStatement))
+ parseEOL())
return addErrorSuffix(" in '.cfi_startproc' directive");
}
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index ace2891c9deea..bde60372be6d0 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11957,7 +11957,7 @@ bool ARMAsmParser::parseDirectiveSetFP(SMLoc L) {
Offset = CE->getValue();
}
- if (Parser.parseToken(AsmToken::EndOfStatement))
+ if (Parser.parseEOL())
return true;
getTargetStreamer().emitSetFP(static_cast<unsigned>(FPReg),
diff --git a/llvm/test/MC/ARM/directive_parsing.s b/llvm/test/MC/ARM/directive_parsing.s
index 90d15ef92d9d5..a8039840ec595 100644
--- a/llvm/test/MC/ARM/directive_parsing.s
+++ b/llvm/test/MC/ARM/directive_parsing.s
@@ -63,7 +63,7 @@
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.personality __gxx_personality_v0 @ EOL COMMENET
-// CHECK: [[@LINE+1]]:28: error: unexpected token
+// CHECK: [[#@LINE+1]]:28: error: expected newline
.setfp fp, sp, #0 $
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.setfp fp, sp, #0 @ EOL COMMENT
diff --git a/llvm/test/MC/MachO/ARM/build-version-diagnostics.s b/llvm/test/MC/MachO/ARM/build-version-diagnostics.s
index 31aa87add3acd..15687c2ad1fb0 100644
--- a/llvm/test/MC/MachO/ARM/build-version-diagnostics.s
+++ b/llvm/test/MC/MachO/ARM/build-version-diagnostics.s
@@ -53,4 +53,4 @@
// CHECK: build-version-diagnostics.s:[[@LINE-1]]:25: error: invalid OS update version number
.build_version ios,10,0,0,
-// CHECK: build-version-diagnostics.s:[[@LINE-1]]:26: error: unexpected token in '.build_version' directive
+// CHECK: build-version-diagnostics.s:[[#@LINE-1]]:26: error: expected newline in '.build_version' directive
More information about the llvm-commits
mailing list