aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2015-02-12 02:06:55 +0000
committerSteven Wu <stevenwu@apple.com>2015-02-12 02:06:55 +0000
commit15b385f8547e6d7236b39e66a8d3a53df5b3f454 (patch)
tree67e6f7cb7e068ed08fd3698211053596d2988548 /clang/lib/CodeGen/CodeGenAction.cpp
parent3c567fce463690d717ca4448c5769524b5a904d8 (diff)
downloadllvm-15b385f8547e6d7236b39e66a8d3a53df5b3f454.zip
llvm-15b385f8547e6d7236b39e66a8d3a53df5b3f454.tar.gz
llvm-15b385f8547e6d7236b39e66a8d3a53df5b3f454.tar.bz2
Add InlineAsmDiagnosticHandler for bitcode input
Summary: This patch installs an InlineAsmDiagnosticsHandler to avoid the crash report when the input is bitcode and the bitcode contains invalid inline assembly. The handler will simply print the same error message that will print from the backend. Add CHECK in test-case Reviewers: echristo, rafael Reviewed By: rafael Subscribers: rafael, cfe-commits Differential Revision: http://reviews.llvm.org/D7568 llvm-svn: 228898
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 499b97d..b5ed12a 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -667,6 +667,12 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return std::move(Result);
}
+static void BitcodeInlineAsmDiagHandler(const llvm::SMDiagnostic &SM,
+ void *Context,
+ unsigned LocCookie) {
+ SM.print(nullptr, llvm::errs());
+}
+
void CodeGenAction::ExecuteAction() {
// If this is an IR file, we have to treat it specially.
if (getCurrentFileKind() == IK_LLVM_IR) {
@@ -715,6 +721,8 @@ void CodeGenAction::ExecuteAction() {
TheModule->setTargetTriple(TargetOpts.Triple);
}
+ LLVMContext &Ctx = TheModule->getContext();
+ Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler);
EmitBackendOutput(CI.getDiagnostics(), CI.getCodeGenOpts(), TargetOpts,
CI.getLangOpts(), CI.getTarget().getTargetDescription(),
TheModule.get(), BA, OS);