[cfe-commits] r100529 - in /cfe/trunk: include/clang/Driver/Tool.h lib/Driver/Driver.cpp lib/Driver/Tools.h

Daniel Dunbar daniel at zuster.org
Tue Apr 6 10:07:49 PDT 2010


Author: ddunbar
Date: Tue Apr  6 12:07:49 2010
New Revision: 100529

URL: http://llvm.org/viewvc/llvm-project?rev=100529&view=rev
Log:
Driver: Add a Tool::hasGoodDiagnostics hook, and use it to simplify logic for
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.

Modified:
    cfe/trunk/include/clang/Driver/Tool.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/include/clang/Driver/Tool.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Tool.h?rev=100529&r1=100528&r2=100529&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Tool.h (original)
+++ cfe/trunk/include/clang/Driver/Tool.h Tue Apr  6 12:07:49 2010
@@ -48,6 +48,10 @@
   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.
   ///

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=100529&r1=100528&r2=100529&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Apr  6 12:07:49 2010
@@ -239,12 +239,8 @@
     // 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)

Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=100529&r1=100528&r2=100529&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Tue Apr  6 12:07:49 2010
@@ -42,6 +42,7 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     virtual bool acceptsPipedInput() const { return true; }
     virtual bool canPipeOutput() const { return true; }
+    virtual bool hasGoodDiagnostics() const { return true; }
     virtual bool hasIntegratedCPP() const { return true; }
   };
 





More information about the cfe-commits mailing list