]> granicus.if.org Git - clang/commitdiff
Driver: Give Compilation::Execute total control over the Driver result
authorDaniel Dunbar <daniel@zuster.org>
Sat, 21 Mar 2009 00:40:53 +0000 (00:40 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 21 Mar 2009 00:40:53 +0000 (00:40 +0000)
code; and don't return an error code when -### is present, even if
errors occur.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67425 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Compilation.cpp
tools/driver/driver.cpp

index 2a91842884025f6ba9b7913ebd21283880f8fad3..7a52498364b0a8027f934098217be78a143f9240 100644 (file)
@@ -109,6 +109,8 @@ public:
 
   const OptTable &getOpts() const { return *Opts; }
 
+  const Diagnostic &getDiags() const { return Diags; }
+
   /// @}
   /// @name Primary Functionality
   /// @{
index 48796afd8276fb6b4a481ef7518e08cb866a40db..a2fc9212a511035f0355f0d51146b66299786ead 100644 (file)
@@ -160,6 +160,10 @@ int Compilation::Execute() const {
     return 0;
   }
 
+  // If there were errors building the compilation, quit now.
+  if (getDriver().getDiags().getNumErrors())
+    return 1;
+
   int Res = ExecuteJob(Jobs);
   
   // Remove temp files.
index 865b57c5aba675e8972d6c2ee387c073ea5c8bf7..b22776119710c44a31685d1b2e2dc512c03de4e3 100644 (file)
@@ -87,15 +87,11 @@ int main(int argc, const char **argv) {
                                                
   llvm::OwningPtr<Compilation> C(TheDriver->BuildCompilation(argc, argv));
 
-  // If there were errors building the compilation, quit now.
-  if (Diags.getNumErrors())
-    return 1;
-  if (!C.get())
-    return 0;
-
-  int res = C->Execute();
+  int Res = 0;
+  if (C.get())
+    Res = C->Execute();
 
   llvm::llvm_shutdown();
 
-  return res;
+  return Res;
 }