]> granicus.if.org Git - clang/commitdiff
Driver: Add a Tool::hasGoodDiagnostics hook, and use it to simplify logic for
authorDaniel Dunbar <daniel@zuster.org>
Tue, 6 Apr 2010 17:07:49 +0000 (17:07 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 6 Apr 2010 17:07:49 +0000 (17:07 +0000)
deciding when we need to emit an extra "command failed" diagnostic.
 - This also fixes the case where we were emitting that extra diagnostics, even
   when using clang w/ the integrated assembler, which has good diagnostics.

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

include/clang/Driver/Tool.h
lib/Driver/Driver.cpp
lib/Driver/Tools.h

index 851e4235b00eb98d577b39261509a42156ab041e..ef77206c659348a6decb84a2eab174c190ed9dbc 100644 (file)
@@ -48,6 +48,10 @@ public:
   virtual bool hasIntegratedAssembler() const { return false; }
   virtual bool hasIntegratedCPP() const = 0;
 
+  /// \brief Does this tool have "good" standardized diagnostics, or should the
+  /// driver add an additional "command failed" diagnostic on failures.
+  virtual bool hasGoodDiagnostics() const { return false; }
+
   /// ConstructJob - Construct jobs to perform the action \arg JA,
   /// writing to \arg Output and with \arg Inputs.
   ///
index 921147f7a09b9afc46593444ff079209fbc09954..7371a930c3370a912ce8f8338a0c1ad6608b5511 100644 (file)
@@ -239,12 +239,8 @@ int Driver::ExecuteCompilation(const Compilation &C) const {
     // other tools are less common, and they generally have worse diagnostics,
     // so always print the diagnostic there.
     const Action &Source = FailingCommand->getSource();
-    bool IsFriendlyTool = (isa<PreprocessJobAction>(Source) ||
-                           isa<PrecompileJobAction>(Source) ||
-                           isa<AnalyzeJobAction>(Source) ||
-                           isa<CompileJobAction>(Source));
 
-    if (!IsFriendlyTool || Res != 1) {
+    if (!FailingCommand->getCreator().hasGoodDiagnostics() || Res != 1) {
       // FIXME: See FIXME above regarding result code interpretation.
       if (Res < 0)
         Diag(clang::diag::err_drv_command_signalled)
index 7a8f1b7cb7033a17627ef9a8368fb09b6d4d1ede..091fec380622db578257f1db4e80fe56cda76e7c 100644 (file)
@@ -42,6 +42,7 @@ namespace tools {
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return true; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedAssembler() const { return true; }
     virtual bool hasIntegratedCPP() const { return true; }
 
@@ -79,6 +80,7 @@ namespace gcc {
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return true; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedCPP() const { return false; }
 
     virtual void RenderExtraToolArgs(const JobAction &JA,
@@ -91,6 +93,7 @@ namespace gcc {
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return false; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedCPP() const { return true; }
 
     virtual void RenderExtraToolArgs(const JobAction &JA,
@@ -103,6 +106,7 @@ namespace gcc {
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return true; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedCPP() const { return true; }
 
     virtual void RenderExtraToolArgs(const JobAction &JA,
@@ -176,6 +180,7 @@ namespace darwin {
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return true; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedCPP() const { return true; }
   };