LLDB  mainline
PDBASTParser.cpp
Go to the documentation of this file.
1 //===-- PDBASTParser.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "PDBASTParser.h"
10 
11 #include "SymbolFilePDB.h"
12 
13 #include "clang/AST/CharUnits.h"
14 #include "clang/AST/Decl.h"
15 #include "clang/AST/DeclCXX.h"
16 
20 #include "lldb/Core/Declaration.h"
21 #include "lldb/Core/Module.h"
22 #include "lldb/Symbol/SymbolFile.h"
23 #include "lldb/Symbol/TypeMap.h"
24 #include "lldb/Symbol/TypeSystem.h"
25 #include "lldb/Utility/LLDBLog.h"
26 #include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
27 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
28 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
29 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
30 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
31 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
32 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
33 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
34 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
35 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
36 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
37 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
38 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
39 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
40 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
41 
43 
44 using namespace lldb;
45 using namespace lldb_private;
46 using namespace llvm::pdb;
47 
48 static int TranslateUdtKind(PDB_UdtType pdb_kind) {
49  switch (pdb_kind) {
50  case PDB_UdtType::Class:
51  return clang::TTK_Class;
52  case PDB_UdtType::Struct:
53  return clang::TTK_Struct;
54  case PDB_UdtType::Union:
55  return clang::TTK_Union;
56  case PDB_UdtType::Interface:
57  return clang::TTK_Interface;
58  }
59  llvm_unreachable("unsuported PDB UDT type");
60 }
61 
62 static lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type) {
63  switch (type) {
64  case PDB_BuiltinType::Float:
66  case PDB_BuiltinType::Int:
67  case PDB_BuiltinType::Long:
68  case PDB_BuiltinType::Char:
69  return lldb::eEncodingSint;
70  case PDB_BuiltinType::Bool:
71  case PDB_BuiltinType::Char16:
72  case PDB_BuiltinType::Char32:
74  case PDB_BuiltinType::ULong:
75  case PDB_BuiltinType::HResult:
76  case PDB_BuiltinType::WCharT:
77  return lldb::eEncodingUint;
78  default:
80  }
81 }
82 
83 static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) {
84  switch (type) {
85  case PDB_VariantType::Int8:
86  case PDB_VariantType::Int16:
87  case PDB_VariantType::Int32:
88  case PDB_VariantType::Int64:
89  return lldb::eEncodingSint;
90 
91  case PDB_VariantType::UInt8:
92  case PDB_VariantType::UInt16:
93  case PDB_VariantType::UInt32:
94  case PDB_VariantType::UInt64:
95  return lldb::eEncodingUint;
96 
97  default:
98  break;
99  }
100 
101  return lldb::eEncodingSint;
102 }
103 
104 static CompilerType
106  const PDBSymbolTypeBuiltin &pdb_type,
107  Encoding encoding, uint32_t width) {
108  clang::ASTContext &ast = clang_ast.getASTContext();
109 
110  switch (pdb_type.getBuiltinType()) {
111  default:
112  break;
113  case PDB_BuiltinType::None:
114  return CompilerType();
115  case PDB_BuiltinType::Void:
116  return clang_ast.GetBasicType(eBasicTypeVoid);
117  case PDB_BuiltinType::Char:
118  return clang_ast.GetBasicType(eBasicTypeChar);
119  case PDB_BuiltinType::Bool:
120  return clang_ast.GetBasicType(eBasicTypeBool);
121  case PDB_BuiltinType::Long:
122  if (width == ast.getTypeSize(ast.LongTy))
123  return CompilerType(clang_ast.weak_from_this(),
124  ast.LongTy.getAsOpaquePtr());
125  if (width == ast.getTypeSize(ast.LongLongTy))
126  return CompilerType(clang_ast.weak_from_this(),
127  ast.LongLongTy.getAsOpaquePtr());
128  break;
129  case PDB_BuiltinType::ULong:
130  if (width == ast.getTypeSize(ast.UnsignedLongTy))
131  return CompilerType(clang_ast.weak_from_this(),
132  ast.UnsignedLongTy.getAsOpaquePtr());
133  if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
134  return CompilerType(clang_ast.weak_from_this(),
135  ast.UnsignedLongLongTy.getAsOpaquePtr());
136  break;
137  case PDB_BuiltinType::WCharT:
138  if (width == ast.getTypeSize(ast.WCharTy))
139  return CompilerType(clang_ast.weak_from_this(),
140  ast.WCharTy.getAsOpaquePtr());
141  break;
142  case PDB_BuiltinType::Char16:
143  return CompilerType(clang_ast.weak_from_this(),
144  ast.Char16Ty.getAsOpaquePtr());
145  case PDB_BuiltinType::Char32:
146  return CompilerType(clang_ast.weak_from_this(),
147  ast.Char32Ty.getAsOpaquePtr());
148  case PDB_BuiltinType::Float:
149  // Note: types `long double` and `double` have same bit size in MSVC and
150  // there is no information in the PDB to distinguish them. So when falling
151  // back to default search, the compiler type of `long double` will be
152  // represented by the one generated for `double`.
153  break;
154  }
155  // If there is no match on PDB_BuiltinType, fall back to default search by
156  // encoding and width only
157  return clang_ast.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
158 }
159 
160 static ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type,
161  CompilerType &compiler_type) {
162  PDB_BuiltinType kind = pdb_type.getBuiltinType();
163  switch (kind) {
164  default:
165  break;
166  case PDB_BuiltinType::Currency:
167  return ConstString("CURRENCY");
168  case PDB_BuiltinType::Date:
169  return ConstString("DATE");
170  case PDB_BuiltinType::Variant:
171  return ConstString("VARIANT");
172  case PDB_BuiltinType::Complex:
173  return ConstString("complex");
174  case PDB_BuiltinType::Bitfield:
175  return ConstString("bitfield");
176  case PDB_BuiltinType::BSTR:
177  return ConstString("BSTR");
178  case PDB_BuiltinType::HResult:
179  return ConstString("HRESULT");
180  case PDB_BuiltinType::BCD:
181  return ConstString("BCD");
182  case PDB_BuiltinType::Char16:
183  return ConstString("char16_t");
184  case PDB_BuiltinType::Char32:
185  return ConstString("char32_t");
186  case PDB_BuiltinType::None:
187  return ConstString("...");
188  }
189  return compiler_type.GetTypeName();
190 }
191 
192 static bool GetDeclarationForSymbol(const PDBSymbol &symbol,
193  Declaration &decl) {
194  auto &raw_sym = symbol.getRawSymbol();
195  auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
196 
197  if (!first_line_up) {
198  auto lines_up = symbol.getSession().findLineNumbersByAddress(
199  raw_sym.getVirtualAddress(), raw_sym.getLength());
200  if (!lines_up)
201  return false;
202  first_line_up = lines_up->getNext();
203  if (!first_line_up)
204  return false;
205  }
206  uint32_t src_file_id = first_line_up->getSourceFileId();
207  auto src_file_up = symbol.getSession().getSourceFileById(src_file_id);
208  if (!src_file_up)
209  return false;
210 
211  FileSpec spec(src_file_up->getFileName());
212  decl.SetFile(spec);
213  decl.SetColumn(first_line_up->getColumnNumber());
214  decl.SetLine(first_line_up->getLineNumber());
215  return true;
216 }
217 
218 static AccessType TranslateMemberAccess(PDB_MemberAccess access) {
219  switch (access) {
220  case PDB_MemberAccess::Private:
221  return eAccessPrivate;
222  case PDB_MemberAccess::Protected:
223  return eAccessProtected;
224  case PDB_MemberAccess::Public:
225  return eAccessPublic;
226  }
227  return eAccessNone;
228 }
229 
230 static AccessType GetDefaultAccessibilityForUdtKind(PDB_UdtType udt_kind) {
231  switch (udt_kind) {
232  case PDB_UdtType::Struct:
233  case PDB_UdtType::Union:
234  return eAccessPublic;
235  case PDB_UdtType::Class:
236  case PDB_UdtType::Interface:
237  return eAccessPrivate;
238  }
239  llvm_unreachable("unsupported PDB UDT type");
240 }
241 
242 static AccessType GetAccessibilityForUdt(const PDBSymbolTypeUDT &udt) {
243  AccessType access = TranslateMemberAccess(udt.getAccess());
244  if (access != lldb::eAccessNone || !udt.isNested())
245  return access;
246 
247  auto parent = udt.getClassParent();
248  if (!parent)
249  return lldb::eAccessNone;
250 
251  auto parent_udt = llvm::dyn_cast<PDBSymbolTypeUDT>(parent.get());
252  if (!parent_udt)
253  return lldb::eAccessNone;
254 
255  return GetDefaultAccessibilityForUdtKind(parent_udt->getUdtKind());
256 }
257 
258 static clang::MSInheritanceAttr::Spelling
259 GetMSInheritance(const PDBSymbolTypeUDT &udt) {
260  int base_count = 0;
261  bool has_virtual = false;
262 
263  auto bases_enum = udt.findAllChildren<PDBSymbolTypeBaseClass>();
264  if (bases_enum) {
265  while (auto base = bases_enum->getNext()) {
266  base_count++;
267  has_virtual |= base->isVirtualBaseClass();
268  }
269  }
270 
271  if (has_virtual)
272  return clang::MSInheritanceAttr::Keyword_virtual_inheritance;
273  if (base_count > 1)
274  return clang::MSInheritanceAttr::Keyword_multiple_inheritance;
275  return clang::MSInheritanceAttr::Keyword_single_inheritance;
276 }
277 
278 static std::unique_ptr<llvm::pdb::PDBSymbol>
279 GetClassOrFunctionParent(const llvm::pdb::PDBSymbol &symbol) {
280  const IPDBSession &session = symbol.getSession();
281  const IPDBRawSymbol &raw = symbol.getRawSymbol();
282  auto tag = symbol.getSymTag();
283 
284  // For items that are nested inside of a class, return the class that it is
285  // nested inside of.
286  // Note that only certain items can be nested inside of classes.
287  switch (tag) {
288  case PDB_SymType::Function:
289  case PDB_SymType::Data:
290  case PDB_SymType::UDT:
291  case PDB_SymType::Enum:
292  case PDB_SymType::FunctionSig:
293  case PDB_SymType::Typedef:
294  case PDB_SymType::BaseClass:
295  case PDB_SymType::VTable: {
296  auto class_parent_id = raw.getClassParentId();
297  if (auto class_parent = session.getSymbolById(class_parent_id))
298  return class_parent;
299  break;
300  }
301  default:
302  break;
303  }
304 
305  // Otherwise, if it is nested inside of a function, return the function.
306  // Note that only certain items can be nested inside of functions.
307  switch (tag) {
308  case PDB_SymType::Block:
309  case PDB_SymType::Data: {
310  auto lexical_parent_id = raw.getLexicalParentId();
311  auto lexical_parent = session.getSymbolById(lexical_parent_id);
312  if (!lexical_parent)
313  return nullptr;
314 
315  auto lexical_parent_tag = lexical_parent->getSymTag();
316  if (lexical_parent_tag == PDB_SymType::Function)
317  return lexical_parent;
318  if (lexical_parent_tag == PDB_SymType::Exe)
319  return nullptr;
320 
321  return GetClassOrFunctionParent(*lexical_parent);
322  }
323  default:
324  return nullptr;
325  }
326 }
327 
328 static clang::NamedDecl *
329 GetDeclFromContextByName(const clang::ASTContext &ast,
330  const clang::DeclContext &decl_context,
331  llvm::StringRef name) {
332  clang::IdentifierInfo &ident = ast.Idents.get(name);
333  clang::DeclarationName decl_name = ast.DeclarationNames.getIdentifier(&ident);
334  clang::DeclContext::lookup_result result = decl_context.lookup(decl_name);
335  if (result.empty())
336  return nullptr;
337 
338  return *result.begin();
339 }
340 
341 static bool IsAnonymousNamespaceName(llvm::StringRef name) {
342  return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
343 }
344 
345 static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) {
346  switch (pdb_cc) {
347  case llvm::codeview::CallingConvention::NearC:
348  return clang::CC_C;
349  case llvm::codeview::CallingConvention::NearStdCall:
350  return clang::CC_X86StdCall;
351  case llvm::codeview::CallingConvention::NearFast:
352  return clang::CC_X86FastCall;
353  case llvm::codeview::CallingConvention::ThisCall:
354  return clang::CC_X86ThisCall;
355  case llvm::codeview::CallingConvention::NearVector:
356  return clang::CC_X86VectorCall;
357  case llvm::codeview::CallingConvention::NearPascal:
358  return clang::CC_X86Pascal;
359  default:
360  assert(false && "Unknown calling convention");
361  return clang::CC_C;
362  }
363 }
364 
366 
367 PDBASTParser::~PDBASTParser() = default;
368 
369 // DebugInfoASTParser interface
370 
371 lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
372  Declaration decl;
373  switch (type.getSymTag()) {
374  case PDB_SymType::BaseClass: {
375  auto symbol_file = m_ast.GetSymbolFile();
376  if (!symbol_file)
377  return nullptr;
378 
379  auto ty = symbol_file->ResolveTypeUID(type.getRawSymbol().getTypeId());
380  return ty ? ty->shared_from_this() : nullptr;
381  } break;
382  case PDB_SymType::UDT: {
383  auto udt = llvm::dyn_cast<PDBSymbolTypeUDT>(&type);
384  assert(udt);
385 
386  // Note that, unnamed UDT being typedef-ed is generated as a UDT symbol
387  // other than a Typedef symbol in PDB. For example,
388  // typedef union { short Row; short Col; } Union;
389  // is generated as a named UDT in PDB:
390  // union Union { short Row; short Col; }
391  // Such symbols will be handled here.
392 
393  // Some UDT with trival ctor has zero length. Just ignore.
394  if (udt->getLength() == 0)
395  return nullptr;
396 
397  // Ignore unnamed-tag UDTs.
398  std::string name =
400  if (name.empty())
401  return nullptr;
402 
403  auto decl_context = GetDeclContextContainingSymbol(type);
404 
405  // Check if such an UDT already exists in the current context.
406  // This may occur with const or volatile types. There are separate type
407  // symbols in PDB for types with const or volatile modifiers, but we need
408  // to create only one declaration for them all.
409  Type::ResolveState type_resolve_state;
410  CompilerType clang_type = m_ast.GetTypeForIdentifier<clang::CXXRecordDecl>(
411  ConstString(name), decl_context);
412  if (!clang_type.IsValid()) {
413  auto access = GetAccessibilityForUdt(*udt);
414 
415  auto tag_type_kind = TranslateUdtKind(udt->getUdtKind());
416 
417  ClangASTMetadata metadata;
418  metadata.SetUserID(type.getSymIndexId());
419  metadata.SetIsDynamicCXXType(false);
420 
421  clang_type = m_ast.CreateRecordType(
422  decl_context, OptionalClangModuleID(), access, name, tag_type_kind,
423  lldb::eLanguageTypeC_plus_plus, &metadata);
424  assert(clang_type.IsValid());
425 
426  auto record_decl =
428  assert(record_decl);
429  m_uid_to_decl[type.getSymIndexId()] = record_decl;
430 
431  auto inheritance_attr = clang::MSInheritanceAttr::CreateImplicit(
433  record_decl->addAttr(inheritance_attr);
434 
435  TypeSystemClang::StartTagDeclarationDefinition(clang_type);
436 
437  auto children = udt->findAllChildren();
438  if (!children || children->getChildCount() == 0) {
439  // PDB does not have symbol of forwarder. We assume we get an udt w/o
440  // any fields. Just complete it at this point.
441  TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
442 
443  TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
444  false);
445 
446  type_resolve_state = Type::ResolveState::Full;
447  } else {
448  // Add the type to the forward declarations. It will help us to avoid
449  // an endless recursion in CompleteTypeFromUdt function.
450  m_forward_decl_to_uid[record_decl] = type.getSymIndexId();
451 
452  TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
453  true);
454 
455  type_resolve_state = Type::ResolveState::Forward;
456  }
457  } else
458  type_resolve_state = Type::ResolveState::Forward;
459 
460  if (udt->isConstType())
461  clang_type = clang_type.AddConstModifier();
462 
463  if (udt->isVolatileType())
464  clang_type = clang_type.AddVolatileModifier();
465 
466  GetDeclarationForSymbol(type, decl);
467  return std::make_shared<lldb_private::Type>(
468  type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
469  udt->getLength(), nullptr, LLDB_INVALID_UID,
470  lldb_private::Type::eEncodingIsUID, decl, clang_type,
471  type_resolve_state);
472  } break;
473  case PDB_SymType::Enum: {
474  auto enum_type = llvm::dyn_cast<PDBSymbolTypeEnum>(&type);
475  assert(enum_type);
476 
477  std::string name =
478  std::string(MSVCUndecoratedNameParser::DropScope(enum_type->getName()));
479  auto decl_context = GetDeclContextContainingSymbol(type);
480  uint64_t bytes = enum_type->getLength();
481 
482  // Check if such an enum already exists in the current context
483  CompilerType ast_enum = m_ast.GetTypeForIdentifier<clang::EnumDecl>(
484  ConstString(name), decl_context);
485  if (!ast_enum.IsValid()) {
486  auto underlying_type_up = enum_type->getUnderlyingType();
487  if (!underlying_type_up)
488  return nullptr;
489 
490  lldb::Encoding encoding =
491  TranslateBuiltinEncoding(underlying_type_up->getBuiltinType());
492  // FIXME: Type of underlying builtin is always `Int`. We correct it with
493  // the very first enumerator's encoding if any.
494  auto first_child = enum_type->findOneChild<PDBSymbolData>();
495  if (first_child)
496  encoding = TranslateEnumEncoding(first_child->getValue().Type);
497 
498  CompilerType builtin_type;
499  if (bytes > 0)
501  m_ast, *underlying_type_up, encoding, bytes * 8);
502  else
503  builtin_type = m_ast.GetBasicType(eBasicTypeInt);
504 
505  // FIXME: PDB does not have information about scoped enumeration (Enum
506  // Class). Set it false for now.
507  bool isScoped = false;
508 
509  ast_enum = m_ast.CreateEnumerationType(name, decl_context,
510  OptionalClangModuleID(), decl,
511  builtin_type, isScoped);
512 
513  auto enum_decl = TypeSystemClang::GetAsEnumDecl(ast_enum);
514  assert(enum_decl);
515  m_uid_to_decl[type.getSymIndexId()] = enum_decl;
516 
517  auto enum_values = enum_type->findAllChildren<PDBSymbolData>();
518  if (enum_values) {
519  while (auto enum_value = enum_values->getNext()) {
520  if (enum_value->getDataKind() != PDB_DataKind::Constant)
521  continue;
522  AddEnumValue(ast_enum, *enum_value);
523  }
524  }
525 
526  if (TypeSystemClang::StartTagDeclarationDefinition(ast_enum))
527  TypeSystemClang::CompleteTagDeclarationDefinition(ast_enum);
528  }
529 
530  if (enum_type->isConstType())
531  ast_enum = ast_enum.AddConstModifier();
532 
533  if (enum_type->isVolatileType())
534  ast_enum = ast_enum.AddVolatileModifier();
535 
536  GetDeclarationForSymbol(type, decl);
537  return std::make_shared<lldb_private::Type>(
538  type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), bytes,
541  } break;
542  case PDB_SymType::Typedef: {
543  auto type_def = llvm::dyn_cast<PDBSymbolTypeTypedef>(&type);
544  assert(type_def);
545 
546  SymbolFile *symbol_file = m_ast.GetSymbolFile();
547  if (!symbol_file)
548  return nullptr;
549 
550  lldb_private::Type *target_type =
551  symbol_file->ResolveTypeUID(type_def->getTypeId());
552  if (!target_type)
553  return nullptr;
554 
555  std::string name =
557  auto decl_ctx = GetDeclContextContainingSymbol(type);
558 
559  // Check if such a typedef already exists in the current context
560  CompilerType ast_typedef =
561  m_ast.GetTypeForIdentifier<clang::TypedefNameDecl>(ConstString(name),
562  decl_ctx);
563  if (!ast_typedef.IsValid()) {
564  CompilerType target_ast_type = target_type->GetFullCompilerType();
565 
566  ast_typedef = target_ast_type.CreateTypedef(
567  name.c_str(), m_ast.CreateDeclContext(decl_ctx), 0);
568  if (!ast_typedef)
569  return nullptr;
570 
571  auto typedef_decl = TypeSystemClang::GetAsTypedefDecl(ast_typedef);
572  assert(typedef_decl);
573  m_uid_to_decl[type.getSymIndexId()] = typedef_decl;
574  }
575 
576  if (type_def->isConstType())
577  ast_typedef = ast_typedef.AddConstModifier();
578 
579  if (type_def->isVolatileType())
580  ast_typedef = ast_typedef.AddVolatileModifier();
581 
582  GetDeclarationForSymbol(type, decl);
583  llvm::Optional<uint64_t> size;
584  if (type_def->getLength())
585  size = type_def->getLength();
586  return std::make_shared<lldb_private::Type>(
587  type_def->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
588  size, nullptr, target_type->GetID(),
591  } break;
592  case PDB_SymType::Function:
593  case PDB_SymType::FunctionSig: {
594  std::string name;
595  PDBSymbolTypeFunctionSig *func_sig = nullptr;
596  if (auto pdb_func = llvm::dyn_cast<PDBSymbolFunc>(&type)) {
597  if (pdb_func->isCompilerGenerated())
598  return nullptr;
599 
600  auto sig = pdb_func->getSignature();
601  if (!sig)
602  return nullptr;
603  func_sig = sig.release();
604  // Function type is named.
605  name = std::string(
606  MSVCUndecoratedNameParser::DropScope(pdb_func->getName()));
607  } else if (auto pdb_func_sig =
608  llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
609  func_sig = const_cast<PDBSymbolTypeFunctionSig *>(pdb_func_sig);
610  } else
611  llvm_unreachable("Unexpected PDB symbol!");
612 
613  auto arg_enum = func_sig->getArguments();
614  uint32_t num_args = arg_enum->getChildCount();
615  std::vector<CompilerType> arg_list;
616 
617  bool is_variadic = func_sig->isCVarArgs();
618  // Drop last variadic argument.
619  if (is_variadic)
620  --num_args;
621  for (uint32_t arg_idx = 0; arg_idx < num_args; arg_idx++) {
622  auto arg = arg_enum->getChildAtIndex(arg_idx);
623  if (!arg)
624  break;
625 
626  SymbolFile *symbol_file = m_ast.GetSymbolFile();
627  if (!symbol_file)
628  return nullptr;
629 
630  lldb_private::Type *arg_type =
631  symbol_file->ResolveTypeUID(arg->getSymIndexId());
632  // If there's some error looking up one of the dependent types of this
633  // function signature, bail.
634  if (!arg_type)
635  return nullptr;
636  CompilerType arg_ast_type = arg_type->GetFullCompilerType();
637  arg_list.push_back(arg_ast_type);
638  }
639  lldbassert(arg_list.size() <= num_args);
640 
641  auto pdb_return_type = func_sig->getReturnType();
642  SymbolFile *symbol_file = m_ast.GetSymbolFile();
643  if (!symbol_file)
644  return nullptr;
645 
646  lldb_private::Type *return_type =
647  symbol_file->ResolveTypeUID(pdb_return_type->getSymIndexId());
648  // If there's some error looking up one of the dependent types of this
649  // function signature, bail.
650  if (!return_type)
651  return nullptr;
652  CompilerType return_ast_type = return_type->GetFullCompilerType();
653  uint32_t type_quals = 0;
654  if (func_sig->isConstType())
655  type_quals |= clang::Qualifiers::Const;
656  if (func_sig->isVolatileType())
657  type_quals |= clang::Qualifiers::Volatile;
658  auto cc = TranslateCallingConvention(func_sig->getCallingConvention());
659  CompilerType func_sig_ast_type =
660  m_ast.CreateFunctionType(return_ast_type, arg_list.data(),
661  arg_list.size(), is_variadic, type_quals, cc);
662 
663  GetDeclarationForSymbol(type, decl);
664  return std::make_shared<lldb_private::Type>(
665  type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
666  llvm::None, nullptr, LLDB_INVALID_UID,
667  lldb_private::Type::eEncodingIsUID, decl, func_sig_ast_type,
669  } break;
670  case PDB_SymType::ArrayType: {
671  auto array_type = llvm::dyn_cast<PDBSymbolTypeArray>(&type);
672  assert(array_type);
673  uint32_t num_elements = array_type->getCount();
674  uint32_t element_uid = array_type->getElementTypeId();
675  llvm::Optional<uint64_t> bytes;
676  if (uint64_t size = array_type->getLength())
677  bytes = size;
678 
679  SymbolFile *symbol_file = m_ast.GetSymbolFile();
680  if (!symbol_file)
681  return nullptr;
682 
683  // If array rank > 0, PDB gives the element type at N=0. So element type
684  // will parsed in the order N=0, N=1,..., N=rank sequentially.
685  lldb_private::Type *element_type = symbol_file->ResolveTypeUID(element_uid);
686  if (!element_type)
687  return nullptr;
688 
689  CompilerType element_ast_type = element_type->GetForwardCompilerType();
690  // If element type is UDT, it needs to be complete.
691  if (TypeSystemClang::IsCXXClassType(element_ast_type) &&
692  !element_ast_type.GetCompleteType()) {
693  if (TypeSystemClang::StartTagDeclarationDefinition(element_ast_type)) {
694  TypeSystemClang::CompleteTagDeclarationDefinition(element_ast_type);
695  } else {
696  // We are not able to start definition.
697  return nullptr;
698  }
699  }
700  CompilerType array_ast_type = m_ast.CreateArrayType(
701  element_ast_type, num_elements, /*is_gnu_vector*/ false);
702  TypeSP type_sp = std::make_shared<lldb_private::Type>(
703  array_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
705  decl, array_ast_type, lldb_private::Type::ResolveState::Full);
706  type_sp->SetEncodingType(element_type);
707  return type_sp;
708  } break;
709  case PDB_SymType::BuiltinType: {
710  auto *builtin_type = llvm::dyn_cast<PDBSymbolTypeBuiltin>(&type);
711  assert(builtin_type);
712  PDB_BuiltinType builtin_kind = builtin_type->getBuiltinType();
713  if (builtin_kind == PDB_BuiltinType::None)
714  return nullptr;
715 
716  llvm::Optional<uint64_t> bytes;
717  if (uint64_t size = builtin_type->getLength())
718  bytes = size;
719  Encoding encoding = TranslateBuiltinEncoding(builtin_kind);
721  m_ast, *builtin_type, encoding, bytes.value_or(0) * 8);
722 
723  if (builtin_type->isConstType())
724  builtin_ast_type = builtin_ast_type.AddConstModifier();
725 
726  if (builtin_type->isVolatileType())
727  builtin_ast_type = builtin_ast_type.AddVolatileModifier();
728 
729  auto type_name = GetPDBBuiltinTypeName(*builtin_type, builtin_ast_type);
730 
731  return std::make_shared<lldb_private::Type>(
732  builtin_type->getSymIndexId(), m_ast.GetSymbolFile(), type_name, bytes,
734  builtin_ast_type, lldb_private::Type::ResolveState::Full);
735  } break;
736  case PDB_SymType::PointerType: {
737  auto *pointer_type = llvm::dyn_cast<PDBSymbolTypePointer>(&type);
738  assert(pointer_type);
739 
740  SymbolFile *symbol_file = m_ast.GetSymbolFile();
741  if (!symbol_file)
742  return nullptr;
743 
744  Type *pointee_type = symbol_file->ResolveTypeUID(
745  pointer_type->getPointeeType()->getSymIndexId());
746  if (!pointee_type)
747  return nullptr;
748 
749  if (pointer_type->isPointerToDataMember() ||
750  pointer_type->isPointerToMemberFunction()) {
751  auto class_parent_uid = pointer_type->getRawSymbol().getClassParentId();
752  auto class_parent_type = symbol_file->ResolveTypeUID(class_parent_uid);
753  assert(class_parent_type);
754 
755  CompilerType pointer_ast_type;
756  pointer_ast_type = TypeSystemClang::CreateMemberPointerType(
757  class_parent_type->GetLayoutCompilerType(),
758  pointee_type->GetForwardCompilerType());
759  assert(pointer_ast_type);
760 
761  return std::make_shared<lldb_private::Type>(
762  pointer_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
763  pointer_type->getLength(), nullptr, LLDB_INVALID_UID,
764  lldb_private::Type::eEncodingIsUID, decl, pointer_ast_type,
766  }
767 
768  CompilerType pointer_ast_type;
769  pointer_ast_type = pointee_type->GetFullCompilerType();
770  if (pointer_type->isReference())
771  pointer_ast_type = pointer_ast_type.GetLValueReferenceType();
772  else if (pointer_type->isRValueReference())
773  pointer_ast_type = pointer_ast_type.GetRValueReferenceType();
774  else
775  pointer_ast_type = pointer_ast_type.GetPointerType();
776 
777  if (pointer_type->isConstType())
778  pointer_ast_type = pointer_ast_type.AddConstModifier();
779 
780  if (pointer_type->isVolatileType())
781  pointer_ast_type = pointer_ast_type.AddVolatileModifier();
782 
783  if (pointer_type->isRestrictedType())
784  pointer_ast_type = pointer_ast_type.AddRestrictModifier();
785 
786  return std::make_shared<lldb_private::Type>(
787  pointer_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
788  pointer_type->getLength(), nullptr, LLDB_INVALID_UID,
789  lldb_private::Type::eEncodingIsUID, decl, pointer_ast_type,
791  } break;
792  default:
793  break;
794  }
795  return nullptr;
796 }
797 
799  lldb_private::CompilerType &compiler_type) {
800  if (GetClangASTImporter().CanImport(compiler_type))
801  return GetClangASTImporter().CompleteType(compiler_type);
802 
803  // Remove the type from the forward declarations to avoid
804  // an endless recursion for types like a linked list.
805  clang::CXXRecordDecl *record_decl =
806  m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType());
807  auto uid_it = m_forward_decl_to_uid.find(record_decl);
808  if (uid_it == m_forward_decl_to_uid.end())
809  return true;
810 
811  auto symbol_file = static_cast<SymbolFilePDB *>(
813  if (!symbol_file)
814  return false;
815 
816  std::unique_ptr<PDBSymbol> symbol =
817  symbol_file->GetPDBSession().getSymbolById(uid_it->getSecond());
818  if (!symbol)
819  return false;
820 
821  m_forward_decl_to_uid.erase(uid_it);
822 
823  TypeSystemClang::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
824  false);
825 
826  switch (symbol->getSymTag()) {
827  case PDB_SymType::UDT: {
828  auto udt = llvm::dyn_cast<PDBSymbolTypeUDT>(symbol.get());
829  if (!udt)
830  return false;
831 
832  return CompleteTypeFromUDT(*symbol_file, compiler_type, *udt);
833  }
834  default:
835  llvm_unreachable("not a forward clang type decl!");
836  }
837 }
838 
839 clang::Decl *
840 PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
841  uint32_t sym_id = symbol.getSymIndexId();
842  auto it = m_uid_to_decl.find(sym_id);
843  if (it != m_uid_to_decl.end())
844  return it->second;
845 
846  auto symbol_file = static_cast<SymbolFilePDB *>(
848  if (!symbol_file)
849  return nullptr;
850 
851  // First of all, check if the symbol is a member of a class. Resolve the full
852  // class type and return the declaration from the cache if so.
853  auto tag = symbol.getSymTag();
854  if (tag == PDB_SymType::Data || tag == PDB_SymType::Function) {
855  const IPDBSession &session = symbol.getSession();
856  const IPDBRawSymbol &raw = symbol.getRawSymbol();
857 
858  auto class_parent_id = raw.getClassParentId();
859  if (std::unique_ptr<PDBSymbol> class_parent =
860  session.getSymbolById(class_parent_id)) {
861  auto class_parent_type = symbol_file->ResolveTypeUID(class_parent_id);
862  if (!class_parent_type)
863  return nullptr;
864 
865  CompilerType class_parent_ct = class_parent_type->GetFullCompilerType();
866 
867  // Look a declaration up in the cache after completing the class
868  clang::Decl *decl = m_uid_to_decl.lookup(sym_id);
869  if (decl)
870  return decl;
871 
872  // A declaration was not found in the cache. It means that the symbol
873  // has the class parent, but the class doesn't have the symbol in its
874  // children list.
875  if (auto func = llvm::dyn_cast_or_null<PDBSymbolFunc>(&symbol)) {
876  // Try to find a class child method with the same RVA and use its
877  // declaration if found.
878  if (uint32_t rva = func->getRelativeVirtualAddress()) {
879  if (std::unique_ptr<ConcreteSymbolEnumerator<PDBSymbolFunc>>
880  methods_enum =
881  class_parent->findAllChildren<PDBSymbolFunc>()) {
882  while (std::unique_ptr<PDBSymbolFunc> method =
883  methods_enum->getNext()) {
884  if (method->getRelativeVirtualAddress() == rva) {
885  decl = m_uid_to_decl.lookup(method->getSymIndexId());
886  if (decl)
887  break;
888  }
889  }
890  }
891  }
892 
893  // If no class methods with the same RVA were found, then create a new
894  // method. It is possible for template methods.
895  if (!decl)
896  decl = AddRecordMethod(*symbol_file, class_parent_ct, *func);
897  }
898 
899  if (decl)
900  m_uid_to_decl[sym_id] = decl;
901 
902  return decl;
903  }
904  }
905 
906  // If we are here, then the symbol is not belonging to a class and is not
907  // contained in the cache. So create a declaration for it.
908  switch (symbol.getSymTag()) {
909  case PDB_SymType::Data: {
910  auto data = llvm::dyn_cast<PDBSymbolData>(&symbol);
911  assert(data);
912 
913  auto decl_context = GetDeclContextContainingSymbol(symbol);
914  assert(decl_context);
915 
916  // May be the current context is a class really, but we haven't found
917  // any class parent. This happens e.g. in the case of class static
918  // variables - they has two symbols, one is a child of the class when
919  // another is a child of the exe. So always complete the parent and use
920  // an existing declaration if possible.
921  if (auto parent_decl = llvm::dyn_cast_or_null<clang::TagDecl>(decl_context))
922  m_ast.GetCompleteDecl(parent_decl);
923 
924  std::string name =
926 
927  // Check if the current context already contains the symbol with the name.
928  clang::Decl *decl =
929  GetDeclFromContextByName(m_ast.getASTContext(), *decl_context, name);
930  if (!decl) {
931  auto type = symbol_file->ResolveTypeUID(data->getTypeId());
932  if (!type)
933  return nullptr;
934 
936  decl_context, OptionalClangModuleID(), name.c_str(),
937  ClangUtil::GetQualType(type->GetLayoutCompilerType()));
938  }
939 
940  m_uid_to_decl[sym_id] = decl;
941 
942  return decl;
943  }
944  case PDB_SymType::Function: {
945  auto func = llvm::dyn_cast<PDBSymbolFunc>(&symbol);
946  assert(func);
947 
948  auto decl_context = GetDeclContextContainingSymbol(symbol);
949  assert(decl_context);
950 
951  std::string name =
953 
954  Type *type = symbol_file->ResolveTypeUID(sym_id);
955  if (!type)
956  return nullptr;
957 
958  auto storage = func->isStatic() ? clang::StorageClass::SC_Static
959  : clang::StorageClass::SC_None;
960 
961  auto decl = m_ast.CreateFunctionDeclaration(
962  decl_context, OptionalClangModuleID(), name,
963  type->GetForwardCompilerType(), storage, func->hasInlineAttribute());
964 
965  std::vector<clang::ParmVarDecl *> params;
966  if (std::unique_ptr<PDBSymbolTypeFunctionSig> sig = func->getSignature()) {
968  arg_enum = sig->findAllChildren<PDBSymbolTypeFunctionArg>()) {
969  while (std::unique_ptr<PDBSymbolTypeFunctionArg> arg =
970  arg_enum->getNext()) {
971  Type *arg_type = symbol_file->ResolveTypeUID(arg->getTypeId());
972  if (!arg_type)
973  continue;
974 
975  clang::ParmVarDecl *param = m_ast.CreateParameterDeclaration(
976  decl, OptionalClangModuleID(), nullptr,
977  arg_type->GetForwardCompilerType(), clang::SC_None, true);
978  if (param)
979  params.push_back(param);
980  }
981  }
982  }
983  if (params.size())
984  m_ast.SetFunctionParameters(decl, params);
985 
986  m_uid_to_decl[sym_id] = decl;
987 
988  return decl;
989  }
990  default: {
991  // It's not a variable and not a function, check if it's a type
992  Type *type = symbol_file->ResolveTypeUID(sym_id);
993  if (!type)
994  return nullptr;
995 
996  return m_uid_to_decl.lookup(sym_id);
997  }
998  }
999 }
1000 
1001 clang::DeclContext *
1002 PDBASTParser::GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol) {
1003  if (symbol.getSymTag() == PDB_SymType::Function) {
1004  clang::DeclContext *result =
1005  llvm::dyn_cast_or_null<clang::FunctionDecl>(GetDeclForSymbol(symbol));
1006 
1007  if (result)
1008  m_decl_context_to_uid[result] = symbol.getSymIndexId();
1009 
1010  return result;
1011  }
1012 
1013  auto symbol_file = static_cast<SymbolFilePDB *>(
1015  if (!symbol_file)
1016  return nullptr;
1017 
1018  auto type = symbol_file->ResolveTypeUID(symbol.getSymIndexId());
1019  if (!type)
1020  return nullptr;
1021 
1022  clang::DeclContext *result =
1023  m_ast.GetDeclContextForType(type->GetForwardCompilerType());
1024 
1025  if (result)
1026  m_decl_context_to_uid[result] = symbol.getSymIndexId();
1027 
1028  return result;
1029 }
1030 
1032  const llvm::pdb::PDBSymbol &symbol) {
1033  auto parent = GetClassOrFunctionParent(symbol);
1034  while (parent) {
1035  if (auto parent_context = GetDeclContextForSymbol(*parent))
1036  return parent_context;
1037 
1038  parent = GetClassOrFunctionParent(*parent);
1039  }
1040 
1041  // We can't find any class or function parent of the symbol. So analyze
1042  // the full symbol name. The symbol may be belonging to a namespace
1043  // or function (or even to a class if it's e.g. a static variable symbol).
1044 
1045  // TODO: Make clang to emit full names for variables in namespaces
1046  // (as MSVC does)
1047 
1048  std::string name(symbol.getRawSymbol().getName());
1049  MSVCUndecoratedNameParser parser(name);
1050  llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
1051  if (specs.empty())
1052  return m_ast.GetTranslationUnitDecl();
1053 
1054  auto symbol_file = static_cast<SymbolFilePDB *>(
1056  if (!symbol_file)
1057  return m_ast.GetTranslationUnitDecl();
1058 
1059  auto global = symbol_file->GetPDBSession().getGlobalScope();
1060  if (!global)
1061  return m_ast.GetTranslationUnitDecl();
1062 
1063  bool has_type_or_function_parent = false;
1064  clang::DeclContext *curr_context = m_ast.GetTranslationUnitDecl();
1065  for (std::size_t i = 0; i < specs.size() - 1; i++) {
1066  // Check if there is a function or a type with the current context's name.
1067  if (std::unique_ptr<IPDBEnumSymbols> children_enum = global->findChildren(
1068  PDB_SymType::None, specs[i].GetFullName(), NS_CaseSensitive)) {
1069  while (IPDBEnumChildren<PDBSymbol>::ChildTypePtr child =
1070  children_enum->getNext()) {
1071  if (clang::DeclContext *child_context =
1072  GetDeclContextForSymbol(*child)) {
1073  // Note that `GetDeclContextForSymbol' retrieves
1074  // a declaration context for functions and types only,
1075  // so if we are here then `child_context' is guaranteed
1076  // a function or a type declaration context.
1077  has_type_or_function_parent = true;
1078  curr_context = child_context;
1079  }
1080  }
1081  }
1082 
1083  // If there were no functions or types above then retrieve a namespace with
1084  // the current context's name. There can be no namespaces inside a function
1085  // or a type. We check it to avoid fake namespaces such as `__l2':
1086  // `N0::N1::CClass::PrivateFunc::__l2::InnerFuncStruct'
1087  if (!has_type_or_function_parent) {
1088  std::string namespace_name = std::string(specs[i].GetBaseName());
1089  const char *namespace_name_c_str =
1090  IsAnonymousNamespaceName(namespace_name) ? nullptr
1091  : namespace_name.data();
1092  clang::NamespaceDecl *namespace_decl =
1094  namespace_name_c_str, curr_context, OptionalClangModuleID());
1095 
1096  m_parent_to_namespaces[curr_context].insert(namespace_decl);
1097  m_namespaces.insert(namespace_decl);
1098 
1099  curr_context = namespace_decl;
1100  }
1101  }
1102 
1103  return curr_context;
1104 }
1105 
1107  const clang::DeclContext *decl_context) {
1108  auto symbol_file = static_cast<SymbolFilePDB *>(
1110  if (!symbol_file)
1111  return;
1112 
1113  IPDBSession &session = symbol_file->GetPDBSession();
1114  auto symbol_up =
1115  session.getSymbolById(m_decl_context_to_uid.lookup(decl_context));
1116  auto global_up = session.getGlobalScope();
1117 
1118  PDBSymbol *symbol;
1119  if (symbol_up)
1120  symbol = symbol_up.get();
1121  else if (global_up)
1122  symbol = global_up.get();
1123  else
1124  return;
1125 
1126  if (auto children = symbol->findAllChildren())
1127  while (auto child = children->getNext())
1128  GetDeclForSymbol(*child);
1129 }
1130 
1131 clang::NamespaceDecl *
1132 PDBASTParser::FindNamespaceDecl(const clang::DeclContext *parent,
1133  llvm::StringRef name) {
1134  NamespacesSet *set;
1135  if (parent) {
1136  auto pit = m_parent_to_namespaces.find(parent);
1137  if (pit == m_parent_to_namespaces.end())
1138  return nullptr;
1139 
1140  set = &pit->second;
1141  } else {
1142  set = &m_namespaces;
1143  }
1144  assert(set);
1145 
1146  for (clang::NamespaceDecl *namespace_decl : *set)
1147  if (namespace_decl->getName().equals(name))
1148  return namespace_decl;
1149 
1150  for (clang::NamespaceDecl *namespace_decl : *set)
1151  if (namespace_decl->isAnonymousNamespace())
1152  return FindNamespaceDecl(namespace_decl, name);
1153 
1154  return nullptr;
1155 }
1156 
1158  const PDBSymbolData &enum_value) {
1159  Declaration decl;
1160  Variant v = enum_value.getValue();
1161  std::string name =
1162  std::string(MSVCUndecoratedNameParser::DropScope(enum_value.getName()));
1163  int64_t raw_value;
1164  switch (v.Type) {
1165  case PDB_VariantType::Int8:
1166  raw_value = v.Value.Int8;
1167  break;
1168  case PDB_VariantType::Int16:
1169  raw_value = v.Value.Int16;
1170  break;
1171  case PDB_VariantType::Int32:
1172  raw_value = v.Value.Int32;
1173  break;
1174  case PDB_VariantType::Int64:
1175  raw_value = v.Value.Int64;
1176  break;
1177  case PDB_VariantType::UInt8:
1178  raw_value = v.Value.UInt8;
1179  break;
1180  case PDB_VariantType::UInt16:
1181  raw_value = v.Value.UInt16;
1182  break;
1183  case PDB_VariantType::UInt32:
1184  raw_value = v.Value.UInt32;
1185  break;
1186  case PDB_VariantType::UInt64:
1187  raw_value = v.Value.UInt64;
1188  break;
1189  default:
1190  return false;
1191  }
1192  CompilerType underlying_type = m_ast.GetEnumerationIntegerType(enum_type);
1193  uint32_t byte_size = m_ast.getASTContext().getTypeSize(
1194  ClangUtil::GetQualType(underlying_type));
1195  auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType(
1196  enum_type, decl, name.c_str(), raw_value, byte_size * 8);
1197  if (!enum_constant_decl)
1198  return false;
1199 
1200  m_uid_to_decl[enum_value.getSymIndexId()] = enum_constant_decl;
1201 
1202  return true;
1203 }
1204 
1206  lldb_private::SymbolFile &symbol_file,
1207  lldb_private::CompilerType &compiler_type,
1208  llvm::pdb::PDBSymbolTypeUDT &udt) {
1209  ClangASTImporter::LayoutInfo layout_info;
1210  layout_info.bit_size = udt.getLength() * 8;
1211 
1212  auto nested_enums = udt.findAllChildren<PDBSymbolTypeUDT>();
1213  if (nested_enums)
1214  while (auto nested = nested_enums->getNext())
1215  symbol_file.ResolveTypeUID(nested->getSymIndexId());
1216 
1217  auto bases_enum = udt.findAllChildren<PDBSymbolTypeBaseClass>();
1218  if (bases_enum)
1219  AddRecordBases(symbol_file, compiler_type,
1220  TranslateUdtKind(udt.getUdtKind()), *bases_enum,
1221  layout_info);
1222 
1223  auto members_enum = udt.findAllChildren<PDBSymbolData>();
1224  if (members_enum)
1225  AddRecordMembers(symbol_file, compiler_type, *members_enum, layout_info);
1226 
1227  auto methods_enum = udt.findAllChildren<PDBSymbolFunc>();
1228  if (methods_enum)
1229  AddRecordMethods(symbol_file, compiler_type, *methods_enum);
1230 
1232  TypeSystemClang::BuildIndirectFields(compiler_type);
1233  TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
1234 
1235  clang::CXXRecordDecl *record_decl =
1236  m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType());
1237  if (!record_decl)
1238  return static_cast<bool>(compiler_type);
1239 
1240  GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
1241 
1242  return static_cast<bool>(compiler_type);
1243 }
1244 
1246  lldb_private::SymbolFile &symbol_file,
1247  lldb_private::CompilerType &record_type,
1248  PDBDataSymbolEnumerator &members_enum,
1250  while (auto member = members_enum.getNext()) {
1251  if (member->isCompilerGenerated())
1252  continue;
1253 
1254  auto member_name = member->getName();
1255 
1256  auto member_type = symbol_file.ResolveTypeUID(member->getTypeId());
1257  if (!member_type)
1258  continue;
1259 
1260  auto member_comp_type = member_type->GetLayoutCompilerType();
1261  if (!member_comp_type.GetCompleteType()) {
1262  symbol_file.GetObjectFile()->GetModule()->ReportError(
1263  ":: Class '%s' has a member '%s' of type '%s' "
1264  "which does not have a complete definition.",
1265  record_type.GetTypeName().GetCString(), member_name.c_str(),
1266  member_comp_type.GetTypeName().GetCString());
1267  if (TypeSystemClang::StartTagDeclarationDefinition(member_comp_type))
1268  TypeSystemClang::CompleteTagDeclarationDefinition(member_comp_type);
1269  }
1270 
1271  auto access = TranslateMemberAccess(member->getAccess());
1272 
1273  switch (member->getDataKind()) {
1274  case PDB_DataKind::Member: {
1275  auto location_type = member->getLocationType();
1276 
1277  auto bit_size = member->getLength();
1278  if (location_type == PDB_LocType::ThisRel)
1279  bit_size *= 8;
1280 
1281  auto decl = TypeSystemClang::AddFieldToRecordType(
1282  record_type, member_name.c_str(), member_comp_type, access, bit_size);
1283  if (!decl)
1284  continue;
1285 
1286  m_uid_to_decl[member->getSymIndexId()] = decl;
1287 
1288  auto offset = member->getOffset() * 8;
1289  if (location_type == PDB_LocType::BitField)
1290  offset += member->getBitPosition();
1291 
1292  layout_info.field_offsets.insert(std::make_pair(decl, offset));
1293 
1294  break;
1295  }
1296  case PDB_DataKind::StaticMember: {
1297  auto decl = TypeSystemClang::AddVariableToRecordType(
1298  record_type, member_name.c_str(), member_comp_type, access);
1299  if (!decl)
1300  continue;
1301 
1302  // Static constant members may be a const[expr] declaration.
1303  // Query the symbol's value as the variable initializer if valid.
1304  if (member_comp_type.IsConst()) {
1305  auto value = member->getValue();
1306  clang::QualType qual_type = decl->getType();
1307  unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
1308  unsigned constant_width = value.getBitWidth();
1309 
1310  if (qual_type->isIntegralOrEnumerationType()) {
1311  if (type_width >= constant_width) {
1312  TypeSystemClang::SetIntegerInitializerForVariable(
1313  decl, value.toAPSInt().extOrTrunc(type_width));
1314  } else {
1315  LLDB_LOG(GetLog(LLDBLog::AST),
1316  "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
1317  "which resolves to a wider constant value ({4} bits). "
1318  "Ignoring constant.",
1319  record_type.GetTypeName(), member_name,
1320  member_comp_type.GetTypeName(), type_width,
1321  constant_width);
1322  }
1323  } else {
1324  switch (member_comp_type.GetBasicTypeEnumeration()) {
1325  case lldb::eBasicTypeFloat:
1328  if (type_width == constant_width) {
1329  TypeSystemClang::SetFloatingInitializerForVariable(
1330  decl, value.toAPFloat());
1331  decl->setConstexpr(true);
1332  } else {
1333  LLDB_LOG(GetLog(LLDBLog::AST),
1334  "Class '{0}' has a member '{1}' of type '{2}' ({3} "
1335  "bits) which resolves to a constant value of mismatched "
1336  "width ({4} bits). Ignoring constant.",
1337  record_type.GetTypeName(), member_name,
1338  member_comp_type.GetTypeName(), type_width,
1339  constant_width);
1340  }
1341  break;
1342  default:
1343  break;
1344  }
1345  }
1346  }
1347 
1348  m_uid_to_decl[member->getSymIndexId()] = decl;
1349 
1350  break;
1351  }
1352  default:
1353  llvm_unreachable("unsupported PDB data kind");
1354  }
1355  }
1356 }
1357 
1359  lldb_private::SymbolFile &symbol_file,
1360  lldb_private::CompilerType &record_type, int record_kind,
1361  PDBBaseClassSymbolEnumerator &bases_enum,
1362  lldb_private::ClangASTImporter::LayoutInfo &layout_info) const {
1363  std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> base_classes;
1364 
1365  while (auto base = bases_enum.getNext()) {
1366  auto base_type = symbol_file.ResolveTypeUID(base->getTypeId());
1367  if (!base_type)
1368  continue;
1369 
1370  auto base_comp_type = base_type->GetFullCompilerType();
1371  if (!base_comp_type.GetCompleteType()) {
1372  symbol_file.GetObjectFile()->GetModule()->ReportError(
1373  ":: Class '%s' has a base class '%s' "
1374  "which does not have a complete definition.",
1375  record_type.GetTypeName().GetCString(),
1376  base_comp_type.GetTypeName().GetCString());
1377  if (TypeSystemClang::StartTagDeclarationDefinition(base_comp_type))
1378  TypeSystemClang::CompleteTagDeclarationDefinition(base_comp_type);
1379  }
1380 
1381  auto access = TranslateMemberAccess(base->getAccess());
1382 
1383  auto is_virtual = base->isVirtualBaseClass();
1384 
1385  std::unique_ptr<clang::CXXBaseSpecifier> base_spec =
1386  m_ast.CreateBaseClassSpecifier(base_comp_type.GetOpaqueQualType(),
1387  access, is_virtual,
1388  record_kind == clang::TTK_Class);
1389  lldbassert(base_spec);
1390 
1391  base_classes.push_back(std::move(base_spec));
1392 
1393  if (is_virtual)
1394  continue;
1395 
1396  auto decl = m_ast.GetAsCXXRecordDecl(base_comp_type.GetOpaqueQualType());
1397  if (!decl)
1398  continue;
1399 
1400  auto offset = clang::CharUnits::fromQuantity(base->getOffset());
1401  layout_info.base_offsets.insert(std::make_pair(decl, offset));
1402  }
1403 
1405  std::move(base_classes));
1406 }
1407 
1409  lldb_private::CompilerType &record_type,
1410  PDBFuncSymbolEnumerator &methods_enum) {
1411  while (std::unique_ptr<PDBSymbolFunc> method = methods_enum.getNext())
1412  if (clang::CXXMethodDecl *decl =
1413  AddRecordMethod(symbol_file, record_type, *method))
1414  m_uid_to_decl[method->getSymIndexId()] = decl;
1415 }
1416 
1417 clang::CXXMethodDecl *
1419  lldb_private::CompilerType &record_type,
1420  const llvm::pdb::PDBSymbolFunc &method) const {
1421  std::string name =
1423 
1424  Type *method_type = symbol_file.ResolveTypeUID(method.getSymIndexId());
1425  // MSVC specific __vecDelDtor.
1426  if (!method_type)
1427  return nullptr;
1428 
1429  CompilerType method_comp_type = method_type->GetFullCompilerType();
1430  if (!method_comp_type.GetCompleteType()) {
1431  symbol_file.GetObjectFile()->GetModule()->ReportError(
1432  ":: Class '%s' has a method '%s' whose type cannot be completed.",
1433  record_type.GetTypeName().GetCString(),
1434  method_comp_type.GetTypeName().GetCString());
1435  if (TypeSystemClang::StartTagDeclarationDefinition(method_comp_type))
1436  TypeSystemClang::CompleteTagDeclarationDefinition(method_comp_type);
1437  }
1438 
1439  AccessType access = TranslateMemberAccess(method.getAccess());
1440  if (access == eAccessNone)
1441  access = eAccessPublic;
1442 
1443  // TODO: get mangled name for the method.
1445  record_type.GetOpaqueQualType(), name.c_str(),
1446  /*mangled_name*/ nullptr, method_comp_type, access, method.isVirtual(),
1447  method.isStatic(), method.hasInlineAttribute(),
1448  /*is_explicit*/ false, // FIXME: Need this field in CodeView.
1449  /*is_attr_used*/ false,
1450  /*is_artificial*/ method.isCompilerGenerated());
1451 }
lldb_private::Declaration::SetLine
void SetLine(uint32_t line)
Set accessor for the declaration line number.
Definition: Declaration.h:168
lldb_private::ClangASTImporter::LayoutInfo::field_offsets
llvm::DenseMap< const clang::FieldDecl *, uint64_t > field_offsets
Definition: ClangASTImporter.h:73
TranslateEnumEncoding
static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type)
Definition: PDBASTParser.cpp:83
PDBASTParser::GetDeclForSymbol
clang::Decl * GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol)
Definition: PDBASTParser.cpp:840
SymbolFilePDB.h
SymbolFilePDB
Definition: SymbolFilePDB.h:24
lldb_private::TypeSystemClang::CreateParameterDeclaration
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType &param_type, int storage, bool add_decl=false)
Definition: TypeSystemClang.cpp:2223
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:46
lldb_private::TypeSystemClang::TransferBaseClasses
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier >> bases)
Definition: TypeSystemClang.cpp:7866
lldb_private::TypeSystemClang::getASTContext
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
Definition: TypeSystemClang.cpp:687
GetDeclarationForSymbol
static bool GetDeclarationForSymbol(const PDBSymbol &symbol, Declaration &decl)
Definition: PDBASTParser.cpp:192
lldb_private::TypeSystemClang::CreateDeclContext
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
Definition: TypeSystemClang.cpp:1200
lldb::eBasicTypeBool
@ eBasicTypeBool
Definition: lldb-enumerations.h:770
lldb::eAccessProtected
@ eAccessProtected
Definition: lldb-enumerations.h:512
TypeMap.h
PDBASTParser::GetClangASTImporter
lldb_private::ClangASTImporter & GetClangASTImporter()
Definition: PDBASTParser.h:63
lldb_private::Type::eEncodingIsTypedefUID
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
Definition: Type.h:83
SymbolFilePDB::GetPDBSession
llvm::pdb::IPDBSession & GetPDBSession()
Definition: SymbolFilePDB.cpp:1728
GetPDBBuiltinTypeName
static ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type, CompilerType &compiler_type)
Definition: PDBASTParser.cpp:160
MSVCUndecoratedNameParser
Definition: MSVCUndecoratedNameParser.h:31
lldb_private::TypeSystemClang::CreateFunctionDeclaration
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline)
Definition: TypeSystemClang.cpp:2153
lldb_private::TypeSystemClang::GetTranslationUnitDecl
clang::TranslationUnitDecl * GetTranslationUnitDecl()
Definition: TypeSystemClang.h:223
PDBASTParser::m_forward_decl_to_uid
CXXRecordDeclToUidMap m_forward_decl_to_uid
Definition: PDBASTParser.h:109
MSVCUndecoratedNameParser::GetSpecifiers
llvm::ArrayRef< MSVCUndecoratedNameSpecifier > GetSpecifiers() const
Definition: MSVCUndecoratedNameParser.h:35
lldb_private::ClangASTMetadata::SetUserID
void SetUserID(lldb::user_id_t user_id)
Definition: ClangASTMetadata.h:29
lldb_private::CompilerType::GetTypeName
ConstString GetTypeName(bool BaseOnly=false) const
Definition: CompilerType.cpp:314
lldb_private::Type::GetLayoutCompilerType
CompilerType GetLayoutCompilerType()
Definition: Type.cpp:656
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:80
lldb_private::TypeSystemClang::CreateFunctionType
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
Definition: TypeSystemClang.cpp:2185
lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
Definition: TypeSystemClang.cpp:796
Module.h
PDBASTParser::AddRecordMethods
void AddRecordMethods(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, PDBFuncSymbolEnumerator &methods_enum)
Definition: PDBASTParser.cpp:1408
lldb::eEncodingIEEE754
@ eEncodingIEEE754
float
Definition: lldb-enumerations.h:151
PDBASTParser::AddEnumValue
bool AddEnumValue(lldb_private::CompilerType enum_type, const llvm::pdb::PDBSymbolData &data)
Definition: PDBASTParser.cpp:1157
lldb_private::TypeSystemClang::CreateEnumerationType
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
Definition: TypeSystemClang.cpp:2322
GetAccessibilityForUdt
static AccessType GetAccessibilityForUdt(const PDBSymbolTypeUDT &udt)
Definition: PDBASTParser.cpp:242
lldb_private::ClangASTImporter::LayoutInfo
Definition: ClangASTImporter.h:66
PDBASTParser::CompleteTypeFromUDT
bool CompleteTypeFromUDT(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &compiler_type, llvm::pdb::PDBSymbolTypeUDT &udt)
Definition: PDBASTParser.cpp:1205
lldb_private::TypeSystemClang::GetTypeForIdentifier
CompilerType GetTypeForIdentifier(ConstString type_name, clang::DeclContext *decl_context=nullptr)
Definition: TypeSystemClang.h:254
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:229
GetDeclFromContextByName
static clang::NamedDecl * GetDeclFromContextByName(const clang::ASTContext &ast, const clang::DeclContext &decl_context, llvm::StringRef name)
Definition: PDBASTParser.cpp:329
lldb::eBasicTypeChar
@ eBasicTypeChar
Definition: lldb-enumerations.h:751
lldb_private::CompilerType::AddVolatileModifier
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
Definition: CompilerType.cpp:502
MSVCUndecoratedNameParser::DropScope
static llvm::StringRef DropScope(llvm::StringRef name)
Definition: MSVCUndecoratedNameParser.cpp:98
PDBASTParser::~PDBASTParser
~PDBASTParser()
lldb_private::TypeSystemClang::CreateArrayType
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
Definition: TypeSystemClang.cpp:2257
GetBuiltinTypeForPDBEncodingAndBitSize
static CompilerType GetBuiltinTypeForPDBEncodingAndBitSize(TypeSystemClang &clang_ast, const PDBSymbolTypeBuiltin &pdb_type, Encoding encoding, uint32_t width)
Definition: PDBASTParser.cpp:105
ClangUtil.h
PDBASTParser::AddRecordBases
void AddRecordBases(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, int record_kind, PDBBaseClassSymbolEnumerator &bases_enum, lldb_private::ClangASTImporter::LayoutInfo &layout_info) const
Definition: PDBASTParser.cpp:1358
PDBASTParser::ParseDeclsForDeclContext
void ParseDeclsForDeclContext(const clang::DeclContext *decl_context)
Definition: PDBASTParser.cpp:1106
PDBASTParser::FindNamespaceDecl
clang::NamespaceDecl * FindNamespaceDecl(const clang::DeclContext *parent, llvm::StringRef name)
Definition: PDBASTParser.cpp:1132
lldb::eBasicTypeFloat
@ eBasicTypeFloat
Definition: lldb-enumerations.h:772
lldb_private::Type::ResolveState
ResolveState
Definition: Type.h:96
llvm::pdb::ConcreteSymbolEnumerator
Definition: PDBASTParser.h:32
lldb_private::ClangASTImporter::LayoutInfo::base_offsets
OffsetMap base_offsets
Definition: ClangASTImporter.h:74
UInt
#define UInt(x)
Definition: EmulateInstructionARM64.cpp:70
lldb::eEncodingInvalid
@ eEncodingInvalid
Definition: lldb-enumerations.h:148
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb::eEncodingSint
@ eEncodingSint
signed integer
Definition: lldb-enumerations.h:150
ClangASTMetadata.h
lldb_private::SymbolFile::ResolveTypeUID
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
SymbolFilePDB::ResolveTypeUID
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
Definition: SymbolFilePDB.cpp:558
lldb_private::TypeSystemClang::GetAsCXXRecordDecl
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
Definition: TypeSystemClang.cpp:7338
lldb_private::CompilerType::CreateTypedef
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
Definition: CompilerType.cpp:516
TypeSystemClang.h
lldb_private::Declaration::SetColumn
void SetColumn(uint16_t column)
Set accessor for the declaration column number.
Definition: Declaration.h:175
PDBASTParser::AddRecordMembers
void AddRecordMembers(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, PDBDataSymbolEnumerator &members_enum, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
Definition: PDBASTParser.cpp:1245
PDBASTParser::m_parent_to_namespaces
ParentToNamespacesMap m_parent_to_namespaces
Definition: PDBASTParser.h:111
PDBASTParser::AddRecordMethod
clang::CXXMethodDecl * AddRecordMethod(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, const llvm::pdb::PDBSymbolFunc &method) const
Definition: PDBASTParser.cpp:1418
lldb::eAccessNone
@ eAccessNone
Definition: lldb-enumerations.h:509
Declaration.h
lldb::eBasicTypeInt
@ eBasicTypeInt
Definition: lldb-enumerations.h:762
lldb_private::ClangASTImporter::CompleteType
bool CompleteType(const CompilerType &compiler_type)
Definition: ClangASTImporter.cpp:505
llvm::pdb
Definition: DWARFLocationExpression.h:23
lldb::eBasicTypeDouble
@ eBasicTypeDouble
Definition: lldb-enumerations.h:773
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:149
lldb_private::ConstString
Definition: ConstString.h:39
MSVCUndecoratedNameParser.h
lldb_private::CompilerType::AddConstModifier
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
Definition: CompilerType.cpp:495
lldb::eLanguageTypeC_plus_plus
@ eLanguageTypeC_plus_plus
ISO C++:1998.
Definition: lldb-enumerations.h:442
GetClassOrFunctionParent
static std::unique_ptr< llvm::pdb::PDBSymbol > GetClassOrFunctionParent(const llvm::pdb::PDBSymbol &symbol)
Definition: PDBASTParser.cpp:279
lldb_private::ClangASTMetadata::SetIsDynamicCXXType
void SetIsDynamicCXXType(bool b)
Definition: ClangASTMetadata.h:27
lldb_private::Declaration::SetFile
void SetFile(const FileSpec &file_spec)
Set accessor for the declaration file specification.
Definition: Declaration.h:161
PDBASTParser::m_uid_to_decl
UidToDeclMap m_uid_to_decl
Definition: PDBASTParser.h:110
TranslateMemberAccess
static AccessType TranslateMemberAccess(PDB_MemberAccess access)
Definition: PDBASTParser.cpp:218
PDBASTParser::GetDeclContextContainingSymbol
clang::DeclContext * GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol)
Definition: PDBASTParser.cpp:1031
lldb::eBasicTypeVoid
@ eBasicTypeVoid
Definition: lldb-enumerations.h:750
lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
Definition: TypeSystemClang.cpp:1870
set
set(option_framework FRAMEWORK) endif() if(LLDB_ENABLE_PYTHON) get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR) set(lldb_python_wrapper $
Definition: API/CMakeLists.txt:5
PDBASTParser::m_ast
lldb_private::TypeSystemClang & m_ast
Definition: PDBASTParser.h:106
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ClangASTMetadata
Definition: ClangASTMetadata.h:18
TypeSystem.h
lldb_private::Type::ResolveState::Full
@ Full
TranslateCallingConvention
static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc)
Definition: PDBASTParser.cpp:345
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:123
lldb_private::CompilerType::GetLValueReferenceType
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
Definition: CompilerType.cpp:474
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::TypeSystemClang::AddMethodOverridesForCXXRecordType
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
Definition: TypeSystemClang.cpp:7843
lldb_private::CompilerType::GetCompleteType
bool GetCompleteType() const
Type Completion.
Definition: CompilerType.cpp:300
lldb_private::ClangASTImporter::SetRecordLayout
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
Definition: ClangASTImporter.cpp:548
lldb_private::TypeSystemClang::SetFunctionParameters
void SetFunctionParameters(clang::FunctionDecl *function_decl, llvm::ArrayRef< clang::ParmVarDecl * > params)
Definition: TypeSystemClang.cpp:2241
lldb::eAccessPublic
@ eAccessPublic
Definition: lldb-enumerations.h:510
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
PDBASTParser::CreateLLDBTypeFromPDBType
lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type)
Definition: PDBASTParser.cpp:371
lldb_private::CompilerType::GetPointerType
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
Definition: CompilerType.cpp:466
lldb::eBasicTypeLongDouble
@ eBasicTypeLongDouble
Definition: lldb-enumerations.h:774
GetMSInheritance
static clang::MSInheritanceAttr::Spelling GetMSInheritance(const PDBSymbolTypeUDT &udt)
Definition: PDBASTParser.cpp:259
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:56
TranslateBuiltinEncoding
static lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type)
Definition: PDBASTParser.cpp:62
uint32_t
lldb_private::TypeSystemClang::GetCompleteDecl
bool GetCompleteDecl(clang::Decl *decl)
Definition: TypeSystemClang.h:177
lldb::eAccessPrivate
@ eAccessPrivate
Definition: lldb-enumerations.h:511
lldb_private::TypeSystemClang::GetEnumerationIntegerType
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
Definition: TypeSystemClang.cpp:4329
PDBASTParser::m_decl_context_to_uid
DeclContextToUidMap m_decl_context_to_uid
Definition: PDBASTParser.h:113
PDBASTParser::GetDeclContextForSymbol
clang::DeclContext * GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol)
Definition: PDBASTParser.cpp:1002
lldb_private::TypeSystemClang::CreateVariableDeclaration
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
Definition: TypeSystemClang.cpp:2002
IsAnonymousNamespaceName
static bool IsAnonymousNamespaceName(llvm::StringRef name)
Definition: PDBASTParser.cpp:341
lldb_private::Type
Definition: Type.h:66
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:661
lldb_private::SymbolFile::GetBackingSymbolFile
virtual SymbolFile * GetBackingSymbolFile()
SymbolFileOnDemand class overrides this to return the underlying backing SymbolFile implementation th...
Definition: SymbolFile.h:83
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::CompilerType::AddRestrictModifier
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
Definition: CompilerType.cpp:509
PDBASTParser::CompleteTypeFromPDB
bool CompleteTypeFromPDB(lldb_private::CompilerType &compiler_type)
Definition: PDBASTParser.cpp:798
lldb::Encoding
Encoding
Register encoding definitions.
Definition: lldb-enumerations.h:147
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
lldb_private::TypeSystemClang::CreateRecordType
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
Definition: TypeSystemClang.cpp:1270
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:35
PDBASTParser::PDBASTParser
PDBASTParser(lldb_private::TypeSystemClang &ast)
Definition: PDBASTParser.cpp:365
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Type::ResolveState::Forward
@ Forward
lldb_private::TypeSystemClang::GetBasicType
CompilerType GetBasicType(lldb::BasicType type)
Definition: TypeSystemClang.cpp:931
GetDefaultAccessibilityForUdtKind
static AccessType GetDefaultAccessibilityForUdtKind(PDB_UdtType udt_kind)
Definition: PDBASTParser.cpp:230
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
lldb_private::TypeSystemClang::AddEnumerationValueToEnumerationType
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
Definition: TypeSystemClang.cpp:8465
lldb_private::TypeSystem::GetSymbolFile
virtual SymbolFile * GetSymbolFile() const
Definition: TypeSystem.h:98
lldb_private::TypeSystemClang::AddMethodToCXXRecordType
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
Definition: TypeSystemClang.cpp:7647
lldb_private::TypeSystemClang::GetDeclContextForType
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
Definition: TypeSystemClang.cpp:2648
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::SymbolFile::GetObjectFile
virtual ObjectFile * GetObjectFile()=0
lldb_private::Declaration
Definition: Declaration.h:24
PDBASTParser::NamespacesSet
std::set< clang::NamespaceDecl * > NamespacesSet
Definition: PDBASTParser.h:71
lldb
Definition: SBAddress.h:15
TranslateUdtKind
static int TranslateUdtKind(PDB_UdtType pdb_kind)
Definition: PDBASTParser.cpp:48
PDBASTParser.h
lldb_private::Type::GetFullCompilerType
CompilerType GetFullCompilerType()
Definition: Type.cpp:651
PDBASTParser::m_namespaces
NamespacesSet m_namespaces
Definition: PDBASTParser.h:112
LLDBLog.h
lldb::AccessType
AccessType
Definition: lldb-enumerations.h:508
SymbolFile.h
lldb_private::TypeSystemClang::CreateBaseClassSpecifier
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
Definition: TypeSystemClang.cpp:7853
lldb_private::ClangASTImporter::LayoutInfo::bit_size
uint64_t bit_size
Definition: ClangASTImporter.h:71
lldb_private::CompilerType::GetRValueReferenceType
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
Definition: CompilerType.cpp:481
lldb_private::Type::eEncodingIsUID
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
Definition: Type.h:72