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 <stdint.h>
13 
14 #include <functional>
15 #include <initializer_list>
16 #include <map>
17 #include <memory>
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/TemplateBase.h"
26 #include "clang/Basic/TargetInfo.h"
27 #include "llvm/ADT/APSInt.h"
28 #include "llvm/ADT/SmallVector.h"
29 
33 #include "lldb/Symbol/TypeSystem.h"
34 #include "lldb/Target/Target.h"
36 #include "lldb/Utility/Flags.h"
37 #include "lldb/Utility/Log.h"
38 #include "lldb/Utility/Logging.h"
39 #include "lldb/lldb-enumerations.h"
40 
42 class PDBASTParser;
43 
44 namespace clang {
45 class FileManager;
46 class HeaderSearch;
47 class ModuleMap;
48 } // namespace clang
49 
50 namespace lldb_private {
51 
52 class ClangASTMetadata;
53 class ClangASTSource;
54 class Declaration;
55 
56 /// A Clang module ID.
58  unsigned m_id = 0;
59 
60 public:
61  OptionalClangModuleID() = default;
62  explicit OptionalClangModuleID(unsigned id) : m_id(id) {}
63  bool HasValue() const { return m_id != 0; }
64  unsigned GetValue() const { return m_id; }
65 };
66 
67 /// The implementation of lldb::Type's m_payload field for TypeSystemClang.
69  /// The Layout is as follows:
70  /// \verbatim
71  /// bit 0..30 ... Owning Module ID.
72  /// bit 31 ...... IsCompleteObjCClass.
73  /// \endverbatim
74  Type::Payload m_payload = 0;
75 
76 public:
77  TypePayloadClang() = default;
78  explicit TypePayloadClang(OptionalClangModuleID owning_module,
79  bool is_complete_objc_class = false);
80  explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
81  operator Type::Payload() { return m_payload; }
82 
83  static constexpr unsigned ObjCClassBit = 1 << 31;
84  bool IsCompleteObjCClass() { return Flags(m_payload).Test(ObjCClassBit); }
85  void SetIsCompleteObjCClass(bool is_complete_objc_class) {
86  m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
87  : Flags(m_payload).Clear(ObjCClassBit);
88  }
90  return OptionalClangModuleID(Flags(m_payload).Clear(ObjCClassBit));
91  }
92  void SetOwningModule(OptionalClangModuleID id);
93  /// \}
94 };
95 
96 /// A TypeSystem implementation based on Clang.
97 ///
98 /// This class uses a single clang::ASTContext as the backend for storing
99 /// its types and declarations. Every clang::ASTContext should also just have
100 /// a single associated TypeSystemClang instance that manages it.
101 ///
102 /// The clang::ASTContext instance can either be created by TypeSystemClang
103 /// itself or it can adopt an existing clang::ASTContext (for example, when
104 /// it is necessary to provide a TypeSystem interface for an existing
105 /// clang::ASTContext that was created by clang::CompilerInstance).
106 class TypeSystemClang : public TypeSystem {
107  // LLVM RTTI support
108  static char ID;
109 
110 public:
111  typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *);
112  typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
113  clang::ObjCInterfaceDecl *);
114 
115  // llvm casting support
116  bool isA(const void *ClassID) const override { return ClassID == &ID; }
117  static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
118 
119  /// Constructs a TypeSystemClang with an ASTContext using the given triple.
120  ///
121  /// \param name The name for the TypeSystemClang (for logging purposes)
122  /// \param triple The llvm::Triple used for the ASTContext. The triple defines
123  /// certain characteristics of the ASTContext and its types
124  /// (e.g., whether certain primitive types exist or what their
125  /// signedness is).
126  explicit TypeSystemClang(llvm::StringRef name, llvm::Triple triple);
127 
128  /// Constructs a TypeSystemClang that uses an existing ASTContext internally.
129  /// Useful when having an existing ASTContext created by Clang.
130  ///
131  /// \param name The name for the TypeSystemClang (for logging purposes)
132  /// \param existing_ctxt An existing ASTContext.
133  explicit TypeSystemClang(llvm::StringRef name,
134  clang::ASTContext &existing_ctxt);
135 
136  ~TypeSystemClang() override;
137 
138  void Finalize() override;
139 
140  // PluginInterface functions
141  ConstString GetPluginName() override;
142 
143  uint32_t GetPluginVersion() override;
144 
145  static ConstString GetPluginNameStatic();
146 
147  static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
148  Module *module, Target *target);
149 
150  static LanguageSet GetSupportedLanguagesForTypes();
151  static LanguageSet GetSupportedLanguagesForExpressions();
152 
153  static void Initialize();
154 
155  static void Terminate();
156 
157  static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
158 
160  bool create_on_demand = true) {
161  auto type_system_or_err = target.GetScratchTypeSystemForLanguage(
162  lldb::eLanguageTypeC, create_on_demand);
163  if (auto err = type_system_or_err.takeError()) {
165  std::move(err), "Couldn't get scratch TypeSystemClang");
166  return nullptr;
167  }
168  return llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
169  }
170 
171  /// Returns the display name of this TypeSystemClang that indicates what
172  /// purpose it serves in LLDB. Used for example in logs.
173  llvm::StringRef getDisplayName() const { return m_display_name; }
174 
175  /// Returns the clang::ASTContext instance managed by this TypeSystemClang.
176  clang::ASTContext &getASTContext();
177 
178  clang::MangleContext *getMangleContext();
179 
180  std::shared_ptr<clang::TargetOptions> &getTargetOptions();
181 
182  clang::TargetInfo *getTargetInfo();
183 
184  void setSema(clang::Sema *s);
185  clang::Sema *getSema() { return m_sema; }
186 
187  const char *GetTargetTriple();
188 
189  void SetExternalSource(
190  llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
191 
192  bool GetCompleteDecl(clang::Decl *decl) {
193  return TypeSystemClang::GetCompleteDecl(&getASTContext(), decl);
194  }
195 
196  static void DumpDeclHiearchy(clang::Decl *decl);
197 
198  static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx);
199 
200  static bool DeclsAreEquivalent(clang::Decl *lhs_decl, clang::Decl *rhs_decl);
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  ClangASTMetadata *GetMetadata(const clang::Decl *object);
211  ClangASTMetadata *GetMetadata(const clang::Type *object);
212 
213  // Basic Types
214  CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
215  size_t bit_size) override;
216 
217  CompilerType GetBasicType(lldb::BasicType type);
218 
219  static lldb::BasicType GetBasicTypeEnumeration(ConstString 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 
231  uint32_t GetPointerByteSize() override;
232 
233  clang::TranslationUnitDecl *GetTranslationUnitDecl() {
234  return getASTContext().getTranslationUnitDecl();
235  }
236 
237  static bool AreTypesSame(CompilerType type1, CompilerType type2,
238  bool ignore_qualifiers = false);
239 
240  /// Creates a CompilerType form the given QualType with the current
241  /// TypeSystemClang instance as the CompilerType's typesystem.
242  /// \param qt The QualType for a type that belongs to the ASTContext of this
243  /// TypeSystemClang.
244  /// \return The CompilerType representing the given QualType. If the
245  /// QualType's type pointer is a nullptr then the function returns an
246  /// invalid CompilerType.
247  CompilerType GetType(clang::QualType qt) {
248  if (qt.getTypePtrOrNull() == nullptr)
249  return CompilerType();
250  // Check that the type actually belongs to this TypeSystemClang.
251  assert(qt->getAsTagDecl() == nullptr ||
252  &qt->getAsTagDecl()->getASTContext() == &getASTContext());
253  return CompilerType(this, qt.getAsOpaquePtr());
254  }
255 
256  CompilerType GetTypeForDecl(clang::NamedDecl *decl);
257 
258  CompilerType GetTypeForDecl(clang::TagDecl *decl);
259 
260  CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl);
261 
262  template <typename RecordDeclType>
265  clang::DeclContext *decl_context = nullptr) {
266  CompilerType compiler_type;
267 
268  if (type_name.GetLength()) {
269  clang::ASTContext &ast = getASTContext();
270  if (!decl_context)
271  decl_context = ast.getTranslationUnitDecl();
272 
273  clang::IdentifierInfo &myIdent = ast.Idents.get(type_name.GetCString());
274  clang::DeclarationName myName =
275  ast.DeclarationNames.getIdentifier(&myIdent);
276 
277  clang::DeclContext::lookup_result result = decl_context->lookup(myName);
278 
279  if (!result.empty()) {
280  clang::NamedDecl *named_decl = result[0];
281  if (const RecordDeclType *record_decl =
282  llvm::dyn_cast<RecordDeclType>(named_decl))
283  compiler_type.SetCompilerType(
284  this, clang::QualType(record_decl->getTypeForDecl(), 0)
285  .getAsOpaquePtr());
286  }
287  }
288 
289  return compiler_type;
290  }
291 
292  CompilerType CreateStructForIdentifier(
293  ConstString type_name,
294  const std::initializer_list<std::pair<const char *, CompilerType>>
295  &type_fields,
296  bool packed = false);
297 
298  CompilerType GetOrCreateStructForIdentifier(
299  ConstString type_name,
300  const std::initializer_list<std::pair<const char *, CompilerType>>
301  &type_fields,
302  bool packed = false);
303 
304  static bool IsOperator(llvm::StringRef name,
305  clang::OverloadedOperatorKind &op_kind);
306 
307  // Structure, Unions, Classes
308 
309  static clang::AccessSpecifier
310  ConvertAccessTypeToAccessSpecifier(lldb::AccessType access);
311 
312  static clang::AccessSpecifier
313  UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs);
314 
315  static uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
316  bool omit_empty_base_classes);
317 
318  /// Synthesize a clang::Module and return its ID or a default-constructed ID.
319  OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name,
320  OptionalClangModuleID parent,
321  bool is_framework = false,
322  bool is_explicit = false);
323 
324  CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
325  OptionalClangModuleID owning_module,
326  lldb::AccessType access_type,
327  llvm::StringRef name, int kind,
328  lldb::LanguageType language,
329  ClangASTMetadata *metadata = nullptr,
330  bool exports_symbols = false);
331 
333  public:
334  bool IsValid() const {
335  if (args.empty())
336  return false;
337  return args.size() == names.size() &&
338  ((bool)pack_name == (bool)packed_args) &&
339  (!packed_args || !packed_args->packed_args);
340  }
341 
342  llvm::SmallVector<const char *, 2> names;
343  llvm::SmallVector<clang::TemplateArgument, 2> args;
344 
345  const char * pack_name = nullptr;
346  std::unique_ptr<TemplateParameterInfos> packed_args;
347  };
348 
349  clang::FunctionTemplateDecl *
350  CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx,
351  OptionalClangModuleID owning_module,
352  clang::FunctionDecl *func_decl, const char *name,
353  const TemplateParameterInfos &infos);
354 
355  void CreateFunctionTemplateSpecializationInfo(
356  clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template,
357  const TemplateParameterInfos &infos);
358 
359  clang::ClassTemplateDecl *
360  CreateClassTemplateDecl(clang::DeclContext *decl_ctx,
361  OptionalClangModuleID owning_module,
362  lldb::AccessType access_type, const char *class_name,
363  int kind, const TemplateParameterInfos &infos);
364 
365  clang::TemplateTemplateParmDecl *
366  CreateTemplateTemplateParmDecl(const char *template_name);
367 
368  clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
369  clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
370  clang::ClassTemplateDecl *class_template_decl, int kind,
371  const TemplateParameterInfos &infos);
372 
374  CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *
375  class_template_specialization_decl);
376 
377  static clang::DeclContext *
378  GetAsDeclContext(clang::FunctionDecl *function_decl);
379 
380  static bool CheckOverloadedOperatorKindParameterCount(
381  bool is_method, clang::OverloadedOperatorKind op_kind,
382  uint32_t num_params);
383 
384  bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size);
385 
386  static bool RecordHasFields(const clang::RecordDecl *record_decl);
387 
388  CompilerType CreateObjCClass(llvm::StringRef name,
389  clang::DeclContext *decl_ctx,
390  OptionalClangModuleID owning_module,
391  bool isForwardDecl, bool isInternal,
392  ClangASTMetadata *metadata = nullptr);
393 
394  bool SetTagTypeKind(clang::QualType type, int kind) const;
395 
396  bool SetDefaultAccessForRecordFields(clang::RecordDecl *record_decl,
397  int default_accessibility,
398  int *assigned_accessibilities,
399  size_t num_assigned_accessibilities);
400 
401  // Returns a mask containing bits from the TypeSystemClang::eTypeXXX
402  // enumerations
403 
404  // Namespace Declarations
405 
406  clang::NamespaceDecl *
407  GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx,
408  OptionalClangModuleID owning_module,
409  bool is_inline = false);
410 
411  // Function Types
412 
413  clang::FunctionDecl *
414  CreateFunctionDeclaration(clang::DeclContext *decl_ctx,
415  OptionalClangModuleID owning_module,
416  const char *name, const CompilerType &function_Type,
417  int storage, bool is_inline);
418 
419  CompilerType CreateFunctionType(const CompilerType &result_type,
420  const CompilerType *args, unsigned num_args,
421  bool is_variadic, unsigned type_quals,
422  clang::CallingConv cc);
423 
425  const CompilerType *args, unsigned num_args,
426  bool is_variadic, unsigned type_quals) {
427  return CreateFunctionType(result_type, args, num_args, is_variadic,
428  type_quals, clang::CC_C);
429  }
430 
431  clang::ParmVarDecl *
432  CreateParameterDeclaration(clang::DeclContext *decl_ctx,
433  OptionalClangModuleID owning_module,
434  const char *name, const CompilerType &param_type,
435  int storage, bool add_decl = false);
436 
437  void SetFunctionParameters(clang::FunctionDecl *function_decl,
438  clang::ParmVarDecl **params, unsigned num_params);
439 
440  CompilerType CreateBlockPointerType(const CompilerType &function_type);
441 
442  // Array Types
443 
444  CompilerType CreateArrayType(const CompilerType &element_type,
445  size_t element_count, bool is_vector);
446 
447  // Enumeration Types
448  CompilerType CreateEnumerationType(const char *name,
449  clang::DeclContext *decl_ctx,
450  OptionalClangModuleID owning_module,
451  const Declaration &decl,
452  const CompilerType &integer_qual_type,
453  bool is_scoped);
454 
455  // Integer type functions
456 
457  CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed);
458 
459  CompilerType GetPointerSizedIntType(bool is_signed);
460 
461  // Floating point functions
462 
463  static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast,
464  size_t bit_size);
465 
466  // TypeSystem methods
467  DWARFASTParser *GetDWARFParser() override;
468  PDBASTParser *GetPDBParser() override;
469 
470  // TypeSystemClang callbacks for external source lookups.
471  void CompleteTagDecl(clang::TagDecl *);
472 
473  void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
474 
475  bool LayoutRecordType(
476  const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
477  llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
478  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
479  &base_offsets,
480  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
481  &vbase_offsets);
482 
483  /// Creates a CompilerDecl from the given Decl with the current
484  /// TypeSystemClang instance as its typesystem.
485  /// The Decl has to come from the ASTContext of this
486  /// TypeSystemClang.
487  CompilerDecl GetCompilerDecl(clang::Decl *decl) {
488  assert(&decl->getASTContext() == &getASTContext() &&
489  "CreateCompilerDecl for Decl from wrong ASTContext?");
490  return CompilerDecl(this, decl);
491  }
492 
493  // CompilerDecl override functions
494  ConstString DeclGetName(void *opaque_decl) override;
495 
496  ConstString DeclGetMangledName(void *opaque_decl) override;
497 
498  CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override;
499 
500  CompilerType DeclGetFunctionReturnType(void *opaque_decl) override;
501 
502  size_t DeclGetFunctionNumArguments(void *opaque_decl) override;
503 
504  CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
505  size_t arg_idx) override;
506 
507  CompilerType GetTypeForDecl(void *opaque_decl) override;
508 
509  // CompilerDeclContext override functions
510 
511  /// Creates a CompilerDeclContext from the given DeclContext
512  /// with the current TypeSystemClang instance as its typesystem.
513  /// The DeclContext has to come from the ASTContext of this
514  /// TypeSystemClang.
515  CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
516 
517  /// Set the owning module for \p decl.
518  static void SetOwningModule(clang::Decl *decl,
519  OptionalClangModuleID owning_module);
520 
521  std::vector<CompilerDecl>
522  DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
523  const bool ignore_using_decls) override;
524 
525  ConstString DeclContextGetName(void *opaque_decl_ctx) override;
526 
527  ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override;
528 
529  bool DeclContextIsClassMethod(void *opaque_decl_ctx,
530  lldb::LanguageType *language_ptr,
531  bool *is_instance_method_ptr,
532  ConstString *language_object_name_ptr) override;
533 
534  bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
535  void *other_opaque_decl_ctx) override;
536 
537  // Clang specific clang::DeclContext functions
538 
539  static clang::DeclContext *
540  DeclContextGetAsDeclContext(const CompilerDeclContext &dc);
541 
542  static clang::ObjCMethodDecl *
543  DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc);
544 
545  static clang::CXXMethodDecl *
546  DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc);
547 
548  static clang::FunctionDecl *
549  DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc);
550 
551  static clang::NamespaceDecl *
552  DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc);
553 
554  static ClangASTMetadata *DeclContextGetMetaData(const CompilerDeclContext &dc,
555  const clang::Decl *object);
556 
557  static clang::ASTContext *
558  DeclContextGetTypeSystemClang(const CompilerDeclContext &dc);
559 
560  // Tests
561 
562 #ifndef NDEBUG
563  bool Verify(lldb::opaque_compiler_type_t type) override;
564 #endif
565 
566  bool IsArrayType(lldb::opaque_compiler_type_t type,
567  CompilerType *element_type, uint64_t *size,
568  bool *is_incomplete) override;
569 
570  bool IsVectorType(lldb::opaque_compiler_type_t type,
571  CompilerType *element_type, uint64_t *size) override;
572 
573  bool IsAggregateType(lldb::opaque_compiler_type_t type) override;
574 
575  bool IsAnonymousType(lldb::opaque_compiler_type_t type) override;
576 
577  bool IsBeingDefined(lldb::opaque_compiler_type_t type) override;
578 
579  bool IsCharType(lldb::opaque_compiler_type_t type) override;
580 
581  bool IsCompleteType(lldb::opaque_compiler_type_t type) override;
582 
583  bool IsConst(lldb::opaque_compiler_type_t type) override;
584 
585  bool IsCStringType(lldb::opaque_compiler_type_t type,
586  uint32_t &length) override;
587 
588  static bool IsCXXClassType(const CompilerType &type);
589 
590  bool IsDefined(lldb::opaque_compiler_type_t type) override;
591 
592  bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
593  bool &is_complex) override;
594 
595  bool IsFunctionType(lldb::opaque_compiler_type_t type,
596  bool *is_variadic_ptr) override;
597 
598  uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
599  CompilerType *base_type_ptr) override;
600 
601  size_t
602  GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override;
603 
604  CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
605  const size_t index) override;
606 
607  bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override;
608 
609  bool IsBlockPointerType(lldb::opaque_compiler_type_t type,
610  CompilerType *function_pointer_type_ptr) override;
611 
612  bool IsIntegerType(lldb::opaque_compiler_type_t type,
613  bool &is_signed) override;
614 
615  bool IsEnumerationType(lldb::opaque_compiler_type_t type,
616  bool &is_signed) override;
617 
618  static bool IsObjCClassType(const CompilerType &type);
619 
620  static bool IsObjCClassTypeAndHasIVars(const CompilerType &type,
621  bool check_superclass);
622 
623  static bool IsObjCObjectOrInterfaceType(const CompilerType &type);
624 
625  static bool IsObjCObjectPointerType(const CompilerType &type,
626  CompilerType *target_type = nullptr);
627 
628  bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override;
629 
630  static bool IsClassType(lldb::opaque_compiler_type_t type);
631 
632  static bool IsEnumType(lldb::opaque_compiler_type_t type);
633 
634  bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
635  CompilerType *target_type, // Can pass nullptr
636  bool check_cplusplus, bool check_objc) override;
637 
638  bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override;
639 
640  bool IsPointerType(lldb::opaque_compiler_type_t type,
641  CompilerType *pointee_type) override;
642 
643  bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
644  CompilerType *pointee_type) override;
645 
646  bool IsReferenceType(lldb::opaque_compiler_type_t type,
647  CompilerType *pointee_type, bool *is_rvalue) override;
648 
649  bool IsScalarType(lldb::opaque_compiler_type_t type) override;
650 
651  bool IsTypedefType(lldb::opaque_compiler_type_t type) override;
652 
653  bool IsVoidType(lldb::opaque_compiler_type_t type) override;
654 
655  bool CanPassInRegisters(const CompilerType &type) override;
656 
657  bool SupportsLanguage(lldb::LanguageType language) override;
658 
659  static llvm::Optional<std::string> GetCXXClassName(const CompilerType &type);
660 
661  // Type Completion
662 
663  bool GetCompleteType(lldb::opaque_compiler_type_t type) override;
664 
665  // Accessors
666 
667  ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
668 
669  ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
670 
671  uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
672  CompilerType *pointee_or_element_compiler_type) override;
673 
675  GetMinimumLanguage(lldb::opaque_compiler_type_t type) override;
676 
677  lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override;
678 
679  unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override;
680 
681  // Creating related types
682 
683  /// Using the current type, create a new typedef to that type using
684  /// "typedef_name" as the name and "decl_ctx" as the decl context.
685  /// \param payload is an opaque TypePayloadClang.
686  static CompilerType
687  CreateTypedefType(const CompilerType &type, const char *typedef_name,
688  const CompilerDeclContext &compiler_decl_ctx,
689  uint32_t opaque_payload);
690 
691  CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
692  uint64_t *stride) override;
693 
694  CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
695  uint64_t size) override;
696 
697  CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override;
698 
700  GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
701 
702  // Returns -1 if this isn't a function of if the function doesn't have a
703  // prototype Returns a value >= 0 if there is a prototype.
704  int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
705 
706  CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type,
707  size_t idx) override;
708 
710  GetFunctionReturnType(lldb::opaque_compiler_type_t type) override;
711 
712  size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override;
713 
715  GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
716  size_t idx) override;
717 
718  CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override;
719 
720  CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override;
721 
722  CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override;
723 
725  GetLValueReferenceType(lldb::opaque_compiler_type_t type) override;
726 
728  GetRValueReferenceType(lldb::opaque_compiler_type_t type) override;
729 
730  CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override;
731 
732  CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override;
733 
734  CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override;
735 
736  CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override;
737 
738  CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
739  const char *name,
740  const CompilerDeclContext &decl_ctx,
741  uint32_t opaque_payload) override;
742 
743  // If the current object represents a typedef type, get the underlying type
744  CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
745 
746  // Create related types using the current type's AST
747  CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override;
748 
749  // Exploring the type
750 
751  const llvm::fltSemantics &GetFloatTypeSemantics(size_t byte_size) override;
752 
753  llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
754  ExecutionContextScope *exe_scope) {
755  if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope))
756  return (*bit_size + 7) / 8;
757  return llvm::None;
758  }
759 
760  llvm::Optional<uint64_t>
762  ExecutionContextScope *exe_scope) override;
763 
765  uint64_t &count) override;
766 
767  lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
768 
769  llvm::Optional<size_t>
770  GetTypeBitAlign(lldb::opaque_compiler_type_t type,
771  ExecutionContextScope *exe_scope) override;
772 
773  uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
774  bool omit_empty_base_classes,
775  const ExecutionContext *exe_ctx) override;
776 
777  CompilerType GetBuiltinTypeByName(ConstString name) override;
778 
780  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override;
781 
782  static lldb::BasicType
783  GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type,
784  ConstString name);
785 
786  void ForEachEnumerator(
788  std::function<bool(const CompilerType &integer_type,
789  ConstString name,
790  const llvm::APSInt &value)> const &callback) override;
791 
792  uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
793 
794  CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx,
795  std::string &name, uint64_t *bit_offset_ptr,
796  uint32_t *bitfield_bit_size_ptr,
797  bool *is_bitfield_ptr) override;
798 
799  uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override;
800 
801  uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override;
802 
803  CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type,
804  size_t idx,
805  uint32_t *bit_offset_ptr) override;
806 
807  CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type,
808  size_t idx,
809  uint32_t *bit_offset_ptr) override;
810 
811  static uint32_t GetNumPointeeChildren(clang::QualType type);
812 
813  CompilerType GetChildCompilerTypeAtIndex(
814  lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
815  bool transparent_pointers, bool omit_empty_base_classes,
816  bool ignore_array_bounds, std::string &child_name,
817  uint32_t &child_byte_size, int32_t &child_byte_offset,
818  uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
819  bool &child_is_base_class, bool &child_is_deref_of_parent,
820  ValueObject *valobj, uint64_t &language_flags) override;
821 
822  // Lookup a child given a name. This function will match base class names and
823  // member member names in "clang_type" only, not descendants.
824  uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
825  const char *name,
826  bool omit_empty_base_classes) override;
827 
828  // Lookup a child member given a name. This function will match member names
829  // only and will descend into "clang_type" children in search for the first
830  // member in this class, or any base class that matches "name".
831  // TODO: Return all matches for a given name by returning a
832  // vector<vector<uint32_t>>
833  // so we catch all names that match a given child name, not just the first.
834  size_t
835  GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
836  const char *name, bool omit_empty_base_classes,
837  std::vector<uint32_t> &child_indexes) override;
838 
839  size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override;
840 
842  GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
843  size_t idx) override;
844  CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
845  size_t idx) override;
846  llvm::Optional<CompilerType::IntegralTemplateArgument>
847  GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
848  size_t idx) override;
849 
850  CompilerType GetTypeForFormatters(void *type) override;
851 
852 #define LLDB_INVALID_DECL_LEVEL UINT32_MAX
853  // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx
854  // could not be found in decl_ctx.
855  uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx,
856  clang::DeclContext *child_decl_ctx,
857  ConstString *child_name = nullptr,
858  CompilerType *child_type = nullptr);
859 
860  // Modifying RecordType
861  static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
862  llvm::StringRef name,
863  const CompilerType &field_type,
864  lldb::AccessType access,
865  uint32_t bitfield_bit_size);
866 
867  static void BuildIndirectFields(const CompilerType &type);
868 
869  static void SetIsPacked(const CompilerType &type);
870 
871  static clang::VarDecl *AddVariableToRecordType(const CompilerType &type,
872  llvm::StringRef name,
873  const CompilerType &var_type,
874  lldb::AccessType access);
875 
876  /// Initializes a variable with an integer value.
877  /// \param var The variable to initialize. Must not already have an
878  /// initializer and must have an integer or enum type.
879  /// \param init_value The integer value that the variable should be
880  /// initialized to. Has to match the bit width of the
881  /// variable type.
882  static void SetIntegerInitializerForVariable(clang::VarDecl *var,
883  const llvm::APInt &init_value);
884 
885  /// Initializes a variable with a floating point value.
886  /// \param var The variable to initialize. Must not already have an
887  /// initializer and must have a floating point type.
888  /// \param init_value The float value that the variable should be
889  /// initialized to.
890  static void
891  SetFloatingInitializerForVariable(clang::VarDecl *var,
892  const llvm::APFloat &init_value);
893 
894  clang::CXXMethodDecl *AddMethodToCXXRecordType(
895  lldb::opaque_compiler_type_t type, llvm::StringRef name,
896  const char *mangled_name, const CompilerType &method_type,
897  lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
898  bool is_explicit, bool is_attr_used, bool is_artificial);
899 
900  void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type);
901 
902  // C++ Base Classes
903  std::unique_ptr<clang::CXXBaseSpecifier>
904  CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
905  lldb::AccessType access, bool is_virtual,
906  bool base_of_class);
907 
908  bool TransferBaseClasses(
910  std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases);
911 
912  static bool SetObjCSuperClass(const CompilerType &type,
913  const CompilerType &superclass_compiler_type);
914 
915  static bool AddObjCClassProperty(const CompilerType &type,
916  const char *property_name,
917  const CompilerType &property_compiler_type,
918  clang::ObjCIvarDecl *ivar_decl,
919  const char *property_setter_name,
920  const char *property_getter_name,
921  uint32_t property_attributes,
922  ClangASTMetadata *metadata);
923 
924  static clang::ObjCMethodDecl *AddMethodToObjCObjectType(
925  const CompilerType &type,
926  const char *name, // the full symbol name as seen in the symbol table
927  // (lldb::opaque_compiler_type_t type, "-[NString
928  // stringWithCString:]")
929  const CompilerType &method_compiler_type, lldb::AccessType access,
930  bool is_artificial, bool is_variadic, bool is_objc_direct_call);
931 
932  static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type,
933  bool has_extern);
934 
935  // Tag Declarations
936  static bool StartTagDeclarationDefinition(const CompilerType &type);
937 
938  static bool CompleteTagDeclarationDefinition(const CompilerType &type);
939 
940  // Modifying Enumeration types
941  clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
942  const CompilerType &enum_type, const Declaration &decl, const char *name,
943  int64_t enum_value, uint32_t enum_value_bit_size);
944  clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
945  const CompilerType &enum_type, const Declaration &decl, const char *name,
946  const llvm::APSInt &value);
947 
948  /// Returns the underlying integer type for an enum type. If the given type
949  /// is invalid or not an enum-type, the function returns an invalid
950  /// CompilerType.
951  CompilerType GetEnumerationIntegerType(CompilerType type);
952 
953  // Pointers & References
954 
955  // Call this function using the class type when you want to make a member
956  // pointer type to pointee_type.
957  static CompilerType CreateMemberPointerType(const CompilerType &type,
958  const CompilerType &pointee_type);
959 
960  // Dumping types
961 #ifndef NDEBUG
962  /// Convenience LLVM-style dump method for use in the debugger only.
963  /// In contrast to the other \p Dump() methods this directly invokes
964  /// \p clang::QualType::dump().
965  LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
966 #endif
967 
968  void Dump(Stream &s);
969 
970  /// Dump clang AST types from the symbol file.
971  ///
972  /// \param[in] s
973  /// A stream to send the dumped AST node(s) to
974  /// \param[in] symbol_name
975  /// The name of the symbol to dump, if it is empty dump all the symbols
976  void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name);
977 
978  void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
979  Stream *s, lldb::Format format, const DataExtractor &data,
980  lldb::offset_t data_offset, size_t data_byte_size,
981  uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
982  bool show_types, bool show_summary, bool verbose,
983  uint32_t depth) override;
984 
985  bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
986  lldb::Format format, const DataExtractor &data,
987  lldb::offset_t data_offset, size_t data_byte_size,
988  uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
989  ExecutionContextScope *exe_scope) override;
990 
991  void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
992  Stream *s, const DataExtractor &data,
993  lldb::offset_t data_offset, size_t data_byte_size) override;
994 
995  void DumpTypeDescription(
998 
999  void DumpTypeDescription(
1000  lldb::opaque_compiler_type_t type, Stream *s,
1002 
1003  static void DumpTypeName(const CompilerType &type);
1004 
1005  static clang::EnumDecl *GetAsEnumDecl(const CompilerType &type);
1006 
1007  static clang::RecordDecl *GetAsRecordDecl(const CompilerType &type);
1008 
1009  static clang::TagDecl *GetAsTagDecl(const CompilerType &type);
1010 
1011  static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type);
1012 
1013  static clang::CXXRecordDecl *
1014  GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type);
1015 
1016  static clang::ObjCInterfaceDecl *
1017  GetAsObjCInterfaceDecl(const CompilerType &type);
1018 
1019  clang::ClassTemplateDecl *ParseClassTemplateDecl(
1020  clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
1021  lldb::AccessType access_type, const char *parent_name, int tag_decl_kind,
1022  const TypeSystemClang::TemplateParameterInfos &template_param_infos);
1023 
1024  clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx,
1025  OptionalClangModuleID owning_module);
1026 
1027  clang::UsingDirectiveDecl *
1028  CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
1029  OptionalClangModuleID owning_module,
1030  clang::NamespaceDecl *ns_decl);
1031 
1032  clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
1033  OptionalClangModuleID owning_module,
1034  clang::NamedDecl *target);
1035 
1036  clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
1037  OptionalClangModuleID owning_module,
1038  const char *name,
1039  clang::QualType type);
1040 
1042  GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type);
1043 
1044  static clang::QualType GetQualType(lldb::opaque_compiler_type_t type) {
1045  if (type)
1046  return clang::QualType::getFromOpaquePtr(type);
1047  return clang::QualType();
1048  }
1049 
1050  static clang::QualType
1052  if (type)
1053  return clang::QualType::getFromOpaquePtr(type).getCanonicalType();
1054  return clang::QualType();
1055  }
1056 
1057  clang::DeclarationName
1058  GetDeclarationName(const char *name, const CompilerType &function_clang_type);
1059 
1060  clang::LangOptions *GetLangOpts() const {
1061  return m_language_options_up.get();
1062  }
1063  clang::SourceManager *GetSourceMgr() const {
1064  return m_source_manager_up.get();
1065  }
1066 
1067 private:
1068  const clang::ClassTemplateSpecializationDecl *
1069  GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
1070 
1071  // Classes that inherit from TypeSystemClang can see and modify these
1072  std::string m_target_triple;
1073  std::unique_ptr<clang::ASTContext> m_ast_up;
1074  std::unique_ptr<clang::LangOptions> m_language_options_up;
1075  std::unique_ptr<clang::FileManager> m_file_manager_up;
1076  std::unique_ptr<clang::SourceManager> m_source_manager_up;
1077  std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
1078  std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
1079  std::shared_ptr<clang::TargetOptions> m_target_options_rp;
1080  std::unique_ptr<clang::TargetInfo> m_target_info_up;
1081  std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
1082  std::unique_ptr<clang::SelectorTable> m_selector_table_up;
1083  std::unique_ptr<clang::Builtin::Context> m_builtins_up;
1084  std::unique_ptr<clang::HeaderSearch> m_header_search_up;
1085  std::unique_ptr<clang::ModuleMap> m_module_map_up;
1086  std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
1087  std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
1088  std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
1089  uint32_t m_pointer_byte_size = 0;
1090  bool m_ast_owned = false;
1091  /// A string describing what this TypeSystemClang represents (e.g.,
1092  /// AST for debug information, an expression, some other utility ClangAST).
1093  /// Useful for logging and debugging.
1094  std::string m_display_name;
1095 
1096  typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap;
1097  /// Maps Decls to their associated ClangASTMetadata.
1098  DeclMetadataMap m_decl_metadata;
1099 
1100  typedef llvm::DenseMap<const clang::Type *, ClangASTMetadata> TypeMetadataMap;
1101  /// Maps Types to their associated ClangASTMetadata.
1102  TypeMetadataMap m_type_metadata;
1103 
1104  /// The sema associated that is currently used to build this ASTContext.
1105  /// May be null if we are already done parsing this ASTContext or the
1106  /// ASTContext wasn't created by parsing source code.
1107  clang::Sema *m_sema = nullptr;
1108 
1109  // For TypeSystemClang only
1111  const TypeSystemClang &operator=(const TypeSystemClang &);
1112  /// Creates the internal ASTContext.
1113  void CreateASTContext();
1114  void SetTargetTriple(llvm::StringRef target_triple);
1115 };
1116 
1117 /// The TypeSystemClang instance used for the scratch ASTContext in a
1118 /// lldb::Target.
1120 public:
1121  TypeSystemClangForExpressions(Target &target, llvm::Triple triple);
1122 
1123  ~TypeSystemClangForExpressions() override = default;
1124 
1125  void Finalize() override;
1126 
1127  UserExpression *
1128  GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
1129  lldb::LanguageType language,
1130  Expression::ResultType desired_type,
1131  const EvaluateExpressionOptions &options,
1132  ValueObject *ctx_obj) override;
1133 
1134  FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
1135  const Address &function_address,
1136  const ValueList &arg_value_list,
1137  const char *name) override;
1138 
1139  UtilityFunction *GetUtilityFunction(const char *text,
1140  const char *name) override;
1141 
1142  PersistentExpressionState *GetPersistentExpressionState() override;
1143 private:
1144  lldb::TargetWP m_target_wp;
1145  std::unique_ptr<ClangPersistentVariables>
1146  m_persistent_variables; // These are the persistent variables associated
1147  // with this process for the expression parser
1148  std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
1149 };
1150 
1151 } // namespace lldb_private
1152 
1153 #endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
std::unique_ptr< clang::Builtin::Context > m_builtins_up
A class that represents a running process on the host machine.
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
Represents a generic declaration context in a program.
A TypeSystem implementation based on Clang.
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
llvm::Expected< TypeSystem & > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
Definition: Target.cpp:2123
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
clang::SourceManager * GetSourceMgr() const
Encapsulates a one-time expression for use in lldb.
void * opaque_compiler_type_t
Definition: lldb-types.h:90
static bool classof(const TypeSystem *ts)
bool GetCompleteDecl(clang::Decl *decl)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
Encoding
Register encoding definitions.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:40
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:265
Format
Display format definitions.
std::unique_ptr< clang::ModuleMap > m_module_map_up
static size_t GetBitSize(Scalar::Type type)
Definition: Scalar.cpp:297
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information, an expression, some other utility ClangAST).
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
llvm::SmallVector< clang::TemplateArgument, 2 > args
clang::LangOptions * GetLangOpts() const
TypePayloadClang(uint32_t opaque_payload)
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
uint64_t user_id_t
Definition: lldb-types.h:84
LanguageType
Programming language type.
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
uint64_t offset_t
Definition: lldb-types.h:87
llvm::SmallVector< const char *, 2 > names
size_t GetLength() const
Get the length in bytes of string value.
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:75
std::unique_ptr< clang::HeaderSearch > m_header_search_up
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
void SetCompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
Encapsulates a function that can be called.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
std::unique_ptr< clang::FileManager > m_file_manager_up
bool isA(const void *ClassID) const override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
CompilerType GetType(clang::QualType qt)
Creates a CompilerType form the given QualType with the current TypeSystemClang instance as the Compi...
llvm::DenseMap< const clang::Decl *, ClangASTMetadata > DeclMetadataMap
#define LIBLLDB_LOG_TARGET
Definition: Logging.h:36
static char ID
llvm::Optional< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
The TypeSystemClang instance used for the scratch ASTContext in a lldb::Target.
A section + offset based address class.
Definition: Address.h:59
ValueType Set(ValueType mask)
Set one or more flags by logical OR&#39;ing mask with the current flags.
Definition: Flags.h:73
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
std::unique_ptr< clang::SelectorTable > m_selector_table_up
std::unique_ptr< clang::LangOptions > m_language_options_up
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB...
Interface for representing a type system.
Definition: TypeSystem.h:71
void SetIsCompleteObjCClass(bool is_complete_objc_class)
llvm::DenseMap< const clang::Type *, ClangASTMetadata > TypeMetadataMap
A class to manage flags.
Definition: Flags.h:22
std::shared_ptr< clang::TargetOptions > m_target_options_rp
virtual bool isA(const void *ClassID) const =0
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:246
Non-standardized C, such as K&R.
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:62
Represents a generic type in a programming language.
Definition: CompilerType.h:33
std::unique_ptr< clang::SourceManager > m_source_manager_up
clang::TranslationUnitDecl * GetTranslationUnitDecl()
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals)
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
std::unique_ptr< TemplateParameterInfos > packed_args
OptionalClangModuleID GetOwningModule()
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
static TypeSystemClang * GetScratch(Target &target, bool create_on_demand=true)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::ASTContext > m_ast_up
static bool DumpValue(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry &entry, ValueObject *valobj)
CompilerType GetTypeForIdentifier(ConstString type_name, clang::DeclContext *decl_context=nullptr)
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
The implementation of lldb::Type&#39;s m_payload field for TypeSystemClang.