clang API Documentation
00001 //===-- MultiplexConsumer.h - AST Consumer for PCH Generation ---*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the MultiplexConsumer class, which can be used to 00011 // multiplex ASTConsumer and SemaConsumer messages to many consumers. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H 00016 #define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H 00017 00018 #include "clang/Basic/LLVM.h" 00019 #include "clang/Sema/SemaConsumer.h" 00020 #include <memory> 00021 #include <vector> 00022 00023 namespace clang { 00024 00025 class MultiplexASTMutationListener; 00026 class MultiplexASTDeserializationListener; 00027 00028 // Has a list of ASTConsumers and calls each of them. Owns its children. 00029 class MultiplexConsumer : public SemaConsumer { 00030 public: 00031 // Takes ownership of the pointers in C. 00032 MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C); 00033 ~MultiplexConsumer(); 00034 00035 // ASTConsumer 00036 void Initialize(ASTContext &Context) override; 00037 void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override; 00038 bool HandleTopLevelDecl(DeclGroupRef D) override; 00039 void HandleInlineMethodDefinition(CXXMethodDecl *D) override; 00040 void HandleInterestingDecl(DeclGroupRef D) override; 00041 void HandleTranslationUnit(ASTContext &Ctx) override; 00042 void HandleTagDeclDefinition(TagDecl *D) override; 00043 void HandleTagDeclRequiredDefinition(const TagDecl *D) override; 00044 void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override; 00045 void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override; 00046 void HandleImplicitImportDecl(ImportDecl *D) override; 00047 void HandleLinkerOptionPragma(llvm::StringRef Opts) override; 00048 void HandleDetectMismatch(llvm::StringRef Name, 00049 llvm::StringRef Value) override; 00050 void HandleDependentLibrary(llvm::StringRef Lib) override; 00051 void CompleteTentativeDefinition(VarDecl *D) override; 00052 void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) override; 00053 ASTMutationListener *GetASTMutationListener() override; 00054 ASTDeserializationListener *GetASTDeserializationListener() override; 00055 void PrintStats() override; 00056 00057 // SemaConsumer 00058 void InitializeSema(Sema &S) override; 00059 void ForgetSema() override; 00060 00061 private: 00062 std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these. 00063 std::unique_ptr<MultiplexASTMutationListener> MutationListener; 00064 std::unique_ptr<MultiplexASTDeserializationListener> DeserializationListener; 00065 }; 00066 00067 } // end namespace clang 00068 00069 #endif