Home | History | Annotate | Download | only in Frontend
      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 HandleInlineFunctionDefinition(FunctionDecl *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 CompleteTentativeDefinition(VarDecl *D) override;
     48   void AssignInheritanceModel(CXXRecordDecl *RD) override;
     49   void HandleVTable(CXXRecordDecl *RD) override;
     50   ASTMutationListener *GetASTMutationListener() override;
     51   ASTDeserializationListener *GetASTDeserializationListener() override;
     52   void PrintStats() override;
     53   bool shouldSkipFunctionBody(Decl *D) override;
     54 
     55   // SemaConsumer
     56   void InitializeSema(Sema &S) override;
     57   void ForgetSema() override;
     58 
     59 private:
     60   std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these.
     61   std::unique_ptr<MultiplexASTMutationListener> MutationListener;
     62   std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener;
     63 };
     64 
     65 }  // end namespace clang
     66 
     67 #endif
     68