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