Nebiroth updated this revision to Diff 126430. Nebiroth added a comment. Removed unique_ptr parameter in PrecompiledPreamble::Build Added method createPPCallbacks() in PreambleCallback to be overriden
Repository: rC Clang https://reviews.llvm.org/D39375 Files: include/clang/Frontend/PrecompiledPreamble.h lib/Frontend/PrecompiledPreamble.cpp Index: lib/Frontend/PrecompiledPreamble.cpp =================================================================== --- lib/Frontend/PrecompiledPreamble.cpp +++ lib/Frontend/PrecompiledPreamble.cpp @@ -351,6 +351,8 @@ if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) return BuildPreambleError::BeginSourceFileFailed; + if (Callbacks.createPPCallbacks()) + Clang->getPreprocessor().addPPCallbacks(std::move(Callbacks.createPPCallbacks())); Act->Execute(); // Run the callbacks. @@ -709,6 +711,7 @@ void PreambleCallbacks::HandleTopLevelDecl(DeclGroupRef DG) {} void PreambleCallbacks::HandleMacroDefined(const Token &MacroNameTok, const MacroDirective *MD) {} +std::unique_ptr<PPCallbacks> PreambleCallbacks::createPPCallbacks() {return nullptr;} std::error_code clang::make_error_code(BuildPreambleError Error) { return std::error_code(static_cast<int>(Error), BuildPreambleErrorCategory()); Index: include/clang/Frontend/PrecompiledPreamble.h =================================================================== --- include/clang/Frontend/PrecompiledPreamble.h +++ include/clang/Frontend/PrecompiledPreamble.h @@ -260,6 +260,9 @@ /// used instead, but having only this method allows a simpler API. virtual void HandleMacroDefined(const Token &MacroNameTok, const MacroDirective *MD); + /// Adds list of Preprocessor callbacks so we can also process information + /// about includes that are outside of a preamble i.e in the middle of a file + virtual std::unique_ptr<PPCallbacks> createPPCallbacks(); }; enum class BuildPreambleError {
Index: lib/Frontend/PrecompiledPreamble.cpp =================================================================== --- lib/Frontend/PrecompiledPreamble.cpp +++ lib/Frontend/PrecompiledPreamble.cpp @@ -351,6 +351,8 @@ if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) return BuildPreambleError::BeginSourceFileFailed; + if (Callbacks.createPPCallbacks()) + Clang->getPreprocessor().addPPCallbacks(std::move(Callbacks.createPPCallbacks())); Act->Execute(); // Run the callbacks. @@ -709,6 +711,7 @@ void PreambleCallbacks::HandleTopLevelDecl(DeclGroupRef DG) {} void PreambleCallbacks::HandleMacroDefined(const Token &MacroNameTok, const MacroDirective *MD) {} +std::unique_ptr<PPCallbacks> PreambleCallbacks::createPPCallbacks() {return nullptr;} std::error_code clang::make_error_code(BuildPreambleError Error) { return std::error_code(static_cast<int>(Error), BuildPreambleErrorCategory()); Index: include/clang/Frontend/PrecompiledPreamble.h =================================================================== --- include/clang/Frontend/PrecompiledPreamble.h +++ include/clang/Frontend/PrecompiledPreamble.h @@ -260,6 +260,9 @@ /// used instead, but having only this method allows a simpler API. virtual void HandleMacroDefined(const Token &MacroNameTok, const MacroDirective *MD); + /// Adds list of Preprocessor callbacks so we can also process information + /// about includes that are outside of a preamble i.e in the middle of a file + virtual std::unique_ptr<PPCallbacks> createPPCallbacks(); }; enum class BuildPreambleError {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits