LLDB mainline
TypeSystemClang.h
Go to the documentation of this file.
1//===-- TypeSystemClang.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_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
10#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
11
12#include <cstdint>
13
14#include <functional>
15#include <initializer_list>
16#include <memory>
17#include <optional>
18#include <set>
19#include <string>
20#include <utility>
21#include <vector>
22
23#include "clang/AST/ASTContext.h"
24#include "clang/AST/ASTFwd.h"
25#include "clang/AST/Decl.h"
26#include "clang/AST/TemplateBase.h"
27#include "clang/AST/Type.h"
28#include "clang/Basic/TargetInfo.h"
29#include "llvm/ADT/APSInt.h"
30#include "llvm/ADT/SmallVector.h"
31
36#include "lldb/Target/Target.h"
38#include "lldb/Utility/Flags.h"
39#include "lldb/Utility/Log.h"
41
43class PDBASTParser;
44
45namespace clang {
46class FileManager;
47class HeaderSearch;
48class ModuleMap;
49} // namespace clang
50
51namespace lldb_private {
52
53class ClangASTMetadata;
54class ClangASTSource;
55class Declaration;
56
57/// A Clang module ID.
59 unsigned m_id = 0;
60
61public:
63 explicit OptionalClangModuleID(unsigned id) : m_id(id) {}
64 bool HasValue() const { return m_id != 0; }
65 unsigned GetValue() const { return m_id; }
66};
67
68/// The implementation of lldb::Type's m_payload field for TypeSystemClang.
70 /// The payload is used for typedefs and ptrauth types.
71 /// For typedefs, the Layout is as follows:
72 /// \verbatim
73 /// bit 0..30 ... Owning Module ID.
74 /// bit 31 ...... IsCompleteObjCClass.
75 /// \endverbatim
76 /// For ptrauth types, we store the PointerAuthQualifier as an opaque value.
78
79public:
80 TypePayloadClang() = default;
81 explicit TypePayloadClang(OptionalClangModuleID owning_module,
82 bool is_complete_objc_class = false);
83 explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
84 operator Type::Payload() { return m_payload; }
85
86 static constexpr unsigned ObjCClassBit = 1 << 31;
88 void SetIsCompleteObjCClass(bool is_complete_objc_class) {
89 m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
91 }
94 }
96 /// \}
97};
98
99/// A TypeSystem implementation based on Clang.
100///
101/// This class uses a single clang::ASTContext as the backend for storing
102/// its types and declarations. Every clang::ASTContext should also just have
103/// a single associated TypeSystemClang instance that manages it.
104///
105/// The clang::ASTContext instance can either be created by TypeSystemClang
106/// itself or it can adopt an existing clang::ASTContext (for example, when
107/// it is necessary to provide a TypeSystem interface for an existing
108/// clang::ASTContext that was created by clang::CompilerInstance).
110 // LLVM RTTI support
111 static char ID;
112
113public:
114 typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
115 typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
116 clang::ObjCInterfaceDecl *);
117
118 // llvm casting support
119 bool isA(const void *ClassID) const override { return ClassID == &ID; }
120 static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
121
122 /// Constructs a TypeSystemClang with an ASTContext using the given triple.
123 ///
124 /// \param name The name for the TypeSystemClang (for logging purposes)
125 /// \param triple The llvm::Triple used for the ASTContext. The triple defines
126 /// certain characteristics of the ASTContext and its types
127 /// (e.g., whether certain primitive types exist or what their
128 /// signedness is).
129 explicit TypeSystemClang(llvm::StringRef name, llvm::Triple triple);
130
131 /// Constructs a TypeSystemClang that uses an existing ASTContext internally.
132 /// Useful when having an existing ASTContext created by Clang.
133 ///
134 /// \param name The name for the TypeSystemClang (for logging purposes)
135 /// \param existing_ctxt An existing ASTContext.
136 explicit TypeSystemClang(llvm::StringRef name,
137 clang::ASTContext &existing_ctxt);
138
139 ~TypeSystemClang() override;
140
141 void Finalize() override;
142
143 // PluginInterface functions
144 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
145
146 static llvm::StringRef GetPluginNameStatic() { return "clang"; }
147
149 Module *module, Target *target);
150
153
154 static void Initialize();
155
156 static void Terminate();
157
158 static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
159
160 /// Returns the display name of this TypeSystemClang that indicates what
161 /// purpose it serves in LLDB. Used for example in logs.
162 llvm::StringRef getDisplayName() const { return m_display_name; }
163
164 /// Returns the clang::ASTContext instance managed by this TypeSystemClang.
165 clang::ASTContext &getASTContext() const;
166
167 clang::MangleContext *getMangleContext();
168
169 std::shared_ptr<clang::TargetOptions> &getTargetOptions();
170
171 clang::TargetInfo *getTargetInfo();
172
173 void setSema(clang::Sema *s);
174 clang::Sema *getSema() { return m_sema; }
175
176 const char *GetTargetTriple();
177
179 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
180
181 bool GetCompleteDecl(clang::Decl *decl) {
183 }
184
185 static void DumpDeclHiearchy(clang::Decl *decl);
186
187 static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx);
188
189 static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl);
190
191 void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id);
192 void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id);
193
194 void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data);
195
196 void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data);
197 ClangASTMetadata *GetMetadata(const clang::Decl *object);
198 ClangASTMetadata *GetMetadata(const clang::Type *object);
199
200 void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object,
201 clang::AccessSpecifier access);
202 clang::AccessSpecifier
203 GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object);
204
205 // Basic Types
207 size_t bit_size) override;
208
210
211 static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name);
212
214 GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name,
215 uint32_t dw_ate, uint32_t bit_size);
216
217 CompilerType GetCStringType(bool is_const);
218
219 static clang::DeclContext *GetDeclContextForType(clang::QualType type);
220
221 static clang::DeclContext *GetDeclContextForType(const CompilerType &type);
222
224 GetCompilerDeclContextForType(const CompilerType &type) override;
225
226 uint32_t GetPointerByteSize() override;
227
228 clang::TranslationUnitDecl *GetTranslationUnitDecl() {
229 return getASTContext().getTranslationUnitDecl();
230 }
231
232 static bool AreTypesSame(CompilerType type1, CompilerType type2,
233 bool ignore_qualifiers = false);
234
235 /// Creates a CompilerType from the given QualType with the current
236 /// TypeSystemClang instance as the CompilerType's typesystem.
237 /// \param qt The QualType for a type that belongs to the ASTContext of this
238 /// TypeSystemClang.
239 /// \return The CompilerType representing the given QualType. If the
240 /// QualType's type pointer is a nullptr then the function returns an
241 /// invalid CompilerType.
242 CompilerType GetType(clang::QualType qt) {
243 if (qt.getTypePtrOrNull() == nullptr)
244 return CompilerType();
245 // Check that the type actually belongs to this TypeSystemClang.
246 assert(qt->getAsTagDecl() == nullptr ||
247 &qt->getAsTagDecl()->getASTContext() == &getASTContext());
248 return CompilerType(weak_from_this(), qt.getAsOpaquePtr());
249 }
250
251 CompilerType GetTypeForDecl(clang::NamedDecl *decl);
252
253 CompilerType GetTypeForDecl(clang::TagDecl *decl);
254
255 CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
256
257 CompilerType GetTypeForDecl(clang::ValueDecl *value_decl);
258
259 template <typename RecordDeclType>
261 GetTypeForIdentifier(llvm::StringRef type_name,
262 clang::DeclContext *decl_context = nullptr) {
263 CompilerType compiler_type;
264 if (type_name.empty())
265 return compiler_type;
266
267 clang::ASTContext &ast = getASTContext();
268 if (!decl_context)
269 decl_context = ast.getTranslationUnitDecl();
270
271 clang::IdentifierInfo &myIdent = ast.Idents.get(type_name);
272 clang::DeclarationName myName =
273 ast.DeclarationNames.getIdentifier(&myIdent);
274 clang::DeclContext::lookup_result result = decl_context->lookup(myName);
275 if (result.empty())
276 return compiler_type;
277
278 clang::NamedDecl *named_decl = *result.begin();
279 if (const RecordDeclType *record_decl =
280 llvm::dyn_cast<RecordDeclType>(named_decl))
281 compiler_type = CompilerType(
282 weak_from_this(),
283 clang::QualType(record_decl->getTypeForDecl(), 0).getAsOpaquePtr());
284
285 return compiler_type;
286 }
287
289 llvm::StringRef type_name,
290 const std::initializer_list<std::pair<const char *, CompilerType>>
291 &type_fields,
292 bool packed = false);
293
295 llvm::StringRef type_name,
296 const std::initializer_list<std::pair<const char *, CompilerType>>
297 &type_fields,
298 bool packed = false);
299
300 static bool IsOperator(llvm::StringRef name,
301 clang::OverloadedOperatorKind &op_kind);
302
303 // Structure, Unions, Classes
304
305 static clang::AccessSpecifier
307
308 static clang::AccessSpecifier
309 UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
310
311 uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
312 bool omit_empty_base_classes);
313
314 uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl,
315 clang::NamedDecl *canonical_decl,
316 bool omit_empty_base_classes);
317
318 uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
319 const clang::CXXBaseSpecifier *base_spec,
320 bool omit_empty_base_classes);
321
322 /// Synthesize a clang::Module and return its ID or a default-constructed ID.
325 bool is_framework = false,
326 bool is_explicit = false);
327
328 CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
329 OptionalClangModuleID owning_module,
330 lldb::AccessType access_type,
331 llvm::StringRef name, int kind,
332 lldb::LanguageType language,
333 ClangASTMetadata *metadata = nullptr,
334 bool exports_symbols = false);
335
337 public:
339 TemplateParameterInfos(llvm::ArrayRef<const char *> names_in,
340 llvm::ArrayRef<clang::TemplateArgument> args_in)
341 : names(names_in), args(args_in) {
342 assert(names.size() == args_in.size());
343 }
344
347
350
352
353 bool IsValid() const {
354 // Having a pack name but no packed args doesn't make sense, so mark
355 // these template parameters as invalid.
356 if (pack_name && !packed_args)
357 return false;
358 return args.size() == names.size() &&
359 (!packed_args || !packed_args->packed_args);
360 }
361
362 bool IsEmpty() const { return args.empty(); }
363 size_t Size() const { return args.size(); }
364
365 llvm::ArrayRef<clang::TemplateArgument> GetArgs() const { return args; }
366 llvm::ArrayRef<const char *> GetNames() const { return names; }
367
368 clang::TemplateArgument const &Front() const {
369 assert(!args.empty());
370 return args.front();
371 }
372
373 void InsertArg(char const *name, clang::TemplateArgument arg) {
374 args.emplace_back(std::move(arg));
375 names.push_back(name);
376 }
377
378 // Parameter pack related
379
380 bool hasParameterPack() const { return static_cast<bool>(packed_args); }
381
383 assert(packed_args != nullptr);
384 return *packed_args;
385 }
386
388 assert(packed_args != nullptr);
389 return *packed_args;
390 }
391
392 llvm::ArrayRef<clang::TemplateArgument> GetParameterPackArgs() const {
393 assert(packed_args != nullptr);
394 return packed_args->GetArgs();
395 }
396
397 bool HasPackName() const { return pack_name && pack_name[0]; }
398
399 llvm::StringRef GetPackName() const {
400 assert(HasPackName());
401 return pack_name;
402 }
403
404 void SetPackName(char const *name) { pack_name = name; }
405
406 void SetParameterPack(std::unique_ptr<TemplateParameterInfos> args) {
407 packed_args = std::move(args);
408 }
409
410 private:
411 /// Element 'names[i]' holds the template argument name
412 /// of 'args[i]'
413 llvm::SmallVector<const char *, 2> names;
414 llvm::SmallVector<clang::TemplateArgument, 2> args;
415
416 const char * pack_name = nullptr;
417 std::unique_ptr<TemplateParameterInfos> packed_args;
418 };
419
420 clang::FunctionTemplateDecl *CreateFunctionTemplateDecl(
421 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
422 clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos);
423
425 clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template,
426 const TemplateParameterInfos &infos);
427
428 clang::ClassTemplateDecl *CreateClassTemplateDecl(
429 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
430 lldb::AccessType access_type, llvm::StringRef class_name, int kind,
431 const TemplateParameterInfos &infos);
432
433 clang::TemplateTemplateParmDecl *
434 CreateTemplateTemplateParmDecl(const char *template_name);
435
436 clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
437 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
438 clang::ClassTemplateDecl *class_template_decl, int kind,
439 const TemplateParameterInfos &infos);
440
442 CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *
443 class_template_specialization_decl);
444
445 static clang::DeclContext *
446 GetAsDeclContext(clang::FunctionDecl *function_decl);
447
449 bool is_method, clang::OverloadedOperatorKind op_kind,
450 uint32_t num_params);
451
452 bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size);
453
454 bool RecordHasFields(const clang::RecordDecl *record_decl);
455
456 bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b);
457
458 CompilerType CreateObjCClass(llvm::StringRef name,
459 clang::DeclContext *decl_ctx,
460 OptionalClangModuleID owning_module,
461 bool isForwardDecl, bool isInternal,
462 ClangASTMetadata *metadata = nullptr);
463
464 // Returns a mask containing bits from the TypeSystemClang::eTypeXXX
465 // enumerations
466
467 // Namespace Declarations
468
469 clang::NamespaceDecl *
470 GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx,
471 OptionalClangModuleID owning_module,
472 bool is_inline = false);
473
474 // Function Types
475
476 clang::FunctionDecl *CreateFunctionDeclaration(
477 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
478 llvm::StringRef name, const CompilerType &function_Type,
479 clang::StorageClass storage, bool is_inline);
480
482 CreateFunctionType(const CompilerType &result_type, const CompilerType *args,
483 unsigned num_args, bool is_variadic, unsigned type_quals,
484 clang::CallingConv cc = clang::CC_C,
485 clang::RefQualifierKind ref_qual = clang::RQ_None);
486
487 clang::ParmVarDecl *
488 CreateParameterDeclaration(clang::DeclContext *decl_ctx,
489 OptionalClangModuleID owning_module,
490 const char *name, const CompilerType &param_type,
491 int storage, bool add_decl = false);
492
493 void SetFunctionParameters(clang::FunctionDecl *function_decl,
494 llvm::ArrayRef<clang::ParmVarDecl *> params);
495
497
498 // Array Types
499
500 CompilerType CreateArrayType(const CompilerType &element_type,
501 size_t element_count, bool is_vector);
502
503 // Enumeration Types
504 CompilerType CreateEnumerationType(llvm::StringRef name,
505 clang::DeclContext *decl_ctx,
506 OptionalClangModuleID owning_module,
507 const Declaration &decl,
508 const CompilerType &integer_qual_type,
509 bool is_scoped);
510
511 // Integer type functions
512
513 CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed);
514
515 CompilerType GetPointerSizedIntType(bool is_signed);
516
517 // Floating point functions
518
519 static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast,
520 size_t bit_size);
521
522 // TypeSystem methods
524 PDBASTParser *GetPDBParser() override;
526
527 // TypeSystemClang callbacks for external source lookups.
528 void CompleteTagDecl(clang::TagDecl *);
529
530 void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
531
532 bool LayoutRecordType(
533 const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
534 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
535 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
536 &base_offsets,
537 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
538 &vbase_offsets);
539
540 /// Creates a CompilerDecl from the given Decl with the current
541 /// TypeSystemClang instance as its typesystem.
542 /// The Decl has to come from the ASTContext of this
543 /// TypeSystemClang.
544 CompilerDecl GetCompilerDecl(clang::Decl *decl) {
545 assert(&decl->getASTContext() == &getASTContext() &&
546 "CreateCompilerDecl for Decl from wrong ASTContext?");
547 return CompilerDecl(this, decl);
548 }
549
550 // CompilerDecl override functions
551 ConstString DeclGetName(void *opaque_decl) override;
552
553 ConstString DeclGetMangledName(void *opaque_decl) override;
554
555 CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override;
556
557 CompilerType DeclGetFunctionReturnType(void *opaque_decl) override;
558
559 size_t DeclGetFunctionNumArguments(void *opaque_decl) override;
560
562 size_t arg_idx) override;
563
564 std::vector<lldb_private::CompilerContext>
565 DeclGetCompilerContext(void *opaque_decl) override;
566
567 Scalar DeclGetConstantValue(void *opaque_decl) override;
568
569 CompilerType GetTypeForDecl(void *opaque_decl) override;
570
571 // CompilerDeclContext override functions
572
573 /// Creates a CompilerDeclContext from the given DeclContext
574 /// with the current TypeSystemClang instance as its typesystem.
575 /// The DeclContext has to come from the ASTContext of this
576 /// TypeSystemClang.
577 CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
578
579 /// Set the owning module for \p decl.
580 static void SetOwningModule(clang::Decl *decl,
581 OptionalClangModuleID owning_module);
582
583 std::vector<CompilerDecl>
584 DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
585 const bool ignore_using_decls) override;
586
587 ConstString DeclContextGetName(void *opaque_decl_ctx) override;
588
589 ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override;
590
591 bool DeclContextIsClassMethod(void *opaque_decl_ctx) override;
592
593 bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
594 void *other_opaque_decl_ctx) override;
595
596 lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override;
597
598 std::vector<lldb_private::CompilerContext>
599 DeclContextGetCompilerContext(void *opaque_decl_ctx) override;
600
601 // Clang specific clang::DeclContext functions
602
603 static clang::DeclContext *
605
606 static clang::ObjCMethodDecl *
608
609 static clang::CXXMethodDecl *
611
612 static clang::FunctionDecl *
614
615 static clang::NamespaceDecl *
617
619 const clang::Decl *object);
620
621 static clang::ASTContext *
623
624 // Tests
625
626#ifndef NDEBUG
627 bool Verify(lldb::opaque_compiler_type_t type) override;
628#endif
629
631 CompilerType *element_type, uint64_t *size,
632 bool *is_incomplete) override;
633
635 CompilerType *element_type, uint64_t *size) override;
636
638
640
642
643 bool IsCharType(lldb::opaque_compiler_type_t type) override;
644
646
647 bool IsConst(lldb::opaque_compiler_type_t type) override;
648
649 bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length);
650
651 static bool IsCXXClassType(const CompilerType &type);
652
653 bool IsDefined(lldb::opaque_compiler_type_t type) override;
654
655 bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
656 bool &is_complex) override;
657
658 unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override;
661
663
665 CompilerType *base_type_ptr) override;
666
667 size_t
669
671 const size_t index) override;
672
674
676
678 CompilerType *function_pointer_type_ptr) override;
679
681 bool &is_signed) override;
682
684 bool &is_signed) override;
685
687
688 static bool IsObjCClassType(const CompilerType &type);
689
690 static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
691 bool check_superclass);
692
693 static bool IsObjCObjectOrInterfaceType(const CompilerType &type);
694
695 static bool IsObjCObjectPointerType(const CompilerType &type,
696 CompilerType *target_type = nullptr);
697
699
701
703
705 CompilerType *target_type, // Can pass nullptr
706 bool check_cplusplus, bool check_objc) override;
707
709
711 CompilerType *pointee_type) override;
712
714 CompilerType *pointee_type) override;
715
717 CompilerType *pointee_type, bool *is_rvalue) override;
718
719 bool IsScalarType(lldb::opaque_compiler_type_t type) override;
720
722
723 bool IsVoidType(lldb::opaque_compiler_type_t type) override;
724
725 bool CanPassInRegisters(const CompilerType &type) override;
726
727 bool SupportsLanguage(lldb::LanguageType language) override;
728
729 static std::optional<std::string> GetCXXClassName(const CompilerType &type);
730
731 // Type Completion
732
734
736
737 // Accessors
738
740 bool base_only) override;
741
743
745 CompilerType *pointee_or_element_compiler_type) override;
746
749
750 lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
751
752 unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
753
754 // Creating related types
755
757 ExecutionContextScope *exe_scope) override;
758
760 uint64_t size) override;
761
763
766
769
770 // Returns -1 if this isn't a function of if the function doesn't have a
771 // prototype Returns a value >= 0 if there is a prototype.
773
775 size_t idx) override;
776
779
781
784 size_t idx) override;
785
787
789
791
794
797
799
801
803 uint32_t payload) override;
804
806
808
809 /// Using the current type, create a new typedef to that type using
810 /// "typedef_name" as the name and "decl_ctx" as the decl context.
811 /// \param opaque_payload is an opaque TypePayloadClang.
813 const char *name,
814 const CompilerDeclContext &decl_ctx,
815 uint32_t opaque_payload) override;
816
817 // If the current object represents a typedef type, get the underlying type
819
820 // Create related types using the current type's AST
822
823 // Create a generic function prototype that can be used in ValuObject types
824 // to correctly display a function pointer with the right value and summary.
826
827 // Exploring the type
828
829 const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override;
830
831 std::optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
832 ExecutionContextScope *exe_scope) {
833 if (std::optional<uint64_t> bit_size = GetBitSize(type, exe_scope))
834 return (*bit_size + 7) / 8;
835 return std::nullopt;
836 }
837
838 std::optional<uint64_t> GetBitSize(lldb::opaque_compiler_type_t type,
839 ExecutionContextScope *exe_scope) override;
840
842 uint64_t &count) override;
843
845
846 std::optional<size_t>
848 ExecutionContextScope *exe_scope) override;
849
850 llvm::Expected<uint32_t>
852 bool omit_empty_base_classes,
853 const ExecutionContext *exe_ctx) override;
854
856
859
862 std::function<bool(const CompilerType &integer_type,
863 ConstString name,
864 const llvm::APSInt &value)> const &callback) override;
865
866 uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
867
869 std::string &name, uint64_t *bit_offset_ptr,
870 uint32_t *bitfield_bit_size_ptr,
871 bool *is_bitfield_ptr) override;
872
874
876
878 size_t idx,
879 uint32_t *bit_offset_ptr) override;
880
882 size_t idx,
883 uint32_t *bit_offset_ptr) override;
884
886 llvm::StringRef name) override;
887
888 static uint32_t GetNumPointeeChildren(clang::QualType type);
889
890 llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
891 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
892 bool transparent_pointers, bool omit_empty_base_classes,
893 bool ignore_array_bounds, std::string &child_name,
894 uint32_t &child_byte_size, int32_t &child_byte_offset,
895 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
896 bool &child_is_base_class, bool &child_is_deref_of_parent,
897 ValueObject *valobj, uint64_t &language_flags) override;
898
899 // Lookup a child given a name. This function will match base class names and
900 // member member names in "clang_type" only, not descendants.
902 llvm::StringRef name,
903 bool omit_empty_base_classes) override;
904
905 // Lookup a child member given a name. This function will match member names
906 // only and will descend into "clang_type" children in search for the first
907 // member in this class, or any base class that matches "name".
908 // TODO: Return all matches for a given name by returning a
909 // vector<vector<uint32_t>>
910 // so we catch all names that match a given child name, not just the first.
911 size_t
913 llvm::StringRef name,
914 bool omit_empty_base_classes,
915 std::vector<uint32_t> &child_indexes) override;
916
918 llvm::StringRef name) override;
919
921
923 bool expand_pack) override;
924
927 bool expand_pack) override;
929 size_t idx, bool expand_pack) override;
930 std::optional<CompilerType::IntegralTemplateArgument>
932 bool expand_pack) override;
933
934 CompilerType GetTypeForFormatters(void *type) override;
935
936#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
937 // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx
938 // could not be found in decl_ctx.
939 uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx,
940 clang::DeclContext *child_decl_ctx,
941 ConstString *child_name = nullptr,
942 CompilerType *child_type = nullptr);
943
944 // Modifying RecordType
945 static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
946 llvm::StringRef name,
947 const CompilerType &field_type,
948 lldb::AccessType access,
949 uint32_t bitfield_bit_size);
950
951 static void BuildIndirectFields(const CompilerType &type);
952
953 static void SetIsPacked(const CompilerType &type);
954
955 static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
956 llvm::StringRef name,
957 const CompilerType &var_type,
958 lldb::AccessType access);
959
960 /// Initializes a variable with an integer value.
961 /// \param var The variable to initialize. Must not already have an
962 /// initializer and must have an integer or enum type.
963 /// \param init_value The integer value that the variable should be
964 /// initialized to. Has to match the bit width of the
965 /// variable type.
966 static void SetIntegerInitializerForVariable(clang::VarDecl *var,
967 const llvm::APInt &init_value);
968
969 /// Initializes a variable with a floating point value.
970 /// \param var The variable to initialize. Must not already have an
971 /// initializer and must have a floating point type.
972 /// \param init_value The float value that the variable should be
973 /// initialized to.
974 static void
975 SetFloatingInitializerForVariable(clang::VarDecl *var,
976 const llvm::APFloat &init_value);
977
978 clang::CXXMethodDecl *AddMethodToCXXRecordType(
979 lldb::opaque_compiler_type_t type, llvm::StringRef name,
980 const char *mangled_name, const CompilerType &method_type,
981 lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
982 bool is_explicit, bool is_attr_used, bool is_artificial);
983
985
986 // C++ Base Classes
987 std::unique_ptr<clang::CXXBaseSpecifier>
989 lldb::AccessType access, bool is_virtual,
990 bool base_of_class);
991
994 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases);
995
996 static bool SetObjCSuperClass(const CompilerType &type,
997 const CompilerType &superclass_compiler_type);
998
999 static bool AddObjCClassProperty(const CompilerType &type,
1000 const char *property_name,
1001 const CompilerType &property_compiler_type,
1002 clang::ObjCIvarDecl *ivar_decl,
1003 const char *property_setter_name,
1004 const char *property_getter_name,
1005 uint32_t property_attributes,
1006 ClangASTMetadata *metadata);
1007
1008 static clang::ObjCMethodDecl *AddMethodToObjCObjectType(
1009 const CompilerType &type,
1010 const char *name, // the full symbol name as seen in the symbol table
1011 // (lldb::opaque_compiler_type_t type, "-[NString
1012 // stringWithCString:]")
1013 const CompilerType &method_compiler_type, bool is_artificial,
1014 bool is_variadic, bool is_objc_direct_call);
1015
1017 bool has_extern);
1018
1019 // Tag Declarations
1020 static bool StartTagDeclarationDefinition(const CompilerType &type);
1021
1022 static bool CompleteTagDeclarationDefinition(const CompilerType &type);
1023
1024 // Modifying Enumeration types
1025 clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
1026 const CompilerType &enum_type, const Declaration &decl, const char *name,
1027 int64_t enum_value, uint32_t enum_value_bit_size);
1028 clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
1029 const CompilerType &enum_type, const Declaration &decl, const char *name,
1030 const llvm::APSInt &value);
1031
1032 /// Returns the underlying integer type for an enum type. If the given type
1033 /// is invalid or not an enum-type, the function returns an invalid
1034 /// CompilerType.
1035 CompilerType GetEnumerationIntegerType(CompilerType type);
1036
1037 // Pointers & References
1038
1039 // Call this function using the class type when you want to make a member
1040 // pointer type to pointee_type.
1041 static CompilerType CreateMemberPointerType(const CompilerType &type,
1042 const CompilerType &pointee_type);
1043
1044 // Dumping types
1045#ifndef NDEBUG
1046 /// Convenience LLVM-style dump method for use in the debugger only.
1047 /// In contrast to the other \p Dump() methods this directly invokes
1048 /// \p clang::QualType::dump().
1049 LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
1050#endif
1051
1052 /// \see lldb_private::TypeSystem::Dump
1053 void Dump(llvm::raw_ostream &output) override;
1054
1055 /// Dump clang AST types from the symbol file.
1056 ///
1057 /// \param[in] s
1058 /// A stream to send the dumped AST node(s) to
1059 /// \param[in] symbol_name
1060 /// The name of the symbol to dump, if it is empty dump all the symbols
1061 void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
1062
1063 bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s,
1064 lldb::Format format, const DataExtractor &data,
1065 lldb::offset_t data_offset, size_t data_byte_size,
1066 uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
1067 ExecutionContextScope *exe_scope) override;
1068
1072
1074 lldb::opaque_compiler_type_t type, Stream &s,
1076
1077 static void DumpTypeName(const CompilerType &type);
1078
1079 static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type);
1080
1081 static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type);
1082
1083 static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
1084
1085 static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type);
1086
1087 static clang::CXXRecordDecl *
1089
1090 static clang::ObjCInterfaceDecl *
1091 GetAsObjCInterfaceDecl(const CompilerType &type);
1092
1093 clang::ClassTemplateDecl *ParseClassTemplateDecl(
1094 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
1095 lldb::AccessType access_type, const char *parent_name, int tag_decl_kind,
1096 const TypeSystemClang::TemplateParameterInfos &template_param_infos);
1097
1098 clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx,
1099 OptionalClangModuleID owning_module);
1100
1101 clang::UsingDirectiveDecl *
1102 CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
1103 OptionalClangModuleID owning_module,
1104 clang::NamespaceDecl *ns_decl);
1105
1106 clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
1107 OptionalClangModuleID owning_module,
1108 clang::NamedDecl *target);
1109
1110 clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
1111 OptionalClangModuleID owning_module,
1112 const char *name,
1113 clang::QualType type);
1114
1116 GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
1117
1118 static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) {
1119 if (type)
1120 return clang::QualType::getFromOpaquePtr(type);
1121 return clang::QualType();
1122 }
1123
1124 static clang::QualType
1126 if (type)
1127 return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
1128 return clang::QualType();
1129 }
1130
1131 clang::DeclarationName
1132 GetDeclarationName(llvm::StringRef name,
1133 const CompilerType &function_clang_type);
1134
1135 clang::LangOptions *GetLangOpts() const {
1136 return m_language_options_up.get();
1137 }
1138 clang::SourceManager *GetSourceMgr() const {
1139 return m_source_manager_up.get();
1140 }
1141
1142 /// Complete a type from debug info, or mark it as forcefully completed if
1143 /// there is no definition of the type in the current Module. Call this
1144 /// function in contexts where the usual C++ rules require a type to be
1145 /// complete (base class, member, etc.).
1146 static void RequireCompleteType(CompilerType type);
1147
1148 bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td);
1149
1150 /// Return the template parameters (including surrounding <>) in string form.
1151 std::string
1152 PrintTemplateParams(const TemplateParameterInfos &template_param_infos);
1153
1154private:
1155 /// Returns the PrintingPolicy used when generating the internal type names.
1156 /// These type names are mostly used for the formatter selection.
1157 clang::PrintingPolicy GetTypePrintingPolicy();
1158 /// Returns the internal type name for the given NamedDecl using the
1159 /// type printing policy.
1160 std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
1161 bool qualified = true);
1162
1163 const clang::ClassTemplateSpecializationDecl *
1165
1167 llvm::function_ref<bool(clang::QualType)> predicate) const;
1168
1169 /// Emits information about this TypeSystem into the expression log.
1170 ///
1171 /// Helper method that is used in \ref TypeSystemClang::TypeSystemClang
1172 /// on creation of a new instance.
1173 void LogCreation() const;
1174
1175 // Classes that inherit from TypeSystemClang can see and modify these
1176 std::string m_target_triple;
1177 std::unique_ptr<clang::ASTContext> m_ast_up;
1178 std::unique_ptr<clang::LangOptions> m_language_options_up;
1179 std::unique_ptr<clang::FileManager> m_file_manager_up;
1180 std::unique_ptr<clang::SourceManager> m_source_manager_up;
1181 std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
1182 std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
1183 std::shared_ptr<clang::TargetOptions> m_target_options_rp;
1184 std::unique_ptr<clang::TargetInfo> m_target_info_up;
1185 std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
1186 std::unique_ptr<clang::SelectorTable> m_selector_table_up;
1187 std::unique_ptr<clang::Builtin::Context> m_builtins_up;
1188 std::unique_ptr<clang::HeaderSearch> m_header_search_up;
1189 std::unique_ptr<clang::ModuleMap> m_module_map_up;
1190 std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
1191 std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
1192 std::unique_ptr<npdb::PdbAstBuilder> m_native_pdb_ast_parser_up;
1193 std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
1195 bool m_ast_owned = false;
1196 /// A string describing what this TypeSystemClang represents (e.g.,
1197 /// AST for debug information, an expression, some other utility ClangAST).
1198 /// Useful for logging and debugging.
1199 std::string m_display_name;
1200
1201 typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap;
1202 /// Maps Decls to their associated ClangASTMetadata.
1204
1205 typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap;
1206 /// Maps Types to their associated ClangASTMetadata.
1208
1209 typedef llvm::DenseMap<const clang::CXXRecordDecl *, clang::AccessSpecifier>
1211 /// Maps CXXRecordDecl to their most recent added method/field's
1212 /// AccessSpecifier.
1214
1215 /// The sema associated that is currently used to build this ASTContext.
1216 /// May be null if we are already done parsing this ASTContext or the
1217 /// ASTContext wasn't created by parsing source code.
1218 clang::Sema *m_sema = nullptr;
1219
1220 // For TypeSystemClang only
1223 /// Creates the internal ASTContext.
1224 void CreateASTContext();
1225 void SetTargetTriple(llvm::StringRef target_triple);
1226};
1227
1228/// The TypeSystemClang instance used for the scratch ASTContext in a
1229/// lldb::Target.
1231 /// LLVM RTTI support
1232 static char ID;
1233
1234public:
1235 ScratchTypeSystemClang(Target &target, llvm::Triple triple);
1236
1237 ~ScratchTypeSystemClang() override = default;
1238
1239 void Finalize() override;
1240
1241 /// The different kinds of isolated ASTs within the scratch TypeSystem.
1242 ///
1243 /// These ASTs are isolated from the main scratch AST and are each
1244 /// dedicated to a special language option/feature that makes the contained
1245 /// AST nodes incompatible with other AST nodes.
1247 /// The isolated AST for declarations/types from expressions that imported
1248 /// type information from a C++ module. The templates from a C++ module
1249 /// often conflict with the templates we generate from debug information,
1250 /// so we put these types in their own AST.
1253
1254 /// Alias for requesting the default scratch TypeSystemClang in GetForTarget.
1255 // This isn't constexpr as gtest/std::optional comparison logic is trying
1256 // to get the address of this for pretty-printing.
1257 static const std::nullopt_t DefaultAST;
1258
1259 /// Infers the appropriate sub-AST from Clang's LangOptions.
1260 static std::optional<IsolatedASTKind>
1261 InferIsolatedASTKindFromLangOpts(const clang::LangOptions &l) {
1262 // If modules are activated we want the dedicated C++ module AST.
1263 // See IsolatedASTKind::CppModules for more info.
1264 if (l.Modules)
1266 return DefaultAST;
1267 }
1268
1269 /// Returns the scratch TypeSystemClang for the given target.
1270 /// \param target The Target which scratch TypeSystemClang should be returned.
1271 /// \param ast_kind Allows requesting a specific sub-AST instead of the
1272 /// default scratch AST. See also `IsolatedASTKind`.
1273 /// \param create_on_demand If the scratch TypeSystemClang instance can be
1274 /// created by this call if it doesn't exist yet. If it doesn't exist yet and
1275 /// this parameter is false, this function returns a nullptr.
1276 /// \return The scratch type system of the target or a nullptr in case an
1277 /// error occurred.
1279 GetForTarget(Target &target,
1280 std::optional<IsolatedASTKind> ast_kind = DefaultAST,
1281 bool create_on_demand = true);
1282
1283 /// Returns the scratch TypeSystemClang for the given target. The returned
1284 /// TypeSystemClang will be the scratch AST or a sub-AST, depending on which
1285 /// fits best to the passed LangOptions.
1286 /// \param target The Target which scratch TypeSystemClang should be returned.
1287 /// \param lang_opts The LangOptions of a clang ASTContext that the caller
1288 /// wants to export type information from. This is used to
1289 /// find the best matching sub-AST that will be returned.
1291 GetForTarget(Target &target, const clang::LangOptions &lang_opts) {
1292 return GetForTarget(target, InferIsolatedASTKindFromLangOpts(lang_opts));
1293 }
1294
1295 /// \see lldb_private::TypeSystem::Dump
1296 void Dump(llvm::raw_ostream &output) override;
1297
1298 UserExpression *GetUserExpression(llvm::StringRef expr,
1299 llvm::StringRef prefix,
1300 SourceLanguage language,
1301 Expression::ResultType desired_type,
1302 const EvaluateExpressionOptions &options,
1303 ValueObject *ctx_obj) override;
1304
1305 FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
1306 const Address &function_address,
1307 const ValueList &arg_value_list,
1308 const char *name) override;
1309
1310 std::unique_ptr<UtilityFunction>
1311 CreateUtilityFunction(std::string text, std::string name) override;
1312
1314
1315 /// Unregisters the given ASTContext as a source from the scratch AST (and
1316 /// all sub-ASTs).
1317 /// \see ClangASTImporter::ForgetSource
1318 void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer);
1319
1320 // llvm casting support
1321 bool isA(const void *ClassID) const override {
1322 return ClassID == &ID || TypeSystemClang::isA(ClassID);
1323 }
1324 static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
1325
1326private:
1327 std::unique_ptr<ClangASTSource> CreateASTSource();
1328 /// Returns the requested sub-AST.
1329 /// Will lazily create the sub-AST if it hasn't been created before.
1331
1332 /// The target triple.
1333 /// This was potentially adjusted and might not be identical to the triple
1334 /// of `m_target_wp`.
1335 llvm::Triple m_triple;
1337 /// The persistent variables associated with this process for the expression
1338 /// parser.
1339 std::unique_ptr<ClangPersistentVariables> m_persistent_variables;
1340 /// The ExternalASTSource that performs lookups and completes minimally
1341 /// imported types.
1342 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
1343
1344 // FIXME: GCC 5.x doesn't support enum as map keys.
1345 typedef int IsolatedASTKey;
1346
1347 /// Map from IsolatedASTKind to their actual TypeSystemClang instance.
1348 /// This map is lazily filled with sub-ASTs and should be accessed via
1349 /// `GetSubAST` (which lazily fills this map).
1350 llvm::DenseMap<IsolatedASTKey, std::shared_ptr<TypeSystemClang>>
1352};
1353
1354} // namespace lldb_private
1355
1356#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
A section + offset based address class.
Definition: Address.h:62
Manages and observes all Clang AST node importing in LLDB.
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A class to manage flags.
Definition: Flags.h:22
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
Encapsulates a function that can be called.
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
The TypeSystemClang instance used for the scratch ASTContext in a lldb::Target.
static std::optional< IsolatedASTKind > InferIsolatedASTKindFromLangOpts(const clang::LangOptions &l)
Infers the appropriate sub-AST from Clang's LangOptions.
void Finalize() override
Free up any resources associated with this TypeSystem.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
bool isA(const void *ClassID) const override
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
static lldb::TypeSystemClangSP GetForTarget(Target &target, const clang::LangOptions &lang_opts)
Returns the scratch TypeSystemClang for the given target.
~ScratchTypeSystemClang() override=default
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static bool classof(const TypeSystem *ts)
void Dump(llvm::raw_ostream &output) override
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
TypePayloadClang(uint32_t opaque_payload)
OptionalClangModuleID GetOwningModule()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
TemplateParameterInfos & operator=(TemplateParameterInfos &&)=delete
void SetParameterPack(std::unique_ptr< TemplateParameterInfos > args)
std::unique_ptr< TemplateParameterInfos > packed_args
clang::TemplateArgument const & Front() const
TemplateParameterInfos(TemplateParameterInfos &&)=delete
void InsertArg(char const *name, clang::TemplateArgument arg)
TemplateParameterInfos & operator=(TemplateParameterInfos const &)=delete
TemplateParameterInfos(TemplateParameterInfos const &)=delete
TemplateParameterInfos(llvm::ArrayRef< const char * > names_in, llvm::ArrayRef< clang::TemplateArgument > args_in)
llvm::SmallVector< clang::TemplateArgument, 2 > args
llvm::SmallVector< const char *, 2 > names
Element 'names[i]' holds the template argument name of 'args[i]'.
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
clang::TranslationUnitDecl * GetTranslationUnitDecl()
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data)
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
static clang::DeclContext * GetAsDeclContext(clang::FunctionDecl *function_decl)
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > &ast_source_up)
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
std::optional< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
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.
void CompleteTagDecl(clang::TagDecl *)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
TypeSystemClang(const TypeSystemClang &)
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
std::optional< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassTypeAndHasIVars(const CompilerType &type, bool check_superclass)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeForIdentifier(llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
llvm::DenseMap< const clang::CXXRecordDecl *, clang::AccessSpecifier > CXXRecordDeclAccessMap
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, clang::AccessSpecifier access)
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata *metadata)
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &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 IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
clang::AccessSpecifier GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object)
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
static bool classof(const TypeSystem *ts)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
void(* CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
llvm::StringRef GetPluginName() override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
static clang::AccessSpecifier UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs)
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
bool isA(const void *ClassID) const override
void Dump(llvm::raw_ostream &output) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
std::string PrintTemplateParams(const TemplateParameterInfos &template_param_infos)
Return the template parameters (including surrounding <>) in string form.
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
TypeSystemClang(llvm::StringRef name, clang::ASTContext &existing_ctxt)
Constructs a TypeSystemClang that uses an existing ASTContext internally.
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
const TypeSystemClang & operator=(const TypeSystemClang &)
static LanguageSet GetSupportedLanguagesForExpressions()
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl)
void SetTargetTriple(llvm::StringRef target_triple)
CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
static bool CheckOverloadedOperatorKindParameterCount(bool is_method, clang::OverloadedOperatorKind op_kind, uint32_t num_params)
clang::DeclarationName GetDeclarationName(llvm::StringRef name, const CompilerType &function_clang_type)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
void(* CompleteTagDeclCallback)(void *baton, clang::TagDecl *)
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
clang::SourceManager * GetSourceMgr() const
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
CXXRecordDeclAccessMap m_cxx_record_decl_access
Maps CXXRecordDecl to their most recent added method/field's AccessSpecifier.
static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast, size_t bit_size)
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
std::unique_ptr< npdb::PdbAstBuilder > m_native_pdb_ast_parser_up
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size) override
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType &param_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType GetTypeForDecl(clang::TagDecl *decl)
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
ClangASTMetadata * GetMetadata(const clang::Decl *object)
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
static ClangASTMetadata * DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
clang::LangOptions * GetLangOpts() const
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isForwardDecl, bool isInternal, ClangASTMetadata *metadata=nullptr)
void SetFunctionParameters(clang::FunctionDecl *function_decl, llvm::ArrayRef< clang::ParmVarDecl * > params)
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::DenseMap< const clang::Type *, ClangASTMetadata > TypeMetadataMap
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
llvm::DenseMap< const clang::Decl *, ClangASTMetadata > DeclMetadataMap
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
Interface for representing a type system.
Definition: TypeSystem.h:70
virtual bool isA(const void *ClassID) const =0
uint32_t Payload
Definition: Type.h:534
Encapsulates a one-time expression for use in lldb.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
Definition: lldb-forward.h:460
void * opaque_compiler_type_t
Definition: lldb-types.h:89
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelFull
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
Format
Display format definitions.
uint64_t offset_t
Definition: lldb-types.h:85
LanguageType
Programming language type.
Encoding
Register encoding definitions.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
Definition: lldb-forward.h:461
uint64_t user_id_t
Definition: lldb-types.h:82
std::weak_ptr< lldb_private::Target > TargetWP
Definition: lldb-forward.h:440
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: Type.h:38
A type-erased pair of llvm::dwarf::SourceLanguageName and version.