[cfe-commits] r99257 - in /cfe/trunk: include/clang/Lex/PPCallbacks.h include/clang/Lex/Preprocessor.h lib/Frontend/DependencyFile.cpp lib/Frontend/FrontendAction.cpp lib/Lex/PPLexerChange.cpp lib/Lex/Preprocessor.cpp
Daniel Dunbar
daniel at zuster.org
Mon Mar 22 22:09:10 PDT 2010
Author: ddunbar
Date: Tue Mar 23 00:09:10 2010
New Revision: 99257
URL: http://llvm.org/viewvc/llvm-project?rev=99257&view=rev
Log:
PPCallbacks: Add hook for reaching the end of the main file, and fix DependencyFile to not do work in its destructor.
Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/PPLexerChange.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Tue Mar 23 00:09:10 2010
@@ -44,6 +44,12 @@
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 @@
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);
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Mar 23 00:09:10 2010
@@ -368,6 +368,10 @@
/// 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.
Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Tue Mar 23 00:09:10 2010
@@ -48,14 +48,15 @@
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);
};
}
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Mar 23 00:09:10 2010
@@ -169,6 +169,10 @@
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();
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Mar 23 00:09:10 2010
@@ -255,6 +255,7 @@
if (!I->second->isUsed())
Diag(I->second->getDefinitionLoc(), diag::pp_macro_not_used);
}
+
return true;
}
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=99257&r1=99256&r2=99257&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Mar 23 00:09:10 2010
@@ -519,6 +519,11 @@
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.
More information about the cfe-commits
mailing list