[cfe-commits] r66913 - in /cfe/trunk: lib/Driver/Driver.cpp test/Driver/ test/Driver/phases.c

Daniel Dunbar daniel at zuster.org
Fri Mar 13 10:57:11 PDT 2009


Author: ddunbar
Date: Fri Mar 13 12:57:10 2009
New Revision: 66913

URL: http://llvm.org/viewvc/llvm-project?rev=66913&view=rev
Log:
Driver: Fix '-x none' handling.
 - Enough stuff works now we can test argument parsing & pipelining.

Added:
    cfe/trunk/test/Driver/   (with props)
    cfe/trunk/test/Driver/phases.c
Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=66913&r1=66912&r2=66913&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Mar 13 12:57:10 2009
@@ -345,11 +345,15 @@
 }
 
 void Driver::BuildActions(ArgList &Args, ActionList &Actions) {
-  types::ID InputType = types::TY_INVALID;
-  Arg *InputTypeArg = 0;
-
   // Start by constructing the list of inputs and their types.
 
+  // Track the current user specified (-x) input. We also explicitly
+  // track the argument used to set the type; we only want to claim
+  // the type when we actually use it, so we warn about unused -x
+  // arguments.
+  types::ID InputType = types::TY_Nothing;
+  Arg *InputTypeArg = 0;
+
   llvm::SmallVector<std::pair<types::ID, const Arg*>, 16> Inputs;
   for (ArgList::const_iterator it = Args.begin(), ie = Args.end(); 
        it != ie; ++it) {
@@ -360,7 +364,11 @@
       types::ID Ty = types::TY_INVALID;
 
       // Infer the input type if necessary.
-      if (InputType == types::TY_INVALID) {
+      if (InputType == types::TY_Nothing) {
+        // If there was an explicit arg for this, claim it.
+        if (InputTypeArg)
+          InputTypeArg->claim();
+
         // stdin must be handled specially.
         if (memcmp(Value, "-", 2) == 0) {
           // If running with -E, treat as a C input (this changes the

Propchange: cfe/trunk/test/Driver/

------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Mar 13 12:57:10 2009
@@ -0,0 +1 @@
+Output

Added: cfe/trunk/test/Driver/phases.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/phases.c?rev=66913&view=auto

==============================================================================
--- cfe/trunk/test/Driver/phases.c (added)
+++ cfe/trunk/test/Driver/phases.c Fri Mar 13 12:57:10 2009
@@ -0,0 +1,26 @@
+// Basic compilation for various types of files.
+// RUN: clang-driver -ccc-host-triple i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s &> %t &&
+// RUN: grep -F '0: input, "phases.c", c' %t &&
+// RUN: grep -F '1: preprocessor, {0}, cpp-output' %t &&
+// RUN: grep -F '2: compiler, {1}, assembler' %t &&
+// RUN: grep -F '3: assembler, {2}, object' %t &&
+// RUN: grep -F '4: input, "phases.c", objective-c' %t &&
+// RUN: grep -F '5: preprocessor, {4}, objective-c-cpp-output' %t &&
+// RUN: grep -F '6: compiler, {5}, assembler' %t &&
+// RUN: grep -F '7: assembler, {6}, object' %t &&
+// RUN: grep -F '8: input, "phases.c", c++' %t &&
+// RUN: grep -F '9: preprocessor, {8}, c++-cpp-output' %t &&
+// RUN: grep -F '10: compiler, {9}, assembler' %t &&
+// RUN: grep -F '11: assembler, {10}, object' %t &&
+// RUN: grep -F '12: input, "phases.c", assembler' %t &&
+// RUN: grep -F '13: assembler, {12}, object' %t &&
+// RUN: grep -F '14: input, "phases.c", assembler-with-cpp' %t &&
+// RUN: grep -F '15: preprocessor, {14}, assembler' %t &&
+// RUN: grep -F '16: assembler, {15}, object' %t &&
+// RUN: grep -F '17: input, "phases.c", c' %t &&
+// RUN: grep -F '18: preprocessor, {17}, cpp-output' %t &&
+// RUN: grep -F '19: compiler, {18}, assembler' %t &&
+// RUN: grep -F '20: assembler, {19}, object' %t &&
+// RUN: grep -F '21: linker, {3, 7, 11, 13, 16, 20}, image' %t &&
+
+// RUN: true





More information about the cfe-commits mailing list