]> granicus.if.org Git - clang/commitdiff
[driver] The failure of any phase (e.g., preprocess, compile, assemble) for a
authorChad Rosier <mcrosier@apple.com>
Wed, 27 Feb 2013 18:46:04 +0000 (18:46 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 27 Feb 2013 18:46:04 +0000 (18:46 +0000)
single translation unit should prevent later phases from executing.  Otherwise,
this generates lots of noise in build systems.  This a fallout from r173825.
Patch by Matthew Curtis <mcurtis@codeaurora.org>.
rdar://13298009

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

lib/Driver/Compilation.cpp
test/Driver/inhibit-downstream-commands.c [new file with mode: 0644]

index df904f06b7dae50c12219faab99b78a45d01c23a..db948a5bfe906c6c2aa1a2381240b1eedf2331af 100644 (file)
@@ -307,9 +307,36 @@ int Compilation::ExecuteCommand(const Command &C,
   return Res;
 }
 
+typedef SmallVectorImpl< std::pair<int, const Command *> > FailingCommandList;
+
+static bool ActionFailed(const Action *A,
+                         const FailingCommandList &FailingCommands) {
+
+  if (FailingCommands.empty())
+    return false;
+
+  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
+         CE = FailingCommands.end(); CI != CE; ++CI)
+    if (A == &(CI->second->getSource()))
+      return true;
+
+  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
+    if (ActionFailed(*AI, FailingCommands))
+      return true;
+
+  return false;
+}
+
+static bool InputsOk(const Command &C,
+                     const FailingCommandList &FailingCommands) {
+  return !ActionFailed(&C.getSource(), FailingCommands);
+}
+
 void Compilation::ExecuteJob(const Job &J,
-    SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands) const {
+                             FailingCommandList &FailingCommands) const {
   if (const Command *C = dyn_cast<Command>(&J)) {
+    if (!InputsOk(*C, FailingCommands))
+      return;
     const Command *FailingCommand = 0;
     if (int Res = ExecuteCommand(*C, FailingCommand))
       FailingCommands.push_back(std::make_pair(Res, FailingCommand));
diff --git a/test/Driver/inhibit-downstream-commands.c b/test/Driver/inhibit-downstream-commands.c
new file mode 100644 (file)
index 0000000..e06fdb1
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang -no-integrated-as %s 2>&1 | FileCheck %s
+// CHECK: error: unknown type name 'invalid'
+// CHECK-NOT: clang: error: assembler command failed 
+// CHECK-NOT: clang: error: linker command failed
+invalid C code!