[cfe-commits] r63901 - in /cfe/trunk/tools/ccc: ccclib/Driver.py test/ccc/stdin.c

Daniel Dunbar daniel at zuster.org
Thu Feb 5 15:44:44 PST 2009


Author: ddunbar
Date: Thu Feb  5 17:44:44 2009
New Revision: 63901

URL: http://llvm.org/viewvc/llvm-project?rev=63901&view=rev
Log:
ccc: Implement special language recognition handling for -.
  - <rdar://problem/6551577> [ccc] require -x with -

Added:
    cfe/trunk/tools/ccc/test/ccc/stdin.c
Modified:
    cfe/trunk/tools/ccc/ccclib/Driver.py

Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=63901&r1=63900&r2=63901&view=diff

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Thu Feb  5 17:44:44 2009
@@ -374,27 +374,35 @@
                 inputValue = args.getValue(a)
                 if inputType is None:
                     base,ext = os.path.splitext(inputValue)
-                    if ext and ext in Types.kTypeSuffixMap:
+                    # stdin is handled specially.
+                    if inputValue == '-':
+                        if args.getLastArg(self.parser.EOption):
+                            # Treat as a C input needing preprocessing
+                            # (or Obj-C if over-ridden below).
+                            klass = Types.CType
+                        else:
+                            raise Arguments.InvalidArgumentsError("-E or -x required when input is from standard input")
+                    elif ext and ext in Types.kTypeSuffixMap:
                         klass = Types.kTypeSuffixMap[ext]
-
-                        # -ObjC and -ObjC++ over-ride the default
-                        # language, but only for "source files". We
-                        # just treat everything that isn't a linker
-                        # input as a source file.
-                        #
-                        # FIXME: Clean this up if we move the phase
-                        # sequence into the type.
-                        if klass is not Types.ObjectType:
-                            if args.getLastArg(self.parser.ObjCOption):
-                                klass = Types.ObjCType
-                            elif args.getLastArg(self.parser.ObjCXXOption):
-                                klass = Types.ObjCType
                     else:
                         # FIXME: Its not clear why we shouldn't just
                         # revert to unknown. I think this is more likely a
                         # bug / unintended behavior in gcc. Not very
                         # important though.
                         klass = Types.ObjectType
+
+                    # -ObjC and -ObjC++ over-ride the default
+                    # language, but only for "source files". We
+                    # just treat everything that isn't a linker
+                    # input as a source file.
+                    #
+                    # FIXME: Clean this up if we move the phase
+                    # sequence into the type.
+                    if klass is not Types.ObjectType:
+                        if args.getLastArg(self.parser.ObjCOption):
+                            klass = Types.ObjCType
+                        elif args.getLastArg(self.parser.ObjCXXOption):
+                            klass = Types.ObjCType
                 else:
                     assert inputTypeOpt is not None
                     self.claim(inputTypeOpt)

Added: cfe/trunk/tools/ccc/test/ccc/stdin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/test/ccc/stdin.c?rev=63901&view=auto

==============================================================================
--- cfe/trunk/tools/ccc/test/ccc/stdin.c (added)
+++ cfe/trunk/tools/ccc/test/ccc/stdin.c Thu Feb  5 17:44:44 2009
@@ -0,0 +1,10 @@
+// RUN: not xcc -### - &> %t &&
+// RUN: grep 'E or -x required when input is from standard input' %t &&
+// RUN: xcc -ccc-print-phases -### -E - &> %t && 
+// RUN: grep '1: preprocessor.*, {0}, cpp-output' %t &&
+// RUN: xcc -ccc-print-phases -### -ObjC -E - &> %t && 
+// RUN: grep '1: preprocessor.*, {0}, objective-c-cpp-output' %t &&
+// RUN: xcc -ccc-print-phases -### -ObjC -x c -E - &> %t && 
+// RUN: grep '1: preprocessor.*, {0}, cpp-output' %t &&
+
+// RUN: true





More information about the cfe-commits mailing list