summaryrefslogtreecommitdiff
path: root/include/llvm/LLVMContext.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-07 23:40:44 +0000
committerChris Lattner <sabre@nondot.org>2010-04-07 23:40:44 +0000
commit38686bdffdebc09aa6fe6b8b54b34ac32c753f59 (patch)
tree86a65f6c9f9b63270378b4c824fe40a3b00c57ef /include/llvm/LLVMContext.h
parenta5ced590c95035793c2ae19bf70d6a0ed2c822a6 (diff)
downloadllvm-38686bdffdebc09aa6fe6b8b54b34ac32c753f59.tar.gz
llvm-38686bdffdebc09aa6fe6b8b54b34ac32c753f59.tar.bz2
llvm-38686bdffdebc09aa6fe6b8b54b34ac32c753f59.tar.xz
introduce a new recoverable error handling API to LLVMContext
and use it in one place in inline asm handling stuff. Before we'd generate this for an invalid modifier letter: $ clang asm.c -c -o t.o fatal error: error in backend: Invalid operand found in inline asm: 'abc incl ${0:Z}' INLINEASM <es:abc incl ${0:Z}>, 10, %EAX<def>, 2147483657, %EAX, 14, %EFLAGS<earlyclobber,def,dead>, <!-1> Now we generate this: $ clang asm.c -c -o t.o error: invalid operand in inline asm: 'incl ${0:Z}' asm.c:3:12: note: generated from here __asm__ ("incl %Z0" : "+r" (X)); ^ 1 error generated. This is much better but still admittedly not great ("why" is the operand invalid??), codegen should try harder with its diagnostics :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/LLVMContext.h')
-rw-r--r--include/llvm/LLVMContext.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h
index 43548407f6..afae08b07d 100644
--- a/include/llvm/LLVMContext.h
+++ b/include/llvm/LLVMContext.h
@@ -19,6 +19,7 @@ namespace llvm {
class LLVMContextImpl;
class StringRef;
+class Instruction;
template <typename T> class SmallVectorImpl;
/// This is an important class for using LLVM in a threaded context. It
@@ -68,6 +69,15 @@ public:
/// setInlineAsmDiagnosticHandler.
void *getInlineAsmDiagnosticContext() const;
+
+ /// emitError - Emit an error message to the currently installed error handler
+ /// with optional location information. This function returns, so code should
+ /// be prepared to drop the erroneous construct on the floor and "not crash".
+ /// The generated code need not be correct. The error message will be
+ /// implicitly prefixed with "error: " and should not end with a ".".
+ void emitError(unsigned LocCookie, StringRef ErrorStr);
+ void emitError(const Instruction *I, StringRef ErrorStr);
+ void emitError(StringRef ErrorStr);
};
/// getGlobalContext - Returns a global context. This is for LLVM clients that