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 CLANG_FRONTEND_MULTIPLEXCONSUMER_H 16 #define CLANG_FRONTEND_MULTIPLEXCONSUMER_H 17 18 #include "clang/Basic/LLVM.h" 19 #include "clang/Sema/SemaConsumer.h" 20 #include "clang/Basic/LLVM.h" 21 #include "llvm/ADT/OwningPtr.h" 22 #include <vector> 23 24 namespace clang { 25 26 class MultiplexASTMutationListener; 27 class MultiplexASTDeserializationListener; 28 29 // Has a list of ASTConsumers and calls each of them. Owns its children. 30 class MultiplexConsumer : public SemaConsumer { 31 public: 32 // Takes ownership of the pointers in C. 33 MultiplexConsumer(ArrayRef<ASTConsumer*> C); 34 ~MultiplexConsumer(); 35 36 // ASTConsumer 37 virtual void Initialize(ASTContext &Context); 38 virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); 39 virtual bool HandleTopLevelDecl(DeclGroupRef D); 40 virtual void HandleInterestingDecl(DeclGroupRef D); 41 virtual void HandleTranslationUnit(ASTContext &Ctx); 42 virtual void HandleTagDeclDefinition(TagDecl *D); 43 virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D); 44 virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D); 45 virtual void CompleteTentativeDefinition(VarDecl *D); 46 virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired); 47 virtual ASTMutationListener *GetASTMutationListener(); 48 virtual ASTDeserializationListener *GetASTDeserializationListener(); 49 virtual void PrintStats(); 50 51 // SemaConsumer 52 virtual void InitializeSema(Sema &S); 53 virtual void ForgetSema(); 54 classof(const MultiplexConsumer *)55 static bool classof(const MultiplexConsumer *) { return true; } 56 private: 57 std::vector<ASTConsumer*> Consumers; // Owns these. 58 OwningPtr<MultiplexASTMutationListener> MutationListener; 59 OwningPtr<MultiplexASTDeserializationListener> DeserializationListener; 60 }; 61 62 } // end namespace clang 63 64 #endif 65