forked from OSchip/llvm-project
ASTUnit: Don't check that input files exist when parsing ASTs from the command
line -- they may be remapped (fake) files. This is useful for testing parsing entirely from memory. llvm-svn: 94395
This commit is contained in:
parent
7baaee93e7
commit
fcf2d428e4
|
@ -77,32 +77,36 @@ public:
|
||||||
/// Information about the host which can be overriden by the user.
|
/// Information about the host which can be overriden by the user.
|
||||||
std::string HostBits, HostMachine, HostSystem, HostRelease;
|
std::string HostBits, HostMachine, HostSystem, HostRelease;
|
||||||
|
|
||||||
/// Whether the driver should follow g++ like behavior.
|
|
||||||
bool CCCIsCXX : 1;
|
|
||||||
|
|
||||||
/// Echo commands while executing (in -v style).
|
|
||||||
bool CCCEcho : 1;
|
|
||||||
|
|
||||||
/// Only print tool bindings, don't build any jobs.
|
|
||||||
bool CCCPrintBindings : 1;
|
|
||||||
|
|
||||||
/// Name to use when calling the generic gcc.
|
/// Name to use when calling the generic gcc.
|
||||||
std::string CCCGenericGCCName;
|
std::string CCCGenericGCCName;
|
||||||
|
|
||||||
|
/// Whether the driver should follow g++ like behavior.
|
||||||
|
unsigned CCCIsCXX : 1;
|
||||||
|
|
||||||
|
/// Echo commands while executing (in -v style).
|
||||||
|
unsigned CCCEcho : 1;
|
||||||
|
|
||||||
|
/// Only print tool bindings, don't build any jobs.
|
||||||
|
unsigned CCCPrintBindings : 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// Whether to check that input files exist when constructing compilation
|
||||||
|
/// jobs.
|
||||||
|
unsigned CheckInputsExist : 1;
|
||||||
|
|
||||||
/// Use the clang compiler where possible.
|
/// Use the clang compiler where possible.
|
||||||
bool CCCUseClang : 1;
|
unsigned CCCUseClang : 1;
|
||||||
|
|
||||||
/// Use clang for handling C++ and Objective-C++ inputs.
|
/// Use clang for handling C++ and Objective-C++ inputs.
|
||||||
bool CCCUseClangCXX : 1;
|
unsigned CCCUseClangCXX : 1;
|
||||||
|
|
||||||
/// Use clang as a preprocessor (clang's preprocessor will still be
|
/// Use clang as a preprocessor (clang's preprocessor will still be
|
||||||
/// used where an integrated CPP would).
|
/// used where an integrated CPP would).
|
||||||
bool CCCUseClangCPP : 1;
|
unsigned CCCUseClangCPP : 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Use lazy precompiled headers for PCH support.
|
/// Use lazy precompiled headers for PCH support.
|
||||||
bool CCCUsePCH;
|
unsigned CCCUsePCH : 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Only use clang for the given architectures (only used when
|
/// Only use clang for the given architectures (only used when
|
||||||
|
@ -129,6 +133,10 @@ public:
|
||||||
|
|
||||||
const Diagnostic &getDiags() const { return Diags; }
|
const Diagnostic &getDiags() const { return Diags; }
|
||||||
|
|
||||||
|
bool getCheckInputsExist() const { return CheckInputsExist; }
|
||||||
|
|
||||||
|
void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Primary Functionality
|
/// @name Primary Functionality
|
||||||
/// @{
|
/// @{
|
||||||
|
|
|
@ -50,8 +50,8 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
|
||||||
Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
|
Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
|
||||||
DefaultImageName(_DefaultImageName),
|
DefaultImageName(_DefaultImageName),
|
||||||
Host(0),
|
Host(0),
|
||||||
CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
|
CCCGenericGCCName("gcc"), CCCIsCXX(false), CCCEcho(false),
|
||||||
CCCGenericGCCName("gcc"), CCCUseClang(true),
|
CCCPrintBindings(false), CheckInputsExist(true), CCCUseClang(true),
|
||||||
CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true),
|
CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true),
|
||||||
SuppressMissingInputWarning(false) {
|
SuppressMissingInputWarning(false) {
|
||||||
if (IsProduction) {
|
if (IsProduction) {
|
||||||
|
@ -579,10 +579,9 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
|
||||||
Ty = InputType;
|
Ty = InputType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the file exists. It isn't clear this is worth doing, since
|
// Check that the file exists, if enabled.
|
||||||
// the tool presumably does this anyway, and this just adds an extra stat
|
if (CheckInputsExist && memcmp(Value, "-", 2) != 0 &&
|
||||||
// to the equation, but this is gcc compatible.
|
!llvm::sys::Path(Value).exists())
|
||||||
if (memcmp(Value, "-", 2) != 0 && !llvm::sys::Path(Value).exists())
|
|
||||||
Diag(clang::diag::err_drv_no_such_file) << A->getValue(Args);
|
Diag(clang::diag::err_drv_no_such_file) << A->getValue(Args);
|
||||||
else
|
else
|
||||||
Inputs.push_back(std::make_pair(Ty, A));
|
Inputs.push_back(std::make_pair(Ty, A));
|
||||||
|
|
|
@ -324,6 +324,10 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
|
||||||
// FIXME: We shouldn't have to pass in the path info.
|
// FIXME: We shouldn't have to pass in the path info.
|
||||||
driver::Driver TheDriver("clang", "/", llvm::sys::getHostTriple(),
|
driver::Driver TheDriver("clang", "/", llvm::sys::getHostTriple(),
|
||||||
"a.out", false, Diags);
|
"a.out", false, Diags);
|
||||||
|
|
||||||
|
// Don't check that inputs exist, they have been remapped.
|
||||||
|
TheDriver.setCheckInputsExist(false);
|
||||||
|
|
||||||
llvm::OwningPtr<driver::Compilation> C(
|
llvm::OwningPtr<driver::Compilation> C(
|
||||||
TheDriver.BuildCompilation(Args.size(), Args.data()));
|
TheDriver.BuildCompilation(Args.size(), Args.data()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue