[PATCH] D29414: [Assembler] Enable nicer diagnostics for inline assembly.
Sanne Wouda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 11:53:34 PST 2017
sanwou01 created this revision.
When a regular SrcMgr is not available, which is the case for inline
assembly, use the InlineSrcMgr to report diagnostics instead of using
the generic report_fatal_error().
https://reviews.llvm.org/D29414
Files:
lib/MC/MCContext.cpp
test/Assembler/inline-asm-diags.ll
Index: test/Assembler/inline-asm-diags.ll
===================================================================
--- /dev/null
+++ test/Assembler/inline-asm-diags.ll
@@ -0,0 +1,9 @@
+; RUN: not llc -filetype=obj < %s 2>&1 -o /dev/null | FileCheck %s
+
+module asm ".word 0x10"
+module asm ".word -bar"
+
+; CHECK: <inline asm>:2:7: error: expected relocatable expression
+
+module asm ".word -foo"
+; CHECK: <inline asm>:3:7: error: expected relocatable expression
Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ lib/MC/MCContext.cpp
@@ -510,13 +510,15 @@
void MCContext::reportError(SMLoc Loc, const Twine &Msg) {
HadError = true;
- // If we have a source manager use it. Otherwise just use the generic
- // report_fatal_error().
- if (!SrcMgr)
+ // If we have a source manager use it. Otherwise, try using the inline source
+ // manager.
+ // If that fails, use the generic report_fatal_error().
+ if (SrcMgr)
+ SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
+ else if (InlineSrcMgr)
+ InlineSrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
+ else
report_fatal_error(Msg, false);
-
- // Use the source manager to print the message.
- SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
}
void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29414.86692.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/07a0e56b/attachment.bin>
More information about the llvm-commits
mailing list