ASTConsumer.h revision 682bf92db408a6cbc3d37b5496a99b6ef85041ec
1//===--- ASTConsumer.h - Abstract interface for reading ASTs ----*- 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 defines the ASTConsumer class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_ASTCONSUMER_H 15#define LLVM_CLANG_AST_ASTCONSUMER_H 16 17namespace clang { 18 class ASTContext; 19 class DeclGroupRef; 20 class TagDecl; 21 class HandleTagDeclDefinition; 22 23/// ASTConsumer - This is an abstract interface that should be implemented by 24/// clients that read ASTs. This abstraction layer allows the client to be 25/// independent of the AST producer (e.g. parser vs AST dump file reader, etc). 26class ASTConsumer { 27public: 28 virtual ~ASTConsumer() {} 29 30 /// Initialize - This is called to initialize the consumer, providing the 31 /// ASTContext. 32 virtual void Initialize(ASTContext &Context) {} 33 34 /// HandleTopLevelDecl - Handle the specified top-level declaration. This is 35 /// called by the parser to process every top-level Decl*. Note that D can 36 /// be the head of a chain of Decls (e.g. for `int a, b` the chain will have 37 /// two elements). Use Decl::getNextDeclarator() to walk the chain. 38 virtual void HandleTopLevelDecl(DeclGroupRef D); 39 40 /// HandleTranslationUnit - This method is called when the ASTs for entire 41 /// translation unit have been parsed. 42 virtual void HandleTranslationUnit(ASTContext &Ctx) {} 43 44 /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl 45 /// (e.g. struct, union, enum, class) is completed. This allows the client to 46 /// hack on the type, which can occur at any point in the file (because these 47 /// can be defined in declspecs). 48 virtual void HandleTagDeclDefinition(TagDecl *D) {} 49 50 /// PrintStats - If desired, print any statistics. 51 virtual void PrintStats() { 52 } 53}; 54 55} // end namespace clang. 56 57#endif 58