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/Attr.h"
26#include "clang/AST/Decl.h"
27#include "clang/AST/TemplateBase.h"
28#include "clang/AST/Type.h"
29#include "clang/Basic/TargetInfo.h"
30#include "llvm/ADT/APSInt.h"
31#include "llvm/ADT/SmallVector.h"
32
38#include "lldb/Target/Target.h"
40#include "lldb/Utility/Flags.h"
41#include "lldb/Utility/Log.h"
43
45class PDBASTParser;
46
47namespace clang {
48class FileManager;
49class HeaderSearch;
50class HeaderSearchOptions;
51class ModuleMap;
52} // namespace clang
53
54namespace lldb_private {
55
56class ClangASTSource;
57class Declaration;
58
59/// A Clang module ID.
61 unsigned m_id = 0;
62
63public:
65 explicit OptionalClangModuleID(unsigned id) : m_id(id) {}
66 bool HasValue() const { return m_id != 0; }
67 unsigned GetValue() const { return m_id; }
68};
69
70/// The implementation of lldb::Type's m_payload field for TypeSystemClang.
72 /// The payload is used for typedefs and ptrauth types.
73 /// For typedefs, the Layout is as follows:
74 /// \verbatim
75 /// bit 0..30 ... Owning Module ID.
76 /// bit 31 ...... IsCompleteObjCClass.
77 /// \endverbatim
78 /// For ptrauth types, we store the PointerAuthQualifier as an opaque value.
80
81public:
82 TypePayloadClang() = default;
83 explicit TypePayloadClang(OptionalClangModuleID owning_module,
84 bool is_complete_objc_class = false);
85 explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
86 operator Type::Payload() { return m_payload; }
87
88 static constexpr unsigned ObjCClassBit = 1 << 31;
90 void SetIsCompleteObjCClass(bool is_complete_objc_class) {
91 m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
93 }
98 /// \}
99};
100
101/// A TypeSystem implementation based on Clang.
102///
103/// This class uses a single clang::ASTContext as the backend for storing
104/// its types and declarations. Every clang::ASTContext should also just have
105/// a single associated TypeSystemClang instance that manages it.
106///
107/// The clang::ASTContext instance can either be created by TypeSystemClang
108/// itself or it can adopt an existing clang::ASTContext (for example, when
109/// it is necessary to provide a TypeSystem interface for an existing
110/// clang::ASTContext that was created by clang::CompilerInstance).
112 // LLVM RTTI support
113 static char ID;
114
115public:
116 typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
117 typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
118 clang::ObjCInterfaceDecl *);
119
120 // llvm casting support
121 bool isA(const void *ClassID) const override { return ClassID == &ID; }
122 static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
123
124 /// Constructs a TypeSystemClang with an ASTContext using the given triple.
125 ///
126 /// \param name The name for the TypeSystemClang (for logging purposes)
127 /// \param triple The llvm::Triple used for the ASTContext. The triple defines
128 /// certain characteristics of the ASTContext and its types
129 /// (e.g., whether certain primitive types exist or what their
130 /// signedness is).
131 explicit TypeSystemClang(llvm::StringRef name, llvm::Triple triple);
132
133 /// Constructs a TypeSystemClang that uses an existing ASTContext internally.
134 /// Useful when having an existing ASTContext created by Clang.
135 ///
136 /// \param name The name for the TypeSystemClang (for logging purposes)
137 /// \param existing_ctxt An existing ASTContext.
138 explicit TypeSystemClang(llvm::StringRef name,
139 clang::ASTContext &existing_ctxt);
140
141 ~TypeSystemClang() override;
142
143 void Finalize() override;
144
145 // PluginInterface functions
146 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
147
148 static llvm::StringRef GetPluginNameStatic() { return "clang"; }
149
151 Module *module, Target *target);
152
155
156 static void Initialize();
157
158 static void Terminate();
159
160 static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
161
162 /// Returns the display name of this TypeSystemClang that indicates what
163 /// purpose it serves in LLDB. Used for example in logs.
164 llvm::StringRef getDisplayName() const { return m_display_name; }
165
166 /// Returns the clang::ASTContext instance managed by this TypeSystemClang.
167 clang::ASTContext &getASTContext() const;
168
169 clang::MangleContext *getMangleContext();
170
171 std::shared_ptr<clang::TargetOptions> &getTargetOptions();
172
173 clang::TargetInfo *getTargetInfo();
174
175 void setSema(clang::Sema *s);
176 clang::Sema *getSema() { return m_sema; }
177
178 const char *GetTargetTriple();
179
181 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_sp);
182
183 bool GetCompleteDecl(clang::Decl *decl) {
185 }
186
187 static void DumpDeclHiearchy(clang::Decl *decl);
188
189 static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx);
190
191 static bool GetCompleteDecl(clang::ASTContext *ast, clang::Decl *decl);
192
193 void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id);
194 void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id);
195
196 void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data);
197
198 void SetMetadata(const clang::Type *object, ClangASTMetadata meta_data);
199 std::optional<ClangASTMetadata> GetMetadata(const clang::Decl *object);
200 std::optional<ClangASTMetadata> GetMetadata(const clang::Type *object);
201
202 void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object,
203 clang::AccessSpecifier access);
204 clang::AccessSpecifier
205 GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object);
206
207 // Basic Types
209 size_t bit_size) override;
210
212
213 static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name);
214
216 GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name,
217 uint32_t dw_ate, uint32_t bit_size);
218
219 CompilerType GetCStringType(bool is_const);
220
221 static clang::DeclContext *GetDeclContextForType(clang::QualType type);
222
223 static clang::DeclContext *GetDeclContextForType(const CompilerType &type);
224
226 GetCompilerDeclContextForType(const CompilerType &type) override;
227
228 uint32_t GetPointerByteSize() override;
229
230 clang::TranslationUnitDecl *GetTranslationUnitDecl() {
231 return getASTContext().getTranslationUnitDecl();
232 }
233
234 static bool AreTypesSame(CompilerType type1, CompilerType type2,
235 bool ignore_qualifiers = false);
236
237 /// Creates a CompilerType from the given QualType with the current
238 /// TypeSystemClang instance as the CompilerType's typesystem.
239 /// \param qt The QualType for a type that belongs to the ASTContext of this
240 /// TypeSystemClang.
241 /// \return The CompilerType representing the given QualType. If the
242 /// QualType's type pointer is a nullptr then the function returns an
243 /// invalid CompilerType.
244 CompilerType GetType(clang::QualType qt) {
245 if (qt.getTypePtrOrNull() == nullptr)
246 return CompilerType();
247 // Check that the type actually belongs to this TypeSystemClang.
248 assert(qt->getAsTagDecl() == nullptr ||
249 &qt->getAsTagDecl()->getASTContext() == &getASTContext());
250 return CompilerType(weak_from_this(), qt.getAsOpaquePtr());
251 }
252
253 CompilerType GetTypeForDecl(clang::NamedDecl *decl);
254
255 CompilerType GetTypeForDecl(clang::TagDecl *decl);
256
257 CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
258
259 CompilerType GetTypeForDecl(clang::ValueDecl *value_decl);
260
261 template <typename RecordDeclType>
263 GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name,
264 clang::DeclContext *decl_context = nullptr) {
265 CompilerType compiler_type;
266 if (type_name.empty())
267 return compiler_type;
268
269 clang::ASTContext &ast = getASTContext();
270 if (!decl_context)
271 decl_context = ast.getTranslationUnitDecl();
272
273 clang::IdentifierInfo &myIdent = ast.Idents.get(type_name);
274 clang::DeclarationName myName =
275 ast.DeclarationNames.getIdentifier(&myIdent);
276 clang::DeclContext::lookup_result result = decl_context->lookup(myName);
277 if (result.empty())
278 return compiler_type;
279
280 clang::NamedDecl *named_decl = *result.begin();
281 if (const auto *type_decl = llvm::dyn_cast<clang::TypeDecl>(named_decl);
282 llvm::isa_and_nonnull<RecordDeclType>(type_decl))
283 compiler_type = CompilerType(
284 weak_from_this(), Ctx.getTypeDeclType(type_decl).getAsOpaquePtr());
285
286 return compiler_type;
287 }
288
290 llvm::StringRef type_name,
291 const std::initializer_list<std::pair<const char *, CompilerType>>
292 &type_fields,
293 bool packed = false);
294
296 llvm::StringRef type_name,
297 const std::initializer_list<std::pair<const char *, CompilerType>>
298 &type_fields,
299 bool packed = false);
300
301 static bool IsOperator(llvm::StringRef name,
302 clang::OverloadedOperatorKind &op_kind);
303
304 // Structure, Unions, Classes
305
306 static clang::AccessSpecifier
308
309 static clang::AccessSpecifier
310 UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
311
312 uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
313 bool omit_empty_base_classes);
314
315 uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl,
316 clang::NamedDecl *canonical_decl,
317 bool omit_empty_base_classes);
318
319 uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
320 const clang::CXXBaseSpecifier *base_spec,
321 bool omit_empty_base_classes);
322
323 /// Synthesize a clang::Module and return its ID or a default-constructed ID.
326 bool is_framework = false,
327 bool is_explicit = false);
328
330 CreateRecordType(clang::DeclContext *decl_ctx,
331 OptionalClangModuleID owning_module,
332 lldb::AccessType access_type, llvm::StringRef name, int kind,
333 lldb::LanguageType language,
334 std::optional<ClangASTMetadata> metadata = std::nullopt,
335 bool exports_symbols = false);
336
338 public:
340 TemplateParameterInfos(llvm::ArrayRef<const char *> names_in,
341 llvm::ArrayRef<clang::TemplateArgument> args_in)
342 : names(names_in), args(args_in) {
343 assert(names.size() == args_in.size());
344 }
345
348
351
353
354 bool IsValid() const {
355 // Having a pack name but no packed args doesn't make sense, so mark
356 // these template parameters as invalid.
357 if (pack_name && !packed_args)
358 return false;
359 return args.size() == names.size() &&
360 (!packed_args || !packed_args->packed_args);
361 }
362
363 bool IsEmpty() const { return args.empty(); }
364 size_t Size() const { return args.size(); }
365
366 llvm::ArrayRef<clang::TemplateArgument> GetArgs() const { return args; }
367 llvm::ArrayRef<const char *> GetNames() const { return names; }
368
369 clang::TemplateArgument const &Front() const {
370 assert(!args.empty());
371 return args.front();
372 }
373
374 void InsertArg(char const *name, clang::TemplateArgument arg) {
375 args.emplace_back(std::move(arg));
376 names.push_back(name);
377 }
378
379 // Parameter pack related
380
381 bool hasParameterPack() const { return static_cast<bool>(packed_args); }
382
384 assert(packed_args != nullptr);
385 return *packed_args;
386 }
387
389 assert(packed_args != nullptr);
390 return *packed_args;
391 }
392
393 llvm::ArrayRef<clang::TemplateArgument> GetParameterPackArgs() const {
394 assert(packed_args != nullptr);
395 return packed_args->GetArgs();
396 }
397
398 bool HasPackName() const { return pack_name && pack_name[0]; }
399
400 llvm::StringRef GetPackName() const {
401 assert(HasPackName());
402 return pack_name;
403 }
404
405 void SetPackName(char const *name) { pack_name = name; }
406
407 void SetParameterPack(std::unique_ptr<TemplateParameterInfos> args) {
408 packed_args = std::move(args);
409 }
410
411 private:
412 /// Element 'names[i]' holds the template argument name
413 /// of 'args[i]'
414 llvm::SmallVector<const char *, 2> names;
415 llvm::SmallVector<clang::TemplateArgument, 2> args;
416
417 const char * pack_name = nullptr;
418 std::unique_ptr<TemplateParameterInfos> packed_args;
419 };
420
421 clang::FunctionTemplateDecl *CreateFunctionTemplateDecl(
422 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
423 clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos);
424
426 clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template,
427 const TemplateParameterInfos &infos);
428
429 clang::ClassTemplateDecl *CreateClassTemplateDecl(
430 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
431 lldb::AccessType access_type, llvm::StringRef class_name, int kind,
432 const TemplateParameterInfos &infos);
433
434 clang::TemplateTemplateParmDecl *
435 CreateTemplateTemplateParmDecl(const char *template_name);
436
437 clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
438 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
439 clang::ClassTemplateDecl *class_template_decl, int kind,
440 const TemplateParameterInfos &infos);
441
443 CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *
444 class_template_specialization_decl);
445
446 static clang::DeclContext *
447 GetAsDeclContext(clang::FunctionDecl *function_decl);
448
450 bool is_method, clang::OverloadedOperatorKind op_kind,
451 uint32_t num_params);
452
453 bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size);
454
455 bool RecordHasFields(const clang::RecordDecl *record_decl);
456
457 bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b);
458
460 CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx,
461 OptionalClangModuleID owning_module, bool isInternal,
462 std::optional<ClangASTMetadata> metadata = std::nullopt);
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, llvm::StringRef asm_label);
480
482 CreateFunctionType(const CompilerType &result_type,
483 llvm::ArrayRef<CompilerType> args, bool is_variadic,
484 unsigned type_quals, 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
494
495 // Array Types
496
497 CompilerType CreateArrayType(const CompilerType &element_type,
498 std::optional<size_t> element_count,
499 bool is_vector);
500
501 // Enumeration Types
503 llvm::StringRef name, clang::DeclContext *decl_ctx,
504 OptionalClangModuleID owning_module, const Declaration &decl,
505 const CompilerType &integer_qual_type, bool is_scoped,
506 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind =
507 std::nullopt);
508
509 // Integer type functions
510
511 CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed);
512
513 CompilerType GetPointerSizedIntType(bool is_signed);
514
515 // Floating point functions
516
517 static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast,
518 size_t bit_size);
519
520 // TypeSystem methods
522 PDBASTParser *GetPDBParser() override;
524
525 // TypeSystemClang callbacks for external source lookups.
526 void CompleteTagDecl(clang::TagDecl *);
527
528 void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
529
530 bool LayoutRecordType(
531 const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
532 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
533 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
534 &base_offsets,
535 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
536 &vbase_offsets);
537
538 /// Creates a CompilerDecl from the given Decl with the current
539 /// TypeSystemClang instance as its typesystem.
540 /// The Decl has to come from the ASTContext of this
541 /// TypeSystemClang.
542 CompilerDecl GetCompilerDecl(clang::Decl *decl) {
543 assert(&decl->getASTContext() == &getASTContext() &&
544 "CreateCompilerDecl for Decl from wrong ASTContext?");
545 return CompilerDecl(this, decl);
546 }
547
548 // CompilerDecl override functions
549 ConstString DeclGetName(void *opaque_decl) override;
550
551 ConstString DeclGetMangledName(void *opaque_decl) override;
552
553 CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override;
554
555 CompilerType DeclGetFunctionReturnType(void *opaque_decl) override;
556
557 size_t DeclGetFunctionNumArguments(void *opaque_decl) override;
558
560 size_t arg_idx) override;
561
562 std::vector<lldb_private::CompilerContext>
563 DeclGetCompilerContext(void *opaque_decl) override;
564
565 Scalar DeclGetConstantValue(void *opaque_decl) override;
566
567 CompilerType GetTypeForDecl(void *opaque_decl) override;
568
569 // CompilerDeclContext override functions
570
571 /// Creates a CompilerDeclContext from the given DeclContext
572 /// with the current TypeSystemClang instance as its typesystem.
573 /// The DeclContext has to come from the ASTContext of this
574 /// TypeSystemClang.
575 CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
576
577 /// Set the owning module for \p decl.
578 static void SetOwningModule(clang::Decl *decl,
579 OptionalClangModuleID owning_module);
580
581 std::vector<CompilerDecl>
582 DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
583 const bool ignore_using_decls) override;
584
585 ConstString DeclContextGetName(void *opaque_decl_ctx) override;
586
587 ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override;
588
589 bool DeclContextIsClassMethod(void *opaque_decl_ctx) override;
590
591 bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
592 void *other_opaque_decl_ctx) override;
593
594 lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override;
595
596 std::vector<lldb_private::CompilerContext>
597 DeclContextGetCompilerContext(void *opaque_decl_ctx) override;
598
599 // Clang specific clang::DeclContext functions
600
601 static clang::DeclContext *
603
604 static clang::ObjCMethodDecl *
606
607 static clang::CXXMethodDecl *
609
610 static clang::FunctionDecl *
612
613 static clang::NamespaceDecl *
615
616 static std::optional<ClangASTMetadata>
618 const clang::Decl *object);
619
620 static clang::ASTContext *
622
623 // Tests
624
625#ifndef NDEBUG
626 bool Verify(lldb::opaque_compiler_type_t type) override;
627#endif
628
630 CompilerType *element_type, uint64_t *size,
631 bool *is_incomplete) override;
632
634 CompilerType *element_type, uint64_t *size) override;
635
637
639
641
642 bool IsCharType(lldb::opaque_compiler_type_t type) override;
643
645
646 bool IsConst(lldb::opaque_compiler_type_t type) override;
647
648 bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length);
649
650 static bool IsCXXClassType(const CompilerType &type);
651
652 bool IsDefined(lldb::opaque_compiler_type_t type) override;
653
654 bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
655 bool &is_complex) override;
656
657 unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override;
660
662
664 CompilerType *base_type_ptr) override;
665
666 size_t
668
670 const size_t index) override;
671
673
675
677 CompilerType *function_pointer_type_ptr) override;
678
680 bool &is_signed) override;
681
683 bool &is_signed) override;
684
686
687 static bool IsObjCClassType(const CompilerType &type);
688
689 static bool IsObjCObjectOrInterfaceType(const CompilerType &type);
690
691 static bool IsObjCObjectPointerType(const CompilerType &type,
692 CompilerType *target_type = nullptr);
693
695
697
699
701 CompilerType *target_type, // Can pass nullptr
702 bool check_cplusplus, bool check_objc) override;
703
705
707 CompilerType *pointee_type) override;
708
710 CompilerType *pointee_type) override;
711
713 CompilerType *pointee_type, bool *is_rvalue) override;
714
715 bool IsScalarType(lldb::opaque_compiler_type_t type) override;
716
718
719 bool IsVoidType(lldb::opaque_compiler_type_t type) override;
720
721 bool CanPassInRegisters(const CompilerType &type) override;
722
723 bool SupportsLanguage(lldb::LanguageType language) override;
724
725 static std::optional<std::string> GetCXXClassName(const CompilerType &type);
726
727 // Type Completion
728
730
732
733 // Accessors
734
736 bool base_only) override;
737
739
741 CompilerType *pointee_or_element_compiler_type) override;
742
745
746 lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
747
748 unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
749
750 // Creating related types
751
753 ExecutionContextScope *exe_scope) override;
754
756 uint64_t size) override;
757
759
762
765
766 // Returns -1 if this isn't a function of if the function doesn't have a
767 // prototype Returns a value >= 0 if there is a prototype.
769
771 size_t idx) override;
772
775
777
780 size_t idx) override;
781
783
785
787
790
793
795
797
799 uint32_t payload) override;
800
802
804
805 /// Using the current type, create a new typedef to that type using
806 /// "typedef_name" as the name and "decl_ctx" as the decl context.
807 /// \param opaque_payload is an opaque TypePayloadClang.
809 const char *name,
810 const CompilerDeclContext &decl_ctx,
811 uint32_t opaque_payload) override;
812
813 // If the current object represents a typedef type, get the underlying type
815
816 // Create related types using the current type's AST
818
819 // Create a generic function prototype that can be used in ValuObject types
820 // to correctly display a function pointer with the right value and summary.
822
823 // Exploring the type
824
825 const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size,
826 lldb::Format format) override;
827
828 llvm::Expected<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
829 ExecutionContextScope *exe_scope) {
830 auto bit_size_or_err = GetBitSize(type, exe_scope);
831 if (!bit_size_or_err)
832 return bit_size_or_err.takeError();
833 return (*bit_size_or_err + 7) / 8;
834 }
835
836 llvm::Expected<uint64_t>
838 ExecutionContextScope *exe_scope) override;
839
841 uint64_t &count) override;
842
844
845 std::optional<size_t>
847 ExecutionContextScope *exe_scope) override;
848
849 llvm::Expected<uint32_t>
851 bool omit_empty_base_classes,
852 const ExecutionContext *exe_ctx) override;
853
855
858
861 std::function<bool(const CompilerType &integer_type,
862 ConstString name,
863 const llvm::APSInt &value)> const &callback) override;
864
865 uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
866
868 std::string &name, uint64_t *bit_offset_ptr,
869 uint32_t *bitfield_bit_size_ptr,
870 bool *is_bitfield_ptr) override;
871
873
875
877 size_t idx,
878 uint32_t *bit_offset_ptr) override;
879
881 size_t idx,
882 uint32_t *bit_offset_ptr) override;
883
885 llvm::StringRef name) override;
886
887 static uint32_t GetNumPointeeChildren(clang::QualType type);
888
889 llvm::Expected<CompilerType>
891 ExecutionContext *exe_ctx, std::string &deref_name,
892 uint32_t &deref_byte_size, int32_t &deref_byte_offset,
893 ValueObject *valobj, uint64_t &language_flags) override;
894
895 llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
896 lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
897 bool transparent_pointers, bool omit_empty_base_classes,
898 bool ignore_array_bounds, std::string &child_name,
899 uint32_t &child_byte_size, int32_t &child_byte_offset,
900 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
901 bool &child_is_base_class, bool &child_is_deref_of_parent,
902 ValueObject *valobj, uint64_t &language_flags) override;
903
904 // Lookup a child given a name. This function will match base class names and
905 // member member names in "clang_type" only, not descendants.
906 llvm::Expected<uint32_t>
908 llvm::StringRef name,
909 bool omit_empty_base_classes) override;
910
911 // Lookup a child member given a name. This function will match member names
912 // only and will descend into "clang_type" children in search for the first
913 // member in this class, or any base class that matches "name".
914 // TODO: Return all matches for a given name by returning a
915 // vector<vector<uint32_t>>
916 // so we catch all names that match a given child name, not just the first.
917 size_t
919 llvm::StringRef name,
920 bool omit_empty_base_classes,
921 std::vector<uint32_t> &child_indexes) override;
922
924 llvm::StringRef name) override;
925
927
929 bool expand_pack) override;
930
933 bool expand_pack) override;
935 size_t idx, bool expand_pack) override;
936 std::optional<CompilerType::IntegralTemplateArgument>
938 bool expand_pack) override;
939
940 CompilerType GetTypeForFormatters(void *type) override;
941
942#define LLDB_INVALID_DECL_LEVEL UINT32_MAX
943 // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx
944 // could not be found in decl_ctx.
945 uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx,
946 clang::DeclContext *child_decl_ctx,
947 ConstString *child_name = nullptr,
948 CompilerType *child_type = nullptr);
949
950 // Modifying RecordType
951 static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
952 llvm::StringRef name,
953 const CompilerType &field_type,
954 lldb::AccessType access,
955 uint32_t bitfield_bit_size);
956
957 static void BuildIndirectFields(const CompilerType &type);
958
959 static void SetIsPacked(const CompilerType &type);
960
961 static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
962 llvm::StringRef name,
963 const CompilerType &var_type,
964 lldb::AccessType access);
965
966 /// Initializes a variable with an integer value.
967 /// \param var The variable to initialize. Must not already have an
968 /// initializer and must have an integer or enum type.
969 /// \param init_value The integer value that the variable should be
970 /// initialized to. Has to match the bit width of the
971 /// variable type.
972 static void SetIntegerInitializerForVariable(clang::VarDecl *var,
973 const llvm::APInt &init_value);
974
975 /// Initializes a variable with a floating point value.
976 /// \param var The variable to initialize. Must not already have an
977 /// initializer and must have a floating point type.
978 /// \param init_value The float value that the variable should be
979 /// initialized to.
980 static void
981 SetFloatingInitializerForVariable(clang::VarDecl *var,
982 const llvm::APFloat &init_value);
983
984 /// For each parameter type of \c prototype, creates a \c clang::ParmVarDecl
985 /// whose \c clang::DeclContext is \c context.
986 ///
987 /// \param[in] context Non-null \c clang::FunctionDecl which will be the \c
988 /// clang::DeclContext of each parameter created/returned by this function.
989 /// \param[in] prototype The \c clang::FunctionProtoType of \c context.
990 /// \param[in] param_names The ith element of this vector contains the name
991 /// of the ith parameter. This parameter may be unnamed, in which case the
992 /// ith entry in \c param_names is an empty string. This vector is either
993 /// empty, or will have an entry for *each* parameter of the prototype
994 /// regardless of whether a parameter is unnamed or not.
995 ///
996 /// \returns A list of newly created of non-null \c clang::ParmVarDecl (one
997 /// for each parameter of \c prototype).
998 llvm::SmallVector<clang::ParmVarDecl *> CreateParameterDeclarations(
999 clang::FunctionDecl *context, const clang::FunctionProtoType &prototype,
1000 const llvm::SmallVector<llvm::StringRef> &param_names);
1001
1002 clang::CXXMethodDecl *AddMethodToCXXRecordType(
1003 lldb::opaque_compiler_type_t type, llvm::StringRef name,
1004 llvm::StringRef asm_label, const CompilerType &method_type,
1005 lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
1006 bool is_explicit, bool is_attr_used, bool is_artificial);
1007
1009
1010 // C++ Base Classes
1011 std::unique_ptr<clang::CXXBaseSpecifier>
1013 lldb::AccessType access, bool is_virtual,
1014 bool base_of_class);
1015
1018 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases);
1019
1020 static bool SetObjCSuperClass(const CompilerType &type,
1021 const CompilerType &superclass_compiler_type);
1022
1023 static bool AddObjCClassProperty(const CompilerType &type,
1024 const char *property_name,
1025 const CompilerType &property_compiler_type,
1026 clang::ObjCIvarDecl *ivar_decl,
1027 const char *property_setter_name,
1028 const char *property_getter_name,
1029 uint32_t property_attributes,
1030 ClangASTMetadata metadata);
1031
1032 static clang::ObjCMethodDecl *AddMethodToObjCObjectType(
1033 const CompilerType &type,
1034 const char *name, // the full symbol name as seen in the symbol table
1035 // (lldb::opaque_compiler_type_t type, "-[NString
1036 // stringWithCString:]")
1037 const CompilerType &method_compiler_type, bool is_artificial,
1038 bool is_variadic, bool is_objc_direct_call);
1039
1041 bool has_extern);
1042
1043 // Tag Declarations
1044 static bool StartTagDeclarationDefinition(const CompilerType &type);
1045
1046 static bool CompleteTagDeclarationDefinition(const CompilerType &type);
1047
1048 // Modifying Enumeration types
1049 clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
1050 const CompilerType &enum_type, const Declaration &decl, const char *name,
1051 uint64_t enum_value, uint32_t enum_value_bit_size);
1052 clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
1053 const CompilerType &enum_type, const Declaration &decl, const char *name,
1054 const llvm::APSInt &value);
1055
1056 /// Returns the underlying integer type for an enum type. If the given type
1057 /// is invalid or not an enum-type, the function returns an invalid
1058 /// CompilerType.
1059 CompilerType GetEnumerationIntegerType(CompilerType type);
1060
1061 // Pointers & References
1062
1063 // Call this function using the class type when you want to make a member
1064 // pointer type to pointee_type.
1065 static CompilerType CreateMemberPointerType(const CompilerType &type,
1066 const CompilerType &pointee_type);
1067
1068 // Dumping types
1069#ifndef NDEBUG
1070 /// Convenience LLVM-style dump method for use in the debugger only.
1071 /// In contrast to the other \p Dump() methods this directly invokes
1072 /// \p clang::QualType::dump().
1073 LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
1074#endif
1075
1076 /// \see lldb_private::TypeSystem::Dump
1077 void Dump(llvm::raw_ostream &output, llvm::StringRef filter,
1078 bool show_color) override;
1079
1080 /// Dump clang AST types from the symbol file.
1081 ///
1082 /// \param[in] s
1083 /// A stream to send the dumped AST node(s) to
1084 /// \param[in] symbol_name
1085 /// The name of the symbol to dump, if it is empty dump all the symbols
1086 void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
1087
1089 lldb::Format format, const DataExtractor &data,
1090 lldb::offset_t data_offset, size_t data_byte_size,
1091 uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
1092 ExecutionContextScope *exe_scope) override;
1093
1097
1101
1102 static void DumpTypeName(const CompilerType &type);
1103
1104 static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type);
1105
1106 static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type);
1107
1108 static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
1109
1110 static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type);
1111
1112 static clang::CXXRecordDecl *
1114
1115 static clang::ObjCInterfaceDecl *
1116 GetAsObjCInterfaceDecl(const CompilerType &type);
1117
1118 clang::ClassTemplateDecl *ParseClassTemplateDecl(
1119 clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
1120 lldb::AccessType access_type, const char *parent_name, int tag_decl_kind,
1121 const TypeSystemClang::TemplateParameterInfos &template_param_infos);
1122
1123 clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx,
1124 OptionalClangModuleID owning_module);
1125
1126 clang::UsingDirectiveDecl *
1127 CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
1128 OptionalClangModuleID owning_module,
1129 clang::NamespaceDecl *ns_decl);
1130
1131 clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
1132 OptionalClangModuleID owning_module,
1133 clang::NamedDecl *target);
1134
1135 clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
1136 OptionalClangModuleID owning_module,
1137 const char *name,
1138 clang::QualType type);
1139
1141 GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
1142
1143 static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) {
1144 if (type)
1145 return clang::QualType::getFromOpaquePtr(type);
1146 return clang::QualType();
1147 }
1148
1149 static clang::QualType
1151 if (type)
1152 return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
1153 return clang::QualType();
1154 }
1155
1156 clang::DeclarationName
1157 GetDeclarationName(llvm::StringRef name,
1158 const CompilerType &function_clang_type);
1159
1160 clang::LangOptions *GetLangOpts() const {
1161 return m_language_options_up.get();
1162 }
1163 clang::SourceManager *GetSourceMgr() const {
1164 return m_source_manager_up.get();
1165 }
1166
1167 /// Complete a type from debug info, or mark it as forcefully completed if
1168 /// there is no definition of the type in the current Module. Call this
1169 /// function in contexts where the usual C++ rules require a type to be
1170 /// complete (base class, member, etc.).
1171 static void RequireCompleteType(CompilerType type);
1172
1173 bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td);
1174
1175private:
1176 /// Returns the PrintingPolicy used when generating the internal type names.
1177 /// These type names are mostly used for the formatter selection.
1178 clang::PrintingPolicy GetTypePrintingPolicy();
1179 /// Returns the internal type name for the given NamedDecl using the
1180 /// type printing policy.
1181 std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl,
1182 bool qualified = true);
1183
1184 const clang::ClassTemplateSpecializationDecl *
1186
1188 llvm::function_ref<bool(clang::QualType)> predicate) const;
1189
1190 /// Emits information about this TypeSystem into the expression log.
1191 ///
1192 /// Helper method that is used in \ref TypeSystemClang::TypeSystemClang
1193 /// on creation of a new instance.
1194 void LogCreation() const;
1195
1196 llvm::Expected<uint64_t> GetObjCBitSize(clang::QualType qual_type,
1197 ExecutionContextScope *exe_scope);
1198
1199 // Classes that inherit from TypeSystemClang can see and modify these
1200 std::string m_target_triple;
1201 std::unique_ptr<clang::ASTContext> m_ast_up;
1202 std::unique_ptr<clang::LangOptions> m_language_options_up;
1203 std::unique_ptr<clang::FileManager> m_file_manager_up;
1204 std::unique_ptr<clang::SourceManager> m_source_manager_up;
1205 std::unique_ptr<clang::DiagnosticOptions> m_diagnostic_options_up;
1206 std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
1207 std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
1208 std::shared_ptr<clang::TargetOptions> m_target_options_rp;
1209 std::unique_ptr<clang::TargetInfo> m_target_info_up;
1210 std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
1211 std::unique_ptr<clang::SelectorTable> m_selector_table_up;
1212 std::unique_ptr<clang::Builtin::Context> m_builtins_up;
1213 std::unique_ptr<clang::HeaderSearchOptions> m_header_search_opts_up;
1214 std::unique_ptr<clang::HeaderSearch> m_header_search_up;
1215 std::unique_ptr<clang::ModuleMap> m_module_map_up;
1216 std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
1217 std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
1218 std::unique_ptr<npdb::PdbAstBuilder> m_native_pdb_ast_parser_up;
1219 std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
1221 bool m_ast_owned = false;
1222 /// A string describing what this TypeSystemClang represents (e.g.,
1223 /// AST for debug information, an expression, some other utility ClangAST).
1224 /// Useful for logging and debugging.
1225 std::string m_display_name;
1226
1227 typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap;
1228 /// Maps Decls to their associated ClangASTMetadata.
1230
1231 typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap;
1232 /// Maps Types to their associated ClangASTMetadata.
1234
1235 typedef llvm::DenseMap<const clang::CXXRecordDecl *, clang::AccessSpecifier>
1237 /// Maps CXXRecordDecl to their most recent added method/field's
1238 /// AccessSpecifier.
1240
1241 /// The sema associated that is currently used to build this ASTContext.
1242 /// May be null if we are already done parsing this ASTContext or the
1243 /// ASTContext wasn't created by parsing source code.
1244 clang::Sema *m_sema = nullptr;
1245
1246 // For TypeSystemClang only
1249 /// Creates the internal ASTContext.
1250 void CreateASTContext();
1251 void SetTargetTriple(llvm::StringRef target_triple);
1252};
1253
1254/// The TypeSystemClang instance used for the scratch ASTContext in a
1255/// lldb::Target.
1257 /// LLVM RTTI support
1258 static char ID;
1259
1260public:
1261 ScratchTypeSystemClang(Target &target, llvm::Triple triple);
1262
1263 ~ScratchTypeSystemClang() override = default;
1264
1265 void Finalize() override;
1266
1267 /// The different kinds of isolated ASTs within the scratch TypeSystem.
1268 ///
1269 /// These ASTs are isolated from the main scratch AST and are each
1270 /// dedicated to a special language option/feature that makes the contained
1271 /// AST nodes incompatible with other AST nodes.
1273 /// The isolated AST for declarations/types from expressions that imported
1274 /// type information from a C++ module. The templates from a C++ module
1275 /// often conflict with the templates we generate from debug information,
1276 /// so we put these types in their own AST.
1278 };
1279
1280 /// Alias for requesting the default scratch TypeSystemClang in GetForTarget.
1281 // This isn't constexpr as gtest/std::optional comparison logic is trying
1282 // to get the address of this for pretty-printing.
1283 static const std::nullopt_t DefaultAST;
1284
1285 /// Infers the appropriate sub-AST from Clang's LangOptions.
1286 static std::optional<IsolatedASTKind>
1287 InferIsolatedASTKindFromLangOpts(const clang::LangOptions &l) {
1288 // If modules are activated we want the dedicated C++ module AST.
1289 // See IsolatedASTKind::CppModules for more info.
1290 if (l.Modules)
1292 return DefaultAST;
1293 }
1294
1295 /// Returns the scratch TypeSystemClang for the given target.
1296 /// \param target The Target which scratch TypeSystemClang should be returned.
1297 /// \param ast_kind Allows requesting a specific sub-AST instead of the
1298 /// default scratch AST. See also `IsolatedASTKind`.
1299 /// \param create_on_demand If the scratch TypeSystemClang instance can be
1300 /// created by this call if it doesn't exist yet. If it doesn't exist yet and
1301 /// this parameter is false, this function returns a nullptr.
1302 /// \return The scratch type system of the target or a nullptr in case an
1303 /// error occurred.
1305 GetForTarget(Target &target,
1306 std::optional<IsolatedASTKind> ast_kind = DefaultAST,
1307 bool create_on_demand = true);
1308
1309 /// Returns the scratch TypeSystemClang for the given target. The returned
1310 /// TypeSystemClang will be the scratch AST or a sub-AST, depending on which
1311 /// fits best to the passed LangOptions.
1312 /// \param target The Target which scratch TypeSystemClang should be returned.
1313 /// \param lang_opts The LangOptions of a clang ASTContext that the caller
1314 /// wants to export type information from. This is used to
1315 /// find the best matching sub-AST that will be returned.
1317 GetForTarget(Target &target, const clang::LangOptions &lang_opts) {
1318 return GetForTarget(target, InferIsolatedASTKindFromLangOpts(lang_opts));
1319 }
1320
1321 /// \see lldb_private::TypeSystem::Dump
1322 void Dump(llvm::raw_ostream &output, llvm::StringRef filter,
1323 bool show_color) override;
1324
1325 UserExpression *GetUserExpression(llvm::StringRef expr,
1326 llvm::StringRef prefix,
1327 SourceLanguage language,
1328 Expression::ResultType desired_type,
1329 const EvaluateExpressionOptions &options,
1330 ValueObject *ctx_obj) override;
1331
1332 FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
1333 const Address &function_address,
1334 const ValueList &arg_value_list,
1335 const char *name) override;
1336
1337 std::unique_ptr<UtilityFunction>
1338 CreateUtilityFunction(std::string text, std::string name) override;
1339
1341
1342 /// Unregisters the given ASTContext as a source from the scratch AST (and
1343 /// all sub-ASTs).
1344 /// \see ClangASTImporter::ForgetSource
1345 void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer);
1346
1347 // llvm casting support
1348 bool isA(const void *ClassID) const override {
1349 return ClassID == &ID || TypeSystemClang::isA(ClassID);
1350 }
1351 static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
1352
1353private:
1354 std::unique_ptr<ClangASTSource> CreateASTSource();
1355 /// Returns the requested sub-AST.
1356 /// Will lazily create the sub-AST if it hasn't been created before.
1358
1359 /// The target triple.
1360 /// This was potentially adjusted and might not be identical to the triple
1361 /// of `m_target_wp`.
1362 llvm::Triple m_triple;
1364 /// The persistent variables associated with this process for the expression
1365 /// parser.
1366 std::unique_ptr<ClangPersistentVariables> m_persistent_variables;
1367 /// The ExternalASTSource that performs lookups and completes minimally
1368 /// imported types.
1369 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
1370
1371 // FIXME: GCC 5.x doesn't support enum as map keys.
1372 typedef int IsolatedASTKey;
1373
1374 /// Map from IsolatedASTKind to their actual TypeSystemClang instance.
1375 /// This map is lazily filled with sub-ASTs and should be accessed via
1376 /// `GetSubAST` (which lazily fills this map).
1377 llvm::DenseMap<IsolatedASTKey, std::shared_ptr<TypeSystemClang>>
1379};
1380
1381} // namespace lldb_private
1382
1383#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.
Provider for named objects defined in the debug info for Clang.
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
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:90
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...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
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)
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
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()
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
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,...
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.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
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)
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
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)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_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
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(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
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)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
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
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
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
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)
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
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
void(* CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
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
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
bool isA(const void *ClassID) const override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
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()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
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)
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)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > &param_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
clang::SourceManager * GetSourceMgr() const
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
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.
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 std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
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
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
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 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)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
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)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType GetTypeForDecl(clang::TagDecl *decl)
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
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
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) 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
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 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
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, 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 bool IsObjCObjectOrInterfaceType(const CompilerType &type)
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.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) 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
llvm::Expected< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
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:570
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
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
uint64_t user_id_t
Definition lldb-types.h:82
std::weak_ptr< lldb_private::Target > TargetWP
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.