forked from OSchip/llvm-project
Revert r144703. It was a dumb idea anyway; will add the new bits more
incrementally with a new frontend action. llvm-svn: 144723
This commit is contained in:
parent
003cea6011
commit
ac42ec6fc5
|
@ -67,40 +67,22 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class GeneratePCHAction : public ASTFrontendAction {
|
class GeneratePCHAction : public ASTFrontendAction {
|
||||||
|
bool MakeModule;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
||||||
StringRef InFile);
|
StringRef InFile);
|
||||||
|
|
||||||
virtual TranslationUnitKind getTranslationUnitKind() {
|
virtual TranslationUnitKind getTranslationUnitKind() {
|
||||||
return TU_Prefix;
|
return MakeModule? TU_Module : TU_Prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasASTFileSupport() const { return false; }
|
virtual bool hasASTFileSupport() const { return false; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Compute the AST consumer arguments that will be used to
|
/// \brief Create a new action
|
||||||
/// create the PCHGenerator instance returned by CreateASTConsumer.
|
explicit GeneratePCHAction(bool MakeModule) : MakeModule(MakeModule) { }
|
||||||
///
|
|
||||||
/// \returns true if an error occurred, false otherwise.
|
|
||||||
static bool ComputeASTConsumerArguments(CompilerInstance &CI,
|
|
||||||
StringRef InFile,
|
|
||||||
std::string &Sysroot,
|
|
||||||
std::string &OutputFile,
|
|
||||||
raw_ostream *&OS);
|
|
||||||
};
|
|
||||||
|
|
||||||
class GenerateModuleAction : public ASTFrontendAction {
|
|
||||||
protected:
|
|
||||||
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
|
|
||||||
StringRef InFile);
|
|
||||||
|
|
||||||
virtual TranslationUnitKind getTranslationUnitKind() {
|
|
||||||
return TU_Module;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool hasASTFileSupport() const { return false; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// \brief Compute the AST consumer arguments that will be used to
|
/// \brief Compute the AST consumer arguments that will be used to
|
||||||
/// create the PCHGenerator instance returned by CreateASTConsumer.
|
/// create the PCHGenerator instance returned by CreateASTConsumer.
|
||||||
///
|
///
|
||||||
|
|
|
@ -647,14 +647,13 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
|
||||||
llvm::EnableStatistics();
|
llvm::EnableStatistics();
|
||||||
|
|
||||||
for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) {
|
||||||
InputKind InKind = getFrontendOpts().Inputs[i].first;
|
const std::string &InFile = getFrontendOpts().Inputs[i].second;
|
||||||
std::string InFile = getFrontendOpts().Inputs[i].second;
|
|
||||||
|
|
||||||
// Reset the ID tables if we are reusing the SourceManager.
|
// Reset the ID tables if we are reusing the SourceManager.
|
||||||
if (hasSourceManager())
|
if (hasSourceManager())
|
||||||
getSourceManager().clearIDTables();
|
getSourceManager().clearIDTables();
|
||||||
|
|
||||||
if (Act.BeginSourceFile(*this, InFile, InKind)) {
|
if (Act.BeginSourceFile(*this, InFile, getFrontendOpts().Inputs[i].first)) {
|
||||||
Act.Execute();
|
Act.Execute();
|
||||||
Act.EndSourceFile();
|
Act.EndSourceFile();
|
||||||
}
|
}
|
||||||
|
@ -699,7 +698,7 @@ static InputKind getSourceInputKindFromOptions(const LangOptions &LangOpts) {
|
||||||
namespace {
|
namespace {
|
||||||
struct CompileModuleData {
|
struct CompileModuleData {
|
||||||
CompilerInstance &Instance;
|
CompilerInstance &Instance;
|
||||||
GenerateModuleAction &CreateModuleAction;
|
GeneratePCHAction &CreateModuleAction;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,7 +1023,7 @@ static void compileModule(CompilerInstance &ImportingInstance,
|
||||||
/*ShouldCloneClient=*/true);
|
/*ShouldCloneClient=*/true);
|
||||||
|
|
||||||
// Construct a module-generating action.
|
// Construct a module-generating action.
|
||||||
GenerateModuleAction CreateModuleAction;
|
GeneratePCHAction CreateModuleAction(true);
|
||||||
|
|
||||||
// Execute the action to actually build the module in-place. Use a separate
|
// Execute the action to actually build the module in-place. Use a separate
|
||||||
// thread so that we get a stack large enough.
|
// thread so that we get a stack large enough.
|
||||||
|
|
|
@ -85,7 +85,7 @@ ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI,
|
||||||
|
|
||||||
if (!CI.getFrontendOpts().RelocatablePCH)
|
if (!CI.getFrontendOpts().RelocatablePCH)
|
||||||
Sysroot.clear();
|
Sysroot.clear();
|
||||||
return new PCHGenerator(CI.getPreprocessor(), OutputFile, /*Module=*/false,
|
return new PCHGenerator(CI.getPreprocessor(), OutputFile, MakeModule,
|
||||||
Sysroot, OS);
|
Sysroot, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,44 +113,6 @@ bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
|
|
||||||
StringRef InFile) {
|
|
||||||
std::string Sysroot;
|
|
||||||
std::string OutputFile;
|
|
||||||
raw_ostream *OS = 0;
|
|
||||||
if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!CI.getFrontendOpts().RelocatablePCH)
|
|
||||||
Sysroot.clear();
|
|
||||||
return new PCHGenerator(CI.getPreprocessor(), OutputFile, /*Module=*/true,
|
|
||||||
Sysroot, OS);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI,
|
|
||||||
StringRef InFile,
|
|
||||||
std::string &Sysroot,
|
|
||||||
std::string &OutputFile,
|
|
||||||
raw_ostream *&OS) {
|
|
||||||
Sysroot = CI.getHeaderSearchOpts().Sysroot;
|
|
||||||
if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
|
|
||||||
CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We use createOutputFile here because this is exposed via libclang, and we
|
|
||||||
// must disable the RemoveFileOnSignal behavior.
|
|
||||||
// We use a temporary to avoid race conditions.
|
|
||||||
OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
|
|
||||||
/*RemoveFileOnSignal=*/false, InFile,
|
|
||||||
/*Extension=*/"", /*useTemporary=*/true);
|
|
||||||
if (!OS)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
OutputFile = CI.getFrontendOpts().OutputFile;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI,
|
ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI,
|
||||||
StringRef InFile) {
|
StringRef InFile) {
|
||||||
return new ASTConsumer();
|
return new ASTConsumer();
|
||||||
|
|
|
@ -49,8 +49,8 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
|
||||||
case EmitCodeGenOnly: return new EmitCodeGenOnlyAction();
|
case EmitCodeGenOnly: return new EmitCodeGenOnlyAction();
|
||||||
case EmitObj: return new EmitObjAction();
|
case EmitObj: return new EmitObjAction();
|
||||||
case FixIt: return new FixItAction();
|
case FixIt: return new FixItAction();
|
||||||
case GenerateModule: return new GenerateModuleAction();
|
case GenerateModule: return new GeneratePCHAction(true);
|
||||||
case GeneratePCH: return new GeneratePCHAction();
|
case GeneratePCH: return new GeneratePCHAction(false);
|
||||||
case GeneratePTH: return new GeneratePTHAction();
|
case GeneratePTH: return new GeneratePTHAction();
|
||||||
case InitOnly: return new InitOnlyAction();
|
case InitOnly: return new InitOnlyAction();
|
||||||
case ParseSyntaxOnly: return new SyntaxOnlyAction();
|
case ParseSyntaxOnly: return new SyntaxOnlyAction();
|
||||||
|
|
Loading…
Reference in New Issue