LLVM: lib/DebugInfo/LogicalView/Core/LVElement.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

17

18using namespace llvm;

21

22#define DEBUG_TYPE "Element"

23

25 {LVElementKind::Discarded, &LVElement::getIsDiscarded},

26 {LVElementKind::Global, &LVElement::getIsGlobalReference},

27 {LVElementKind::Optimized, &LVElement::getIsOptimized}};

28

32 : nullptr;

33}

34

38 : nullptr;

39}

40

41

45 return;

46 }

47

48 if (options().getAttributeArgument()) {

53 } else

55}

56

57

65}

66

67

70}

71

72

75}

76

78

80

81

82

83 if (options().getAttributePathname()) {

84

86 size_t Pos = Basename.rfind('/');

87 if (Pos != std:🧵:npos)

88 Basename = Basename.substr(Pos + 1);

90 }

91

93}

94

96

97 NameIndex = getTransformName() ? getStringIndex(ElementName)

99}

100

102

104}

105

107 if (Name.size()) {

111 }

112}

113

114

116 if (options().getAttributeOffset()) {

119 }

120 return {};

121}

122

127 return "public";

129 return "protected";

131 return "private";

132 default:

134 }

135}

136

139 case MemberAccess::Private:

141 case MemberAccess::Protected:

143 case MemberAccess::Public:

145 default:

146 return std::nullopt;

147 }

148}

149

151 return getIsExternal() ? "extern" : StringRef();

152}

153

158 return "not_inlined";

160 return "inlined";

162 return "declared_not_inlined";

164 return "declared_inlined";

165 default:

167 }

168}

169

172 switch (Value ? Value : Virtuality) {

173 case dwarf::DW_VIRTUALITY_none:

175 case dwarf::DW_VIRTUALITY_virtual:

176 return "virtual";

177 case dwarf::DW_VIRTUALITY_pure_virtual:

178 return "pure virtual";

179 default:

181 }

182}

183

185 switch (Virtuality) {

186 case MethodKind::Virtual:

187 return dwarf::DW_VIRTUALITY_virtual;

188 case MethodKind::PureVirtual:

189 return dwarf::DW_VIRTUALITY_pure_virtual;

190 case MethodKind::IntroducingVirtual:

191 case MethodKind::PureIntroducingVirtual:

192

193 return dwarf::DW_VIRTUALITY_virtual;

194 default:

195 return std::nullopt;

196 }

197}

198

200 if (getIsResolved())

201 return;

202 setIsResolved();

203

208}

209

210

211void LVElement::setFileLine(LVElement *Specification) {

212

213

216 setIsLineFromReference();

217 }

220 setIsFileFromReference();

221 }

222}

223

225

226 if (options().getAttributeQualified())

227 resolveQualifiedName();

228

229 setIsResolvedName();

230}

231

232

235 return;

236

238 if (Parent && !Parent->getIsCompileUnit())

240}

241

242

246 return;

247

248

249 Prefix.append(std::string(Scope->getName()));

250 Prefix.append("::");

252

253

255}

256

257

259 setIsAnonymous();

260 std::string Name;

263 setIsGeneratedName();

264}

265

268 if (Moved)

269 setHasMoved();

270}

271

272

274

275

276

277

278

279

280

281

282

283

285 bool GetBaseTypename = false;

286 bool UseBaseTypename = true;

287 bool UseNameText = true;

288

290 case dwarf::DW_TAG_pointer_type:

293 break;

294 case dwarf::DW_TAG_const_type:

295 case dwarf::DW_TAG_ptr_to_member_type:

296 case dwarf::DW_TAG_rvalue_reference_type:

297 case dwarf::DW_TAG_reference_type:

298 case dwarf::DW_TAG_restrict_type:

299 case dwarf::DW_TAG_volatile_type:

301 break;

302 case dwarf::DW_TAG_base_type:

303 case dwarf::DW_TAG_compile_unit:

304 case dwarf::DW_TAG_class_type:

305 case dwarf::DW_TAG_enumerator:

306 case dwarf::DW_TAG_namespace:

307 case dwarf::DW_TAG_skeleton_unit:

308 case dwarf::DW_TAG_structure_type:

309 case dwarf::DW_TAG_union_type:

310 case dwarf::DW_TAG_unspecified_type:

311 case dwarf::DW_TAG_GNU_template_parameter_pack:

312 GetBaseTypename = true;

313 break;

314 case dwarf::DW_TAG_array_type:

315 case dwarf::DW_TAG_call_site:

316 case dwarf::DW_TAG_entry_point:

317 case dwarf::DW_TAG_enumeration_type:

318 case dwarf::DW_TAG_GNU_call_site:

319 case dwarf::DW_TAG_imported_module:

320 case dwarf::DW_TAG_imported_declaration:

321 case dwarf::DW_TAG_inlined_subroutine:

322 case dwarf::DW_TAG_label:

323 case dwarf::DW_TAG_subprogram:

324 case dwarf::DW_TAG_subrange_type:

325 case dwarf::DW_TAG_subroutine_type:

326 case dwarf::DW_TAG_typedef:

327 GetBaseTypename = true;

328 UseBaseTypename = false;

329 break;

330 case dwarf::DW_TAG_template_type_parameter:

331 case dwarf::DW_TAG_template_value_parameter:

332 UseBaseTypename = false;

333 break;

334 case dwarf::DW_TAG_GNU_template_template_param:

335 break;

336 case dwarf::DW_TAG_catch_block:

337 case dwarf::DW_TAG_lexical_block:

338 case dwarf::DW_TAG_try_block:

339 UseNameText = false;

340 break;

341 default:

343 return;

344 break;

345 }

346

347

348

349 if (Name.empty() && GetBaseTypename)

351

352

353

354 std::string Fullname;

355

356 if (UseNameText && Name.size())

357 Fullname.append(std::string(Name));

358 if (UseBaseTypename && BaseTypename.size()) {

359 if (UseNameText && Name.size())

360 Fullname.append(" ");

361 Fullname.append(std::string(BaseTypename));

362 }

363

364

365

366 assert((Fullname.find(" ", 0) == std:🧵:npos) &&

367 "Extra double spaces in name.");

368

369 LLVM_DEBUG({ dbgs() << "Fullname = '" << Fullname << "'\n"; });

371}

372

374 if (options().getAttributeAnySource())

375 return;

376

377

378

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396 size_t Index = 0;

397

398

399

400

401 if (getIsFileFromReference() && Reference) {

402 Index = Reference->getFilenameIndex();

403 if (Reference->getInvalidFilename())

404 setInvalidFilename();

406 return;

407 }

408

409

410

412 if (Index) {

415 }

416}

417

420 while (Parent && !(Parent->*GetFunction)())

422 return Parent;

423}

424

427}

428

431}

432

433

434void LVElement::resolveQualifiedName() {

435 if (!getIsReferencedType() || isBase() || getQualifiedResolved() ||

436 !getIncludeInPrint())

437 return;

438

439 std::string Name;

440

441

443 if (Parent && !Parent->getIsRoot()) {

444 while (Parent && !Parent->getIsCompileUnit()) {

445 Name.insert(0, "::");

447 Name.insert(0, std::string(Parent->getName()));

448 else {

449 std::string Temp;

451 Name.insert(0, Temp);

452 }

454 }

455 }

456

457 if (Name.size()) {

459 setQualifiedResolved();

460 }

466 });

467}

468

470 return (getHasReference() && Element->getHasReference()) ||

471 (!getHasReference() && Element->getHasReference());

472}

473

475

476

478 dbgs() << "\n[Element::equals]\n";

479 if (options().getAttributeOffset()) {

482 }

483 dbgs() << "Reference: "

487 << "Target : "

491 << "\n"

492 << "Reference: "

496 << "Target : "

499 << ", "

501 });

504 return false;

505

509 return false;

510

512 return true;

515 return false;

516}

517

518

520 if (options().getPrintFormatting() && options().getAttributeAnySource() &&

522

523

525 if (options().changeFilenameIndex(Index)) {

526

527 OS << "\n";

529

530 OS << " {Source} ";

531 if (getInvalidFilename())

532 OS << format("[0x%08x]\n", Index);

533 else

535 }

536 }

537}

538

541 if (options().getPrintFormatting() && options().getAttributeReference())

544 false, true);

545}

546

549 if (options().getPrintFormatting() && options().getAttributeLinkage()) {

551 true, false);

552 }

553}

554

557 if (options().getPrintFormatting() && options().getAttributeLinkage()) {

561 .str();

563 false, false);

564 }

565}

static size_t getStringIndex(StringRef Name)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

StringRef - Represent a constant reference to a string, i.e.

constexpr StringRef substr(size_t Start, size_t N=npos) const

Return a reference to the substring from [Start, Start + N).

constexpr size_t size() const

size - Get the string size.

size_t rfind(char C, size_t From=npos) const

Search for the last character C in the string.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

static Twine utohexstr(const uint64_t &Val)

LLVM Value Representation.

size_t getNameIndex() const

std::string discriminatorAsString() const

LVScope * traverseParents(LVScopeGetFunction GetFunction) const

virtual bool isTemplateParam() const

virtual LVScope * getCompileUnitParent() const

StringRef getQualifiedName() const

void resolveFullname(LVElement *BaseType, StringRef Name=emptyString())

LVScope * getFunctionParent() const

virtual bool isRoot() const

virtual void updateLevel(LVScope *Parent, bool Moved=false)

virtual void resolveName()

StringRef virtualityString(uint32_t Virtuality=dwarf::DW_VIRTUALITY_none) const

bool isFiled() const override

uint32_t getInlineCode() const

StringRef typeAsString() const

virtual uint32_t getDiscriminator() const

virtual bool isBase() const

void setFilename(StringRef Filename)

void setQualifiedName(StringRef Name)

StringRef externalString() const

bool getIsKindScope() const

virtual StringRef getLinkageName() const

void setName(StringRef ElementName) override

void setGenericType(LVElement *Element)

virtual bool isCompileUnit() const

StringRef getName() const override

void generateName(std::string &Prefix) const

LVType * getTypeAsType() const

LVElement * getType() const

bool referenceMatch(const LVElement *Element) const

uint32_t getAccessibilityCode() const

void setFile(LVElement *Reference=nullptr)

void setType(LVElement *Element=nullptr)

StringRef getTypeName() const

void printLinkageName(raw_ostream &OS, bool Full, LVElement *Parent, LVScope *Scope) const

bool getIsKindType() const

StringRef accessibilityString(uint32_t Access=dwarf::DW_ACCESS_private) const

void setFilenameIndex(size_t Index)

bool equals(const LVElement *Element) const

StringRef inlineCodeString(uint32_t Code) const

uint32_t getVirtualityCode() const

size_t getFilenameIndex() const

std::string typeOffsetAsString() const

void printFileIndex(raw_ostream &OS, bool Full=true) const override

StringRef getPathname() const

size_t getQualifiedNameIndex() const

bool isNamed() const override

void printReference(raw_ostream &OS, bool Full, LVElement *Parent) const

virtual void resolveExtra()

LVScope * getTypeAsScope() const

virtual void resolveReferences()

std::string referenceAsString(uint32_t LineNumber, bool Spaces) const

virtual const char * kind() const

LVScope * getParentScope() const

dwarf::Tag getTag() const

void setLevel(LVLevel Level)

void printAttributes(raw_ostream &OS, bool Full=true) const

virtual std::string lineNumberAsString(bool ShowZero=false) const

uint32_t getLineNumber() const

LVOffset getOffset() const

void setLineNumber(uint32_t Number)

StringRef getFilename(LVObject *Object, size_t Index) const

virtual LVSectionIndex getSectionIndex(LVScope *Scope)

size_t getIndex(StringRef Key)

This class implements an extremely fast bulk output stream that can only output to a stream.

A raw_ostream that writes to an std::string.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

MethodKind

Part of member attribute flags. (CV_methodprop_e)

MemberAccess

Source-level access specifier. (CV_access_e)

@ DW_INL_declared_not_inlined

@ DW_INL_declared_inlined

constexpr Tag DW_TAG_unaligned

LVStringPool & getStringPool()

std::string formattedKind(StringRef Kind)

std::string hexSquareString(uint64_t Value)

bool(LVScope::*)() const LVScopeGetFunction

std::string transformPath(StringRef Path)

LVLexicalComponent getInnerComponent(StringRef Name)

std::string formattedName(StringRef Name)

std::map< LVElementKind, LVElementGetFunction > LVElementDispatch

This is an optimization pass for GlobalISel generic memory operations.

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

void erase_if(Container &C, UnaryPredicate P)

Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...