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