clang  14.0.0git
ExternalASTSource.cpp
Go to the documentation of this file.
1 //===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the default implementation of the ExternalASTSource
10 // interface, which enables construction of AST nodes from some external
11 // source.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "clang/AST/ASTContext.h"
20 #include "clang/Basic/LLVM.h"
21 #include "clang/Basic/Module.h"
23 #include "llvm/ADT/None.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include <cstdint>
26 
27 using namespace clang;
28 
29 char ExternalASTSource::ID;
30 
32 
35  return None;
36 }
37 
40  return EK_ReplyHazy;
41 }
42 
44  unsigned Length,
45  SmallVectorImpl<Decl *> &Decls) {}
46 
48 
50 
52 
54 
56 
58 
60 
62 
64  const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
65  llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
66  llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
67  llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
68  return false;
69 }
70 
72  return nullptr;
73 }
74 
76  return Selector();
77 }
78 
80  return 0;
81 }
82 
84  return nullptr;
85 }
86 
89  return nullptr;
90 }
91 
94  return nullptr;
95 }
96 
97 bool
99  DeclarationName Name) {
100  return false;
101 }
102 
104 
106  const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
107  SmallVectorImpl<Decl *> &Result) {}
108 
110 
112  uint32_t OldGeneration = CurrentGeneration;
113 
114  // Make sure the generation of the topmost external source for the context is
115  // incremented. That might not be us.
116  auto *P = C.getExternalSource();
117  if (P && P != this)
118  CurrentGeneration = P->incrementGeneration(C);
119  else {
120  // FIXME: Only bump the generation counter if the current generation number
121  // has been observed?
122  if (!++CurrentGeneration)
123  llvm::report_fatal_error("generation counter overflowed", false);
124  }
125 
126  return OldGeneration;
127 }
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1151
clang::ExternalASTSource::ReadComments
virtual void ReadComments()
Loads comment ranges.
Definition: ExternalASTSource.cpp:53
clang::ExternalASTSource::StartTranslationUnit
virtual void StartTranslationUnit(ASTConsumer *Consumer)
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
Definition: ExternalASTSource.cpp:59
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::ExternalASTSource::CompleteRedeclChain
virtual void CompleteRedeclChain(const Decl *D)
Gives the external AST source an opportunity to complete the redeclaration chain for a declaration.
Definition: ExternalASTSource.cpp:47
clang::ExternalASTSource::FindExternalVisibleDeclsByName
virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name)
Find all declarations with the given name in the given context, and add them to the context by callin...
Definition: ExternalASTSource.cpp:98
clang::ExternalASTSource::FinishedDeserializing
virtual void FinishedDeserializing()
Notify ExternalASTSource that we finished the deserialization of a decl or type.
Definition: ExternalASTSource.cpp:57
Module.h
llvm::Optional
Definition: LLVM.h:40
clang::ExternalASTSource::getSourceDescriptor
virtual llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID)
Return a descriptor for the corresponding module, if one exists.
Definition: ExternalASTSource.cpp:34
clang::ExternalASTSource::layoutRecordType
virtual bool layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &BaseOffsets, llvm::DenseMap< const CXXRecordDecl *, CharUnits > &VirtualBaseOffsets)
Perform layout on the given record.
Definition: ExternalASTSource.cpp:63
SourceManager.h
clang::ExternalASTSource::GetExternalSelector
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
Definition: ExternalASTSource.cpp:75
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
Offset
unsigned Offset
Definition: Format.cpp:2381
clang::ExternalASTSource::FindExternalLexicalDecls
virtual void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Result)
Finds all declarations lexically contained within the given DeclContext, after applying an optional f...
Definition: ExternalASTSource.cpp:105
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:92
clang::ExternalASTSource::GetExternalDeclStmt
virtual Stmt * GetExternalDeclStmt(uint64_t Offset)
Resolve the offset of a statement in the decl stream into a statement.
Definition: ExternalASTSource.cpp:83
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::ExternalASTSource::MemoryBufferSizes
Definition: ExternalASTSource.h:278
clang::ASTConsumer
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:33
IdentifierTable.h
ASTContext.h
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3333
clang::ExternalASTSource::PrintStats
virtual void PrintStats()
Print any statistics that have been gathered regarding the external AST source.
Definition: ExternalASTSource.cpp:61
clang::ExternalASTSource::~ExternalASTSource
virtual ~ExternalASTSource()
ExternalASTSource.h
clang::ExternalASTSource::FindFileRegionDecls
virtual void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls)
Get the decls that are contained in a file in the Offset/Length range.
Definition: ExternalASTSource.cpp:43
clang::ExternalASTSource::getMemoryBufferSizes
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
Definition: ExternalASTSource.h:288
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::ExternalASTSource::hasExternalDefinitions
virtual ExtKind hasExternalDefinitions(const Decl *D)
Definition: ExternalASTSource.cpp:39
clang::ExternalASTSource::EK_ReplyHazy
@ EK_ReplyHazy
Definition: ExternalASTSource.h:165
clang::ExternalASTSource::CompleteType
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
Definition: ExternalASTSource.cpp:49
clang::ExternalASTSource::incrementGeneration
uint32_t incrementGeneration(ASTContext &C)
Increment the current generation.
Definition: ExternalASTSource.cpp:111
clang::ExternalASTSource::ExtKind
ExtKind
Definition: ExternalASTSource.h:165
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
LLVM.h
clang::ExternalASTSource::GetExternalCXXCtorInitializers
virtual CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset)
Resolve the offset of a set of C++ constructor initializers in the decl stream into an array of initi...
Definition: ExternalASTSource.cpp:88
DeclarationName.h
clang::ExternalASTSource::GetExternalCXXBaseSpecifiers
virtual CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset)
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers.
Definition: ExternalASTSource.cpp:93
clang::ExternalASTSource::GetNumExternalSelectors
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
Definition: ExternalASTSource.cpp:79
clang::Builtin::ID
ID
Definition: Builtins.h:48
clang
Definition: CalledOnceCheck.h:17
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:748
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::ExternalASTSource::completeVisibleDeclsMap
virtual void completeVisibleDeclsMap(const DeclContext *DC)
Ensures that the table of all visible declarations inside this context is up to date.
Definition: ExternalASTSource.cpp:103
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:147
clang::ExternalASTSource::StartedDeserializing
virtual void StartedDeserializing()
Notify ExternalASTSource that we started deserialization of a decl or type so until FinishedDeseriali...
Definition: ExternalASTSource.cpp:55
clang::ExternalASTSource::GetExternalDecl
virtual Decl * GetExternalDecl(uint32_t ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ExternalASTSource.cpp:71
llvm::SmallVectorImpl
Definition: LLVM.h:39
FileManager.h
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2172
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3868