From 7a50aa98f0147ce1fcd64aea6a2eb2bb7d7da241 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 28 May 2007 00:47:06 +0000 Subject: [PATCH] Stop generating code after the first error is emitted. llvm-svn: 39503 --- clang/Driver/LLVMCodegen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/Driver/LLVMCodegen.cpp b/clang/Driver/LLVMCodegen.cpp index 299d55793a67..e86a0359fa47 100644 --- a/clang/Driver/LLVMCodegen.cpp +++ b/clang/Driver/LLVMCodegen.cpp @@ -16,6 +16,7 @@ #include "clang/Sema/ASTStreamer.h" #include "clang/AST/AST.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Basic/Diagnostic.h" #include "llvm/Module.h" #include using namespace llvm; @@ -38,7 +39,10 @@ void llvm::clang::EmitLLVMFromASTs(Preprocessor &PP, unsigned MainFileID, CodeGen::BuilderTy *Builder = CodeGen::Init(Context, M); while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) { - // FIXME: if (Diags.error ever occurred) continue; + // If an error occurred, stop code generation, but continue parsing and + // semantic analysis (to ensure all warnings and errors are emitted). + if (Diags.hasErrorOccurred()) + continue; if (FunctionDecl *FD = dyn_cast(D)) { CodeGen::CodeGenFunction(Builder, FD);