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