2009-03-16 14:56:51 +08:00
|
|
|
//===--- InputInfo.h - Input Source & Type Information ----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#ifndef LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
|
|
|
|
#define LLVM_CLANG_LIB_DRIVER_INPUTINFO_H
|
2009-03-16 14:56:51 +08:00
|
|
|
|
2009-03-18 15:06:02 +08:00
|
|
|
#include "clang/Driver/Types.h"
|
2013-06-15 01:17:23 +08:00
|
|
|
#include "llvm/Option/Arg.h"
|
2009-03-16 14:56:51 +08:00
|
|
|
#include <cassert>
|
2009-03-18 06:47:06 +08:00
|
|
|
#include <string>
|
2009-03-16 14:56:51 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace driver {
|
|
|
|
|
|
|
|
/// InputInfo - Wrapper for information about an input source.
|
|
|
|
class InputInfo {
|
2009-03-19 15:29:38 +08:00
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
2009-03-16 14:56:51 +08:00
|
|
|
union {
|
|
|
|
const char *Filename;
|
2013-06-17 21:59:19 +08:00
|
|
|
const llvm::opt::Arg *InputArg;
|
2009-03-16 14:56:51 +08:00
|
|
|
} Data;
|
2009-03-19 15:29:38 +08:00
|
|
|
Class Kind;
|
2009-03-16 14:56:51 +08:00
|
|
|
types::ID Type;
|
|
|
|
const char *BaseInput;
|
|
|
|
|
|
|
|
public:
|
|
|
|
InputInfo() {}
|
2009-03-18 06:47:06 +08:00
|
|
|
InputInfo(types::ID _Type, const char *_BaseInput)
|
2009-03-19 15:29:38 +08:00
|
|
|
: 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;
|
2009-03-18 06:47:06 +08:00
|
|
|
}
|
2013-06-17 21:59:19 +08:00
|
|
|
InputInfo(const llvm::opt::Arg *_InputArg, types::ID _Type,
|
|
|
|
const char *_BaseInput)
|
|
|
|
: Kind(InputArg), Type(_Type), BaseInput(_BaseInput) {
|
2009-03-19 15:29:38 +08:00
|
|
|
Data.InputArg = _InputArg;
|
2009-03-16 14:56:51 +08:00
|
|
|
}
|
|
|
|
|
2009-03-19 15:29:38 +08:00
|
|
|
bool isNothing() const { return Kind == Nothing; }
|
|
|
|
bool isFilename() const { return Kind == Filename; }
|
|
|
|
bool isInputArg() const { return Kind == InputArg; }
|
2009-03-16 14:56:51 +08:00
|
|
|
types::ID getType() const { return Type; }
|
|
|
|
const char *getBaseInput() const { return BaseInput; }
|
|
|
|
|
2009-03-19 15:29:38 +08:00
|
|
|
const char *getFilename() const {
|
|
|
|
assert(isFilename() && "Invalid accessor.");
|
2009-03-16 14:56:51 +08:00
|
|
|
return Data.Filename;
|
|
|
|
}
|
2013-06-17 21:59:19 +08:00
|
|
|
const llvm::opt::Arg &getInputArg() const {
|
2009-03-19 15:29:38 +08:00
|
|
|
assert(isInputArg() && "Invalid accessor.");
|
|
|
|
return *Data.InputArg;
|
|
|
|
}
|
2009-03-18 06:47:06 +08:00
|
|
|
|
|
|
|
/// getAsString - Return a string name for this input, for
|
|
|
|
/// debugging.
|
|
|
|
std::string getAsString() const {
|
2010-08-02 10:38:21 +08:00
|
|
|
if (isFilename())
|
2009-03-19 15:29:38 +08:00
|
|
|
return std::string("\"") + getFilename() + '"';
|
|
|
|
else if (isInputArg())
|
|
|
|
return "(input arg)";
|
2009-03-18 06:47:06 +08:00
|
|
|
else
|
|
|
|
return "(nothing)";
|
|
|
|
}
|
2009-03-16 14:56:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace driver
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|