]> granicus.if.org Git - clang/blobdiff - lib/Driver/InputInfo.h
Header guard canonicalization, clang part.
[clang] / lib / Driver / InputInfo.h
index 617e70365dd6df824531f57f77dc92d473ed33e2..b23ba575b65e09eca6d6abd9a14fea9e45e7e79d 100644 (file)
@@ -7,63 +7,77 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef CLANG_LIB_DRIVER_INPUTINFO_H_
-#define CLANG_LIB_DRIVER_INPUTINFO_H_
+#ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
+#define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
 
 #include "clang/Driver/Types.h"
-
+#include "llvm/Option/Arg.h"
 #include <cassert>
 #include <string>
 
 namespace clang {
 namespace driver {
-  class PipedJob;
 
 /// InputInfo - Wrapper for information about an input source.
 class InputInfo {
+  // FIXME: The distinction between filenames and inputarg here is
+  // gross; we should probably drop the idea of a "linker
+  // input". Doing so means tweaking pipelining to still create link
+  // steps when it sees linker inputs (but not treat them as
+  // arguments), and making sure that arguments get rendered
+  // correctly.
+  enum Class {
+    Nothing,
+    Filename,
+    InputArg,
+    Pipe
+  };
+
   union {
     const char *Filename;
-    PipedJob *Pipe;
+    const llvm::opt::Arg *InputArg;
   } Data;
-  bool IsPipe;
+  Class Kind;
   types::ID Type;
   const char *BaseInput;
 
 public:
   InputInfo() {}
   InputInfo(types::ID _Type, const char *_BaseInput)
-    : IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
-    Data.Filename = 0;
+    : Kind(Nothing), Type(_Type), BaseInput(_BaseInput) {
   }
-  InputInfo(const char *Filename, types::ID _Type, const char *_BaseInput)
-    : IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
-    Data.Filename = Filename;
+  InputInfo(const char *_Filename, types::ID _Type, const char *_BaseInput)
+    : Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
+    Data.Filename = _Filename;
   }
-  InputInfo(PipedJob *Pipe, types::ID _Type, const char *_BaseInput)
-    : IsPipe(true), Type(_Type), BaseInput(_BaseInput) {
-    Data.Pipe = Pipe;
+  InputInfo(const llvm::opt::Arg *_InputArg, types::ID _Type,
+            const char *_BaseInput)
+      : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
+    Data.InputArg = _InputArg;
   }
 
-  bool isPipe() const { return IsPipe; }
+  bool isNothing() const { return Kind == Nothing; }
+  bool isFilename() const { return Kind == Filename; }
+  bool isInputArg() const { return Kind == InputArg; }
   types::ID getType() const { return Type; }
   const char *getBaseInput() const { return BaseInput; }
 
-  const char *getInputFilename() const {
-    assert(!isPipe() && "Invalid accessor.");
+  const char *getFilename() const {
+    assert(isFilename() && "Invalid accessor.");
     return Data.Filename;
   }
-  PipedJob &getPipe() const {
-    assert(isPipe() && "Invalid accessor.");
-    return *Data.Pipe;
+  const llvm::opt::Arg &getInputArg() const {
+    assert(isInputArg() && "Invalid accessor.");
+    return *Data.InputArg;
   }
 
   /// getAsString - Return a string name for this input, for
   /// debugging.
   std::string getAsString() const {
-    if (isPipe())
-      return "(pipe)";
-    else if (const char *N = getInputFilename())
-      return std::string("\"") + N + '"';
+    if (isFilename())
+      return std::string("\"") + getFilename() + '"';
+    else if (isInputArg())
+      return "(input arg)";
     else
       return "(nothing)";
   }