summaryrefslogtreecommitdiff
path: root/clang/lib/Driver/InputInfo.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-19 07:29:38 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-19 07:29:38 +0000
commit5cdf3e0fb9c857d5d281324d132a940fc27d78c0 (patch)
treef2bf2e46fc63d8f11dadf33a365cee7beb5f830f /clang/lib/Driver/InputInfo.h
parent0e227785cb2514e397f1b9b45c688e2d9c092a3e (diff)
downloadllvm-5cdf3e0fb9c857d5d281324d132a940fc27d78c0.tar.gz
Driver: Handle "linker input" arguments.
- Make InputInfo a variant of filename, pipe, input argument, nothing. - Leave a FIXME in InputInfo that this should be revisited. llvm-svn: 67292
Diffstat (limited to 'clang/lib/Driver/InputInfo.h')
-rw-r--r--clang/lib/Driver/InputInfo.h54
1 files changed, 40 insertions, 14 deletions
diff --git a/clang/lib/Driver/InputInfo.h b/clang/lib/Driver/InputInfo.h
index 617e70365dd6..c657bef95af0 100644
--- a/clang/lib/Driver/InputInfo.h
+++ b/clang/lib/Driver/InputInfo.h
@@ -21,37 +21,61 @@ namespace driver {
/// 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;
+ const Arg *InputArg;
PipedJob *Pipe;
} 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)
+ : Kind(Filename), Type(_Type), BaseInput(_BaseInput) {
+ Data.Filename = _Filename;
}
- InputInfo(const char *Filename, types::ID _Type, const char *_BaseInput)
- : IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
- Data.Filename = Filename;
+ InputInfo(const Arg *_InputArg, types::ID _Type, const char *_BaseInput)
+ : Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
+ Data.InputArg = _InputArg;
}
- InputInfo(PipedJob *Pipe, types::ID _Type, const char *_BaseInput)
- : IsPipe(true), Type(_Type), BaseInput(_BaseInput) {
- Data.Pipe = Pipe;
+ InputInfo(PipedJob *_Pipe, types::ID _Type, const char *_BaseInput)
+ : Kind(Pipe), Type(_Type), BaseInput(_BaseInput) {
+ Data.Pipe = _Pipe;
}
- bool isPipe() const { return IsPipe; }
+ bool isNothing() const { return Kind == Nothing; }
+ bool isFilename() const { return Kind == Filename; }
+ bool isInputArg() const { return Kind == InputArg; }
+ bool isPipe() const { return Kind == Pipe; }
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;
}
+ const Arg &getInputArg() const {
+ assert(isInputArg() && "Invalid accessor.");
+ return *Data.InputArg;
+ }
PipedJob &getPipe() const {
assert(isPipe() && "Invalid accessor.");
return *Data.Pipe;
@@ -62,8 +86,10 @@ public:
std::string getAsString() const {
if (isPipe())
return "(pipe)";
- else if (const char *N = getInputFilename())
- return std::string("\"") + N + '"';
+ else if (isFilename())
+ return std::string("\"") + getFilename() + '"';
+ else if (isInputArg())
+ return "(input arg)";
else
return "(nothing)";
}