]> granicus.if.org Git - clang/blob - include/clang/AST/ExternalASTSource.h
Various minor fixes to PCH reading and writing, with general
[clang] / include / clang / AST / ExternalASTSource.h
1 //===--- ExternalASTSource.h - Abstract External AST Interface --*- 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 ExternalASTSource interface, 
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
14 #define LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
15
16 #include "clang/AST/DeclarationName.h"
17 #include "clang/AST/Type.h"
18 #include "llvm/ADT/SmallVector.h"
19 namespace clang {
20
21 class Decl;
22 class DeclContext;
23
24 /// \brief The deserialized representation of a set of declarations
25 /// with the same name that are visible in a given context.
26 struct VisibleDeclaration {
27   /// \brief The name of the declarations.
28   DeclarationName Name;
29
30   /// \brief The ID numbers of all of the declarations with this name. 
31   ///
32   /// These declarations have not necessarily been de-serialized.
33   llvm::SmallVector<unsigned, 4> Declarations;
34 };
35
36 /// \brief Abstract interface for external sources of AST nodes.
37 ///
38 /// External AST sources provide AST nodes constructed from some
39 /// external source, such as a precompiled header. External AST
40 /// sources can resolve types and declarations from abstract IDs into
41 /// actual type and declaration nodes, and read parts of declaration
42 /// contexts.
43 class ExternalASTSource {
44 public:
45   virtual ~ExternalASTSource();
46
47   /// \brief Resolve a type ID into a type, potentially building a new
48   /// type.
49   virtual QualType GetType(unsigned ID) = 0;
50
51   /// \brief Resolve a declaration ID into a declaration, potentially
52   /// building a new declaration.
53   virtual Decl *GetDecl(unsigned ID) = 0;
54
55   /// \brief Read all of the declarations lexically stored in a
56   /// declaration context.
57   ///
58   /// \param DC The declaration context whose declarations will be
59   /// read.
60   ///
61   /// \param Decls Vector that will contain the declarations loaded
62   /// from the external source. The caller is responsible for merging
63   /// these declarations with any declarations already stored in the
64   /// declaration context.
65   ///
66   /// \returns true if there was an error while reading the
67   /// declarations for this declaration context.
68   virtual bool ReadDeclsLexicallyInContext(DeclContext *DC,
69                                   llvm::SmallVectorImpl<unsigned> &Decls) = 0;
70
71   /// \brief Read all of the declarations visible from a declaration
72   /// context.
73   ///
74   /// \param DC The declaration context whose visible declarations
75   /// will be read.
76   ///
77   /// \param Decls A vector of visible declaration structures,
78   /// providing the mapping from each name visible in the declaration
79   /// context to the declaration IDs of declarations with that name.
80   ///
81   /// \returns true if there was an error while reading the
82   /// declarations for this declaration context.
83   virtual bool ReadDeclsVisibleInContext(DeclContext *DC,
84                        llvm::SmallVectorImpl<VisibleDeclaration> & Decls) = 0;
85
86   /// \brief Print any statistics that have been gathered regarding
87   /// the external AST source.
88   virtual void PrintStats();
89 };
90
91 } // end namespace clang
92
93 #endif // LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H