1 //===--- ExternalASTSource.h - Abstract External AST Interface --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the ExternalASTSource interface,
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
14 #define LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
16 #include "clang/AST/DeclarationName.h"
17 #include "clang/AST/Type.h"
18 #include "llvm/ADT/SmallVector.h"
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.
30 /// \brief The ID numbers of all of the declarations with this name.
32 /// These declarations have not necessarily been de-serialized.
33 llvm::SmallVector<unsigned, 4> Declarations;
36 /// \brief Abstract interface for external sources of AST nodes.
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
43 class ExternalASTSource {
45 virtual ~ExternalASTSource();
47 /// \brief Resolve a type ID into a type, potentially building a new
49 virtual QualType GetType(unsigned ID) = 0;
51 /// \brief Resolve a declaration ID into a declaration, potentially
52 /// building a new declaration.
53 virtual Decl *GetDecl(unsigned ID) = 0;
55 /// \brief Read all of the declarations lexically stored in a
56 /// declaration context.
58 /// \param DC The declaration context whose declarations will be
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.
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;
71 /// \brief Read all of the declarations visible from a declaration
74 /// \param DC The declaration context whose visible declarations
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.
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;
86 /// \brief Print any statistics that have been gathered regarding
87 /// the external AST source.
88 virtual void PrintStats();
91 } // end namespace clang
93 #endif // LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H