ASTConsumer.h revision 17861c5ed9cb5eab947d99520a6ef9c706e65dbc
1//===--- ASTConsumer.h - Abstract interface for reading ASTs ----*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file was developed by Chris Lattner and is distributed under 6// the University of Illinois Open Source 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 Decl; 20 21/// ASTConsumer - This is an abstract interface that should be implemented by 22/// clients that read ASTs. This abstraction layer allows the client to be 23/// independent of the AST producer (e.g. parser vs AST dump file reader, etc). 24class ASTConsumer { 25public: 26 virtual ~ASTConsumer(); 27 28 /// Initialize - This is called to initialize the consumer, providing the 29 /// ASTContext. 30 virtual void Initialize(ASTContext &Context) {} 31 32 /// HandleTopLevelDecl - Handle the specified top-level declaration. This is 33 /// called by HandleTopLevelDeclaration to process every top-level Decl*. 34 virtual void HandleTopLevelDecl(Decl *D) {}; 35 36 37 /// HandleTopLevelDeclaration - Handle the specified top-level declaration. 38 /// This is called only for Decl* that are the head of a chain of 39 /// Decl's (in the case that the Decl* is a ScopedDecl*). Subclasses 40 /// can override its behavior; by default it calls HandleTopLevelDecl 41 /// for every Decl* in a decl chain. 42 virtual void HandleTopLevelDeclaration(Decl *D); 43 44 /// PrintStats - If desired, print any statistics. 45 virtual void PrintStats() { 46 } 47}; 48 49} // end namespace clang. 50 51#endif 52