Frontend: Change FrontendAction::BeginSourceFile to take the input kind instead of an IsAST bool.

llvm-svn: 105578
This commit is contained in:
Daniel Dunbar 2010-06-07 23:23:06 +00:00
parent 9b491e79fc
commit 8654638b23
4 changed files with 12 additions and 10 deletions

View File

@ -166,17 +166,18 @@ public:
/// \param Filename - The input filename, which will be made available to /// \param Filename - The input filename, which will be made available to
/// clients via \see getCurrentFile(). /// clients via \see getCurrentFile().
/// ///
/// \param IsAST - Indicates whether this is an AST input. AST inputs require /// \param InputKind - The type of input. Some input kinds are handled
/// special handling, since the AST file itself contains several objects which /// specially, for example AST inputs, since the AST file itself contains
/// would normally be owned by the CompilerInstance. When processing AST input /// several objects which would normally be owned by the
/// files, these objects should generally not be initialized in the /// CompilerInstance. When processing AST input files, these objects should
/// CompilerInstance -- they will automatically be shared with the AST file in /// generally not be initialized in the CompilerInstance -- they will
/// between \see BeginSourceFile() and \see EndSourceFile(). /// automatically be shared with the AST file in between \see
/// BeginSourceFile() and \see EndSourceFile().
/// ///
/// \return True on success; the compilation of this file should be aborted /// \return True on success; the compilation of this file should be aborted
/// and neither Execute nor EndSourceFile should be called. /// and neither Execute nor EndSourceFile should be called.
bool BeginSourceFile(CompilerInstance &CI, llvm::StringRef Filename, bool BeginSourceFile(CompilerInstance &CI, llvm::StringRef Filename,
bool IsAST = false); InputKind Kind);
/// Execute - Set the source managers main input file, and run the action. /// Execute - Set the source managers main input file, and run the action.
void Execute(); void Execute();

View File

@ -359,7 +359,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI,
Act.reset(new TopLevelDeclTrackerAction(*AST)); Act.reset(new TopLevelDeclTrackerAction(*AST));
if (!Act->BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0].second, if (!Act->BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0].second,
/*IsAST=*/false)) Clang.getFrontendOpts().Inputs[0].first))
goto error; goto error;
Act->Execute(); Act->Execute();

View File

@ -509,7 +509,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
createPreprocessor(); createPreprocessor();
} }
if (Act.BeginSourceFile(*this, InFile, IsAST)) { if (Act.BeginSourceFile(*this, InFile, getFrontendOpts().Inputs[i].first)) {
Act.Execute(); Act.Execute();
Act.EndSourceFile(); Act.EndSourceFile();
} }

View File

@ -32,7 +32,7 @@ void FrontendAction::setCurrentFile(llvm::StringRef Value, ASTUnit *AST) {
bool FrontendAction::BeginSourceFile(CompilerInstance &CI, bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
llvm::StringRef Filename, llvm::StringRef Filename,
bool IsAST) { InputKind InputKind) {
assert(!Instance && "Already processing a source file!"); assert(!Instance && "Already processing a source file!");
assert(!Filename.empty() && "Unexpected empty filename!"); assert(!Filename.empty() && "Unexpected empty filename!");
setCurrentFile(Filename); setCurrentFile(Filename);
@ -40,6 +40,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
// AST files follow a very different path, since they share objects via the // AST files follow a very different path, since they share objects via the
// AST unit. // AST unit.
bool IsAST = InputKind == IK_AST;
if (IsAST) { if (IsAST) {
assert(!usesPreprocessorOnly() && assert(!usesPreprocessorOnly() &&
"Attempt to pass AST file to preprocessor only action!"); "Attempt to pass AST file to preprocessor only action!");