r353030 - [clang] Add getCommentHandler to PreambleCallbacks
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 4 01:42:33 PST 2019
Author: kadircet
Date: Mon Feb 4 01:42:33 2019
New Revision: 353030
URL: http://llvm.org/viewvc/llvm-project?rev=353030&view=rev
Log:
[clang] Add getCommentHandler to PreambleCallbacks
Summary:
Enables users to add comment handlers to preprocessor when building
preambles.
Reviewers: ilya-biryukov, ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D57507
Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=353030&r1=353029&r2=353030&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Mon Feb 4 01:42:33 2019
@@ -283,6 +283,8 @@ public:
/// Creates wrapper class for PPCallbacks so we can also process information
/// about includes that are inside of a preamble
virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
+ /// The returned CommentHandler will be added to the preprocessor if not null.
+ virtual CommentHandler *getCommentHandler();
};
enum class BuildPreambleError {
Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=353030&r1=353029&r2=353030&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Mon Feb 4 01:42:33 2019
@@ -18,6 +18,7 @@
#include "clang/Frontend/FrontendActions.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/ASTWriter.h"
#include "llvm/ADT/StringExtras.h"
@@ -346,6 +347,8 @@ llvm::ErrorOr<PrecompiledPreamble> Preco
Callbacks.createPPCallbacks();
if (DelegatedPPCallbacks)
Clang->getPreprocessor().addPPCallbacks(std::move(DelegatedPPCallbacks));
+ if (auto CommentHandler = Callbacks.getCommentHandler())
+ Clang->getPreprocessor().addCommentHandler(CommentHandler);
Act->Execute();
@@ -742,6 +745,7 @@ void PreambleCallbacks::HandleTopLevelDe
std::unique_ptr<PPCallbacks> PreambleCallbacks::createPPCallbacks() {
return nullptr;
}
+CommentHandler *PreambleCallbacks::getCommentHandler() { return nullptr; }
static llvm::ManagedStatic<BuildPreambleErrorCategory> BuildPreambleErrCategory;
More information about the cfe-commits
mailing list