1 //===--- InputInfo.h - Input Source & Type Information ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_LIB_DRIVER_INPUTINFO_H_
11 #define CLANG_LIB_DRIVER_INPUTINFO_H_
13 #include "clang/Driver/Types.h"
22 /// InputInfo - Wrapper for information about an input source.
24 // FIXME: The distinction between filenames and inputarg here is
25 // gross; we should probably drop the idea of a "linker
26 // input". Doing so means tweaking pipelining to still create link
27 // steps when it sees linker inputs (but not treat them as
28 // arguments), and making sure that arguments get rendered
44 const char *BaseInput
;
48 InputInfo(types::ID _Type
, const char *_BaseInput
)
49 : Kind(Nothing
), Type(_Type
), BaseInput(_BaseInput
) {
51 InputInfo(const char *_Filename
, types::ID _Type
, const char *_BaseInput
)
52 : Kind(Filename
), Type(_Type
), BaseInput(_BaseInput
) {
53 Data
.Filename
= _Filename
;
55 InputInfo(const Arg
*_InputArg
, types::ID _Type
, const char *_BaseInput
)
56 : Kind(InputArg
), Type(_Type
), BaseInput(_BaseInput
) {
57 Data
.InputArg
= _InputArg
;
59 InputInfo(PipedJob
*_Pipe
, types::ID _Type
, const char *_BaseInput
)
60 : Kind(Pipe
), Type(_Type
), BaseInput(_BaseInput
) {
64 bool isNothing() const { return Kind
== Nothing
; }
65 bool isFilename() const { return Kind
== Filename
; }
66 bool isInputArg() const { return Kind
== InputArg
; }
67 bool isPipe() const { return Kind
== Pipe
; }
68 types::ID
getType() const { return Type
; }
69 const char *getBaseInput() const { return BaseInput
; }
71 const char *getFilename() const {
72 assert(isFilename() && "Invalid accessor.");
75 const Arg
&getInputArg() const {
76 assert(isInputArg() && "Invalid accessor.");
77 return *Data
.InputArg
;
79 PipedJob
&getPipe() const {
80 assert(isPipe() && "Invalid accessor.");
84 /// getAsString - Return a string name for this input, for
86 std::string
getAsString() const {
89 else if (isFilename())
90 return std::string("\"") + getFilename() + '"';
91 else if (isInputArg())
98 } // end namespace driver
99 } // end namespace clang