[PATCH] D22806: [ARM] Improve error messages for .arch_extension directive
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 06:41:24 PDT 2016
olista01 created this revision.
olista01 added reviewers: t.p.northover, rengolin.
olista01 added a subscriber: llvm-commits.
olista01 set the repository for this revision to rL LLVM.
Herald added subscribers: samparker, rengolin, aemerson.
* More informative message when extension name is not an identifier token.
* Stop parsing directive if extension is unknown (avoid duplicate error messages).
* Report unsupported extensions with a source location, rather than report_fatal_error.
Repository:
rL LLVM
https://reviews.llvm.org/D22806
Files:
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/directive-arch_extension-unsupported.s
Index: test/MC/ARM/directive-arch_extension-unsupported.s
===================================================================
--- /dev/null
+++ test/MC/ARM/directive-arch_extension-unsupported.s
@@ -0,0 +1,22 @@
+@ RUN: not llvm-mc -triple armv7--none-eabi -filetype asm -o /dev/null 2>&1 %s | FileCheck %s
+
+ .arch_extension os
+CHECK: error: unsupported architectural extension: os
+
+ .arch_extension iwmmxt
+CHECK: error: unsupported architectural extension: iwmmxt
+
+ .arch_extension iwmmxt2
+CHECK: error: unsupported architectural extension: iwmmxt2
+
+ .arch_extension maverick
+CHECK: error: unsupported architectural extension: maverick
+
+ .arch_extension xscale
+CHECK: error: unsupported architectural extension: xscale
+
+ .arch_extension invalid_extension_name
+CHECK: error: unknown architectural extension: invalid_extension_name
+
+ .arch_extension 42
+CHECK: error: expected architecture extension name
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -10216,7 +10216,7 @@
MCAsmParser &Parser = getParser();
if (getLexer().isNot(AsmToken::Identifier)) {
- Error(getLexer().getLoc(), "unexpected token");
+ Error(getLexer().getLoc(), "expected architecture extension name");
Parser.eatToEndOfStatement();
return false;
}
@@ -10231,15 +10231,19 @@
Name = Name.substr(2);
}
unsigned FeatureKind = ARM::parseArchExt(Name);
- if (FeatureKind == ARM::AEK_INVALID)
+ if (FeatureKind == ARM::AEK_INVALID) {
Error(ExtLoc, "unknown architectural extension: " + Name);
+ return false;
+ }
for (const auto &Extension : Extensions) {
if (Extension.Kind != FeatureKind)
continue;
- if (Extension.Features.none())
- report_fatal_error("unsupported architectural extension: " + Name);
+ if (Extension.Features.none()) {
+ Error(ExtLoc, "unsupported architectural extension: " + Name);
+ return false;
+ }
if ((getAvailableFeatures() & Extension.ArchCheck) != Extension.ArchCheck) {
Error(ExtLoc, "architectural extension '" + Name + "' is not "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22806.65505.patch
Type: text/x-patch
Size: 2219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160726/f1a37494/attachment.bin>
More information about the llvm-commits
mailing list