]> granicus.if.org Git - clang/commitdiff
Move -verify-pch to use VerifyJobAction
authorBen Langmuir <blangmuir@apple.com>
Thu, 6 Feb 2014 18:53:25 +0000 (18:53 +0000)
committerBen Langmuir <blangmuir@apple.com>
Thu, 6 Feb 2014 18:53:25 +0000 (18:53 +0000)
Use the verify hook rather than the compile hook to represent the
-verify-pch action, and move the exising --verify-debug-info action
into its own subclass of VerifyJobAction.  Incidentally change the name
printed by -ccc-print-phases for --verify-debug-info.

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

include/clang/Driver/Action.h
lib/Driver/Action.cpp
lib/Driver/Driver.cpp
lib/Driver/ToolChain.cpp
lib/Driver/ToolChains.cpp
lib/Driver/Tools.cpp
test/Driver/darwin-verify-debug.c

index 289dbe3ee4f851ac20e75b82507b5909830744fa..ea3da304ca19a736274367062e9dd9a1610d53a5 100644 (file)
@@ -50,10 +50,11 @@ public:
     LinkJobClass,
     LipoJobClass,
     DsymutilJobClass,
-    VerifyJobClass,
+    VerifyDebugInfoJobClass,
+    VerifyPCHJobClass,
 
     JobClassFirst=PreprocessJobClass,
-    JobClassLast=VerifyJobClass
+    JobClassLast=VerifyPCHJobClass
   };
 
   static const char *getClassName(ActionClass AC);
@@ -233,9 +234,29 @@ public:
 class VerifyJobAction : public JobAction {
   virtual void anchor();
 public:
-  VerifyJobAction(ActionList &Inputs, types::ID Type);
+  VerifyJobAction(ActionClass Kind, Action *Input, types::ID Type);
+  VerifyJobAction(ActionClass Kind, ActionList &Inputs, types::ID Type);
   static bool classof(const Action *A) {
-    return A->getKind() == VerifyJobClass;
+    return A->getKind() == VerifyDebugInfoJobClass ||
+           A->getKind() == VerifyPCHJobClass;
+  }
+};
+
+class VerifyDebugInfoJobAction : public VerifyJobAction {
+  virtual void anchor();
+public:
+  VerifyDebugInfoJobAction(Action *Input, types::ID Type);
+  static bool classof(const Action *A) {
+    return A->getKind() == VerifyDebugInfoJobClass;
+  }
+};
+
+class VerifyPCHJobAction : public VerifyJobAction {
+  virtual void anchor();
+public:
+  VerifyPCHJobAction(Action *Input, types::ID Type);
+  static bool classof(const Action *A) {
+    return A->getKind() == VerifyPCHJobClass;
   }
 };
 
index ddd2d599da06df03c6344f452bab082ead03e09d..86a48fd8b7f9594426ce87794afd76933e657da5 100644 (file)
@@ -33,7 +33,8 @@ const char *Action::getClassName(ActionClass AC) {
   case LinkJobClass: return "linker";
   case LipoJobClass: return "lipo";
   case DsymutilJobClass: return "dsymutil";
-  case VerifyJobClass: return "verify";
+  case VerifyDebugInfoJobClass: return "verify-debug-info";
+  case VerifyPCHJobClass: return "verify-pch";
   }
 
   llvm_unreachable("invalid class");
@@ -117,6 +118,29 @@ DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
 
 void VerifyJobAction::anchor() {}
 
-VerifyJobAction::VerifyJobAction(ActionList &Inputs, types::ID Type)
-  : JobAction(VerifyJobClass, Inputs, Type) {
+VerifyJobAction::VerifyJobAction(ActionClass Kind, Action *Input,
+                                 types::ID Type)
+    : JobAction(Kind, Input, Type) {
+  assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
+         "ActionClass is not a valid VerifyJobAction");
+}
+
+VerifyJobAction::VerifyJobAction(ActionClass Kind, ActionList &Inputs,
+                                 types::ID Type)
+    : JobAction(Kind, Inputs, Type) {
+  assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
+           "ActionClass is not a valid VerifyJobAction");
+}
+
+void VerifyDebugInfoJobAction::anchor() {}
+
+VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input,
+                                                   types::ID Type)
+    : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) {
+}
+
+void VerifyPCHJobAction::anchor() {}
+
+VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type)
+    : VerifyJobAction(VerifyPCHJobClass, Input, Type) {
 }
index 270c3a701b03f8e0197cde4577e62fdecdbe473d..898bdc94e29c26d4ebbc66d8740ef6fb6f5ee00f 100644 (file)
@@ -936,13 +936,12 @@ void Driver::BuildUniversalActions(const ToolChain &TC,
         Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM));
       }
 
-      // Verify the output (debug information only for now).
+      // Verify the debug info output.
       if (Args.hasArg(options::OPT_verify_debug_info)) {
-        ActionList VerifyInputs;
-        VerifyInputs.push_back(Actions.back());
+        Action *VerifyInput = Actions.back();
         Actions.pop_back();
-        Actions.push_back(new VerifyJobAction(VerifyInputs,
-                                              types::TY_Nothing));
+        Actions.push_back(new VerifyDebugInfoJobAction(VerifyInput,
+                                                       types::TY_Nothing));
       }
     }
   }
@@ -1318,7 +1317,7 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
     } else if (Args.hasArg(options::OPT_module_file_info)) {
       return new CompileJobAction(Input, types::TY_ModuleFile);
     } else if (Args.hasArg(options::OPT_verify_pch)) {
-      return new CompileJobAction(Input, types::TY_Nothing);
+      return new VerifyPCHJobAction(Input, types::TY_Nothing);
     } else if (IsUsingLTO(Args)) {
       types::ID Output =
         Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
index 9b09b4ecd66639ea427340229d07cbab894829e4..9c43706d4f925fae5e08b3105b7d9dc0b4b43329 100644 (file)
@@ -114,7 +114,7 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
   case Action::BindArchClass:
   case Action::LipoJobClass:
   case Action::DsymutilJobClass:
-  case Action::VerifyJobClass:
+  case Action::VerifyDebugInfoJobClass:
     llvm_unreachable("Invalid tool kind.");
 
   case Action::CompileJobClass:
@@ -122,6 +122,7 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
   case Action::PreprocessJobClass:
   case Action::AnalyzeJobClass:
   case Action::MigrateJobClass:
+  case Action::VerifyPCHJobClass:
     return getClang();
   }
 
index 9c4213bc18d9edb34f475c350fc205edc09b25b6..d328b1671ddb20181022bb95493a990c0e77e885 100644 (file)
@@ -212,7 +212,7 @@ Tool *MachO::getTool(Action::ActionClass AC) const {
     if (!Dsymutil)
       Dsymutil.reset(new tools::darwin::Dsymutil(*this));
     return Dsymutil.get();
-  case Action::VerifyJobClass:
+  case Action::VerifyDebugInfoJobClass:
     if (!VerifyDebug)
       VerifyDebug.reset(new tools::darwin::VerifyDebug(*this));
     return VerifyDebug.get();
index af8696c42a7bbf6182cf128806ded91d0ba73e59..6885f2410f2f3758ce03c81cba19969121d10afb 100644 (file)
@@ -2066,14 +2066,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
       CmdArgs.push_back("-emit-pch");
     else
       CmdArgs.push_back("-emit-pth");
+  } else if (isa<VerifyPCHJobAction>(JA)) {
+    CmdArgs.push_back("-verify-pch");
   } else {
     assert(isa<CompileJobAction>(JA) && "Invalid action for clang tool.");
 
     if (JA.getType() == types::TY_Nothing) {
-      if (Args.hasArg(options::OPT_verify_pch))
-        CmdArgs.push_back("-verify-pch");
-      else
-        CmdArgs.push_back("-fsyntax-only");
+      CmdArgs.push_back("-fsyntax-only");
     } else if (JA.getType() == types::TY_LLVM_IR ||
                JA.getType() == types::TY_LTO_IR) {
       CmdArgs.push_back("-emit-llvm");
index 9688eaa6e13213f2ab9af25277b05f1845bea9c0..4878c746e07efb3d10e4c817c567549aa4680a6a 100644 (file)
@@ -7,7 +7,7 @@
 //
 // CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-verify-debug.c", c
 // CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
-// CHECK-MULTIARCH-ACTIONS: 9: verify, {8}, none
+// CHECK-MULTIARCH-ACTIONS: 9: verify-debug-info, {8}, none
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   --verify-debug-info -arch i386 -arch x86_64 %s -g 2> %t