1 //===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file declares the MultiplexConsumer class, which can be used to 11 // multiplex ASTConsumer and SemaConsumer messages to many consumers. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H 16 #define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H 17 18 #include "clang/Basic/LLVM.h" 19 #include "clang/Sema/SemaConsumer.h" 20 #include <memory> 21 #include <vector> 22 23 namespace clang { 24 25 class MultiplexASTMutationListener; 26 class MultiplexASTDeserializationListener; 27 28 // Has a list of ASTConsumers and calls each of them. Owns its children. 29 class MultiplexConsumer : public SemaConsumer { 30 public: 31 // Takes ownership of the pointers in C. 32 MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C); 33 ~MultiplexConsumer() override; 34 35 // ASTConsumer 36 void Initialize(ASTContext &Context) override; 37 void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override; 38 bool HandleTopLevelDecl(DeclGroupRef D) override; 39 void HandleInlineMethodDefinition(CXXMethodDecl *D) override; 40 void HandleInterestingDecl(DeclGroupRef D) override; 41 void HandleTranslationUnit(ASTContext &Ctx) override; 42 void HandleTagDeclDefinition(TagDecl *D) override; 43 void HandleTagDeclRequiredDefinition(const TagDecl *D) override; 44 void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override; 45 void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override; 46 void HandleImplicitImportDecl(ImportDecl *D) override; 47 void HandleLinkerOptionPragma(llvm::StringRef Opts) override; 48 void HandleDetectMismatch(llvm::StringRef Name, 49 llvm::StringRef Value) override; 50 void HandleDependentLibrary(llvm::StringRef Lib) override; 51 void CompleteTentativeDefinition(VarDecl *D) override; 52 void HandleVTable(CXXRecordDecl *RD) override; 53 ASTMutationListener *GetASTMutationListener() override; 54 ASTDeserializationListener *GetASTDeserializationListener() override; 55 void PrintStats() override; 56 57 // SemaConsumer 58 void InitializeSema(Sema &S) override; 59 void ForgetSema() override; 60 61 private: 62 std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these. 63 std::unique_ptr<MultiplexASTMutationListener> MutationListener; 64 std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener; 65 }; 66 67 } // end namespace clang 68 69 #endif 70