[PATCH] D145949: [RISCV] Consistently error for arch strings with trailing _
Alex Bradbury via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 13 08:55:27 PDT 2023
asb created this revision.
asb added reviewers: kito-cheng, MaskRay, reames, craig.topper.
Herald added subscribers: jobnoorman, luke, wingo, pmatos, VincentWu, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
asb requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD.
Herald added a project: LLVM.
RISCVISAInfo::parseArchString would sometimes error for arch strings with a trailing `_` and sometimes accept them. This patch makes it consistently error.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145949
Files:
llvm/lib/Support/RISCVISAInfo.cpp
llvm/unittests/Support/RISCVISAInfoTest.cpp
Index: llvm/unittests/Support/RISCVISAInfoTest.cpp
===================================================================
--- llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -317,16 +317,14 @@
EXPECT_EQ(
toString(RISCVISAInfo::parseArchString("rv64i__m", true).takeError()),
"invalid standard user-level extension '_'");
- EXPECT_EQ(
- toString(RISCVISAInfo::parseArchString("rv32ezicsr_", true).takeError()),
- "extension name missing after separator '_'");
-
- // FIXME: Trailing underscores after single letter extensions are accepted,
- // which is inconsistent.
- ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv32i_", true),
- Succeeded());
- ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv64im_", true),
- Succeeded());
+ EXPECT_EQ(toString(RISCVISAInfo::parseArchString("rv32ezicsr__zifencei", true)
+ .takeError()),
+ "extension name missing after separator '_'");
+
+ for (StringRef Input : {"rv32i_", "rv32izicsr_", "rv64im_"}) {
+ EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+ "invalid format - trailing underscore");
+ }
}
TEST(ParseArchString, RejectsDuplicateExtensionNames) {
Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -626,6 +626,10 @@
break;
}
+ if (Arch.back() == '_')
+ return createStringError(errc::invalid_argument,
+ "invalid format - trailing underscore");
+
// Skip rvxxx
StringRef Exts = Arch.substr(5);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145949.504690.patch
Type: text/x-patch
Size: 1749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230313/c334d877/attachment.bin>
More information about the llvm-commits
mailing list