LLDB mainline
ASTUtils.h
Go to the documentation of this file.
1//===-- ASTUtils.h ----------------------------------------------*- C++ -*-===//
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#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
10#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
11
12#include "clang/Basic/ASTSourceDescriptor.h"
13#include "clang/Sema/Lookup.h"
14#include "clang/Sema/MultiplexExternalSemaSource.h"
15#include "clang/Sema/Sema.h"
16#include "clang/Sema/SemaConsumer.h"
17#include "llvm/ADT/IntrusiveRefCntPtr.h"
18#include "llvm/Support/Casting.h"
19#include <optional>
20
21namespace clang {
22
23class Module;
24
25} // namespace clang
26
27namespace lldb_private {
28
29/// Wraps an ExternalASTSource into an ExternalSemaSource.
30///
31/// Assumes shared ownership of the underlying source.
32class ExternalASTSourceWrapper : public clang::ExternalSemaSource {
33 llvm::IntrusiveRefCntPtr<ExternalASTSource> m_Source;
34
35public:
37 llvm::IntrusiveRefCntPtr<ExternalASTSource> Source)
38 : m_Source(std::move(Source)) {
39 assert(m_Source && "Can't wrap nullptr ExternalASTSource");
40 }
41
43
44 clang::Decl *GetExternalDecl(clang::GlobalDeclID ID) override {
45 return m_Source->GetExternalDecl(ID);
46 }
47
48 clang::Selector GetExternalSelector(uint32_t ID) override {
49 return m_Source->GetExternalSelector(ID);
50 }
51
52 uint32_t GetNumExternalSelectors() override {
53 return m_Source->GetNumExternalSelectors();
54 }
55
56 clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override {
57 return m_Source->GetExternalDeclStmt(Offset);
58 }
59
60 clang::CXXCtorInitializer **
61 GetExternalCXXCtorInitializers(uint64_t Offset) override {
62 return m_Source->GetExternalCXXCtorInitializers(Offset);
63 }
64
65 clang::CXXBaseSpecifier *
66 GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
67 return m_Source->GetExternalCXXBaseSpecifiers(Offset);
68 }
69
70 void updateOutOfDateIdentifier(const clang::IdentifierInfo &II) override {
71 m_Source->updateOutOfDateIdentifier(II);
72 }
73
75 const clang::DeclContext *DC, clang::DeclarationName Name,
76 const clang::DeclContext *OriginalDC) override {
77 return m_Source->FindExternalVisibleDeclsByName(DC, Name, OriginalDC);
78 }
79
80 bool LoadExternalSpecializations(const clang::Decl *D,
81 bool OnlyPartial) override {
82 return m_Source->LoadExternalSpecializations(D, OnlyPartial);
83 }
84
86 const clang::Decl *D,
87 llvm::ArrayRef<clang::TemplateArgument> TemplateArgs) override {
88 return m_Source->LoadExternalSpecializations(D, TemplateArgs);
89 }
90
91 void completeVisibleDeclsMap(const clang::DeclContext *DC) override {
92 m_Source->completeVisibleDeclsMap(DC);
93 }
94
95 clang::Module *getModule(unsigned ID) override {
96 return m_Source->getModule(ID);
97 }
98
99 std::optional<clang::ASTSourceDescriptor>
100 getSourceDescriptor(unsigned ID) override {
101 return m_Source->getSourceDescriptor(ID);
102 }
103
104 ExtKind hasExternalDefinitions(const clang::Decl *D) override {
105 return m_Source->hasExternalDefinitions(D);
106 }
107
109 const clang::DeclContext *DC,
110 llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
111 llvm::SmallVectorImpl<clang::Decl *> &Result) override {
112 m_Source->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
113 }
114
115 void
116 FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length,
117 llvm::SmallVectorImpl<clang::Decl *> &Decls) override {
118 m_Source->FindFileRegionDecls(File, Offset, Length, Decls);
119 }
120
121 void CompleteRedeclChain(const clang::Decl *D) override {
122 m_Source->CompleteRedeclChain(D);
123 }
124
125 void CompleteType(clang::TagDecl *Tag) override {
126 m_Source->CompleteType(Tag);
127 }
128
129 void CompleteType(clang::ObjCInterfaceDecl *Class) override {
130 m_Source->CompleteType(Class);
131 }
132
133 void ReadComments() override { m_Source->ReadComments(); }
134
135 void StartedDeserializing() override { m_Source->StartedDeserializing(); }
136
137 void FinishedDeserializing() override { m_Source->FinishedDeserializing(); }
138
139 void StartTranslationUnit(clang::ASTConsumer *Consumer) override {
140 m_Source->StartTranslationUnit(Consumer);
141 }
142
143 void PrintStats() override;
144
146 const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
147 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
148 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
149 &BaseOffsets,
150 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
151 &VirtualBaseOffsets) override {
152 return m_Source->layoutRecordType(Record, Size, Alignment, FieldOffsets,
153 BaseOffsets, VirtualBaseOffsets);
154 }
155
156 void StartedQualifiedLookup(const clang::DeclContext *DC) override {
157 if (auto *sema_source =
158 llvm::dyn_cast<clang::ExternalSemaSource>(m_Source.get()))
159 sema_source->StartedQualifiedLookup(DC);
160 }
161
162 void FinishedQualifiedLookup(const clang::DeclContext *DC) override {
163 if (auto *sema_source =
164 llvm::dyn_cast<clang::ExternalSemaSource>(m_Source.get()))
165 sema_source->FinishedQualifiedLookup(DC);
166 }
167
168 /// This gets called when Sema is reconciling undefined but used decls.
169 /// For LLDB's use-case, we never provide Clang with function definitions,
170 /// instead we rely on linkage names and symbol resolution to call the
171 /// correct funcitons during JITting. So this implementation clears
172 /// any "undefined" FunctionDecls that Clang found while parsing.
173 ///
174 /// \param[in,out] Undefined A set of used decls for which Clang has not
175 /// been provided a definition with.
176 ///
178 llvm::MapVector<clang::NamedDecl *, clang::SourceLocation> &Undefined)
179 override {
180 Undefined.remove_if([](auto const &decl_loc_pair) {
181 const clang::NamedDecl *ND = decl_loc_pair.first;
182 return llvm::isa_and_present<clang::FunctionDecl>(ND);
183 });
184 }
185};
186
187/// Wraps an ASTConsumer into an SemaConsumer. Doesn't take ownership of the
188/// provided consumer. If the provided ASTConsumer is also a SemaConsumer,
189/// the wrapper will also forward SemaConsumer functions.
190class ASTConsumerForwarder : public clang::SemaConsumer {
191 clang::ASTConsumer *m_c;
192 clang::SemaConsumer *m_sc;
193
194public:
195 ASTConsumerForwarder(clang::ASTConsumer *c) : m_c(c) {
196 m_sc = llvm::dyn_cast<clang::SemaConsumer>(m_c);
197 }
198
200
201 void Initialize(clang::ASTContext &Context) override {
202 m_c->Initialize(Context);
203 }
204
205 bool HandleTopLevelDecl(clang::DeclGroupRef D) override {
206 return m_c->HandleTopLevelDecl(D);
207 }
208
209 void HandleInlineFunctionDefinition(clang::FunctionDecl *D) override {
210 m_c->HandleInlineFunctionDefinition(D);
211 }
212
213 void HandleInterestingDecl(clang::DeclGroupRef D) override {
214 m_c->HandleInterestingDecl(D);
215 }
216
217 void HandleTranslationUnit(clang::ASTContext &Ctx) override {
218 m_c->HandleTranslationUnit(Ctx);
219 }
220
221 void HandleTagDeclDefinition(clang::TagDecl *D) override {
222 m_c->HandleTagDeclDefinition(D);
223 }
224
225 void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override {
226 m_c->HandleTagDeclRequiredDefinition(D);
227 }
228
229 void HandleCXXImplicitFunctionInstantiation(clang::FunctionDecl *D) override {
230 m_c->HandleCXXImplicitFunctionInstantiation(D);
231 }
232
233 void HandleTopLevelDeclInObjCContainer(clang::DeclGroupRef D) override {
234 m_c->HandleTopLevelDeclInObjCContainer(D);
235 }
236
237 void HandleImplicitImportDecl(clang::ImportDecl *D) override {
238 m_c->HandleImplicitImportDecl(D);
239 }
240
241 void CompleteTentativeDefinition(clang::VarDecl *D) override {
242 m_c->CompleteTentativeDefinition(D);
243 }
244
245 void AssignInheritanceModel(clang::CXXRecordDecl *RD) override {
246 m_c->AssignInheritanceModel(RD);
247 }
248
249 void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override {
250 m_c->HandleCXXStaticMemberVarInstantiation(D);
251 }
252
253 void HandleVTable(clang::CXXRecordDecl *RD) override {
254 m_c->HandleVTable(RD);
255 }
256
257 clang::ASTMutationListener *GetASTMutationListener() override {
258 return m_c->GetASTMutationListener();
259 }
260
261 clang::ASTDeserializationListener *GetASTDeserializationListener() override {
262 return m_c->GetASTDeserializationListener();
263 }
264
265 void PrintStats() override;
266
267 void InitializeSema(clang::Sema &S) override {
268 if (m_sc)
269 m_sc->InitializeSema(S);
270 }
271
272 /// Inform the semantic consumer that Sema is no longer available.
273 void ForgetSema() override {
274 if (m_sc)
275 m_sc->ForgetSema();
276 }
277
278 bool shouldSkipFunctionBody(clang::Decl *D) override {
279 return m_c->shouldSkipFunctionBody(D);
280 }
281};
282
283/// A ExternalSemaSource multiplexer that prioritizes its sources.
284///
285/// This ExternalSemaSource will forward all requests to its attached sources.
286/// However, unlike a normal multiplexer it will not forward a request to all
287/// sources, but instead give priority to certain sources. If a source with a
288/// higher priority can fulfill a request, all sources with a lower priority
289/// will not receive the request.
290///
291/// This class is mostly use to multiplex between sources of different
292/// 'quality', e.g. a C++ modules and debug information. The C++ module will
293/// provide more accurate replies to the requests, but might not be able to
294/// answer all requests. The debug information will be used as a fallback then
295/// to provide information that is not in the C++ module.
296class SemaSourceWithPriorities : public clang::ExternalSemaSource {
297
298private:
299 /// The sources ordered in decreasing priority.
300 llvm::SmallVector<llvm::IntrusiveRefCntPtr<clang::ExternalSemaSource>, 2>
302
303public:
304 /// Construct a SemaSourceWithPriorities with a 'high quality' source that
305 /// has the higher priority and a 'low quality' source that will be used
306 /// as a fallback.
307 ///
308 /// This class assumes shared ownership of the sources provided to it.
310 llvm::IntrusiveRefCntPtr<clang::ExternalSemaSource> high_quality_source,
311 llvm::IntrusiveRefCntPtr<clang::ExternalSemaSource> low_quality_source) {
312 assert(high_quality_source);
313 assert(low_quality_source);
314
315 Sources.push_back(std::move(high_quality_source));
316 Sources.push_back(std::move(low_quality_source));
317 }
318
320
321 //===--------------------------------------------------------------------===//
322 // ExternalASTSource.
323 //===--------------------------------------------------------------------===//
324
325 clang::Decl *GetExternalDecl(clang::GlobalDeclID ID) override {
326 for (size_t i = 0; i < Sources.size(); ++i)
327 if (clang::Decl *Result = Sources[i]->GetExternalDecl(ID))
328 return Result;
329 return nullptr;
330 }
331
332 bool LoadExternalSpecializations(const clang::Decl *D,
333 bool OnlyPartial) override {
334 bool newDeclFound = false;
335 for (size_t i = 0; i < Sources.size(); ++i)
336 newDeclFound |= Sources[i]->LoadExternalSpecializations(D, OnlyPartial);
337 return newDeclFound;
338 }
339
341 const clang::Decl *D,
342 llvm::ArrayRef<clang::TemplateArgument> TemplateArgs) override {
343 bool newDeclFound = false;
344 for (size_t i = 0; i < Sources.size(); ++i)
345 newDeclFound |= Sources[i]->LoadExternalSpecializations(D, TemplateArgs);
346 return newDeclFound;
347 }
348
349 void CompleteRedeclChain(const clang::Decl *D) override {
350 for (size_t i = 0; i < Sources.size(); ++i)
352 }
353
354 clang::Selector GetExternalSelector(uint32_t ID) override {
355 clang::Selector Sel;
356 for (size_t i = 0; i < Sources.size(); ++i) {
357 Sel = Sources[i]->GetExternalSelector(ID);
358 if (!Sel.isNull())
359 return Sel;
360 }
361 return Sel;
362 }
363
364 uint32_t GetNumExternalSelectors() override {
365 for (size_t i = 0; i < Sources.size(); ++i)
366 if (uint32_t total = Sources[i]->GetNumExternalSelectors())
367 return total;
368 return 0;
369 }
370
371 clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override {
372 for (size_t i = 0; i < Sources.size(); ++i)
373 if (clang::Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset))
374 return Result;
375 return nullptr;
376 }
377
378 clang::CXXBaseSpecifier *
379 GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
380 for (size_t i = 0; i < Sources.size(); ++i)
381 if (clang::CXXBaseSpecifier *R =
383 return R;
384 return nullptr;
385 }
386
387 clang::CXXCtorInitializer **
388 GetExternalCXXCtorInitializers(uint64_t Offset) override {
389 for (const auto &S : Sources)
390 if (auto *R = S->GetExternalCXXCtorInitializers(Offset))
391 return R;
392 return nullptr;
393 }
394
395 ExtKind hasExternalDefinitions(const clang::Decl *D) override {
396 for (const auto &S : Sources)
397 if (auto EK = S->hasExternalDefinitions(D))
398 if (EK != EK_ReplyHazy)
399 return EK;
400 return EK_ReplyHazy;
401 }
402
404 const clang::DeclContext *DC, clang::DeclarationName Name,
405 const clang::DeclContext *OriginalDC) override {
406 for (size_t i = 0; i < Sources.size(); ++i)
407 if (Sources[i]->FindExternalVisibleDeclsByName(DC, Name, OriginalDC))
408 return true;
409 return false;
410 }
411
412 void completeVisibleDeclsMap(const clang::DeclContext *DC) override {
413 // FIXME: Only one source should be able to complete the decls map.
414 for (size_t i = 0; i < Sources.size(); ++i)
416 }
417
419 const clang::DeclContext *DC,
420 llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
421 llvm::SmallVectorImpl<clang::Decl *> &Result) override {
422 for (size_t i = 0; i < Sources.size(); ++i) {
423 Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
424 if (!Result.empty())
425 return;
426 }
427 }
428
429 void
430 FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length,
431 llvm::SmallVectorImpl<clang::Decl *> &Decls) override {
432 for (size_t i = 0; i < Sources.size(); ++i)
433 Sources[i]->FindFileRegionDecls(File, Offset, Length, Decls);
434 }
435
436 void CompleteType(clang::TagDecl *Tag) override {
437 for (const auto &S : Sources) {
438 S->CompleteType(Tag);
439 // Stop after the first source completed the type.
440 if (Tag->isCompleteDefinition())
441 break;
442 }
443 }
444
445 void CompleteType(clang::ObjCInterfaceDecl *Class) override {
446 for (size_t i = 0; i < Sources.size(); ++i)
447 Sources[i]->CompleteType(Class);
448 }
449
450 void ReadComments() override {
451 for (size_t i = 0; i < Sources.size(); ++i)
452 Sources[i]->ReadComments();
453 }
454
455 void StartedDeserializing() override {
456 for (size_t i = 0; i < Sources.size(); ++i)
458 }
459
460 void FinishedDeserializing() override {
461 for (size_t i = 0; i < Sources.size(); ++i)
463 }
464
465 void StartTranslationUnit(clang::ASTConsumer *Consumer) override {
466 for (size_t i = 0; i < Sources.size(); ++i)
467 Sources[i]->StartTranslationUnit(Consumer);
468 }
469
470 void PrintStats() override;
471
472 clang::Module *getModule(unsigned ID) override {
473 for (size_t i = 0; i < Sources.size(); ++i)
474 if (auto M = Sources[i]->getModule(ID))
475 return M;
476 return nullptr;
477 }
478
480 const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
481 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
482 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
483 &BaseOffsets,
484 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
485 &VirtualBaseOffsets) override {
486 for (size_t i = 0; i < Sources.size(); ++i)
487 if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
488 BaseOffsets, VirtualBaseOffsets))
489 return true;
490 return false;
491 }
492
493 void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override {
494 for (auto &Source : Sources)
495 Source->getMemoryBufferSizes(sizes);
496 }
497
498 //===--------------------------------------------------------------------===//
499 // ExternalSemaSource.
500 //===--------------------------------------------------------------------===//
501
502 void InitializeSema(clang::Sema &S) override {
503 for (auto &Source : Sources)
504 Source->InitializeSema(S);
505 }
506
507 void ForgetSema() override {
508 for (auto &Source : Sources)
509 Source->ForgetSema();
510 }
511
512 void ReadMethodPool(clang::Selector Sel) override {
513 for (auto &Source : Sources)
514 Source->ReadMethodPool(Sel);
515 }
516
517 void updateOutOfDateSelector(clang::Selector Sel) override {
518 for (auto &Source : Sources)
519 Source->updateOutOfDateSelector(Sel);
520 }
521
524 for (auto &Source : Sources)
525 Source->ReadKnownNamespaces(Namespaces);
526 }
527
529 llvm::MapVector<clang::NamedDecl *, clang::SourceLocation> &Undefined)
530 override {
531 for (auto &Source : Sources)
532 Source->ReadUndefinedButUsed(Undefined);
533 }
534
536 llvm::MapVector<clang::FieldDecl *,
537 llvm::SmallVector<std::pair<clang::SourceLocation, bool>,
538 4>> &Exprs) override {
539 for (auto &Source : Sources)
540 Source->ReadMismatchingDeleteExpressions(Exprs);
541 }
542
543 bool LookupUnqualified(clang::LookupResult &R, clang::Scope *S) override {
544 for (auto &Source : Sources) {
545 Source->LookupUnqualified(R, S);
546 if (!R.empty())
547 break;
548 }
549
550 return !R.empty();
551 }
552
555 for (auto &Source : Sources)
556 Source->ReadTentativeDefinitions(Defs);
557 }
558
561 for (auto &Source : Sources)
562 Source->ReadUnusedFileScopedDecls(Decls);
563 }
564
567 for (auto &Source : Sources)
568 Source->ReadDelegatingConstructors(Decls);
569 }
570
573 for (auto &Source : Sources)
574 Source->ReadExtVectorDecls(Decls);
575 }
576
578 llvm::SmallPtrSetImpl<const clang::TypedefNameDecl *> &Decls) override {
579 for (auto &Source : Sources)
580 Source->ReadUnusedLocalTypedefNameCandidates(Decls);
581 }
582
584 llvm::SmallVectorImpl<std::pair<clang::Selector, clang::SourceLocation>>
585 &Sels) override {
586 for (auto &Source : Sources)
587 Source->ReadReferencedSelectors(Sels);
588 }
589
591 llvm::SmallVectorImpl<std::pair<clang::IdentifierInfo *, clang::WeakInfo>>
592 &WI) override {
593 for (auto &Source : Sources)
594 Source->ReadWeakUndeclaredIdentifiers(WI);
595 }
596
598 llvm::SmallVectorImpl<std::pair<clang::IdentifierInfo *,
599 clang::AsmLabelAttr *>> &EI) override {
600 for (auto &Source : Sources)
601 Source->ReadExtnameUndeclaredIdentifiers(EI);
602 }
603
606 for (auto &Source : Sources)
607 Source->ReadUsedVTables(VTables);
608 }
609
612 std::pair<clang::ValueDecl *, clang::SourceLocation>> &Pending)
613 override {
614 for (auto &Source : Sources)
615 Source->ReadPendingInstantiations(Pending);
616 }
617
619 llvm::MapVector<const clang::FunctionDecl *,
620 std::unique_ptr<clang::LateParsedTemplate>> &LPTMap)
621 override {
622 for (auto &Source : Sources)
623 Source->ReadLateParsedTemplates(LPTMap);
624 }
625
626 clang::TypoCorrection
627 CorrectTypo(const clang::DeclarationNameInfo &Typo, int LookupKind,
628 clang::Scope *S, clang::CXXScopeSpec *SS,
629 clang::CorrectionCandidateCallback &CCC,
630 clang::DeclContext *MemberContext, bool EnteringContext,
631 const clang::ObjCObjectPointerType *OPT) override {
632 for (auto &Source : Sources) {
633 if (clang::TypoCorrection C =
634 Source->CorrectTypo(Typo, LookupKind, S, SS, CCC,
635 MemberContext, EnteringContext, OPT))
636 return C;
637 }
638 return clang::TypoCorrection();
639 }
640
641 bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation Loc,
642 clang::QualType T) override {
643 for (auto &Source : Sources) {
644 if (Source->MaybeDiagnoseMissingCompleteType(Loc, T))
645 return true;
646 }
647 return false;
648 }
649
650 void StartedQualifiedLookup(const clang::DeclContext *DC) override {
651 for (auto &Source : Sources)
652 Source->StartedQualifiedLookup(DC);
653 }
654
655 void FinishedQualifiedLookup(const clang::DeclContext *DC) override {
656 for (auto &Source : Sources)
657 Source->FinishedQualifiedLookup(DC);
658 }
659};
660
661} // namespace lldb_private
662#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
static char ID
void HandleTranslationUnit(clang::ASTContext &Ctx) override
Definition ASTUtils.h:217
void HandleInlineFunctionDefinition(clang::FunctionDecl *D) override
Definition ASTUtils.h:209
void InitializeSema(clang::Sema &S) override
Definition ASTUtils.h:267
void HandleInterestingDecl(clang::DeclGroupRef D) override
Definition ASTUtils.h:213
ASTConsumerForwarder(clang::ASTConsumer *c)
Definition ASTUtils.h:195
bool shouldSkipFunctionBody(clang::Decl *D) override
Definition ASTUtils.h:278
void HandleTagDeclDefinition(clang::TagDecl *D) override
Definition ASTUtils.h:221
void AssignInheritanceModel(clang::CXXRecordDecl *RD) override
Definition ASTUtils.h:245
clang::SemaConsumer * m_sc
Definition ASTUtils.h:192
void HandleTopLevelDeclInObjCContainer(clang::DeclGroupRef D) override
Definition ASTUtils.h:233
clang::ASTDeserializationListener * GetASTDeserializationListener() override
Definition ASTUtils.h:261
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Definition ASTUtils.h:273
bool HandleTopLevelDecl(clang::DeclGroupRef D) override
Definition ASTUtils.h:205
void HandleCXXImplicitFunctionInstantiation(clang::FunctionDecl *D) override
Definition ASTUtils.h:229
void CompleteTentativeDefinition(clang::VarDecl *D) override
Definition ASTUtils.h:241
void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override
Definition ASTUtils.h:225
void HandleVTable(clang::CXXRecordDecl *RD) override
Definition ASTUtils.h:253
void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override
Definition ASTUtils.h:249
void Initialize(clang::ASTContext &Context) override
Definition ASTUtils.h:201
void HandleImplicitImportDecl(clang::ImportDecl *D) override
Definition ASTUtils.h:237
clang::ASTMutationListener * GetASTMutationListener() override
Definition ASTUtils.h:257
std::optional< clang::ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Definition ASTUtils.h:100
void ReadUndefinedButUsed(llvm::MapVector< clang::NamedDecl *, clang::SourceLocation > &Undefined) override
This gets called when Sema is reconciling undefined but used decls.
Definition ASTUtils.h:177
clang::Module * getModule(unsigned ID) override
Definition ASTUtils.h:95
void StartedQualifiedLookup(const clang::DeclContext *DC) override
Definition ASTUtils.h:156
clang::Selector GetExternalSelector(uint32_t ID) override
Definition ASTUtils.h:48
ExtKind hasExternalDefinitions(const clang::Decl *D) override
Definition ASTUtils.h:104
ExternalASTSourceWrapper(llvm::IntrusiveRefCntPtr< ExternalASTSource > Source)
Definition ASTUtils.h:36
clang::Stmt * GetExternalDeclStmt(uint64_t Offset) override
Definition ASTUtils.h:56
void completeVisibleDeclsMap(const clang::DeclContext *DC) override
Definition ASTUtils.h:91
llvm::IntrusiveRefCntPtr< ExternalASTSource > m_Source
Definition ASTUtils.h:33
void FinishedQualifiedLookup(const clang::DeclContext *DC) override
Definition ASTUtils.h:162
void FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length, llvm::SmallVectorImpl< clang::Decl * > &Decls) override
Definition ASTUtils.h:116
bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name, const clang::DeclContext *OriginalDC) override
Definition ASTUtils.h:74
void CompleteType(clang::ObjCInterfaceDecl *Class) override
Definition ASTUtils.h:129
clang::Decl * GetExternalDecl(clang::GlobalDeclID ID) override
Definition ASTUtils.h:44
uint32_t GetNumExternalSelectors() override
Definition ASTUtils.h:52
void FindExternalLexicalDecls(const clang::DeclContext *DC, llvm::function_ref< bool(clang::Decl::Kind)> IsKindWeWant, llvm::SmallVectorImpl< clang::Decl * > &Result) override
Definition ASTUtils.h:108
clang::CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Definition ASTUtils.h:66
void StartTranslationUnit(clang::ASTConsumer *Consumer) override
Definition ASTUtils.h:139
bool LoadExternalSpecializations(const clang::Decl *D, bool OnlyPartial) override
Definition ASTUtils.h:80
void CompleteRedeclChain(const clang::Decl *D) override
Definition ASTUtils.h:121
clang::CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Definition ASTUtils.h:61
bool LoadExternalSpecializations(const clang::Decl *D, llvm::ArrayRef< clang::TemplateArgument > TemplateArgs) override
Definition ASTUtils.h:85
void updateOutOfDateIdentifier(const clang::IdentifierInfo &II) override
Definition ASTUtils.h:70
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &BaseOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &VirtualBaseOffsets) override
Definition ASTUtils.h:145
void CompleteType(clang::TagDecl *Tag) override
Definition ASTUtils.h:125
An abstract base class for files.
Definition FileBase.h:34
void ReadUndefinedButUsed(llvm::MapVector< clang::NamedDecl *, clang::SourceLocation > &Undefined) override
Definition ASTUtils.h:528
void ReadKnownNamespaces(llvm::SmallVectorImpl< clang::NamespaceDecl * > &Namespaces) override
Definition ASTUtils.h:522
void ReadExtVectorDecls(llvm::SmallVectorImpl< clang::TypedefNameDecl * > &Decls) override
Definition ASTUtils.h:571
uint32_t GetNumExternalSelectors() override
Definition ASTUtils.h:364
bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation Loc, clang::QualType T) override
Definition ASTUtils.h:641
void StartedQualifiedLookup(const clang::DeclContext *DC) override
Definition ASTUtils.h:650
clang::Selector GetExternalSelector(uint32_t ID) override
Definition ASTUtils.h:354
llvm::SmallVector< llvm::IntrusiveRefCntPtr< clang::ExternalSemaSource >, 2 > Sources
The sources ordered in decreasing priority.
Definition ASTUtils.h:301
clang::Module * getModule(unsigned ID) override
Definition ASTUtils.h:472
void FindExternalLexicalDecls(const clang::DeclContext *DC, llvm::function_ref< bool(clang::Decl::Kind)> IsKindWeWant, llvm::SmallVectorImpl< clang::Decl * > &Result) override
Definition ASTUtils.h:418
bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name, const clang::DeclContext *OriginalDC) override
Definition ASTUtils.h:403
void ReadUsedVTables(llvm::SmallVectorImpl< clang::ExternalVTableUse > &VTables) override
Definition ASTUtils.h:604
clang::TypoCorrection CorrectTypo(const clang::DeclarationNameInfo &Typo, int LookupKind, clang::Scope *S, clang::CXXScopeSpec *SS, clang::CorrectionCandidateCallback &CCC, clang::DeclContext *MemberContext, bool EnteringContext, const clang::ObjCObjectPointerType *OPT) override
Definition ASTUtils.h:627
bool LoadExternalSpecializations(const clang::Decl *D, llvm::ArrayRef< clang::TemplateArgument > TemplateArgs) override
Definition ASTUtils.h:340
void CompleteRedeclChain(const clang::Decl *D) override
Definition ASTUtils.h:349
clang::Stmt * GetExternalDeclStmt(uint64_t Offset) override
Definition ASTUtils.h:371
void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override
Definition ASTUtils.h:493
clang::Decl * GetExternalDecl(clang::GlobalDeclID ID) override
Definition ASTUtils.h:325
void ReadExtnameUndeclaredIdentifiers(llvm::SmallVectorImpl< std::pair< clang::IdentifierInfo *, clang::AsmLabelAttr * > > &EI) override
Definition ASTUtils.h:597
void StartTranslationUnit(clang::ASTConsumer *Consumer) override
Definition ASTUtils.h:465
clang::CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Definition ASTUtils.h:388
void ReadTentativeDefinitions(llvm::SmallVectorImpl< clang::VarDecl * > &Defs) override
Definition ASTUtils.h:553
void ReadReferencedSelectors(llvm::SmallVectorImpl< std::pair< clang::Selector, clang::SourceLocation > > &Sels) override
Definition ASTUtils.h:583
void ReadLateParsedTemplates(llvm::MapVector< const clang::FunctionDecl *, std::unique_ptr< clang::LateParsedTemplate > > &LPTMap) override
Definition ASTUtils.h:618
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &BaseOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &VirtualBaseOffsets) override
Definition ASTUtils.h:479
void FinishedQualifiedLookup(const clang::DeclContext *DC) override
Definition ASTUtils.h:655
void ReadMethodPool(clang::Selector Sel) override
Definition ASTUtils.h:512
clang::CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Definition ASTUtils.h:379
void CompleteType(clang::TagDecl *Tag) override
Definition ASTUtils.h:436
SemaSourceWithPriorities(llvm::IntrusiveRefCntPtr< clang::ExternalSemaSource > high_quality_source, llvm::IntrusiveRefCntPtr< clang::ExternalSemaSource > low_quality_source)
Construct a SemaSourceWithPriorities with a 'high quality' source that has the higher priority and a ...
Definition ASTUtils.h:309
void FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length, llvm::SmallVectorImpl< clang::Decl * > &Decls) override
Definition ASTUtils.h:430
bool LoadExternalSpecializations(const clang::Decl *D, bool OnlyPartial) override
Definition ASTUtils.h:332
void ReadUnusedFileScopedDecls(llvm::SmallVectorImpl< const clang::DeclaratorDecl * > &Decls) override
Definition ASTUtils.h:559
void CompleteType(clang::ObjCInterfaceDecl *Class) override
Definition ASTUtils.h:445
void completeVisibleDeclsMap(const clang::DeclContext *DC) override
Definition ASTUtils.h:412
void ReadPendingInstantiations(llvm::SmallVectorImpl< std::pair< clang::ValueDecl *, clang::SourceLocation > > &Pending) override
Definition ASTUtils.h:610
void ReadDelegatingConstructors(llvm::SmallVectorImpl< clang::CXXConstructorDecl * > &Decls) override
Definition ASTUtils.h:565
bool LookupUnqualified(clang::LookupResult &R, clang::Scope *S) override
Definition ASTUtils.h:543
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallPtrSetImpl< const clang::TypedefNameDecl * > &Decls) override
Definition ASTUtils.h:577
void updateOutOfDateSelector(clang::Selector Sel) override
Definition ASTUtils.h:517
void ReadWeakUndeclaredIdentifiers(llvm::SmallVectorImpl< std::pair< clang::IdentifierInfo *, clang::WeakInfo > > &WI) override
Definition ASTUtils.h:590
void ReadMismatchingDeleteExpressions(llvm::MapVector< clang::FieldDecl *, llvm::SmallVector< std::pair< clang::SourceLocation, bool >, 4 > > &Exprs) override
Definition ASTUtils.h:535
ExtKind hasExternalDefinitions(const clang::Decl *D) override
Definition ASTUtils.h:395
void InitializeSema(clang::Sema &S) override
Definition ASTUtils.h:502
A class that represents a running process on the host machine.