PPCallbacks: Add hook for reaching the end of the main file, and fix DependencyFile to not do work in its destructor.
llvm-svn: 99257
This commit is contained in:
parent
de04b3f62c
commit
cb9eaf59fb
|
@ -44,6 +44,12 @@ public:
|
|||
SrcMgr::CharacteristicKind FileType) {
|
||||
}
|
||||
|
||||
|
||||
/// EndOfMainFile - This callback is invoked when the end of the main file is
|
||||
/// reach, no subsequent callbacks will be made.
|
||||
virtual void EndOfMainFile() {
|
||||
}
|
||||
|
||||
/// Ident - This callback is invoked when a #ident or #sccs directive is read.
|
||||
///
|
||||
virtual void Ident(SourceLocation Loc, const std::string &str) {
|
||||
|
@ -90,6 +96,11 @@ public:
|
|||
Second->FileChanged(Loc, Reason, FileType);
|
||||
}
|
||||
|
||||
virtual void EndOfMainFile() {
|
||||
First->EndOfMainFile();
|
||||
Second->EndOfMainFile();
|
||||
}
|
||||
|
||||
virtual void Ident(SourceLocation Loc, const std::string &str) {
|
||||
First->Ident(Loc, str);
|
||||
Second->Ident(Loc, str);
|
||||
|
|
|
@ -368,6 +368,10 @@ public:
|
|||
/// which implicitly adds the builtin defines etc.
|
||||
bool EnterMainSourceFile();
|
||||
|
||||
/// EndSourceFile - Inform the preprocessor callbacks that processing is
|
||||
/// complete.
|
||||
void EndSourceFile();
|
||||
|
||||
/// EnterSourceFile - Add a source file to the top of the include stack and
|
||||
/// start lexing tokens from it instead of the current buffer. Return true
|
||||
/// and fill in ErrorStr with the error information on failure.
|
||||
|
|
|
@ -48,14 +48,15 @@ public:
|
|||
IncludeSystemHeaders(Opts.IncludeSystemHeaders),
|
||||
PhonyTarget(Opts.UsePhonyTargets) {}
|
||||
|
||||
~DependencyFileCallback() {
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType);
|
||||
|
||||
virtual void EndOfMainFile() {
|
||||
OutputDependencyFile();
|
||||
OS->flush();
|
||||
delete OS;
|
||||
OS = 0;
|
||||
}
|
||||
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,10 @@ void FrontendAction::EndSourceFile() {
|
|||
CI.setASTContext(0);
|
||||
}
|
||||
|
||||
// Inform the preprocessor we are done.
|
||||
if (CI.hasPreprocessor())
|
||||
CI.getPreprocessor().EndSourceFile();
|
||||
|
||||
if (CI.getFrontendOpts().ShowStats) {
|
||||
llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
|
||||
CI.getPreprocessor().PrintStats();
|
||||
|
|
|
@ -255,6 +255,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
|
|||
if (!I->second->isUsed())
|
||||
Diag(I->second->getDefinitionLoc(), diag::pp_macro_not_used);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -519,6 +519,11 @@ bool Preprocessor::EnterMainSourceFile() {
|
|||
return EnterSourceFile(FID, 0, ErrorStr);
|
||||
}
|
||||
|
||||
void Preprocessor::EndSourceFile() {
|
||||
// Notify the client that we reached the end of the source file.
|
||||
if (Callbacks)
|
||||
Callbacks->EndOfMainFile();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Lexer Event Handling.
|
||||
|
|
Loading…
Reference in New Issue