]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/AST/ASTConsumer.h
Merge ACPICA 20100702.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / AST / ASTConsumer.h
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
17 namespace clang {
18   class ASTContext;
19   class CXXRecordDecl;
20   class DeclGroupRef;
21   class TagDecl;
22   class HandleTagDeclDefinition;
23   class SemaConsumer; // layering violation required for safe SemaConsumer
24   class VarDecl;
25
26 /// ASTConsumer - This is an abstract interface that should be implemented by
27 /// clients that read ASTs.  This abstraction layer allows the client to be
28 /// independent of the AST producer (e.g. parser vs AST dump file reader, etc).
29 class ASTConsumer {
30   /// \brief Whether this AST consumer also requires information about
31   /// semantic analysis.
32   bool SemaConsumer;
33
34   friend class SemaConsumer;
35
36 public:
37   ASTConsumer() : SemaConsumer(false) { }
38
39   virtual ~ASTConsumer() {}
40
41   /// Initialize - This is called to initialize the consumer, providing the
42   /// ASTContext.
43   virtual void Initialize(ASTContext &Context) {}
44
45   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
46   /// called by the parser to process every top-level Decl*. Note that D can be
47   /// the head of a chain of Decls (e.g. for `int a, b` the chain will have two
48   /// elements). Use Decl::getNextDeclarator() to walk the chain.
49   virtual void HandleTopLevelDecl(DeclGroupRef D);
50
51   /// HandleTranslationUnit - This method is called when the ASTs for entire
52   /// translation unit have been parsed.
53   virtual void HandleTranslationUnit(ASTContext &Ctx) {}
54
55   /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
56   /// (e.g. struct, union, enum, class) is completed.  This allows the client to
57   /// hack on the type, which can occur at any point in the file (because these
58   /// can be defined in declspecs).
59   virtual void HandleTagDeclDefinition(TagDecl *D) {}
60
61   /// CompleteTentativeDefinition - Callback invoked at the end of a translation
62   /// unit to notify the consumer that the given tentative definition should be
63   /// completed.
64   ///
65   /// The variable declaration itself will be a tentative
66   /// definition. If it had an incomplete array type, its type will
67   /// have already been changed to an array of size 1. However, the
68   /// declaration remains a tentative definition and has not been
69   /// modified by the introduction of an implicit zero initializer.
70   virtual void CompleteTentativeDefinition(VarDecl *D) {}
71
72   /// \brief Callback involved at the end of a translation unit to
73   /// notify the consumer that a vtable for the given C++ class is
74   /// required.
75   ///
76   /// \param RD The class whose vtable was used.
77   ///
78   /// \param DefinitionRequired Whether a definition of this vtable is
79   /// required in this translation unit; otherwise, it is only needed if
80   /// it was actually used.
81   virtual void HandleVTable(CXXRecordDecl *RD, bool DefinitionRequired) {}
82
83   /// PrintStats - If desired, print any statistics.
84   virtual void PrintStats() {}
85
86   // Support isa/cast/dyn_cast
87   static bool classof(const ASTConsumer *) { return true; }
88 };
89
90 } // end namespace clang.
91
92 #endif