LLDB mainline
ClangASTImporter.cpp
Go to the documentation of this file.
1//===-- ClangASTImporter.cpp ----------------------------------------------===//
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#include "lldb/Core/Module.h"
12#include "lldb/Utility/Log.h"
13#include "clang/AST/Decl.h"
14#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclObjC.h"
16#include "clang/Sema/Lookup.h"
17#include "clang/Sema/Sema.h"
18#include "llvm/Support/raw_ostream.h"
19
26
27#include <memory>
28#include <optional>
29
30using namespace lldb_private;
31using namespace clang;
32
34 const CompilerType &src_type) {
35 clang::ASTContext &dst_clang_ast = dst_ast.getASTContext();
36
37 auto src_ast = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
38 if (!src_ast)
39 return CompilerType();
40
41 clang::ASTContext &src_clang_ast = src_ast->getASTContext();
42
43 clang::QualType src_qual_type = ClangUtil::GetQualType(src_type);
44
45 ImporterDelegateSP delegate_sp(GetDelegate(&dst_clang_ast, &src_clang_ast));
46 if (!delegate_sp)
47 return CompilerType();
48
49 ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
50
51 llvm::Expected<QualType> ret_or_error = delegate_sp->Import(src_qual_type);
52 if (!ret_or_error) {
54 LLDB_LOG_ERROR(log, ret_or_error.takeError(),
55 "Couldn't import type: {0}");
56 return CompilerType();
57 }
58
59 lldb::opaque_compiler_type_t dst_clang_type = ret_or_error->getAsOpaquePtr();
60
61 if (dst_clang_type)
62 return CompilerType(dst_ast.weak_from_this(), dst_clang_type);
63 return CompilerType();
64}
65
66clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
67 clang::Decl *decl) {
68 ImporterDelegateSP delegate_sp;
69
70 clang::ASTContext *src_ast = &decl->getASTContext();
71 delegate_sp = GetDelegate(dst_ast, src_ast);
72
73 ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
74
75 if (!delegate_sp)
76 return nullptr;
77
78 llvm::Expected<clang::Decl *> result = delegate_sp->Import(decl);
79 if (!result) {
81 LLDB_LOG_ERROR(log, result.takeError(), "Couldn't import decl: {0}");
82 if (log) {
84 ClangASTMetadata *metadata = GetDeclMetadata(decl);
85 if (metadata)
86 user_id = metadata->GetUserID();
87
88 if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
89 LLDB_LOG(log,
90 " [ClangASTImporter] WARNING: Failed to import a {0} "
91 "'{1}', metadata {2}",
92 decl->getDeclKindName(), named_decl->getNameAsString(),
93 user_id);
94 else
95 LLDB_LOG(log,
96 " [ClangASTImporter] WARNING: Failed to import a {0}, "
97 "metadata {1}",
98 decl->getDeclKindName(), user_id);
99 }
100 return nullptr;
101 }
102
103 return *result;
104}
105
107private:
108 struct Backup {
109 clang::DeclContext *decl_context;
110 clang::DeclContext *lexical_decl_context;
111 };
112
113 llvm::DenseMap<clang::Decl *, Backup> m_backups;
114
115 void OverrideOne(clang::Decl *decl) {
116 if (m_backups.contains(decl)) {
117 return;
118 }
119
120 m_backups[decl] = {decl->getDeclContext(), decl->getLexicalDeclContext()};
121
122 decl->setDeclContext(decl->getASTContext().getTranslationUnitDecl());
123 decl->setLexicalDeclContext(decl->getASTContext().getTranslationUnitDecl());
124 }
125
127 clang::Decl *decl, clang::DeclContext *base,
128 clang::DeclContext *(clang::Decl::*contextFromDecl)(),
129 clang::DeclContext *(clang::DeclContext::*contextFromContext)()) {
130 for (DeclContext *decl_ctx = (decl->*contextFromDecl)(); decl_ctx;
131 decl_ctx = (decl_ctx->*contextFromContext)()) {
132 if (decl_ctx == base) {
133 return true;
134 }
135 }
136
137 return false;
138 }
139
140 clang::Decl *GetEscapedChild(clang::Decl *decl,
141 clang::DeclContext *base = nullptr) {
142 if (base) {
143 // decl's DeclContext chains must pass through base.
144
145 if (!ChainPassesThrough(decl, base, &clang::Decl::getDeclContext,
146 &clang::DeclContext::getParent) ||
147 !ChainPassesThrough(decl, base, &clang::Decl::getLexicalDeclContext,
148 &clang::DeclContext::getLexicalParent)) {
149 return decl;
150 }
151 } else {
152 base = clang::dyn_cast<clang::DeclContext>(decl);
153
154 if (!base) {
155 return nullptr;
156 }
157 }
158
159 if (clang::DeclContext *context =
160 clang::dyn_cast<clang::DeclContext>(decl)) {
161 for (clang::Decl *decl : context->decls()) {
162 if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
163 return escaped_child;
164 }
165 }
166 }
167
168 return nullptr;
169 }
170
171 void Override(clang::Decl *decl) {
172 if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
173 Log *log = GetLog(LLDBLog::Expressions);
174
175 LLDB_LOG(log,
176 " [ClangASTImporter] DeclContextOverride couldn't "
177 "override ({0}Decl*){1} - its child ({2}Decl*){3} escapes",
178 decl->getDeclKindName(), decl, escaped_child->getDeclKindName(),
179 escaped_child);
180 lldbassert(0 && "Couldn't override!");
181 }
182
183 OverrideOne(decl);
184 }
185
186public:
188
190 for (DeclContext *decl_context = decl->getLexicalDeclContext();
191 decl_context; decl_context = decl_context->getLexicalParent()) {
192 DeclContext *redecl_context = decl_context->getRedeclContext();
193
194 if (llvm::isa<FunctionDecl>(redecl_context) &&
195 llvm::isa<TranslationUnitDecl>(redecl_context->getLexicalParent())) {
196 for (clang::Decl *child_decl : decl_context->decls()) {
197 Override(child_decl);
198 }
199 }
200 }
201 }
202
204 for (const std::pair<clang::Decl *, Backup> &backup : m_backups) {
205 backup.first->setDeclContext(backup.second.decl_context);
206 backup.first->setLexicalDeclContext(backup.second.lexical_decl_context);
207 }
208 }
209};
210
211namespace {
212/// Completes all imported TagDecls at the end of the scope.
213///
214/// While in a CompleteTagDeclsScope, every decl that could be completed will
215/// be completed at the end of the scope (including all Decls that are
216/// imported while completing the original Decls).
217class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
219 /// List of declarations in the target context that need to be completed.
220 /// Every declaration should only be completed once and therefore should only
221 /// be once in this list.
222 llvm::SetVector<NamedDecl *> m_decls_to_complete;
223 /// Set of declarations that already were successfully completed (not just
224 /// added to m_decls_to_complete).
225 llvm::SmallPtrSet<NamedDecl *, 32> m_decls_already_completed;
226 clang::ASTContext *m_dst_ctx;
227 clang::ASTContext *m_src_ctx;
228 ClangASTImporter &importer;
229
230public:
231 /// Constructs a CompleteTagDeclsScope.
232 /// \param importer The ClangASTImporter that we should observe.
233 /// \param dst_ctx The ASTContext to which Decls are imported.
234 /// \param src_ctx The ASTContext from which Decls are imported.
235 explicit CompleteTagDeclsScope(ClangASTImporter &importer,
236 clang::ASTContext *dst_ctx,
237 clang::ASTContext *src_ctx)
238 : m_delegate(importer.GetDelegate(dst_ctx, src_ctx)), m_dst_ctx(dst_ctx),
239 m_src_ctx(src_ctx), importer(importer) {
240 m_delegate->SetImportListener(this);
241 }
242
243 ~CompleteTagDeclsScope() override {
245 importer.GetContextMetadata(m_dst_ctx);
246
247 // Complete all decls we collected until now.
248 while (!m_decls_to_complete.empty()) {
249 NamedDecl *decl = m_decls_to_complete.pop_back_val();
250 m_decls_already_completed.insert(decl);
251
252 // The decl that should be completed has to be imported into the target
253 // context from some other context.
254 assert(to_context_md->hasOrigin(decl));
255 // We should only complete decls coming from the source context.
256 assert(to_context_md->getOrigin(decl).ctx == m_src_ctx);
257
258 Decl *original_decl = to_context_md->getOrigin(decl).decl;
259
260 // Complete the decl now.
261 TypeSystemClang::GetCompleteDecl(m_src_ctx, original_decl);
262 if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
263 if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
264 if (original_tag_decl->isCompleteDefinition()) {
265 m_delegate->ImportDefinitionTo(tag_decl, original_tag_decl);
266 tag_decl->setCompleteDefinition(true);
267 }
268 }
269
270 tag_decl->setHasExternalLexicalStorage(false);
271 tag_decl->setHasExternalVisibleStorage(false);
272 } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
273 container_decl->setHasExternalLexicalStorage(false);
274 container_decl->setHasExternalVisibleStorage(false);
275 }
276
277 to_context_md->removeOrigin(decl);
278 }
279
280 // Stop listening to imported decls. We do this after clearing the
281 // Decls we needed to import to catch all Decls they might have pulled in.
282 m_delegate->RemoveImportListener();
283 }
284
285 void NewDeclImported(clang::Decl *from, clang::Decl *to) override {
286 // Filter out decls that we can't complete later.
287 if (!isa<TagDecl>(to) && !isa<ObjCInterfaceDecl>(to))
288 return;
289 RecordDecl *from_record_decl = dyn_cast<RecordDecl>(from);
290 // We don't need to complete injected class name decls.
291 if (from_record_decl && from_record_decl->isInjectedClassName())
292 return;
293
294 NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
295 // Check if we already completed this type.
296 if (m_decls_already_completed.contains(to_named_decl))
297 return;
298 // Queue this type to be completed.
299 m_decls_to_complete.insert(to_named_decl);
300 }
301};
302} // namespace
303
305 const CompilerType &src_type) {
307
308 auto src_ctxt = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
309 if (!src_ctxt)
310 return {};
311
312 LLDB_LOG(log,
313 " [ClangASTImporter] DeportType called on ({0}Type*){1} "
314 "from (ASTContext*){2} to (ASTContext*){3}",
315 src_type.GetTypeName(), src_type.GetOpaqueQualType(),
316 &src_ctxt->getASTContext(), &dst.getASTContext());
317
318 DeclContextOverride decl_context_override;
319
320 if (auto *t = ClangUtil::GetQualType(src_type)->getAs<TagType>())
321 decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
322
323 CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
324 &src_ctxt->getASTContext());
325 return CopyType(dst, src_type);
326}
327
328clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
329 clang::Decl *decl) {
331
332 clang::ASTContext *src_ctx = &decl->getASTContext();
333 LLDB_LOG(log,
334 " [ClangASTImporter] DeportDecl called on ({0}Decl*){1} from "
335 "(ASTContext*){2} to (ASTContext*){3}",
336 decl->getDeclKindName(), decl, src_ctx, dst_ctx);
337
338 DeclContextOverride decl_context_override;
339
340 decl_context_override.OverrideAllDeclsFromContainingFunction(decl);
341
342 clang::Decl *result;
343 {
344 CompleteTagDeclsScope complete_scope(*this, dst_ctx, src_ctx);
345 result = CopyDecl(dst_ctx, decl);
346 }
347
348 if (!result)
349 return nullptr;
350
351 LLDB_LOG(log,
352 " [ClangASTImporter] DeportDecl deported ({0}Decl*){1} to "
353 "({2}Decl*){3}",
354 decl->getDeclKindName(), decl, result->getDeclKindName(), result);
355
356 return result;
357}
358
360 if (!ClangUtil::IsClangType(type))
361 return false;
362
363 clang::QualType qual_type(
365
366 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
367 switch (type_class) {
368 case clang::Type::Record: {
369 const clang::CXXRecordDecl *cxx_record_decl =
370 qual_type->getAsCXXRecordDecl();
371 if (cxx_record_decl) {
372 if (GetDeclOrigin(cxx_record_decl).Valid())
373 return true;
374 }
375 } break;
376
377 case clang::Type::Enum: {
378 clang::EnumDecl *enum_decl =
379 llvm::cast<clang::EnumType>(qual_type)->getDecl();
380 if (enum_decl) {
381 if (GetDeclOrigin(enum_decl).Valid())
382 return true;
383 }
384 } break;
385
386 case clang::Type::ObjCObject:
387 case clang::Type::ObjCInterface: {
388 const clang::ObjCObjectType *objc_class_type =
389 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
390 if (objc_class_type) {
391 clang::ObjCInterfaceDecl *class_interface_decl =
392 objc_class_type->getInterface();
393 // We currently can't complete objective C types through the newly added
394 // ASTContext because it only supports TagDecl objects right now...
395 if (class_interface_decl) {
396 if (GetDeclOrigin(class_interface_decl).Valid())
397 return true;
398 }
399 }
400 } break;
401
402 case clang::Type::Typedef:
404 llvm::cast<clang::TypedefType>(qual_type)
405 ->getDecl()
406 ->getUnderlyingType()
407 .getAsOpaquePtr()));
408
409 case clang::Type::Auto:
411 llvm::cast<clang::AutoType>(qual_type)
412 ->getDeducedType()
413 .getAsOpaquePtr()));
414
415 case clang::Type::Elaborated:
417 llvm::cast<clang::ElaboratedType>(qual_type)
418 ->getNamedType()
419 .getAsOpaquePtr()));
420
421 case clang::Type::Paren:
422 return CanImport(CompilerType(
423 type.GetTypeSystem(),
424 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
425
426 default:
427 break;
428 }
429
430 return false;
431}
432
434 if (!ClangUtil::IsClangType(type))
435 return false;
436
437 clang::QualType qual_type(
439
440 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
441 switch (type_class) {
442 case clang::Type::Record: {
443 const clang::CXXRecordDecl *cxx_record_decl =
444 qual_type->getAsCXXRecordDecl();
445 if (cxx_record_decl) {
446 if (GetDeclOrigin(cxx_record_decl).Valid())
447 return CompleteAndFetchChildren(qual_type);
448 }
449 } break;
450
451 case clang::Type::Enum: {
452 clang::EnumDecl *enum_decl =
453 llvm::cast<clang::EnumType>(qual_type)->getDecl();
454 if (enum_decl) {
455 if (GetDeclOrigin(enum_decl).Valid())
456 return CompleteAndFetchChildren(qual_type);
457 }
458 } break;
459
460 case clang::Type::ObjCObject:
461 case clang::Type::ObjCInterface: {
462 const clang::ObjCObjectType *objc_class_type =
463 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
464 if (objc_class_type) {
465 clang::ObjCInterfaceDecl *class_interface_decl =
466 objc_class_type->getInterface();
467 // We currently can't complete objective C types through the newly added
468 // ASTContext because it only supports TagDecl objects right now...
469 if (class_interface_decl) {
470 if (GetDeclOrigin(class_interface_decl).Valid())
471 return CompleteAndFetchChildren(qual_type);
472 }
473 }
474 } break;
475
476 case clang::Type::Typedef:
477 return Import(CompilerType(type.GetTypeSystem(),
478 llvm::cast<clang::TypedefType>(qual_type)
479 ->getDecl()
480 ->getUnderlyingType()
481 .getAsOpaquePtr()));
482
483 case clang::Type::Auto:
484 return Import(CompilerType(type.GetTypeSystem(),
485 llvm::cast<clang::AutoType>(qual_type)
486 ->getDeducedType()
487 .getAsOpaquePtr()));
488
489 case clang::Type::Elaborated:
490 return Import(CompilerType(type.GetTypeSystem(),
491 llvm::cast<clang::ElaboratedType>(qual_type)
492 ->getNamedType()
493 .getAsOpaquePtr()));
494
495 case clang::Type::Paren:
496 return Import(CompilerType(
497 type.GetTypeSystem(),
498 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
499
500 default:
501 break;
502 }
503 return false;
504}
505
507 if (!CanImport(compiler_type))
508 return false;
509
510 if (Import(compiler_type)) {
512 return true;
513 }
514
516 false);
517 return false;
518}
519
521 const clang::RecordDecl *record_decl, uint64_t &bit_size,
522 uint64_t &alignment,
523 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
524 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
525 &base_offsets,
526 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
527 &vbase_offsets) {
528 RecordDeclToLayoutMap::iterator pos =
529 m_record_decl_to_layout_map.find(record_decl);
530 bool success = false;
531 base_offsets.clear();
532 vbase_offsets.clear();
533 if (pos != m_record_decl_to_layout_map.end()) {
534 bit_size = pos->second.bit_size;
535 alignment = pos->second.alignment;
536 field_offsets.swap(pos->second.field_offsets);
537 base_offsets.swap(pos->second.base_offsets);
538 vbase_offsets.swap(pos->second.vbase_offsets);
540 success = true;
541 } else {
542 bit_size = 0;
543 alignment = 0;
544 field_offsets.clear();
545 }
546 return success;
547}
548
549void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
550 const LayoutInfo &layout) {
551 m_record_decl_to_layout_map.insert(std::make_pair(decl, layout));
552}
553
554bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
555 DeclOrigin decl_origin = GetDeclOrigin(decl);
556
557 if (!decl_origin.Valid())
558 return false;
559
560 if (!TypeSystemClang::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
561 return false;
562
563 ImporterDelegateSP delegate_sp(
564 GetDelegate(&decl->getASTContext(), decl_origin.ctx));
565
566 ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
567 &decl->getASTContext());
568 if (delegate_sp)
569 delegate_sp->ImportDefinitionTo(decl, decl_origin.decl);
570
571 return true;
572}
573
575 clang::TagDecl *origin_decl) {
576 clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();
577
578 if (!TypeSystemClang::GetCompleteDecl(origin_ast_ctx, origin_decl))
579 return false;
580
581 ImporterDelegateSP delegate_sp(
582 GetDelegate(&decl->getASTContext(), origin_ast_ctx));
583
584 if (delegate_sp)
585 delegate_sp->ImportDefinitionTo(decl, origin_decl);
586
587 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
588
589 context_md->setOrigin(decl, DeclOrigin(origin_ast_ctx, origin_decl));
590 return true;
591}
592
594 clang::ObjCInterfaceDecl *interface_decl) {
595 DeclOrigin decl_origin = GetDeclOrigin(interface_decl);
596
597 if (!decl_origin.Valid())
598 return false;
599
600 if (!TypeSystemClang::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
601 return false;
602
603 ImporterDelegateSP delegate_sp(
604 GetDelegate(&interface_decl->getASTContext(), decl_origin.ctx));
605
606 if (delegate_sp)
607 delegate_sp->ImportDefinitionTo(interface_decl, decl_origin.decl);
608
609 if (ObjCInterfaceDecl *super_class = interface_decl->getSuperClass())
610 RequireCompleteType(clang::QualType(super_class->getTypeForDecl(), 0));
611
612 return true;
613}
614
616 if (!RequireCompleteType(type))
617 return false;
618
620
621 if (const TagType *tag_type = type->getAs<TagType>()) {
622 TagDecl *tag_decl = tag_type->getDecl();
623
624 DeclOrigin decl_origin = GetDeclOrigin(tag_decl);
625
626 if (!decl_origin.Valid())
627 return false;
628
629 ImporterDelegateSP delegate_sp(
630 GetDelegate(&tag_decl->getASTContext(), decl_origin.ctx));
631
632 ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
633 &tag_decl->getASTContext());
634
635 TagDecl *origin_tag_decl = llvm::dyn_cast<TagDecl>(decl_origin.decl);
636
637 for (Decl *origin_child_decl : origin_tag_decl->decls()) {
638 llvm::Expected<Decl *> imported_or_err =
639 delegate_sp->Import(origin_child_decl);
640 if (!imported_or_err) {
641 LLDB_LOG_ERROR(log, imported_or_err.takeError(),
642 "Couldn't import decl: {0}");
643 return false;
644 }
645 }
646
647 if (RecordDecl *record_decl = dyn_cast<RecordDecl>(origin_tag_decl))
648 record_decl->setHasLoadedFieldsFromExternalStorage(true);
649
650 return true;
651 }
652
653 if (const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>()) {
654 if (ObjCInterfaceDecl *objc_interface_decl =
655 objc_object_type->getInterface()) {
656 DeclOrigin decl_origin = GetDeclOrigin(objc_interface_decl);
657
658 if (!decl_origin.Valid())
659 return false;
660
661 ImporterDelegateSP delegate_sp(
662 GetDelegate(&objc_interface_decl->getASTContext(), decl_origin.ctx));
663
664 ObjCInterfaceDecl *origin_interface_decl =
665 llvm::dyn_cast<ObjCInterfaceDecl>(decl_origin.decl);
666
667 for (Decl *origin_child_decl : origin_interface_decl->decls()) {
668 llvm::Expected<Decl *> imported_or_err =
669 delegate_sp->Import(origin_child_decl);
670 if (!imported_or_err) {
671 LLDB_LOG_ERROR(log, imported_or_err.takeError(),
672 "Couldn't import decl: {0}");
673 return false;
674 }
675 }
676
677 return true;
678 }
679 return false;
680 }
681
682 return true;
683}
684
685bool ClangASTImporter::RequireCompleteType(clang::QualType type) {
686 if (type.isNull())
687 return false;
688
689 if (const TagType *tag_type = type->getAs<TagType>()) {
690 TagDecl *tag_decl = tag_type->getDecl();
691
692 if (tag_decl->getDefinition() || tag_decl->isBeingDefined())
693 return true;
694
695 return CompleteTagDecl(tag_decl);
696 }
697 if (const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>()) {
698 if (ObjCInterfaceDecl *objc_interface_decl =
699 objc_object_type->getInterface())
700 return CompleteObjCInterfaceDecl(objc_interface_decl);
701 return false;
702 }
703 if (const ArrayType *array_type = type->getAsArrayTypeUnsafe())
704 return RequireCompleteType(array_type->getElementType());
705 if (const AtomicType *atomic_type = type->getAs<AtomicType>())
706 return RequireCompleteType(atomic_type->getPointeeType());
707
708 return true;
709}
710
712 DeclOrigin decl_origin = GetDeclOrigin(decl);
713
714 if (decl_origin.Valid()) {
716 return ast->GetMetadata(decl_origin.decl);
717 }
718 TypeSystemClang *ast = TypeSystemClang::GetASTContext(&decl->getASTContext());
719 return ast->GetMetadata(decl);
720}
721
723ClangASTImporter::GetDeclOrigin(const clang::Decl *decl) {
724 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
725
726 return context_md->getOrigin(decl);
727}
728
729void ClangASTImporter::SetDeclOrigin(const clang::Decl *decl,
730 clang::Decl *original_decl) {
731 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
732 context_md->setOrigin(
733 decl, DeclOrigin(&original_decl->getASTContext(), original_decl));
734}
735
736void ClangASTImporter::RegisterNamespaceMap(const clang::NamespaceDecl *decl,
737 NamespaceMapSP &namespace_map) {
738 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
739
740 context_md->m_namespace_maps[decl] = namespace_map;
741}
742
744ClangASTImporter::GetNamespaceMap(const clang::NamespaceDecl *decl) {
745 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
746
747 NamespaceMetaMap &namespace_maps = context_md->m_namespace_maps;
748
749 NamespaceMetaMap::iterator iter = namespace_maps.find(decl);
750
751 if (iter != namespace_maps.end())
752 return iter->second;
753 return NamespaceMapSP();
754}
755
756void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
757 assert(decl);
758 ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
759
760 const DeclContext *parent_context = decl->getDeclContext();
761 const NamespaceDecl *parent_namespace =
762 dyn_cast<NamespaceDecl>(parent_context);
763 NamespaceMapSP parent_map;
764
765 if (parent_namespace)
766 parent_map = GetNamespaceMap(parent_namespace);
767
768 NamespaceMapSP new_map;
769
770 new_map = std::make_shared<NamespaceMap>();
771
772 if (context_md->m_map_completer) {
773 std::string namespace_string = decl->getDeclName().getAsString();
774
775 context_md->m_map_completer->CompleteNamespaceMap(
776 new_map, ConstString(namespace_string.c_str()), parent_map);
777 }
778
779 context_md->m_namespace_maps[decl] = new_map;
780}
781
782void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
784
785 LLDB_LOG(log,
786 " [ClangASTImporter] Forgetting destination (ASTContext*){0}",
787 dst_ast);
788
789 m_metadata_map.erase(dst_ast);
790}
791
792void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
793 clang::ASTContext *src_ast) {
795
797
798 LLDB_LOG(log,
799 " [ClangASTImporter] Forgetting source->dest "
800 "(ASTContext*){0}->(ASTContext*){1}",
801 src_ast, dst_ast);
802
803 if (!md)
804 return;
805
806 md->m_delegates.erase(src_ast);
807 md->removeOriginsWithContext(src_ast);
808}
809
811
812llvm::Expected<Decl *>
814 if (m_std_handler) {
815 std::optional<Decl *> D = m_std_handler->Import(From);
816 if (D) {
817 // Make sure we don't use this decl later to map it back to it's original
818 // decl. The decl the CxxModuleHandler created has nothing to do with
819 // the one from debug info, and linking those two would just cause the
820 // ASTImporter to try 'updating' the module decl with the minimal one from
821 // the debug info.
822 m_decls_to_ignore.insert(*D);
823 return *D;
824 }
825 }
826
827 // Check which ASTContext this declaration originally came from.
828 DeclOrigin origin = m_main.GetDeclOrigin(From);
829
830 // Prevent infinite recursion when the origin tracking contains a cycle.
831 assert(origin.decl != From && "Origin points to itself?");
832
833 // If it originally came from the target ASTContext then we can just
834 // pretend that the original is the one we imported. This can happen for
835 // example when inspecting a persistent declaration from the scratch
836 // ASTContext (which will provide the declaration when parsing the
837 // expression and then we later try to copy the declaration back to the
838 // scratch ASTContext to store the result).
839 // Without this check we would ask the ASTImporter to import a declaration
840 // into the same ASTContext where it came from (which doesn't make a lot of
841 // sense).
842 if (origin.Valid() && origin.ctx == &getToContext()) {
843 RegisterImportedDecl(From, origin.decl);
844 return origin.decl;
845 }
846
847 // This declaration came originally from another ASTContext. Instead of
848 // copying our potentially incomplete 'From' Decl we instead go to the
849 // original ASTContext and copy the original to the target. This is not
850 // only faster than first completing our current decl and then copying it
851 // to the target, but it also prevents that indirectly copying the same
852 // declaration to the same target requires the ASTImporter to merge all
853 // the different decls that appear to come from different ASTContexts (even
854 // though all these different source ASTContexts just got a copy from
855 // one source AST).
856 if (origin.Valid()) {
857 auto R = m_main.CopyDecl(&getToContext(), origin.decl);
858 if (R) {
859 RegisterImportedDecl(From, R);
860 return R;
861 }
862 }
863
864 // If we have a forcefully completed type, try to find an actual definition
865 // for it in other modules.
866 const ClangASTMetadata *md = m_main.GetDeclMetadata(From);
867 auto *td = dyn_cast<TagDecl>(From);
868 if (td && md && md->IsForcefullyCompleted()) {
870 LLDB_LOG(log,
871 "[ClangASTImporter] Searching for a complete definition of {0} in "
872 "other modules",
873 td->getName());
874 Expected<DeclContext *> dc_or_err = ImportContext(td->getDeclContext());
875 if (!dc_or_err)
876 return dc_or_err.takeError();
877 Expected<DeclarationName> dn_or_err = Import(td->getDeclName());
878 if (!dn_or_err)
879 return dn_or_err.takeError();
880 DeclContext *dc = *dc_or_err;
881 DeclContext::lookup_result lr = dc->lookup(*dn_or_err);
882 for (clang::Decl *candidate : lr) {
883 if (candidate->getKind() == From->getKind()) {
884 RegisterImportedDecl(From, candidate);
885 m_decls_to_ignore.insert(candidate);
886 return candidate;
887 }
888 }
889 LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
890 }
891
892 return ASTImporter::ImportImpl(From);
893}
894
896 clang::Decl *to, clang::Decl *from) {
897 // We might have a forward declaration from a shared library that we
898 // gave external lexical storage so that Clang asks us about the full
899 // definition when it needs it. In this case the ASTImporter isn't aware
900 // that the forward decl from the shared library is the actual import
901 // target but would create a second declaration that would then be defined.
902 // We want that 'to' is actually complete after this function so let's
903 // tell the ASTImporter that 'to' was imported from 'from'.
904 MapImported(from, to);
905
907
908 if (llvm::Error err = ImportDefinition(from)) {
909 LLDB_LOG_ERROR(log, std::move(err),
910 "[ClangASTImporter] Error during importing definition: {0}");
911 return;
912 }
913
914 if (clang::TagDecl *to_tag = dyn_cast<clang::TagDecl>(to)) {
915 if (clang::TagDecl *from_tag = dyn_cast<clang::TagDecl>(from)) {
916 to_tag->setCompleteDefinition(from_tag->isCompleteDefinition());
917
918 if (Log *log_ast = GetLog(LLDBLog::AST)) {
919 std::string name_string;
920 if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
921 llvm::raw_string_ostream name_stream(name_string);
922 from_named_decl->printName(name_stream);
923 name_stream.flush();
924 }
925 LLDB_LOG(log_ast, "==== [ClangASTImporter][TUDecl: {0}] Imported "
926 "({1}Decl*){2}, named {3} (from "
927 "(Decl*){4})",
928 static_cast<void *>(to->getTranslationUnitDecl()),
929 from->getDeclKindName(), static_cast<void *>(to), name_string,
930 static_cast<void *>(from));
931
932 // Log the AST of the TU.
933 std::string ast_string;
934 llvm::raw_string_ostream ast_stream(ast_string);
935 to->getTranslationUnitDecl()->dump(ast_stream);
936 LLDB_LOG(log_ast, "{0}", ast_string);
937 }
938 }
939 }
940
941 // If we're dealing with an Objective-C class, ensure that the inheritance
942 // has been set up correctly. The ASTImporter may not do this correctly if
943 // the class was originally sourced from symbols.
944
945 if (ObjCInterfaceDecl *to_objc_interface = dyn_cast<ObjCInterfaceDecl>(to)) {
946 do {
947 ObjCInterfaceDecl *to_superclass = to_objc_interface->getSuperClass();
948
949 if (to_superclass)
950 break; // we're not going to override it if it's set
951
952 ObjCInterfaceDecl *from_objc_interface =
953 dyn_cast<ObjCInterfaceDecl>(from);
954
955 if (!from_objc_interface)
956 break;
957
958 ObjCInterfaceDecl *from_superclass = from_objc_interface->getSuperClass();
959
960 if (!from_superclass)
961 break;
962
963 llvm::Expected<Decl *> imported_from_superclass_decl =
964 Import(from_superclass);
965
966 if (!imported_from_superclass_decl) {
967 LLDB_LOG_ERROR(log, imported_from_superclass_decl.takeError(),
968 "Couldn't import decl: {0}");
969 break;
970 }
971
972 ObjCInterfaceDecl *imported_from_superclass =
973 dyn_cast<ObjCInterfaceDecl>(*imported_from_superclass_decl);
974
975 if (!imported_from_superclass)
976 break;
977
978 if (!to_objc_interface->hasDefinition())
979 to_objc_interface->startDefinition();
980
981 to_objc_interface->setSuperClass(m_source_ctx->getTrivialTypeSourceInfo(
982 m_source_ctx->getObjCInterfaceType(imported_from_superclass)));
983 } while (false);
984 }
985}
986
987/// Takes a CXXMethodDecl and completes the return type if necessary. This
988/// is currently only necessary for virtual functions with covariant return
989/// types where Clang's CodeGen expects that the underlying records are already
990/// completed.
992 CXXMethodDecl *to_method) {
993 if (!to_method->isVirtual())
994 return;
995 QualType return_type = to_method->getReturnType();
996 if (!return_type->isPointerType() && !return_type->isReferenceType())
997 return;
998
999 clang::RecordDecl *rd = return_type->getPointeeType()->getAsRecordDecl();
1000 if (!rd)
1001 return;
1002 if (rd->getDefinition())
1003 return;
1004
1005 importer.CompleteTagDecl(rd);
1006}
1007
1008/// Recreate a module with its parents in \p to_source and return its id.
1013 if (!from_id.HasValue())
1014 return {};
1015 clang::Module *module = from_source.getModule(from_id.GetValue());
1017 from_source.GetIDForModule(module->Parent), from_source, to_source);
1018 TypeSystemClang &to_ts = to_source.GetTypeSystem();
1019 return to_ts.GetOrCreateClangModule(module->Name, parent, module->IsFramework,
1020 module->IsExplicit);
1021}
1022
1024 clang::Decl *to) {
1026
1027 // Some decls shouldn't be tracked here because they were not created by
1028 // copying 'from' to 'to'. Just exit early for those.
1029 if (m_decls_to_ignore.count(to))
1030 return;
1031
1032 // Transfer module ownership information.
1033 auto *from_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1034 getFromContext().getExternalSource());
1035 // Can also be a ClangASTSourceProxy.
1036 auto *to_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1037 getToContext().getExternalSource());
1038 if (from_source && to_source) {
1039 OptionalClangModuleID from_id(from->getOwningModuleID());
1040 OptionalClangModuleID to_id =
1041 RemapModule(from_id, *from_source, *to_source);
1042 TypeSystemClang &to_ts = to_source->GetTypeSystem();
1043 to_ts.SetOwningModule(to, to_id);
1044 }
1045
1047 ClangASTMetadata *metadata = m_main.GetDeclMetadata(from);
1048 if (metadata)
1049 user_id = metadata->GetUserID();
1050
1051 if (log) {
1052 if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
1053 std::string name_string;
1054 llvm::raw_string_ostream name_stream(name_string);
1055 from_named_decl->printName(name_stream);
1056 name_stream.flush();
1057
1058 LLDB_LOG(log,
1059 " [ClangASTImporter] Imported ({0}Decl*){1}, named {2} (from "
1060 "(Decl*){3}), metadata {4}",
1061 from->getDeclKindName(), to, name_string, from, user_id);
1062 } else {
1063 LLDB_LOG(log,
1064 " [ClangASTImporter] Imported ({0}Decl*){1} (from "
1065 "(Decl*){2}), metadata {3}",
1066 from->getDeclKindName(), to, from, user_id);
1067 }
1068 }
1069
1070 ASTContextMetadataSP to_context_md =
1071 m_main.GetContextMetadata(&to->getASTContext());
1072 ASTContextMetadataSP from_context_md =
1073 m_main.MaybeGetContextMetadata(m_source_ctx);
1074
1075 if (from_context_md) {
1076 DeclOrigin origin = from_context_md->getOrigin(from);
1077
1078 if (origin.Valid()) {
1079 if (origin.ctx != &to->getASTContext()) {
1080 if (!to_context_md->hasOrigin(to) || user_id != LLDB_INVALID_UID)
1081 to_context_md->setOrigin(to, origin);
1082
1083 LLDB_LOG(log,
1084 " [ClangASTImporter] Propagated origin "
1085 "(Decl*){0}/(ASTContext*){1} from (ASTContext*){2} to "
1086 "(ASTContext*){3}",
1087 origin.decl, origin.ctx, &from->getASTContext(),
1088 &to->getASTContext());
1089 }
1090 } else {
1091 if (m_new_decl_listener)
1092 m_new_decl_listener->NewDeclImported(from, to);
1093
1094 if (!to_context_md->hasOrigin(to) || user_id != LLDB_INVALID_UID)
1095 to_context_md->setOrigin(to, DeclOrigin(m_source_ctx, from));
1096
1097 LLDB_LOG(log,
1098 " [ClangASTImporter] Decl has no origin information in "
1099 "(ASTContext*){0}",
1100 &from->getASTContext());
1101 }
1102
1103 if (auto *to_namespace = dyn_cast<clang::NamespaceDecl>(to)) {
1104 auto *from_namespace = cast<clang::NamespaceDecl>(from);
1105
1106 NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps;
1107
1108 NamespaceMetaMap::iterator namespace_map_iter =
1109 namespace_maps.find(from_namespace);
1110
1111 if (namespace_map_iter != namespace_maps.end())
1112 to_context_md->m_namespace_maps[to_namespace] =
1113 namespace_map_iter->second;
1114 }
1115 } else {
1116 to_context_md->setOrigin(to, DeclOrigin(m_source_ctx, from));
1117
1118 LLDB_LOG(log,
1119 " [ClangASTImporter] Sourced origin "
1120 "(Decl*){0}/(ASTContext*){1} into (ASTContext*){2}",
1121 from, m_source_ctx, &to->getASTContext());
1122 }
1123
1124 if (auto *to_tag_decl = dyn_cast<TagDecl>(to)) {
1125 to_tag_decl->setHasExternalLexicalStorage();
1126 to_tag_decl->getPrimaryContext()->setMustBuildLookupTable();
1127 auto from_tag_decl = cast<TagDecl>(from);
1128
1129 LLDB_LOG(
1130 log,
1131 " [ClangASTImporter] To is a TagDecl - attributes {0}{1} [{2}->{3}]",
1132 (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
1133 (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
1134 (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
1135 (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
1136 }
1137
1138 if (auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
1139 m_main.BuildNamespaceMap(to_namespace_decl);
1140 to_namespace_decl->setHasExternalVisibleStorage();
1141 }
1142
1143 if (auto *to_container_decl = dyn_cast<ObjCContainerDecl>(to)) {
1144 to_container_decl->setHasExternalLexicalStorage();
1145 to_container_decl->setHasExternalVisibleStorage();
1146
1147 if (log) {
1148 if (ObjCInterfaceDecl *to_interface_decl =
1149 llvm::dyn_cast<ObjCInterfaceDecl>(to_container_decl)) {
1150 LLDB_LOG(
1151 log,
1152 " [ClangASTImporter] To is an ObjCInterfaceDecl - attributes "
1153 "{0}{1}{2}",
1154 (to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
1155 (to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""),
1156 (to_interface_decl->hasDefinition() ? " HasDefinition" : ""));
1157 } else {
1158 LLDB_LOG(
1159 log, " [ClangASTImporter] To is an {0}Decl - attributes {1}{2}",
1160 ((Decl *)to_container_decl)->getDeclKindName(),
1161 (to_container_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
1162 (to_container_decl->hasExternalVisibleStorage() ? " Visible" : ""));
1163 }
1164 }
1165 }
1166
1167 if (clang::CXXMethodDecl *to_method = dyn_cast<CXXMethodDecl>(to))
1168 MaybeCompleteReturnType(m_main, to_method);
1169}
1170
1171clang::Decl *
1173 return m_main.GetDeclOrigin(To).decl;
1174}
static OptionalClangModuleID RemapModule(OptionalClangModuleID from_id, ClangExternalASTSourceCallbacks &from_source, ClangExternalASTSourceCallbacks &to_source)
Recreate a module with its parents in to_source and return its id.
static void MaybeCompleteReturnType(ClangASTImporter &importer, CXXMethodDecl *to_method)
Takes a CXXMethodDecl and completes the return type if necessary.
#define lldbassert(x)
Definition: LLDBAssert.h:15
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:342
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:365
DeclContextOverride()=default
void Override(clang::Decl *decl)
llvm::DenseMap< clang::Decl *, Backup > m_backups
void OverrideAllDeclsFromContainingFunction(clang::Decl *decl)
void OverrideOne(clang::Decl *decl)
clang::Decl * GetEscapedChild(clang::Decl *decl, clang::DeclContext *base=nullptr)
bool ChainPassesThrough(clang::Decl *decl, clang::DeclContext *base, clang::DeclContext *(clang::Decl::*contextFromDecl)(), clang::DeclContext *(clang::DeclContext::*contextFromContext)())
Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate and deattaches it at the end o...
Manages and observes all Clang AST node importing in LLDB.
bool CompleteTagDecl(clang::TagDecl *decl)
clang::Decl * DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl)
Copies the given decl to the destination type system.
void BuildNamespaceMap(const clang::NamespaceDecl *decl)
void RegisterNamespaceMap(const clang::NamespaceDecl *decl, NamespaceMapSP &namespace_map)
void ForgetDestination(clang::ASTContext *dst_ctx)
CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
clang::Decl * CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl)
DeclOrigin GetDeclOrigin(const clang::Decl *decl)
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin)
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
ASTContextMetadataSP GetContextMetadata(clang::ASTContext *dst_ctx)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
bool CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *interface_decl)
ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx)
std::shared_ptr< NamespaceMap > NamespaceMapSP
NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl)
std::shared_ptr< ASTImporterDelegate > ImporterDelegateSP
llvm::DenseMap< const clang::NamespaceDecl *, NamespaceMapSP > NamespaceMetaMap
bool CompleteType(const CompilerType &compiler_type)
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
ClangASTMetadata * GetDeclMetadata(const clang::Decl *decl)
bool RequireCompleteType(clang::QualType type)
CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
RecordDeclToLayoutMap m_record_decl_to_layout_map
bool Import(const CompilerType &type)
If the given type was copied from another TypeSystemClang then copy over all missing information (e....
ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl)
Updates the internal origin-tracking information so that the given 'original' decl is from now on use...
std::shared_ptr< ASTContextMetadata > ASTContextMetadataSP
bool CompleteAndFetchChildren(clang::QualType type)
bool IsForcefullyCompleted() const
A type is "forcefully completed" if it was declared complete to satisfy an AST invariant (e....
lldb::user_id_t GetUserID() const
OptionalClangModuleID GetIDForModule(clang::Module *module)
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Definition: CompilerType.h:65
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:227
ConstString GetTypeName(bool BaseOnly=false) const
A uniqued constant string class.
Definition: ConstString.h:40
std::optional< clang::Decl * > Import(clang::Decl *d)
Attempts to import the given decl into the target ASTContext by deserializing it from the 'std' modul...
A TypeSystem implementation based on Clang.
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
ClangASTMetadata * GetMetadata(const clang::Decl *object)
bool GetCompleteDecl(clang::Decl *decl)
#define LLDB_INVALID_UID
Definition: lldb-defines.h:88
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
void * opaque_compiler_type_t
Definition: lldb-types.h:87
uint64_t user_id_t
Definition: lldb-types.h:80
clang::DeclContext * decl_context
clang::DeclContext * lexical_decl_context
clang::Decl * GetOriginalDecl(clang::Decl *To) override
llvm::Expected< clang::Decl * > ImportImpl(clang::Decl *From) override
llvm::SmallPtrSet< clang::Decl *, 16 > m_decls_to_ignore
Decls we should ignore when mapping decls back to their original ASTContext.
void Imported(clang::Decl *from, clang::Decl *to) override
void ImportDefinitionTo(clang::Decl *to, clang::Decl *from)
Listener interface used by the ASTImporterDelegate to inform other code about decls that have been im...
static clang::QualType GetQualType(const CompilerType &ct)
Definition: ClangUtil.cpp:36
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
Definition: ClangUtil.cpp:44
static bool IsClangType(const CompilerType &ct)
Definition: ClangUtil.cpp:17
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
Definition: ClangUtil.cpp:51