Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
LVCodeViewVisitor.cpp
Go to the documentation of this file.
1//===-- LVCodeViewVisitor.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// This implements the LVCodeViewVisitor class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.h"
14#include "llvm/BinaryFormat/Magic.h"
15#include "llvm/DebugInfo/CodeView/EnumTables.h"
16#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
17#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
18#include "llvm/DebugInfo/CodeView/TypeRecordHelpers.h"
19#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
20#include "llvm/DebugInfo/LogicalView/Core/LVScope.h"
21#include "llvm/DebugInfo/LogicalView/Core/LVSymbol.h"
22#include "llvm/DebugInfo/LogicalView/Core/LVType.h"
23#include "llvm/DebugInfo/LogicalView/Readers/LVCodeViewReader.h"
24#include "llvm/DebugInfo/PDB/Native/InputFile.h"
25#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
26#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
27#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
28#include "llvm/Demangle/Demangle.h"
29#include "llvm/Object/COFF.h"
30#include "llvm/Support/Error.h"
31#include "llvm/Support/FormatAdapters.h"
32#include "llvm/Support/FormatVariadic.h"
33
34using namespacellvm;
35using namespacellvm::codeview;
36using namespacellvm::object;
37using namespacellvm::pdb;
38using namespacellvm::logicalview;
39
40#define DEBUG_TYPE "CodeViewUtilities"
41
42namespacellvm {
43namespacelogicalview {
44
45staticTypeIndexgetTrueType(TypeIndex &TI) {
46// Dealing with a MSVC generated PDB, we encountered a type index with the
47// value of: 0x0280xxxx where xxxx=0000.
48//
49// There is some documentation about type indices:
50// https://llvm.org/docs/PDB/TpiStream.html
51//
52// A type index is a 32-bit integer that uniquely identifies a type inside
53// of an object file’s .debug$T section or a PDB file’s TPI or IPI stream.
54// The value of the type index for the first type record from the TPI stream
55// is given by the TypeIndexBegin member of the TPI Stream Header although
56// in practice this value is always equal to 0x1000 (4096).
57//
58// Any type index with a high bit set is considered to come from the IPI
59// stream, although this appears to be more of a hack, and LLVM does not
60// generate type indices of this nature. They can, however, be observed in
61// Microsoft PDBs occasionally, so one should be prepared to handle them.
62// Note that having the high bit set is not a necessary condition to
63// determine whether a type index comes from the IPI stream, it is only
64// sufficient.
65LLVM_DEBUG(
66 {dbgs() <<"Index before: " <<HexNumber(TI.getIndex()) <<"\n"; });
67 TI.setIndex(TI.getIndex() & 0x0000ffff);
68LLVM_DEBUG(
69 {dbgs() <<"Index after: " <<HexNumber(TI.getIndex()) <<"\n"; });
70return TI;
71}
72
73staticconstEnumEntry<TypeLeafKind>LeafTypeNames[] = {
74#define CV_TYPE(enum, val) {#enum, enum},
75#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
76};
77
78// Return the type name pointed by the type index. It uses the kind to query
79// the associated name for the record type.
80staticStringRefgetRecordName(LazyRandomTypeCollection &Types,TypeIndex TI) {
81if (TI.isSimple())
82return {};
83
84StringRef RecordName;
85CVType CVReference =Types.getType(TI);
86auto GetName = [&](autoRecord) {
87if (Error Err =TypeDeserializer::deserializeAs(
88const_cast<CVType &>(CVReference),Record))
89consumeError(std::move(Err));
90else
91 RecordName =Record.getName();
92 };
93
94TypeRecordKind RK =static_cast<TypeRecordKind>(CVReference.kind());
95if (RK == TypeRecordKind::Class || RK == TypeRecordKind::Struct)
96 GetName(ClassRecord(RK));
97elseif (RK == TypeRecordKind::Union)
98 GetName(UnionRecord(RK));
99elseif (RK == TypeRecordKind::Enum)
100 GetName(EnumRecord(RK));
101
102return RecordName;
103}
104
105}// namespace logicalview
106}// namespace llvm
107
108#undef DEBUG_TYPE
109#define DEBUG_TYPE "CodeViewDataVisitor"
110
111namespacellvm {
112namespacelogicalview {
113
114// Keeps the type indexes with line information.
115usingLVLineRecords = std::vector<TypeIndex>;
116
117namespace{
118
119classLVTypeRecords {
120LVShared *Shared =nullptr;
121
122// Logical elements associated to their CodeView Type Index.
123usingRecordEntry = std::pair<TypeLeafKind, LVElement *>;
124usingRecordTable = std::map<TypeIndex, RecordEntry>;
125 RecordTable RecordFromTypes;
126 RecordTable RecordFromIds;
127
128usingNameTable = std::map<StringRef, TypeIndex>;
129 NameTable NameFromTypes;
130 NameTable NameFromIds;
131
132public:
133 LVTypeRecords(LVShared *Shared) : Shared(Shared) {}
134
135void add(uint32_t StreamIdx,TypeIndex TI,TypeLeafKindKind,
136LVElement *Element =nullptr);
137void add(uint32_t StreamIdx,TypeIndex TI,StringRefName);
138LVElement *find(uint32_t StreamIdx,TypeIndex TI,bool Create =true);
139TypeIndexfind(uint32_t StreamIdx,StringRefName);
140};
141
142classLVForwardReferences {
143// Forward reference and its definitions (Name as key).
144usingForwardEntry = std::pair<TypeIndex, TypeIndex>;
145usingForwardTypeNames = std::map<StringRef, ForwardEntry>;
146 ForwardTypeNames ForwardTypesNames;
147
148// Forward reference and its definition (TypeIndex as key).
149usingForwardType = std::map<TypeIndex, TypeIndex>;
150 ForwardType ForwardTypes;
151
152// Forward types and its references.
153void add(TypeIndex TIForward,TypeIndex TIReference) {
154 ForwardTypes.emplace(TIForward, TIReference);
155 }
156
157void add(StringRefName,TypeIndex TIForward) {
158if (ForwardTypesNames.find(Name) == ForwardTypesNames.end()) {
159 ForwardTypesNames.emplace(
160 std::piecewise_construct, std::forward_as_tuple(Name),
161 std::forward_as_tuple(TIForward,TypeIndex::None()));
162 }else {
163// Update a recorded definition with its reference.
164 ForwardTypesNames[Name].first = TIForward;
165 add(TIForward, ForwardTypesNames[Name].second);
166 }
167 }
168
169// Update a previously recorded forward reference with its definition.
170void update(StringRefName,TypeIndex TIReference) {
171auto It = ForwardTypesNames.find(Name);
172if (It != ForwardTypesNames.end()) {
173// Update the recorded forward reference with its definition.
174 It->second.second = TIReference;
175 add(It->second.first, TIReference);
176 }else {
177// We have not seen the forward reference. Insert the definition.
178 ForwardTypesNames.emplace(
179 std::piecewise_construct, std::forward_as_tuple(Name),
180 std::forward_as_tuple(TypeIndex::None(), TIReference));
181 }
182 }
183
184public:
185 LVForwardReferences() =default;
186
187void record(bool IsForwardRef,StringRefName,TypeIndex TI) {
188// We are expecting for the forward references to be first. But that
189// is not always the case. A name must be recorded regardless of the
190// order in which the forward reference appears.
191 (IsForwardRef) ? add(Name, TI) : update(Name, TI);
192 }
193
194TypeIndexfind(TypeIndex TIForward) {
195auto It = ForwardTypes.find(TIForward);
196return It != ForwardTypes.end() ? It->second :TypeIndex::None();
197 }
198
199TypeIndexfind(StringRefName) {
200auto It = ForwardTypesNames.find(Name);
201return It != ForwardTypesNames.end() ? It->second.second
202 :TypeIndex::None();
203 }
204
205// If the given TI corresponds to a reference, return the reference.
206// Otherwise return the given TI.
207TypeIndex remap(TypeIndex TI) {
208TypeIndex Forward =find(TI);
209return Forward.isNoneType() ? TI : Forward;
210 }
211};
212
213// Namespace deduction.
214classLVNamespaceDeduction {
215LVShared *Shared =nullptr;
216
217usingNames = std::map<StringRef, LVScope *>;
218 Names NamespaceNames;
219
220usingLookupSet = std::set<StringRef>;
221 LookupSet DeducedScopes;
222 LookupSet UnresolvedScopes;
223 LookupSet IdentifiedNamespaces;
224
225void add(StringRefName,LVScope *Namespace) {
226if (NamespaceNames.find(Name) == NamespaceNames.end())
227 NamespaceNames.emplace(Name, Namespace);
228 }
229
230public:
231 LVNamespaceDeduction(LVShared *Shared) : Shared(Shared) {}
232
233void init();
234void add(StringRefString);
235LVScope *get(LVStringRefs Components);
236LVScope *get(StringRefName,bool CheckScope =true);
237
238// Find the logical namespace for the 'Name' component.
239LVScope *find(StringRefName) {
240auto It = NamespaceNames.find(Name);
241LVScope *Namespace = It != NamespaceNames.end() ? It->second :nullptr;
242return Namespace;
243 }
244
245// For the given lexical components, return a tuple with the first entry
246// being the outermost namespace and the second entry being the first
247// non-namespace.
248LVLexicalIndexfind(LVStringRefs Components) {
249if (Components.empty())
250return {};
251
252 LVStringRefs::size_type FirstNamespace = 0;
253 LVStringRefs::size_type FirstNonNamespace;
254for (LVStringRefs::size_type Index = 0; Index < Components.size();
255 ++Index) {
256 FirstNonNamespace = Index;
257 LookupSet::iterator Iter = IdentifiedNamespaces.find(Components[Index]);
258if (Iter == IdentifiedNamespaces.end())
259// The component is not a namespace name.
260break;
261 }
262return std::make_tuple(FirstNamespace, FirstNonNamespace);
263 }
264};
265
266// Strings.
267classLVStringRecords {
268usingStringEntry = std::tuple<uint32_t, std::string, LVScopeCompileUnit *>;
269usingStringIds = std::map<TypeIndex, StringEntry>;
270 StringIds Strings;
271
272public:
273 LVStringRecords() =default;
274
275void add(TypeIndex TI,StringRefString) {
276staticuint32_t Index = 0;
277if (Strings.find(TI) == Strings.end())
278 Strings.emplace(
279 std::piecewise_construct, std::forward_as_tuple(TI),
280 std::forward_as_tuple(++Index, std::string(String),nullptr));
281 }
282
283StringReffind(TypeIndex TI) {
284 StringIds::iterator Iter = Strings.find(TI);
285return Iter != Strings.end() ? std::get<1>(Iter->second) :StringRef{};
286 }
287
288uint32_t findIndex(TypeIndex TI) {
289 StringIds::iterator Iter = Strings.find(TI);
290return Iter != Strings.end() ? std::get<0>(Iter->second) : 0;
291 }
292
293// Move strings representing the filenames to the compile unit.
294void addFilenames();
295void addFilenames(LVScopeCompileUnit *Scope);
296};
297}// namespace
298
299usingLVTypeKinds = std::set<TypeLeafKind>;
300usingLVSymbolKinds = std::set<SymbolKind>;
301
302// The following data keeps forward information, type records, names for
303// namespace deduction, strings records, line records.
304// It is shared by the type visitor, symbol visitor and logical visitor and
305// it is independent from the CodeViewReader.
306structLVShared {
307LVCodeViewReader *Reader;
308LVLogicalVisitor *Visitor;
309 LVForwardReferencesForwardReferences;
310LVLineRecordsLineRecords;
311 LVNamespaceDeductionNamespaceDeduction;
312 LVStringRecordsStringRecords;
313 LVTypeRecordsTypeRecords;
314
315// In order to determine which types and/or symbols records should be handled
316// by the reader, we record record kinds seen by the type and symbol visitors.
317// At the end of the scopes creation, the '--internal=tag' option will allow
318// to print the unique record ids collected.
319LVTypeKindsTypeKinds;
320LVSymbolKindsSymbolKinds;
321
322LVShared(LVCodeViewReader *Reader,LVLogicalVisitor *Visitor)
323 :Reader(Reader),Visitor(Visitor),NamespaceDeduction(this),
324TypeRecords(this) {}
325~LVShared() =default;
326};
327}// namespace logicalview
328}// namespace llvm
329
330void LVTypeRecords::add(uint32_t StreamIdx,TypeIndex TI,TypeLeafKindKind,
331LVElement *Element) {
332 RecordTable &Target =
333 (StreamIdx ==StreamTPI) ? RecordFromTypes : RecordFromIds;
334Target.emplace(std::piecewise_construct, std::forward_as_tuple(TI),
335 std::forward_as_tuple(Kind, Element));
336}
337
338void LVTypeRecords::add(uint32_t StreamIdx,TypeIndex TI,StringRefName) {
339 NameTable &Target = (StreamIdx ==StreamTPI) ? NameFromTypes : NameFromIds;
340Target.emplace(Name, TI);
341}
342
343LVElement *LVTypeRecords::find(uint32_t StreamIdx,TypeIndex TI,bool Create) {
344 RecordTable &Target =
345 (StreamIdx ==StreamTPI) ? RecordFromTypes : RecordFromIds;
346
347LVElement *Element =nullptr;
348 RecordTable::iterator Iter =Target.find(TI);
349if (Iter !=Target.end()) {
350 Element = Iter->second.second;
351if (Element || !Create)
352return Element;
353
354// Create the logical element if not found.
355 Element = Shared->Visitor->createElement(Iter->second.first);
356if (Element) {
357 Element->setOffset(TI.getIndex());
358 Element->setOffsetFromTypeIndex();
359Target[TI].second = Element;
360 }
361 }
362return Element;
363}
364
365TypeIndex LVTypeRecords::find(uint32_t StreamIdx,StringRefName) {
366 NameTable &Target = (StreamIdx ==StreamTPI) ? NameFromTypes : NameFromIds;
367 NameTable::iterator Iter =Target.find(Name);
368return Iter !=Target.end() ? Iter->second :TypeIndex::None();
369}
370
371void LVStringRecords::addFilenames() {
372for (StringIds::const_reference Entry : Strings) {
373StringRefName = std::get<1>(Entry.second);
374LVScopeCompileUnit *Scope = std::get<2>(Entry.second);
375Scope->addFilename(transformPath(Name));
376 }
377 Strings.clear();
378}
379
380void LVStringRecords::addFilenames(LVScopeCompileUnit *Scope) {
381for (StringIds::reference Entry : Strings)
382if (!std::get<2>(Entry.second))
383 std::get<2>(Entry.second) =Scope;
384}
385
386void LVNamespaceDeduction::add(StringRefString) {
387StringRef InnerComponent;
388StringRef OuterComponent;
389 std::tie(OuterComponent, InnerComponent) =getInnerComponent(String);
390 DeducedScopes.insert(InnerComponent);
391if (OuterComponent.size())
392 UnresolvedScopes.insert(OuterComponent);
393}
394
395void LVNamespaceDeduction::init() {
396// We have 2 sets of names:
397// - deduced scopes (class, structure, union and enum) and
398// - unresolved scopes, that can represent namespaces or any deduced.
399// Before creating the namespaces, we have to traverse the unresolved
400// and remove any references to already deduced scopes.
401LVStringRefs Components;
402for (constStringRef &Unresolved : UnresolvedScopes) {
403 Components =getAllLexicalComponents(Unresolved);
404for (constStringRef &Component : Components) {
405 LookupSet::iterator Iter = DeducedScopes.find(Component);
406if (Iter == DeducedScopes.end())
407 IdentifiedNamespaces.insert(Component);
408 }
409 }
410
411LLVM_DEBUG({
412autoPrint = [&](LookupSet &Container,constchar *Title) {
413auto Header = [&]() {
414dbgs() <<formatv("\n{0}\n",fmt_repeat('=', 72));
415dbgs() <<formatv("{0}\n", Title);
416dbgs() <<formatv("{0}\n",fmt_repeat('=', 72));
417 };
418 Header();
419for (constStringRef &Item : Container)
420dbgs() <<formatv("'{0}'\n", Item.str().c_str());
421 };
422
423Print(DeducedScopes,"Deducted Scopes");
424Print(UnresolvedScopes,"Unresolved Scopes");
425Print(IdentifiedNamespaces,"Namespaces");
426 });
427}
428
429LVScope *LVNamespaceDeduction::get(LVStringRefs Components) {
430LLVM_DEBUG({
431for (constStringRef &Component : Components)
432dbgs() <<formatv("'{0}'\n",Component.str().c_str());
433 });
434
435if (Components.empty())
436returnnullptr;
437
438// Update the namespaces relationship.
439LVScope *Namespace =nullptr;
440LVScope *Parent = Shared->Reader->getCompileUnit();
441for (constStringRef &Component : Components) {
442// Check if we have seen the namespace.
443 Namespace =find(Component);
444if (!Namespace) {
445// We have identified namespaces that are generated by MSVC. Mark them
446// as 'system' so they will be excluded from the logical view.
447 Namespace = Shared->Reader->createScopeNamespace();
448 Namespace->setTag(dwarf::DW_TAG_namespace);
449 Namespace->setName(Component);
450 Parent->addElement(Namespace);
451getReader().isSystemEntry(Namespace);
452add(Component, Namespace);
453 }
454 Parent = Namespace;
455 }
456return Parent;
457}
458
459LVScope *LVNamespaceDeduction::get(StringRef ScopedName,bool CheckScope) {
460LVStringRefs Components =getAllLexicalComponents(ScopedName);
461if (CheckScope)
462llvm::erase_if(Components, [&](StringRef Component) {
463 LookupSet::iterator Iter = IdentifiedNamespaces.find(Component);
464return Iter == IdentifiedNamespaces.end();
465 });
466
467LLVM_DEBUG(
468 {dbgs() <<formatv("ScopedName: '{0}'\n", ScopedName.str().c_str()); });
469
470returnget(Components);
471}
472
473#undef DEBUG_TYPE
474#define DEBUG_TYPE "CodeViewTypeVisitor"
475
476//===----------------------------------------------------------------------===//
477// TypeRecord traversal.
478//===----------------------------------------------------------------------===//
479void LVTypeVisitor::printTypeIndex(StringRef FieldName,TypeIndex TI,
480uint32_t StreamIdx) const{
481codeview::printTypeIndex(W, FieldName, TI,
482 StreamIdx ==StreamTPI ? Types : Ids);
483}
484
485ErrorLVTypeVisitor::visitTypeBegin(CVType &Record) {
486returnvisitTypeBegin(Record,TypeIndex::fromArrayIndex(Types.size()));
487}
488
489ErrorLVTypeVisitor::visitTypeBegin(CVType &Record,TypeIndex TI) {
490LLVM_DEBUG({
491 W.getOStream() <<formatTypeLeafKind(Record.kind());
492 W.getOStream() <<" (" <<HexNumber(TI.getIndex()) <<")\n";
493 });
494
495if (options().getInternalTag())
496 Shared->TypeKinds.insert(Record.kind());
497
498// The collected type records, will be use to create the logical elements
499// during the symbols traversal when a type is referenced.
500 CurrentTypeIndex = TI;
501 Shared->TypeRecords.add(StreamIdx, TI,Record.kind());
502returnError::success();
503}
504
505ErrorLVTypeVisitor::visitUnknownType(CVType &Record) {
506LLVM_DEBUG({ W.printNumber("Length",uint32_t(Record.content().size())); });
507returnError::success();
508}
509
510ErrorLVTypeVisitor::visitMemberBegin(CVMemberRecord &Record) {
511LLVM_DEBUG({
512 W.startLine() <<formatTypeLeafKind(Record.Kind);
513 W.getOStream() <<" {\n";
514 W.indent();
515 });
516returnError::success();
517}
518
519ErrorLVTypeVisitor::visitMemberEnd(CVMemberRecord &Record) {
520LLVM_DEBUG({
521 W.unindent();
522 W.startLine() <<"}\n";
523 });
524returnError::success();
525}
526
527ErrorLVTypeVisitor::visitUnknownMember(CVMemberRecord &Record) {
528LLVM_DEBUG({ W.printHex("UnknownMember",unsigned(Record.Kind)); });
529returnError::success();
530}
531
532// LF_BUILDINFO (TPI)/(IPI)
533ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,BuildInfoRecord &Args) {
534// All the args are references into the TPI/IPI stream.
535LLVM_DEBUG({
536 W.printNumber("NumArgs",static_cast<uint32_t>(Args.getArgs().size()));
537ListScopeArguments(W,"Arguments");
538for (TypeIndex Arg : Args.getArgs())
539 printTypeIndex("ArgType", Arg,StreamIPI);
540 });
541
542// Only add the strings that hold information about filenames. They will be
543// used to complete the line/file information for the logical elements.
544// There are other strings holding information about namespaces.
545TypeIndex TI;
546StringRefString;
547
548// Absolute CWD path
549 TI = Args.getArgs()[BuildInfoRecord::BuildInfoArg::CurrentDirectory];
550String = Ids.getTypeName(TI);
551if (!String.empty())
552 Shared->StringRecords.add(TI,String);
553
554// Get the compile unit name.
555 TI = Args.getArgs()[BuildInfoRecord::BuildInfoArg::SourceFile];
556String = Ids.getTypeName(TI);
557if (!String.empty())
558 Shared->StringRecords.add(TI,String);
559 LogicalVisitor->setCompileUnitName(std::string(String));
560
561returnError::success();
562}
563
564// LF_CLASS, LF_STRUCTURE, LF_INTERFACE (TPI)
565ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,ClassRecord &Class) {
566LLVM_DEBUG({
567 printTypeIndex("TypeIndex", CurrentTypeIndex,StreamTPI);
568 printTypeIndex("FieldListType",Class.getFieldList(),StreamTPI);
569 W.printString("Name",Class.getName());
570 });
571
572// Collect class name for scope deduction.
573 Shared->NamespaceDeduction.add(Class.getName());
574 Shared->ForwardReferences.record(Class.isForwardRef(),Class.getName(),
575 CurrentTypeIndex);
576
577// Collect class name for contained scopes deduction.
578 Shared->TypeRecords.add(StreamIdx, CurrentTypeIndex,Class.getName());
579returnError::success();
580}
581
582// LF_ENUM (TPI)
583ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,EnumRecord &Enum) {
584LLVM_DEBUG({
585 printTypeIndex("TypeIndex", CurrentTypeIndex,StreamTPI);
586 printTypeIndex("FieldListType",Enum.getFieldList(),StreamTPI);
587 W.printString("Name",Enum.getName());
588 });
589
590// Collect enum name for scope deduction.
591 Shared->NamespaceDeduction.add(Enum.getName());
592returnError::success();
593}
594
595// LF_FUNC_ID (TPI)/(IPI)
596ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,FuncIdRecord &Func) {
597LLVM_DEBUG({
598 printTypeIndex("TypeIndex", CurrentTypeIndex,StreamTPI);
599 printTypeIndex("Type", Func.getFunctionType(),StreamTPI);
600 printTypeIndex("Parent", Func.getParentScope(),StreamTPI);
601 W.printString("Name", Func.getName());
602 });
603
604// Collect function name for scope deduction.
605 Shared->NamespaceDeduction.add(Func.getName());
606returnError::success();
607}
608
609// LF_PROCEDURE (TPI)
610ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,ProcedureRecord &Proc) {
611LLVM_DEBUG({
612 printTypeIndex("TypeIndex", CurrentTypeIndex,StreamTPI);
613 printTypeIndex("ReturnType", Proc.getReturnType(),StreamTPI);
614 W.printNumber("NumParameters", Proc.getParameterCount());
615 printTypeIndex("ArgListType", Proc.getArgumentList(),StreamTPI);
616 });
617
618// Collect procedure information as they can be referenced by typedefs.
619 Shared->TypeRecords.add(StreamTPI, CurrentTypeIndex, {});
620returnError::success();
621}
622
623// LF_STRING_ID (TPI)/(IPI)
624ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,StringIdRecord &String) {
625// No additional references are needed.
626LLVM_DEBUG({
627 printTypeIndex("Id",String.getId(),StreamIPI);
628 W.printString("StringData",String.getString());
629 });
630returnError::success();
631}
632
633// LF_UDT_SRC_LINE (TPI)/(IPI)
634ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,
635UdtSourceLineRecord &Line) {
636// UDT and SourceFile are references into the TPI/IPI stream.
637LLVM_DEBUG({
638 printTypeIndex("UDT",Line.getUDT(),StreamIPI);
639 printTypeIndex("SourceFile",Line.getSourceFile(),StreamIPI);
640 W.printNumber("LineNumber",Line.getLineNumber());
641 });
642
643 Shared->LineRecords.push_back(CurrentTypeIndex);
644returnError::success();
645}
646
647// LF_UNION (TPI)
648ErrorLVTypeVisitor::visitKnownRecord(CVType &Record,UnionRecord &Union) {
649LLVM_DEBUG({
650 W.printNumber("MemberCount",Union.getMemberCount());
651 printTypeIndex("FieldList",Union.getFieldList(),StreamTPI);
652 W.printNumber("SizeOf",Union.getSize());
653 W.printString("Name",Union.getName());
654if (Union.hasUniqueName())
655 W.printString("UniqueName",Union.getUniqueName());
656 });
657
658// Collect union name for scope deduction.
659 Shared->NamespaceDeduction.add(Union.getName());
660 Shared->ForwardReferences.record(Union.isForwardRef(),Union.getName(),
661 CurrentTypeIndex);
662
663// Collect class name for contained scopes deduction.
664 Shared->TypeRecords.add(StreamIdx, CurrentTypeIndex,Union.getName());
665returnError::success();
666}
667
668#undef DEBUG_TYPE
669#define DEBUG_TYPE "CodeViewSymbolVisitor"
670
671//===----------------------------------------------------------------------===//
672// SymbolRecord traversal.
673//===----------------------------------------------------------------------===//
674voidLVSymbolVisitorDelegate::printRelocatedField(StringRefLabel,
675uint32_t RelocOffset,
676uint32_tOffset,
677StringRef *RelocSym) {
678 Reader->printRelocatedField(Label, CoffSection, RelocOffset,Offset,
679 RelocSym);
680}
681
682voidLVSymbolVisitorDelegate::getLinkageName(uint32_t RelocOffset,
683uint32_tOffset,
684StringRef *RelocSym) {
685 Reader->getLinkageName(CoffSection, RelocOffset,Offset, RelocSym);
686}
687
688StringRef
689LVSymbolVisitorDelegate::getFileNameForFileOffset(uint32_t FileOffset) {
690Expected<StringRef>Name = Reader->getFileNameForFileOffset(FileOffset);
691if (!Name) {
692consumeError(Name.takeError());
693return {};
694 }
695return *Name;
696}
697
698DebugStringTableSubsectionRefLVSymbolVisitorDelegate::getStringTable() {
699return Reader->CVStringTable;
700}
701
702void LVSymbolVisitor::printLocalVariableAddrRange(
703constLocalVariableAddrRange &Range,uint32_t RelocationOffset) {
704DictScope S(W,"LocalVariableAddrRange");
705if (ObjDelegate)
706 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
707Range.OffsetStart);
708 W.printHex("ISectStart",Range.ISectStart);
709 W.printHex("Range",Range.Range);
710}
711
712void LVSymbolVisitor::printLocalVariableAddrGap(
713ArrayRef<LocalVariableAddrGap>Gaps) {
714for (constLocalVariableAddrGap &Gap :Gaps) {
715ListScope S(W,"LocalVariableAddrGap");
716 W.printHex("GapStartOffset", Gap.GapStartOffset);
717 W.printHex("Range", Gap.Range);
718 }
719}
720
721void LVSymbolVisitor::printTypeIndex(StringRef FieldName,TypeIndex TI) const{
722codeview::printTypeIndex(W, FieldName, TI, Types);
723}
724
725ErrorLVSymbolVisitor::visitSymbolBegin(CVSymbol &Record) {
726returnvisitSymbolBegin(Record, 0);
727}
728
729ErrorLVSymbolVisitor::visitSymbolBegin(CVSymbol &Record,uint32_tOffset) {
730SymbolKindKind =Record.kind();
731LLVM_DEBUG({
732 W.printNumber("Offset",Offset);
733 W.printEnum("Begin Kind",unsigned(Kind),getSymbolTypeNames());
734 });
735
736if (options().getInternalTag())
737 Shared->SymbolKinds.insert(Kind);
738
739 LogicalVisitor->CurrentElement = LogicalVisitor->createElement(Kind);
740if (!LogicalVisitor->CurrentElement) {
741LLVM_DEBUG({
742// We have an unsupported Symbol or Type Record.
743// W.printEnum("Kind ignored", unsigned(Kind), getSymbolTypeNames());
744 });
745returnError::success();
746 }
747
748// Offset carried by the traversal routines when dealing with streams.
749 CurrentOffset =Offset;
750 IsCompileUnit =false;
751if (!LogicalVisitor->CurrentElement->getOffsetFromTypeIndex())
752 LogicalVisitor->CurrentElement->setOffset(Offset);
753if (symbolOpensScope(Kind) || (IsCompileUnit = symbolIsCompileUnit(Kind))) {
754assert(LogicalVisitor->CurrentScope &&"Invalid scope!");
755 LogicalVisitor->addElement(LogicalVisitor->CurrentScope, IsCompileUnit);
756 }else {
757if (LogicalVisitor->CurrentSymbol)
758 LogicalVisitor->addElement(LogicalVisitor->CurrentSymbol);
759if (LogicalVisitor->CurrentType)
760 LogicalVisitor->addElement(LogicalVisitor->CurrentType);
761 }
762
763returnError::success();
764}
765
766ErrorLVSymbolVisitor::visitSymbolEnd(CVSymbol &Record) {
767SymbolKindKind =Record.kind();
768LLVM_DEBUG(
769 { W.printEnum("End Kind",unsigned(Kind),getSymbolTypeNames()); });
770
771if (symbolEndsScope(Kind)) {
772 LogicalVisitor->popScope();
773 }
774
775returnError::success();
776}
777
778ErrorLVSymbolVisitor::visitUnknownSymbol(CVSymbol &Record) {
779LLVM_DEBUG({ W.printNumber("Length",Record.length()); });
780returnError::success();
781}
782
783// S_BLOCK32
784ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,BlockSym &Block) {
785LLVM_DEBUG({
786 W.printHex("CodeSize",Block.CodeSize);
787 W.printHex("Segment",Block.Segment);
788 W.printString("BlockName",Block.Name);
789 });
790
791if (LVScope *Scope = LogicalVisitor->CurrentScope) {
792StringRefLinkageName;
793if (ObjDelegate)
794 ObjDelegate->getLinkageName(Block.getRelocationOffset(),Block.CodeOffset,
795 &LinkageName);
796 Scope->setLinkageName(LinkageName);
797
798if (options().getGeneralCollectRanges()) {
799// Record converted segment::offset addressing for this scope.
800LVAddress Addendum = Reader->getSymbolTableAddress(LinkageName);
801LVAddress LowPC =
802 Reader->linearAddress(Block.Segment,Block.CodeOffset, Addendum);
803LVAddress HighPC = LowPC +Block.CodeSize - 1;
804 Scope->addObject(LowPC, HighPC);
805 }
806 }
807
808returnError::success();
809}
810
811// S_BPREL32
812ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
813BPRelativeSym &Local) {
814LLVM_DEBUG({
815 printTypeIndex("Type",Local.Type);
816 W.printNumber("Offset",Local.Offset);
817 W.printString("VarName",Local.Name);
818 });
819
820if (LVSymbol *Symbol = LogicalVisitor->CurrentSymbol) {
821 Symbol->setName(Local.Name);
822// From the MS_Symbol_Type.pdf documentation (S_BPREL32):
823// This symbol specifies symbols that are allocated on the stack for a
824// procedure. For C and C++, these include the actual function parameters
825// and the local non-static variables of functions.
826// However, the offset for 'this' comes as a negative value.
827
828// Symbol was created as 'variable'; determine its real kind.
829 Symbol->resetIsVariable();
830
831if (Local.Name =="this") {
832 Symbol->setIsParameter();
833 Symbol->setIsArtificial();
834 }else {
835// Determine symbol kind.
836bool(Local.Offset > 0) ? Symbol->setIsParameter()
837 : Symbol->setIsVariable();
838 }
839
840// Update correct debug information tag.
841if (Symbol->getIsParameter())
842 Symbol->setTag(dwarf::DW_TAG_formal_parameter);
843
844LVElement *Element = LogicalVisitor->getElement(StreamTPI,Local.Type);
845if (Element && Element->getIsScoped()) {
846// We have a local type. Find its parent function.
847LVScope *Parent = Symbol->getFunctionParent();
848// The element representing the type has been already finalized. If
849// the type is an aggregate type, its members have been already added.
850// As the type is local, its level will be changed.
851
852// FIXME: Currently the algorithm used to scope lambda functions is
853// incorrect. Before we allocate the type at this scope, check if is
854// already allocated in other scope.
855if (!Element->getParentScope()) {
856 Parent->addElement(Element);
857 Element->updateLevel(Parent);
858 }
859 }
860 Symbol->setType(Element);
861 }
862
863returnError::success();
864}
865
866// S_REGREL32
867ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
868RegRelativeSym &Local) {
869LLVM_DEBUG({
870 printTypeIndex("Type",Local.Type);
871 W.printNumber("Offset",Local.Offset);
872 W.printString("VarName",Local.Name);
873 });
874
875if (LVSymbol *Symbol = LogicalVisitor->CurrentSymbol) {
876 Symbol->setName(Local.Name);
877
878// Symbol was created as 'variable'; determine its real kind.
879 Symbol->resetIsVariable();
880
881// Check for the 'this' symbol.
882if (Local.Name =="this") {
883 Symbol->setIsArtificial();
884 Symbol->setIsParameter();
885 }else {
886// Determine symbol kind.
887 determineSymbolKind(Symbol,Local.Register);
888 }
889
890// Update correct debug information tag.
891if (Symbol->getIsParameter())
892 Symbol->setTag(dwarf::DW_TAG_formal_parameter);
893
894LVElement *Element = LogicalVisitor->getElement(StreamTPI,Local.Type);
895if (Element && Element->getIsScoped()) {
896// We have a local type. Find its parent function.
897LVScope *Parent = Symbol->getFunctionParent();
898// The element representing the type has been already finalized. If
899// the type is an aggregate type, its members have been already added.
900// As the type is local, its level will be changed.
901
902// FIXME: Currently the algorithm used to scope lambda functions is
903// incorrect. Before we allocate the type at this scope, check if is
904// already allocated in other scope.
905if (!Element->getParentScope()) {
906 Parent->addElement(Element);
907 Element->updateLevel(Parent);
908 }
909 }
910 Symbol->setType(Element);
911 }
912
913returnError::success();
914}
915
916// S_BUILDINFO
917ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &CVR,
918BuildInfoSym &BuildInfo) {
919LLVM_DEBUG({ printTypeIndex("BuildId", BuildInfo.BuildId); });
920
921CVType CVBuildType = Ids.getType(BuildInfo.BuildId);
922if (Error Err = LogicalVisitor->finishVisitation(
923 CVBuildType, BuildInfo.BuildId, Reader->getCompileUnit()))
924return Err;
925
926returnError::success();
927}
928
929// S_COMPILE2
930ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
931Compile2Sym &Compile2) {
932LLVM_DEBUG({
933 W.printEnum("Language",uint8_t(Compile2.getLanguage()),
934getSourceLanguageNames());
935 W.printFlags("Flags",uint32_t(Compile2.getFlags()),
936getCompileSym3FlagNames());
937 W.printEnum("Machine",unsigned(Compile2.Machine),getCPUTypeNames());
938 W.printString("VersionName", Compile2.Version);
939 });
940
941// MSVC generates the following sequence for a CodeView module:
942// S_OBJNAME --> Set 'CurrentObjectName'.
943// S_COMPILE2 --> Set the compile unit name using 'CurrentObjectName'.
944// ...
945// S_BUILDINFO --> Extract the source name.
946//
947// Clang generates the following sequence for a CodeView module:
948// S_COMPILE2 --> Set the compile unit name to empty string.
949// ...
950// S_BUILDINFO --> Extract the source name.
951//
952// For both toolchains, update the compile unit name from S_BUILDINFO.
953if (LVScope *Scope = LogicalVisitor->CurrentScope) {
954// The name of the CU, was extracted from the 'BuildInfo' subsection.
955 Reader->setCompileUnitCPUType(Compile2.Machine);
956 Scope->setName(CurrentObjectName);
957if (options().getAttributeProducer())
958 Scope->setProducer(Compile2.Version);
959getReader().isSystemEntry(Scope, CurrentObjectName);
960
961// The line records in CodeView are recorded per Module ID. Update
962// the relationship between the current CU and the Module ID.
963 Reader->addModule(Scope);
964
965// Updated the collected strings with their associated compile unit.
966 Shared->StringRecords.addFilenames(Reader->getCompileUnit());
967 }
968
969// Clear any previous ObjectName.
970 CurrentObjectName ="";
971returnError::success();
972}
973
974// S_COMPILE3
975ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
976Compile3Sym &Compile3) {
977LLVM_DEBUG({
978 W.printEnum("Language",uint8_t(Compile3.getLanguage()),
979getSourceLanguageNames());
980 W.printFlags("Flags",uint32_t(Compile3.getFlags()),
981getCompileSym3FlagNames());
982 W.printEnum("Machine",unsigned(Compile3.Machine),getCPUTypeNames());
983 W.printString("VersionName", Compile3.Version);
984 });
985
986// MSVC generates the following sequence for a CodeView module:
987// S_OBJNAME --> Set 'CurrentObjectName'.
988// S_COMPILE3 --> Set the compile unit name using 'CurrentObjectName'.
989// ...
990// S_BUILDINFO --> Extract the source name.
991//
992// Clang generates the following sequence for a CodeView module:
993// S_COMPILE3 --> Set the compile unit name to empty string.
994// ...
995// S_BUILDINFO --> Extract the source name.
996//
997// For both toolchains, update the compile unit name from S_BUILDINFO.
998if (LVScope *Scope = LogicalVisitor->CurrentScope) {
999// The name of the CU, was extracted from the 'BuildInfo' subsection.
1000 Reader->setCompileUnitCPUType(Compile3.Machine);
1001 Scope->setName(CurrentObjectName);
1002if (options().getAttributeProducer())
1003 Scope->setProducer(Compile3.Version);
1004getReader().isSystemEntry(Scope, CurrentObjectName);
1005
1006// The line records in CodeView are recorded per Module ID. Update
1007// the relationship between the current CU and the Module ID.
1008 Reader->addModule(Scope);
1009
1010// Updated the collected strings with their associated compile unit.
1011 Shared->StringRecords.addFilenames(Reader->getCompileUnit());
1012 }
1013
1014// Clear any previous ObjectName.
1015 CurrentObjectName ="";
1016returnError::success();
1017}
1018
1019// S_CONSTANT, S_MANCONSTANT
1020ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1021ConstantSym &Constant) {
1022LLVM_DEBUG({
1023 printTypeIndex("Type",Constant.Type);
1024 W.printNumber("Value",Constant.Value);
1025 W.printString("Name",Constant.Name);
1026 });
1027
1028if (LVSymbol *Symbol = LogicalVisitor->CurrentSymbol) {
1029 Symbol->setName(Constant.Name);
1030 Symbol->setType(LogicalVisitor->getElement(StreamTPI,Constant.Type));
1031 Symbol->resetIncludeInPrint();
1032 }
1033
1034returnError::success();
1035}
1036
1037// S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE
1038ErrorLVSymbolVisitor::visitKnownRecord(
1039CVSymbol &Record,
1040DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
1041// DefRanges don't have types, just registers and code offsets.
1042LLVM_DEBUG({
1043if (LocalSymbol)
1044 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1045
1046 W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset);
1047 });
1048
1049if (LVSymbol *Symbol = LocalSymbol) {
1050 Symbol->setHasCodeViewLocation();
1051 LocalSymbol =nullptr;
1052
1053// Add location debug location. Operands: [Offset, 0].
1054dwarf::Attribute Attr =
1055dwarf::Attribute(SymbolKind::S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE);
1056
1057uint64_t Operand1 = DefRangeFramePointerRelFullScope.Offset;
1058 Symbol->addLocation(Attr, 0, 0, 0, 0);
1059 Symbol->addLocationOperands(LVSmall(Attr), {Operand1});
1060 }
1061
1062returnError::success();
1063}
1064
1065// S_DEFRANGE_FRAMEPOINTER_REL
1066ErrorLVSymbolVisitor::visitKnownRecord(
1067CVSymbol &Record,DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
1068// DefRanges don't have types, just registers and code offsets.
1069LLVM_DEBUG({
1070if (LocalSymbol)
1071 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1072
1073 W.printNumber("Offset", DefRangeFramePointerRel.Hdr.Offset);
1074 printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
1075 DefRangeFramePointerRel.getRelocationOffset());
1076 printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
1077 });
1078
1079// We are expecting the following sequence:
1080// 128 | S_LOCAL [size = 20] `ParamBar`
1081// ...
1082// 148 | S_DEFRANGE_FRAMEPOINTER_REL [size = 16]
1083if (LVSymbol *Symbol = LocalSymbol) {
1084 Symbol->setHasCodeViewLocation();
1085 LocalSymbol =nullptr;
1086
1087// Add location debug location. Operands: [Offset, 0].
1088dwarf::Attribute Attr =
1089dwarf::Attribute(SymbolKind::S_DEFRANGE_FRAMEPOINTER_REL);
1090uint64_t Operand1 = DefRangeFramePointerRel.Hdr.Offset;
1091
1092LocalVariableAddrRangeRange = DefRangeFramePointerRel.Range;
1093LVAddressAddress =
1094 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1095
1096 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1097 Symbol->addLocationOperands(LVSmall(Attr), {Operand1});
1098 }
1099
1100returnError::success();
1101}
1102
1103// S_DEFRANGE_REGISTER_REL
1104ErrorLVSymbolVisitor::visitKnownRecord(
1105CVSymbol &Record,DefRangeRegisterRelSym &DefRangeRegisterRel) {
1106// DefRanges don't have types, just registers and code offsets.
1107LLVM_DEBUG({
1108if (LocalSymbol)
1109 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1110
1111 W.printBoolean("HasSpilledUDTMember",
1112 DefRangeRegisterRel.hasSpilledUDTMember());
1113 W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
1114 W.printNumber("BasePointerOffset",
1115 DefRangeRegisterRel.Hdr.BasePointerOffset);
1116 printLocalVariableAddrRange(DefRangeRegisterRel.Range,
1117 DefRangeRegisterRel.getRelocationOffset());
1118 printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
1119 });
1120
1121if (LVSymbol *Symbol = LocalSymbol) {
1122 Symbol->setHasCodeViewLocation();
1123 LocalSymbol =nullptr;
1124
1125// Add location debug location. Operands: [Register, Offset].
1126dwarf::Attribute Attr =
1127dwarf::Attribute(SymbolKind::S_DEFRANGE_REGISTER_REL);
1128uint64_t Operand1 = DefRangeRegisterRel.Hdr.Register;
1129uint64_t Operand2 = DefRangeRegisterRel.Hdr.BasePointerOffset;
1130
1131LocalVariableAddrRangeRange = DefRangeRegisterRel.Range;
1132LVAddressAddress =
1133 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1134
1135 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1136 Symbol->addLocationOperands(LVSmall(Attr), {Operand1, Operand2});
1137 }
1138
1139returnError::success();
1140}
1141
1142// S_DEFRANGE_REGISTER
1143ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1144DefRangeRegisterSym &DefRangeRegister) {
1145// DefRanges don't have types, just registers and code offsets.
1146LLVM_DEBUG({
1147if (LocalSymbol)
1148 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1149
1150 W.printEnum("Register",uint16_t(DefRangeRegister.Hdr.Register),
1151getRegisterNames(Reader->getCompileUnitCPUType()));
1152 W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
1153 printLocalVariableAddrRange(DefRangeRegister.Range,
1154 DefRangeRegister.getRelocationOffset());
1155 printLocalVariableAddrGap(DefRangeRegister.Gaps);
1156 });
1157
1158if (LVSymbol *Symbol = LocalSymbol) {
1159 Symbol->setHasCodeViewLocation();
1160 LocalSymbol =nullptr;
1161
1162// Add location debug location. Operands: [Register, 0].
1163dwarf::Attribute Attr =dwarf::Attribute(SymbolKind::S_DEFRANGE_REGISTER);
1164uint64_t Operand1 = DefRangeRegister.Hdr.Register;
1165
1166LocalVariableAddrRangeRange = DefRangeRegister.Range;
1167LVAddressAddress =
1168 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1169
1170 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1171 Symbol->addLocationOperands(LVSmall(Attr), {Operand1});
1172 }
1173
1174returnError::success();
1175}
1176
1177// S_DEFRANGE_SUBFIELD_REGISTER
1178ErrorLVSymbolVisitor::visitKnownRecord(
1179CVSymbol &Record,DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
1180// DefRanges don't have types, just registers and code offsets.
1181LLVM_DEBUG({
1182if (LocalSymbol)
1183 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1184
1185 W.printEnum("Register",uint16_t(DefRangeSubfieldRegister.Hdr.Register),
1186getRegisterNames(Reader->getCompileUnitCPUType()));
1187 W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
1188 W.printNumber("OffsetInParent",
1189 DefRangeSubfieldRegister.Hdr.OffsetInParent);
1190 printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
1191 DefRangeSubfieldRegister.getRelocationOffset());
1192 printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
1193 });
1194
1195if (LVSymbol *Symbol = LocalSymbol) {
1196 Symbol->setHasCodeViewLocation();
1197 LocalSymbol =nullptr;
1198
1199// Add location debug location. Operands: [Register, 0].
1200dwarf::Attribute Attr =
1201dwarf::Attribute(SymbolKind::S_DEFRANGE_SUBFIELD_REGISTER);
1202uint64_t Operand1 = DefRangeSubfieldRegister.Hdr.Register;
1203
1204LocalVariableAddrRangeRange = DefRangeSubfieldRegister.Range;
1205LVAddressAddress =
1206 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1207
1208 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1209 Symbol->addLocationOperands(LVSmall(Attr), {Operand1});
1210 }
1211
1212returnError::success();
1213}
1214
1215// S_DEFRANGE_SUBFIELD
1216ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1217DefRangeSubfieldSym &DefRangeSubfield) {
1218// DefRanges don't have types, just registers and code offsets.
1219LLVM_DEBUG({
1220if (LocalSymbol)
1221 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1222
1223if (ObjDelegate) {
1224DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
1225auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
1226if (!ExpectedProgram) {
1227consumeError(ExpectedProgram.takeError());
1228return llvm::make_error<CodeViewError>(
1229"String table offset outside of bounds of String Table!");
1230 }
1231 W.printString("Program", *ExpectedProgram);
1232 }
1233 W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
1234 printLocalVariableAddrRange(DefRangeSubfield.Range,
1235 DefRangeSubfield.getRelocationOffset());
1236 printLocalVariableAddrGap(DefRangeSubfield.Gaps);
1237 });
1238
1239if (LVSymbol *Symbol = LocalSymbol) {
1240 Symbol->setHasCodeViewLocation();
1241 LocalSymbol =nullptr;
1242
1243// Add location debug location. Operands: [Program, 0].
1244dwarf::Attribute Attr =dwarf::Attribute(SymbolKind::S_DEFRANGE_SUBFIELD);
1245uint64_t Operand1 = DefRangeSubfield.Program;
1246
1247LocalVariableAddrRangeRange = DefRangeSubfield.Range;
1248LVAddressAddress =
1249 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1250
1251 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1252 Symbol->addLocationOperands(LVSmall(Attr), {Operand1,/*Operand2=*/0});
1253 }
1254
1255returnError::success();
1256}
1257
1258// S_DEFRANGE
1259ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1260DefRangeSym &DefRange) {
1261// DefRanges don't have types, just registers and code offsets.
1262LLVM_DEBUG({
1263if (LocalSymbol)
1264 W.getOStream() <<formatv("Symbol: {0}, ", LocalSymbol->getName());
1265
1266if (ObjDelegate) {
1267DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
1268auto ExpectedProgram = Strings.getString(DefRange.Program);
1269if (!ExpectedProgram) {
1270consumeError(ExpectedProgram.takeError());
1271return llvm::make_error<CodeViewError>(
1272"String table offset outside of bounds of String Table!");
1273 }
1274 W.printString("Program", *ExpectedProgram);
1275 }
1276 printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
1277 printLocalVariableAddrGap(DefRange.Gaps);
1278 });
1279
1280if (LVSymbol *Symbol = LocalSymbol) {
1281 Symbol->setHasCodeViewLocation();
1282 LocalSymbol =nullptr;
1283
1284// Add location debug location. Operands: [Program, 0].
1285dwarf::Attribute Attr =dwarf::Attribute(SymbolKind::S_DEFRANGE);
1286uint64_t Operand1 = DefRange.Program;
1287
1288LocalVariableAddrRangeRange = DefRange.Range;
1289LVAddressAddress =
1290 Reader->linearAddress(Range.ISectStart,Range.OffsetStart);
1291
1292 Symbol->addLocation(Attr,Address,Address +Range.Range, 0, 0);
1293 Symbol->addLocationOperands(LVSmall(Attr), {Operand1,/*Operand2=*/0});
1294 }
1295
1296returnError::success();
1297}
1298
1299// S_FRAMEPROC
1300ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1301FrameProcSym &FrameProc) {
1302if (LVScope *Function = LogicalVisitor->getReaderScope()) {
1303// S_FRAMEPROC contains extra information for the function described
1304// by any of the previous generated records:
1305// S_GPROC32, S_LPROC32, S_LPROC32_ID, S_GPROC32_ID.
1306
1307// The generated sequence is:
1308// S_GPROC32_ID ...
1309// S_FRAMEPROC ...
1310
1311// Collect additional inline flags for the current scope function.
1312FrameProcedureOptions Flags = FrameProc.Flags;
1313if (FrameProcedureOptions::MarkedInline ==
1314 (Flags & FrameProcedureOptions::MarkedInline))
1315Function->setInlineCode(dwarf::DW_INL_declared_inlined);
1316if (FrameProcedureOptions::Inlined ==
1317 (Flags & FrameProcedureOptions::Inlined))
1318Function->setInlineCode(dwarf::DW_INL_inlined);
1319
1320// To determine the symbol kind for any symbol declared in that function,
1321// we can access the S_FRAMEPROC for the parent scope function. It contains
1322// information about the local fp and param fp registers and compare with
1323// the register in the S_REGREL32 to get a match.
1324codeview::CPUType CPU = Reader->getCompileUnitCPUType();
1325 LocalFrameRegister = FrameProc.getLocalFramePtrReg(CPU);
1326 ParamFrameRegister = FrameProc.getParamFramePtrReg(CPU);
1327 }
1328
1329returnError::success();
1330}
1331
1332// S_GDATA32, S_LDATA32, S_LMANDATA, S_GMANDATA
1333ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,DataSym &Data) {
1334LLVM_DEBUG({
1335 printTypeIndex("Type",Data.Type);
1336 W.printString("DisplayName",Data.Name);
1337 });
1338
1339if (LVSymbol *Symbol = LogicalVisitor->CurrentSymbol) {
1340StringRefLinkageName;
1341if (ObjDelegate)
1342 ObjDelegate->getLinkageName(Data.getRelocationOffset(),Data.DataOffset,
1343 &LinkageName);
1344
1345 Symbol->setName(Data.Name);
1346 Symbol->setLinkageName(LinkageName);
1347
1348// The MSVC generates local data as initialization for aggregates. It
1349// contains the address for an initialization function.
1350// The symbols contains the '$initializer$' pattern. Allow them only if
1351// the '--internal=system' option is given.
1352// 0 | S_LDATA32 `Struct$initializer$`
1353// type = 0x1040 (void ()*)
1354if (getReader().isSystemEntry(Symbol) && !options().getAttributeSystem()) {
1355 Symbol->resetIncludeInPrint();
1356returnError::success();
1357 }
1358
1359if (LVScope *Namespace = Shared->NamespaceDeduction.get(Data.Name)) {
1360// The variable is already at different scope. In order to reflect
1361// the correct parent, move it to the namespace.
1362if (Symbol->getParentScope()->removeElement(Symbol))
1363 Namespace->addElement(Symbol);
1364 }
1365
1366 Symbol->setType(LogicalVisitor->getElement(StreamTPI,Data.Type));
1367if (Record.kind() == SymbolKind::S_GDATA32)
1368 Symbol->setIsExternal();
1369 }
1370
1371returnError::success();
1372}
1373
1374// S_INLINESITE
1375ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1376InlineSiteSym &InlineSite) {
1377LLVM_DEBUG({ printTypeIndex("Inlinee",InlineSite.Inlinee); });
1378
1379if (LVScope *InlinedFunction = LogicalVisitor->CurrentScope) {
1380LVScope *AbstractFunction = Reader->createScopeFunction();
1381 AbstractFunction->setIsSubprogram();
1382 AbstractFunction->setTag(dwarf::DW_TAG_subprogram);
1383 AbstractFunction->setInlineCode(dwarf::DW_INL_inlined);
1384 AbstractFunction->setIsInlinedAbstract();
1385 InlinedFunction->setReference(AbstractFunction);
1386
1387 LogicalVisitor->startProcessArgumentList();
1388// 'Inlinee' is a Type ID.
1389CVType CVFunctionType = Ids.getType(InlineSite.Inlinee);
1390if (Error Err = LogicalVisitor->finishVisitation(
1391 CVFunctionType,InlineSite.Inlinee, AbstractFunction))
1392return Err;
1393 LogicalVisitor->stopProcessArgumentList();
1394
1395// For inlined functions set the linkage name to be the same as
1396// the name. It used to find their lines and ranges.
1397StringRefName = AbstractFunction->getName();
1398 InlinedFunction->setName(Name);
1399 InlinedFunction->setLinkageName(Name);
1400
1401// Process annotation bytes to calculate code and line offsets.
1402if (Error Err = LogicalVisitor->inlineSiteAnnotation(
1403 AbstractFunction, InlinedFunction,InlineSite))
1404return Err;
1405 }
1406
1407returnError::success();
1408}
1409
1410// S_LOCAL
1411ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,LocalSym &Local) {
1412LLVM_DEBUG({
1413 printTypeIndex("Type",Local.Type);
1414 W.printFlags("Flags",uint16_t(Local.Flags),getLocalFlagNames());
1415 W.printString("VarName",Local.Name);
1416 });
1417
1418if (LVSymbol *Symbol = LogicalVisitor->CurrentSymbol) {
1419 Symbol->setName(Local.Name);
1420
1421// Symbol was created as 'variable'; determine its real kind.
1422 Symbol->resetIsVariable();
1423
1424// Be sure the 'this' symbol is marked as 'compiler generated'.
1425if (bool(Local.Flags & LocalSymFlags::IsCompilerGenerated) ||
1426Local.Name =="this") {
1427 Symbol->setIsArtificial();
1428 Symbol->setIsParameter();
1429 }else {
1430bool(Local.Flags & LocalSymFlags::IsParameter) ? Symbol->setIsParameter()
1431 : Symbol->setIsVariable();
1432 }
1433
1434// Update correct debug information tag.
1435if (Symbol->getIsParameter())
1436 Symbol->setTag(dwarf::DW_TAG_formal_parameter);
1437
1438LVElement *Element = LogicalVisitor->getElement(StreamTPI,Local.Type);
1439if (Element && Element->getIsScoped()) {
1440// We have a local type. Find its parent function.
1441LVScope *Parent = Symbol->getFunctionParent();
1442// The element representing the type has been already finalized. If
1443// the type is an aggregate type, its members have been already added.
1444// As the type is local, its level will be changed.
1445 Parent->addElement(Element);
1446 Element->updateLevel(Parent);
1447 }
1448 Symbol->setType(Element);
1449
1450// The CodeView records (S_DEFFRAME_*) describing debug location for
1451// this symbol, do not have any direct reference to it. Those records
1452// are emitted after this symbol. Record the current symbol.
1453 LocalSymbol = Symbol;
1454 }
1455
1456returnError::success();
1457}
1458
1459// S_OBJNAME
1460ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,ObjNameSym &ObjName) {
1461LLVM_DEBUG({
1462 W.printHex("Signature", ObjName.Signature);
1463 W.printString("ObjectName", ObjName.Name);
1464 });
1465
1466 CurrentObjectName = ObjName.Name;
1467returnError::success();
1468}
1469
1470// S_GPROC32, S_LPROC32, S_LPROC32_ID, S_GPROC32_ID
1471ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,ProcSym &Proc) {
1472if (InFunctionScope)
1473return llvm::make_error<CodeViewError>("Visiting a ProcSym while inside "
1474"function scope!");
1475
1476 InFunctionScope =true;
1477
1478LLVM_DEBUG({
1479 printTypeIndex("FunctionType", Proc.FunctionType);
1480 W.printHex("Segment", Proc.Segment);
1481 W.printFlags("Flags",static_cast<uint8_t>(Proc.Flags),
1482getProcSymFlagNames());
1483 W.printString("DisplayName", Proc.Name);
1484 });
1485
1486// Clang and Microsoft generated different debug information records:
1487// For functions definitions:
1488// Clang: S_GPROC32 -> LF_FUNC_ID -> LF_PROCEDURE
1489// Microsoft: S_GPROC32 -> LF_PROCEDURE
1490
1491// For member function definition:
1492// Clang: S_GPROC32 -> LF_MFUNC_ID -> LF_MFUNCTION
1493// Microsoft: S_GPROC32 -> LF_MFUNCTION
1494// In order to support both sequences, if we found LF_FUNCTION_ID, just
1495// get the TypeIndex for LF_PROCEDURE.
1496
1497// For the given test case, we have the sequence:
1498// namespace NSP_local {
1499// void foo_local() {
1500// }
1501// }
1502//
1503// 0x1000 | LF_STRING_ID String: NSP_local
1504// 0x1002 | LF_PROCEDURE
1505// return type = 0x0003 (void), # args = 0, param list = 0x1001
1506// calling conv = cdecl, options = None
1507// 0x1003 | LF_FUNC_ID
1508// name = foo_local, type = 0x1002, parent scope = 0x1000
1509// 0 | S_GPROC32_ID `NSP_local::foo_local`
1510// type = `0x1003 (foo_local)`
1511// 0x1004 | LF_STRING_ID String: suite
1512// 0x1005 | LF_STRING_ID String: suite_local.cpp
1513//
1514// The LF_STRING_ID can hold different information:
1515// 0x1000 - The enclosing namespace.
1516// 0x1004 - The compile unit directory name.
1517// 0x1005 - The compile unit name.
1518//
1519// Before deducting its scope, we need to evaluate its type and create any
1520// associated namespaces.
1521if (LVScope *Function = LogicalVisitor->CurrentScope) {
1522StringRefLinkageName;
1523if (ObjDelegate)
1524 ObjDelegate->getLinkageName(Proc.getRelocationOffset(), Proc.CodeOffset,
1525 &LinkageName);
1526
1527// The line table can be accessed using the linkage name.
1528 Reader->addToSymbolTable(LinkageName,Function);
1529Function->setName(Proc.Name);
1530Function->setLinkageName(LinkageName);
1531
1532if (options().getGeneralCollectRanges()) {
1533// Record converted segment::offset addressing for this scope.
1534LVAddress Addendum = Reader->getSymbolTableAddress(LinkageName);
1535LVAddress LowPC =
1536 Reader->linearAddress(Proc.Segment, Proc.CodeOffset, Addendum);
1537LVAddress HighPC = LowPC + Proc.CodeSize - 1;
1538Function->addObject(LowPC, HighPC);
1539
1540// If the scope is a function, add it to the public names.
1541if ((options().getAttributePublics() ||options().getPrintAnyLine()) &&
1542 !Function->getIsInlinedFunction())
1543 Reader->getCompileUnit()->addPublicName(Function, LowPC, HighPC);
1544 }
1545
1546if (Function->getIsSystem() && !options().getAttributeSystem()) {
1547Function->resetIncludeInPrint();
1548returnError::success();
1549 }
1550
1551TypeIndex TIFunctionType = Proc.FunctionType;
1552if (TIFunctionType.isSimple())
1553Function->setType(LogicalVisitor->getElement(StreamTPI, TIFunctionType));
1554else {
1555// We have to detect the correct stream, using the lexical parent
1556// name, as there is not other obvious way to get the stream.
1557// Normal function: LF_FUNC_ID (TPI)/(IPI)
1558// LF_PROCEDURE (TPI)
1559// Lambda function: LF_MFUNCTION (TPI)
1560// Member function: LF_MFUNC_ID (TPI)/(IPI)
1561
1562StringRef OuterComponent;
1563 std::tie(OuterComponent, std::ignore) =getInnerComponent(Proc.Name);
1564TypeIndex TI = Shared->ForwardReferences.find(OuterComponent);
1565
1566 std::optional<CVType> CVFunctionType;
1567auto GetRecordType = [&]() ->bool {
1568 CVFunctionType = Ids.tryGetType(TIFunctionType);
1569if (!CVFunctionType)
1570returnfalse;
1571
1572if (TI.isNoneType())
1573// Normal function.
1574if (CVFunctionType->kind() == LF_FUNC_ID)
1575returntrue;
1576
1577// Member function.
1578return (CVFunctionType->kind() == LF_MFUNC_ID);
1579 };
1580
1581// We can have a LF_FUNC_ID, LF_PROCEDURE or LF_MFUNCTION.
1582if (!GetRecordType()) {
1583 CVFunctionType = Types.tryGetType(TIFunctionType);
1584if (!CVFunctionType)
1585return llvm::make_error<CodeViewError>("Invalid type index");
1586 }
1587
1588if (Error Err = LogicalVisitor->finishVisitation(
1589 *CVFunctionType, TIFunctionType,Function))
1590return Err;
1591 }
1592
1593if (Record.kind() == SymbolKind::S_GPROC32 ||
1594Record.kind() == SymbolKind::S_GPROC32_ID)
1595Function->setIsExternal();
1596
1597// We don't have a way to see if the symbol is compiler generated. Use
1598// the linkage name, to detect `scalar deleting destructor' functions.
1599 std::string DemangledSymbol =demangle(LinkageName);
1600if (DemangledSymbol.find("scalar deleting dtor") != std::string::npos) {
1601Function->setIsArtificial();
1602 }else {
1603// Clang generates global ctor and dtor names containing the substrings:
1604// 'dynamic initializer for' and 'dynamic atexit destructor for'.
1605if (DemangledSymbol.find("dynamic atexit destructor for") !=
1606 std::string::npos)
1607Function->setIsArtificial();
1608 }
1609 }
1610
1611returnError::success();
1612}
1613
1614// S_END
1615ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1616ScopeEndSym &ScopeEnd) {
1617 InFunctionScope =false;
1618returnError::success();
1619}
1620
1621// S_THUNK32
1622ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,Thunk32Sym &Thunk) {
1623if (InFunctionScope)
1624return llvm::make_error<CodeViewError>("Visiting a Thunk32Sym while inside "
1625"function scope!");
1626
1627 InFunctionScope =true;
1628
1629LLVM_DEBUG({
1630 W.printHex("Segment",Thunk.Segment);
1631 W.printString("Name",Thunk.Name);
1632 });
1633
1634if (LVScope *Function = LogicalVisitor->CurrentScope)
1635Function->setName(Thunk.Name);
1636
1637returnError::success();
1638}
1639
1640// S_UDT, S_COBOLUDT
1641ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,UDTSym &UDT) {
1642LLVM_DEBUG({
1643 printTypeIndex("Type",UDT.Type);
1644 W.printString("UDTName",UDT.Name);
1645 });
1646
1647if (LVType *Type = LogicalVisitor->CurrentType) {
1648if (LVScope *Namespace = Shared->NamespaceDeduction.get(UDT.Name)) {
1649if (Type->getParentScope()->removeElement(Type))
1650 Namespace->addElement(Type);
1651 }
1652
1653Type->setName(UDT.Name);
1654
1655// We have to determine if the typedef is a real C/C++ definition or is
1656// the S_UDT record that describe all the user defined types.
1657// 0 | S_UDT `Name` original type = 0x1009
1658// 0x1009 | LF_STRUCTURE `Name`
1659// Ignore type definitions for RTTI types:
1660// _s__RTTIBaseClassArray, _s__RTTIBaseClassDescriptor,
1661// _s__RTTICompleteObjectLocator, _s__RTTIClassHierarchyDescriptor.
1662if (getReader().isSystemEntry(Type))
1663Type->resetIncludeInPrint();
1664else {
1665StringRef RecordName =getRecordName(Types,UDT.Type);
1666if (UDT.Name == RecordName)
1667Type->resetIncludeInPrint();
1668Type->setType(LogicalVisitor->getElement(StreamTPI,UDT.Type));
1669 }
1670 }
1671
1672returnError::success();
1673}
1674
1675// S_UNAMESPACE
1676ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,
1677UsingNamespaceSym &UN) {
1678LLVM_DEBUG({ W.printString("Namespace", UN.Name); });
1679returnError::success();
1680}
1681
1682// S_ARMSWITCHTABLE
1683ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &CVR,
1684JumpTableSym &JumpTable) {
1685LLVM_DEBUG({
1686 W.printHex("BaseOffset", JumpTable.BaseOffset);
1687 W.printNumber("BaseSegment", JumpTable.BaseSegment);
1688 W.printFlags("SwitchType",static_cast<uint16_t>(JumpTable.SwitchType),
1689getJumpTableEntrySizeNames());
1690 W.printHex("BranchOffset", JumpTable.BranchOffset);
1691 W.printHex("TableOffset", JumpTable.TableOffset);
1692 W.printNumber("BranchSegment", JumpTable.BranchSegment);
1693 W.printNumber("TableSegment", JumpTable.TableSegment);
1694 W.printNumber("EntriesCount", JumpTable.EntriesCount);
1695 });
1696returnError::success();
1697}
1698
1699// S_CALLERS, S_CALLEES, S_INLINEES
1700ErrorLVSymbolVisitor::visitKnownRecord(CVSymbol &Record,CallerSym &Caller) {
1701LLVM_DEBUG({
1702llvm::StringRef FieldName;
1703switch (Caller.getKind()) {
1704 case SymbolRecordKind::CallerSym:
1705 FieldName ="Callee";
1706 break;
1707 case SymbolRecordKind::CalleeSym:
1708 FieldName ="Caller";
1709 break;
1710 case SymbolRecordKind::InlineesSym:
1711 FieldName ="Inlinee";
1712 break;
1713 default:
1714 return llvm::make_error<CodeViewError>(
1715"Unknown CV Record type for a CallerSym object!");
1716 }
1717for (auto FuncID :Caller.Indices) {
1718 printTypeIndex(FieldName, FuncID);
1719 }
1720 });
1721returnError::success();
1722}
1723
1724#undef DEBUG_TYPE
1725#define DEBUG_TYPE "CodeViewLogicalVisitor"
1726
1727//===----------------------------------------------------------------------===//
1728// Logical visitor.
1729//===----------------------------------------------------------------------===//
1730LVLogicalVisitor::LVLogicalVisitor(LVCodeViewReader *Reader,ScopedPrinter &W,
1731InputFile &Input)
1732 : Reader(Reader), W(W), Input(Input) {
1733// The LogicalVisitor connects the CodeViewReader with the visitors that
1734// traverse the types, symbols, etc. Do any initialization that is needed.
1735 Shared = std::make_shared<LVShared>(Reader,this);
1736}
1737
1738voidLVLogicalVisitor::printTypeIndex(StringRef FieldName,TypeIndex TI,
1739uint32_t StreamIdx) {
1740codeview::printTypeIndex(W, FieldName, TI,
1741 StreamIdx ==StreamTPI ? types() : ids());
1742}
1743
1744voidLVLogicalVisitor::printTypeBegin(CVType &Record,TypeIndex TI,
1745LVElement *Element,uint32_t StreamIdx) {
1746 W.getOStream() <<"\n";
1747 W.startLine() <<formatTypeLeafKind(Record.kind());
1748 W.getOStream() <<" (" <<HexNumber(TI.getIndex()) <<")";
1749 W.getOStream() <<" {\n";
1750 W.indent();
1751 W.printEnum("TypeLeafKind",unsigned(Record.kind()),ArrayRef(LeafTypeNames));
1752printTypeIndex("TI", TI, StreamIdx);
1753 W.startLine() <<"Element: " <<HexNumber(Element->getOffset()) <<" "
1754 << Element->getName() <<"\n";
1755}
1756
1757voidLVLogicalVisitor::printTypeEnd(CVType &Record) {
1758 W.unindent();
1759 W.startLine() <<"}\n";
1760}
1761
1762voidLVLogicalVisitor::printMemberBegin(CVMemberRecord &Record,TypeIndex TI,
1763LVElement *Element,
1764uint32_t StreamIdx) {
1765 W.getOStream() <<"\n";
1766 W.startLine() <<formatTypeLeafKind(Record.Kind);
1767 W.getOStream() <<" (" <<HexNumber(TI.getIndex()) <<")";
1768 W.getOStream() <<" {\n";
1769 W.indent();
1770 W.printEnum("TypeLeafKind",unsigned(Record.Kind),ArrayRef(LeafTypeNames));
1771printTypeIndex("TI", TI, StreamIdx);
1772 W.startLine() <<"Element: " <<HexNumber(Element->getOffset()) <<" "
1773 << Element->getName() <<"\n";
1774}
1775
1776voidLVLogicalVisitor::printMemberEnd(CVMemberRecord &Record) {
1777 W.unindent();
1778 W.startLine() <<"}\n";
1779}
1780
1781ErrorLVLogicalVisitor::visitUnknownType(CVType &Record,TypeIndex TI) {
1782LLVM_DEBUG({
1783printTypeIndex("\nTI", TI,StreamTPI);
1784 W.printNumber("Length",uint32_t(Record.content().size()));
1785 });
1786returnError::success();
1787}
1788
1789// LF_ARGLIST (TPI)
1790ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,ArgListRecord &Args,
1791TypeIndex TI,LVElement *Element) {
1792ArrayRef<TypeIndex> Indices = Args.getIndices();
1793uint32_tSize = Indices.size();
1794LLVM_DEBUG({
1795printTypeBegin(Record, TI, Element,StreamTPI);
1796 W.printNumber("NumArgs",Size);
1797ListScopeArguments(W,"Arguments");
1798for (uint32_tI = 0;I <Size; ++I)
1799printTypeIndex("ArgType", Indices[I],StreamTPI);
1800printTypeEnd(Record);
1801 });
1802
1803LVScope *Function =static_cast<LVScope *>(Element);
1804for (uint32_t Index = 0; Index <Size; ++Index) {
1805TypeIndex ParameterType = Indices[Index];
1806 createParameter(ParameterType,StringRef(),Function);
1807 }
1808
1809returnError::success();
1810}
1811
1812// LF_ARRAY (TPI)
1813ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,ArrayRecord &AT,
1814TypeIndex TI,LVElement *Element) {
1815LLVM_DEBUG({
1816printTypeBegin(Record, TI, Element,StreamTPI);
1817printTypeIndex("ElementType", AT.getElementType(),StreamTPI);
1818printTypeIndex("IndexType", AT.getIndexType(),StreamTPI);
1819 W.printNumber("SizeOf", AT.getSize());
1820 W.printString("Name", AT.getName());
1821printTypeEnd(Record);
1822 });
1823
1824if (Element->getIsFinalized())
1825returnError::success();
1826 Element->setIsFinalized();
1827
1828LVScopeArray *Array =static_cast<LVScopeArray *>(Element);
1829if (!Array)
1830returnError::success();
1831
1832 Reader->getCompileUnit()->addElement(Array);
1833TypeIndex TIElementType = AT.getElementType();
1834
1835LVType *PrevSubrange =nullptr;
1836LazyRandomTypeCollection &Types = types();
1837
1838// As the logical view is modeled on DWARF, for each dimension we have to
1839// create a DW_TAG_subrange_type, with dimension size.
1840// The subrange type can be: unsigned __int32 or unsigned __int64.
1841auto AddSubrangeType = [&](ArrayRecord &AR) {
1842LVType *Subrange = Reader->createTypeSubrange();
1843Subrange->setTag(dwarf::DW_TAG_subrange_type);
1844Subrange->setType(getElement(StreamTPI, AR.getIndexType()));
1845Subrange->setCount(AR.getSize());
1846Subrange->setOffset(
1847 TIElementType.isSimple()
1848 ? (uint32_t)(TypeLeafKind)TIElementType.getSimpleKind()
1849 : TIElementType.getIndex());
1850 Array->addElement(Subrange);
1851
1852if (PrevSubrange)
1853if (int64_t Count =Subrange->getCount())
1854 PrevSubrange->setCount(PrevSubrange->getCount() / Count);
1855 PrevSubrange =Subrange;
1856 };
1857
1858// Preserve the original TypeIndex; it would be updated in the case of:
1859// - The array type contains qualifiers.
1860// - In multidimensional arrays, the last LF_ARRAY entry contains the type.
1861TypeIndex TIArrayType;
1862
1863// For each dimension in the array, there is a LF_ARRAY entry. The last
1864// entry contains the array type, which can be a LF_MODIFIER in the case
1865// of the type being modified by a qualifier (const, etc).
1866ArrayRecord AR(AT);
1867CVType CVEntry =Record;
1868while (CVEntry.kind() == LF_ARRAY) {
1869// Create the subrange information, required by the logical view. Once
1870// the array has been processed, the dimension sizes will updated, as
1871// the sizes are a progression. For instance:
1872// sizeof(int) = 4
1873// int Array[2]; Sizes: 8 Dim: 8 / 4 -> [2]
1874// int Array[2][3]; Sizes: 24, 12 Dim: 24 / 12 -> [2]
1875// Dim: 12 / 4 -> [3]
1876// int Array[2][3][4]; sizes: 96, 48, 16 Dim: 96 / 48 -> [2]
1877// Dim: 48 / 16 -> [3]
1878// Dim: 16 / 4 -> [4]
1879 AddSubrangeType(AR);
1880 TIArrayType = TIElementType;
1881
1882// The current ElementType can be a modifier, in which case we need to
1883// get the type being modified.
1884// If TypeIndex is not a simple type, check if we have a qualified type.
1885if (!TIElementType.isSimple()) {
1886CVType CVElementType =Types.getType(TIElementType);
1887if (CVElementType.kind() == LF_MODIFIER) {
1888LVElement *QualifiedType =
1889 Shared->TypeRecords.find(StreamTPI, TIElementType);
1890if (Error Err =
1891finishVisitation(CVElementType, TIElementType, QualifiedType))
1892return Err;
1893// Get the TypeIndex of the type that the LF_MODIFIER modifies.
1894 TIElementType =getModifiedType(CVElementType);
1895 }
1896 }
1897// Ends the traversal, as we have reached a simple type (int, char, etc).
1898if (TIElementType.isSimple())
1899break;
1900
1901// Read next dimension linked entry, if any.
1902 CVEntry =Types.getType(TIElementType);
1903if (Error Err =TypeDeserializer::deserializeAs(
1904const_cast<CVType &>(CVEntry), AR)) {
1905consumeError(std::move(Err));
1906break;
1907 }
1908 TIElementType = AR.getElementType();
1909// NOTE: The typeindex has a value of: 0x0280.0000
1910getTrueType(TIElementType);
1911 }
1912
1913 Array->setName(AT.getName());
1914 TIArrayType = Shared->ForwardReferences.remap(TIArrayType);
1915 Array->setType(getElement(StreamTPI, TIArrayType));
1916
1917if (PrevSubrange)
1918// In the case of an aggregate type (class, struct, union, interface),
1919// get the aggregate size. As the original record is pointing to its
1920// reference, we have to update it.
1921if (uint64_tSize =
1922isAggregate(CVEntry)
1923 ?getSizeInBytesForTypeRecord(Types.getType(TIArrayType))
1924 :getSizeInBytesForTypeIndex(TIElementType))
1925 PrevSubrange->setCount(PrevSubrange->getCount() /Size);
1926
1927returnError::success();
1928}
1929
1930// LF_BITFIELD (TPI)
1931ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,BitFieldRecord &BF,
1932TypeIndex TI,LVElement *Element) {
1933LLVM_DEBUG({
1934printTypeBegin(Record, TI, Element,StreamTPI);
1935printTypeIndex("Type", TI,StreamTPI);
1936 W.printNumber("BitSize", BF.getBitSize());
1937 W.printNumber("BitOffset", BF.getBitOffset());
1938printTypeEnd(Record);
1939 });
1940
1941 Element->setType(getElement(StreamTPI, BF.getType()));
1942 Element->setBitSize(BF.getBitSize());
1943returnError::success();
1944}
1945
1946// LF_BUILDINFO (TPI)/(IPI)
1947ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,BuildInfoRecord &BI,
1948TypeIndex TI,LVElement *Element) {
1949LLVM_DEBUG({
1950printTypeBegin(Record, TI, Element,StreamIPI);
1951 W.printNumber("NumArgs",static_cast<uint32_t>(BI.getArgs().size()));
1952ListScopeArguments(W,"Arguments");
1953for (TypeIndex Arg : BI.getArgs())
1954printTypeIndex("ArgType", Arg,StreamIPI);
1955printTypeEnd(Record);
1956 });
1957
1958// The given 'Element' refers to the current compilation unit.
1959// All the args are references into the TPI/IPI stream.
1960TypeIndex TIName = BI.getArgs()[BuildInfoRecord::BuildInfoArg::SourceFile];
1961 std::stringName = std::string(ids().getTypeName(TIName));
1962
1963// There are cases where LF_BUILDINFO fields are empty.
1964if (!Name.empty())
1965 Element->setName(Name);
1966
1967returnError::success();
1968}
1969
1970// LF_CLASS, LF_STRUCTURE, LF_INTERFACE (TPI)
1971ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,ClassRecord &Class,
1972TypeIndex TI,LVElement *Element) {
1973LLVM_DEBUG({
1974printTypeBegin(Record, TI, Element,StreamTPI);
1975 W.printNumber("MemberCount",Class.getMemberCount());
1976printTypeIndex("FieldList",Class.getFieldList(),StreamTPI);
1977printTypeIndex("DerivedFrom",Class.getDerivationList(),StreamTPI);
1978printTypeIndex("VShape",Class.getVTableShape(),StreamTPI);
1979 W.printNumber("SizeOf",Class.getSize());
1980 W.printString("Name",Class.getName());
1981if (Class.hasUniqueName())
1982 W.printString("UniqueName",Class.getUniqueName());
1983printTypeEnd(Record);
1984 });
1985
1986if (Element->getIsFinalized())
1987returnError::success();
1988 Element->setIsFinalized();
1989
1990LVScopeAggregate *Scope =static_cast<LVScopeAggregate *>(Element);
1991if (!Scope)
1992returnError::success();
1993
1994 Scope->setName(Class.getName());
1995if (Class.hasUniqueName())
1996 Scope->setLinkageName(Class.getUniqueName());
1997
1998if (Class.isNested()) {
1999 Scope->setIsNested();
2000 createParents(Class.getName(), Scope);
2001 }
2002
2003if (Class.isScoped())
2004 Scope->setIsScoped();
2005
2006// Nested types will be added to their parents at creation. The forward
2007// references are only processed to finish the referenced element creation.
2008if (!(Class.isNested() ||Class.isScoped())) {
2009if (LVScope *Namespace = Shared->NamespaceDeduction.get(Class.getName()))
2010 Namespace->addElement(Scope);
2011else
2012 Reader->getCompileUnit()->addElement(Scope);
2013 }
2014
2015LazyRandomTypeCollection &Types = types();
2016TypeIndex TIFieldList =Class.getFieldList();
2017if (TIFieldList.isNoneType()) {
2018TypeIndex ForwardType = Shared->ForwardReferences.find(Class.getName());
2019if (!ForwardType.isNoneType()) {
2020CVType CVReference =Types.getType(ForwardType);
2021TypeRecordKind RK =static_cast<TypeRecordKind>(CVReference.kind());
2022ClassRecord ReferenceRecord(RK);
2023if (Error Err =TypeDeserializer::deserializeAs(
2024const_cast<CVType &>(CVReference), ReferenceRecord))
2025return Err;
2026 TIFieldList = ReferenceRecord.getFieldList();
2027 }
2028 }
2029
2030if (!TIFieldList.isNoneType()) {
2031// Pass down the TypeIndex 'TI' for the aggregate containing the field list.
2032CVType CVFieldList =Types.getType(TIFieldList);
2033if (Error Err =finishVisitation(CVFieldList, TI, Scope))
2034return Err;
2035 }
2036
2037returnError::success();
2038}
2039
2040// LF_ENUM (TPI)
2041ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,EnumRecord &Enum,
2042TypeIndex TI,LVElement *Element) {
2043LLVM_DEBUG({
2044printTypeBegin(Record, TI, Element,StreamTPI);
2045 W.printNumber("NumEnumerators",Enum.getMemberCount());
2046printTypeIndex("UnderlyingType",Enum.getUnderlyingType(),StreamTPI);
2047printTypeIndex("FieldListType",Enum.getFieldList(),StreamTPI);
2048 W.printString("Name",Enum.getName());
2049printTypeEnd(Record);
2050 });
2051
2052LVScopeEnumeration *Scope =static_cast<LVScopeEnumeration *>(Element);
2053if (!Scope)
2054returnError::success();
2055
2056if (Scope->getIsFinalized())
2057returnError::success();
2058 Scope->setIsFinalized();
2059
2060// Set the name, as in the case of nested, it would determine the relation
2061// to any potential parent, via the LF_NESTTYPE record.
2062 Scope->setName(Enum.getName());
2063if (Enum.hasUniqueName())
2064 Scope->setLinkageName(Enum.getUniqueName());
2065
2066 Scope->setType(getElement(StreamTPI,Enum.getUnderlyingType()));
2067
2068if (Enum.isNested()) {
2069 Scope->setIsNested();
2070 createParents(Enum.getName(), Scope);
2071 }
2072
2073if (Enum.isScoped()) {
2074 Scope->setIsScoped();
2075 Scope->setIsEnumClass();
2076 }
2077
2078// Nested types will be added to their parents at creation.
2079if (!(Enum.isNested() ||Enum.isScoped())) {
2080if (LVScope *Namespace = Shared->NamespaceDeduction.get(Enum.getName()))
2081 Namespace->addElement(Scope);
2082else
2083 Reader->getCompileUnit()->addElement(Scope);
2084 }
2085
2086TypeIndex TIFieldList =Enum.getFieldList();
2087if (!TIFieldList.isNoneType()) {
2088LazyRandomTypeCollection &Types = types();
2089CVType CVFieldList =Types.getType(TIFieldList);
2090if (Error Err =finishVisitation(CVFieldList, TIFieldList, Scope))
2091return Err;
2092 }
2093
2094returnError::success();
2095}
2096
2097// LF_FIELDLIST (TPI)
2098ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2099FieldListRecord &FieldList,
2100TypeIndex TI,LVElement *Element) {
2101LLVM_DEBUG({
2102printTypeBegin(Record, TI, Element,StreamTPI);
2103printTypeEnd(Record);
2104 });
2105
2106if (Error Err = visitFieldListMemberStream(TI, Element,FieldList.Data))
2107return Err;
2108
2109returnError::success();
2110}
2111
2112// LF_FUNC_ID (TPI)/(IPI)
2113ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,FuncIdRecord &Func,
2114TypeIndex TI,LVElement *Element) {
2115// ParentScope and FunctionType are references into the TPI stream.
2116LLVM_DEBUG({
2117printTypeBegin(Record, TI, Element,StreamIPI);
2118printTypeIndex("ParentScope", Func.getParentScope(),StreamTPI);
2119printTypeIndex("FunctionType", Func.getFunctionType(),StreamTPI);
2120 W.printString("Name", Func.getName());
2121printTypeEnd(Record);
2122 });
2123
2124// The TypeIndex (LF_PROCEDURE) returned by 'getFunctionType' is the
2125// function propotype, we need to use the function definition.
2126if (LVScope *FunctionDcl =static_cast<LVScope *>(Element)) {
2127// For inlined functions, the inlined instance has been already processed
2128// (all its information is contained in the Symbols section).
2129// 'Element' points to the created 'abstract' (out-of-line) function.
2130// Use the parent scope information to allocate it to the correct scope.
2131LazyRandomTypeCollection &Types = types();
2132TypeIndex TIParent = Func.getParentScope();
2133if (FunctionDcl->getIsInlinedAbstract()) {
2134 FunctionDcl->setName(Func.getName());
2135if (TIParent.isNoneType())
2136 Reader->getCompileUnit()->addElement(FunctionDcl);
2137 }
2138
2139if (!TIParent.isNoneType()) {
2140CVType CVParentScope = ids().getType(TIParent);
2141if (Error Err =finishVisitation(CVParentScope, TIParent, FunctionDcl))
2142return Err;
2143 }
2144
2145TypeIndex TIFunctionType = Func.getFunctionType();
2146CVType CVFunctionType =Types.getType(TIFunctionType);
2147if (Error Err =
2148finishVisitation(CVFunctionType, TIFunctionType, FunctionDcl))
2149return Err;
2150
2151 FunctionDcl->setIsFinalized();
2152 }
2153
2154returnError::success();
2155}
2156
2157// LF_LABEL (TPI)
2158ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,LabelRecord &LR,
2159TypeIndex TI,LVElement *Element) {
2160LLVM_DEBUG({
2161printTypeBegin(Record, TI, Element,StreamTPI);
2162printTypeEnd(Record);
2163 });
2164returnError::success();
2165}
2166
2167// LF_MFUNC_ID (TPI)/(IPI)
2168ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,MemberFuncIdRecord &Id,
2169TypeIndex TI,LVElement *Element) {
2170// ClassType and FunctionType are references into the TPI stream.
2171LLVM_DEBUG({
2172printTypeBegin(Record, TI, Element,StreamIPI);
2173printTypeIndex("ClassType", Id.getClassType(),StreamTPI);
2174printTypeIndex("FunctionType", Id.getFunctionType(),StreamTPI);
2175 W.printString("Name", Id.getName());
2176printTypeEnd(Record);
2177 });
2178
2179LVScope *FunctionDcl =static_cast<LVScope *>(Element);
2180if (FunctionDcl->getIsInlinedAbstract()) {
2181// For inlined functions, the inlined instance has been already processed
2182// (all its information is contained in the Symbols section).
2183// 'Element' points to the created 'abstract' (out-of-line) function.
2184// Use the parent scope information to allocate it to the correct scope.
2185if (LVScope *Class =static_cast<LVScope *>(
2186 Shared->TypeRecords.find(StreamTPI, Id.getClassType())))
2187Class->addElement(FunctionDcl);
2188 }
2189
2190TypeIndex TIFunctionType = Id.getFunctionType();
2191CVType CVFunction = types().getType(TIFunctionType);
2192if (Error Err =finishVisitation(CVFunction, TIFunctionType, Element))
2193return Err;
2194
2195returnError::success();
2196}
2197
2198// LF_MFUNCTION (TPI)
2199ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2200MemberFunctionRecord &MF,TypeIndex TI,
2201LVElement *Element) {
2202LLVM_DEBUG({
2203printTypeBegin(Record, TI, Element,StreamTPI);
2204printTypeIndex("ReturnType", MF.getReturnType(),StreamTPI);
2205printTypeIndex("ClassType", MF.getClassType(),StreamTPI);
2206printTypeIndex("ThisType", MF.getThisType(),StreamTPI);
2207 W.printNumber("NumParameters", MF.getParameterCount());
2208printTypeIndex("ArgListType", MF.getArgumentList(),StreamTPI);
2209 W.printNumber("ThisAdjustment", MF.getThisPointerAdjustment());
2210printTypeEnd(Record);
2211 });
2212
2213if (LVScope *MemberFunction =static_cast<LVScope *>(Element)) {
2214LVElement *Class =getElement(StreamTPI, MF.getClassType());
2215
2216 MemberFunction->setIsFinalized();
2217 MemberFunction->setType(getElement(StreamTPI, MF.getReturnType()));
2218 MemberFunction->setOffset(TI.getIndex());
2219 MemberFunction->setOffsetFromTypeIndex();
2220
2221if (ProcessArgumentList) {
2222 ProcessArgumentList =false;
2223
2224if (!MemberFunction->getIsStatic()) {
2225LVElement *ThisPointer =getElement(StreamTPI, MF.getThisType());
2226// When creating the 'this' pointer, check if it points to a reference.
2227 ThisPointer->setType(Class);
2228LVSymbol *This =
2229 createParameter(ThisPointer,StringRef(), MemberFunction);
2230This->setIsArtificial();
2231 }
2232
2233// Create formal parameters.
2234LazyRandomTypeCollection &Types = types();
2235CVType CVArguments =Types.getType(MF.getArgumentList());
2236if (Error Err =finishVisitation(CVArguments, MF.getArgumentList(),
2237 MemberFunction))
2238return Err;
2239 }
2240 }
2241
2242returnError::success();
2243}
2244
2245// LF_METHODLIST (TPI)
2246ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2247MethodOverloadListRecord &Overloads,
2248TypeIndex TI,LVElement *Element) {
2249LLVM_DEBUG({
2250printTypeBegin(Record, TI, Element,StreamTPI);
2251printTypeEnd(Record);
2252 });
2253
2254for (OneMethodRecord &Method : Overloads.Methods) {
2255CVMemberRecordRecord;
2256Record.Kind = LF_METHOD;
2257 Method.Name = OverloadedMethodName;
2258if (Error Err =visitKnownMember(Record, Method, TI, Element))
2259return Err;
2260 }
2261
2262returnError::success();
2263}
2264
2265// LF_MODIFIER (TPI)
2266ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,ModifierRecord &Mod,
2267TypeIndex TI,LVElement *Element) {
2268LLVM_DEBUG({
2269printTypeBegin(Record, TI, Element,StreamTPI);
2270printTypeIndex("ModifiedType",Mod.getModifiedType(),StreamTPI);
2271printTypeEnd(Record);
2272 });
2273
2274// Create the modified type, which will be attached to the type(s) that
2275// contains the modifiers.
2276LVElement *ModifiedType =getElement(StreamTPI,Mod.getModifiedType());
2277
2278// At this point the types recording the qualifiers do not have a
2279// scope parent. They must be assigned to the current compile unit.
2280LVScopeCompileUnit *CompileUnit = Reader->getCompileUnit();
2281
2282// The incoming element does not have a defined kind. Use the given
2283// modifiers to complete its type. A type can have more than one modifier;
2284// in that case, we have to create an extra type to have the other modifier.
2285LVType *LastLink =static_cast<LVType *>(Element);
2286if (!LastLink->getParentScope())
2287CompileUnit->addElement(LastLink);
2288
2289bool SeenModifier =false;
2290uint16_t Mods =static_cast<uint16_t>(Mod.getModifiers());
2291if (Mods &uint16_t(ModifierOptions::Const)) {
2292 SeenModifier =true;
2293 LastLink->setTag(dwarf::DW_TAG_const_type);
2294 LastLink->setIsConst();
2295 LastLink->setName("const");
2296 }
2297if (Mods &uint16_t(ModifierOptions::Volatile)) {
2298if (SeenModifier) {
2299LVType *Volatile = Reader->createType();
2300Volatile->setIsModifier();
2301 LastLink->setType(Volatile);
2302 LastLink =Volatile;
2303CompileUnit->addElement(LastLink);
2304 }
2305 LastLink->setTag(dwarf::DW_TAG_volatile_type);
2306 LastLink->setIsVolatile();
2307 LastLink->setName("volatile");
2308 }
2309if (Mods &uint16_t(ModifierOptions::Unaligned)) {
2310if (SeenModifier) {
2311LVType *Unaligned = Reader->createType();
2312Unaligned->setIsModifier();
2313 LastLink->setType(Unaligned);
2314 LastLink =Unaligned;
2315CompileUnit->addElement(LastLink);
2316 }
2317 LastLink->setTag(dwarf::DW_TAG_unaligned);
2318 LastLink->setIsUnaligned();
2319 LastLink->setName("unaligned");
2320 }
2321
2322 LastLink->setType(ModifiedType);
2323returnError::success();
2324}
2325
2326// LF_POINTER (TPI)
2327ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,PointerRecord &Ptr,
2328TypeIndex TI,LVElement *Element) {
2329LLVM_DEBUG({
2330printTypeBegin(Record, TI, Element,StreamTPI);
2331printTypeIndex("PointeeType",Ptr.getReferentType(),StreamTPI);
2332 W.printNumber("IsFlat",Ptr.isFlat());
2333 W.printNumber("IsConst",Ptr.isConst());
2334 W.printNumber("IsVolatile",Ptr.isVolatile());
2335 W.printNumber("IsUnaligned",Ptr.isUnaligned());
2336 W.printNumber("IsRestrict",Ptr.isRestrict());
2337 W.printNumber("IsThisPtr&",Ptr.isLValueReferenceThisPtr());
2338 W.printNumber("IsThisPtr&&",Ptr.isRValueReferenceThisPtr());
2339 W.printNumber("SizeOf",Ptr.getSize());
2340
2341if (Ptr.isPointerToMember()) {
2342constMemberPointerInfo &MI =Ptr.getMemberInfo();
2343printTypeIndex("ClassType",MI.getContainingType(),StreamTPI);
2344 }
2345printTypeEnd(Record);
2346 });
2347
2348// Find the pointed-to type.
2349LVType *Pointer =static_cast<LVType *>(Element);
2350LVElement *Pointee =nullptr;
2351
2352PointerMode Mode =Ptr.getMode();
2353 Pointee =Ptr.isPointerToMember()
2354 ? Shared->TypeRecords.find(StreamTPI,Ptr.getReferentType())
2355 :getElement(StreamTPI,Ptr.getReferentType());
2356
2357// At this point the types recording the qualifiers do not have a
2358// scope parent. They must be assigned to the current compile unit.
2359LVScopeCompileUnit *CompileUnit = Reader->getCompileUnit();
2360
2361// Order for the different modifiers:
2362// <restrict> <pointer, Reference, ValueReference> <const, volatile>
2363// Const and volatile already processed.
2364bool SeenModifier =false;
2365LVType *LastLink =Pointer;
2366if (!LastLink->getParentScope())
2367CompileUnit->addElement(LastLink);
2368
2369if (Ptr.isRestrict()) {
2370 SeenModifier =true;
2371LVType *Restrict = Reader->createType();
2372Restrict->setTag(dwarf::DW_TAG_restrict_type);
2373Restrict->setIsRestrict();
2374Restrict->setName("restrict");
2375 LastLink->setType(Restrict);
2376 LastLink =Restrict;
2377CompileUnit->addElement(LastLink);
2378 }
2379if (Mode == PointerMode::LValueReference) {
2380if (SeenModifier) {
2381LVType *LReference = Reader->createType();
2382 LReference->setIsModifier();
2383 LastLink->setType(LReference);
2384 LastLink = LReference;
2385CompileUnit->addElement(LastLink);
2386 }
2387 LastLink->setTag(dwarf::DW_TAG_reference_type);
2388 LastLink->setIsReference();
2389 LastLink->setName("&");
2390 }
2391if (Mode == PointerMode::RValueReference) {
2392if (SeenModifier) {
2393LVType *RReference = Reader->createType();
2394 RReference->setIsModifier();
2395 LastLink->setType(RReference);
2396 LastLink = RReference;
2397CompileUnit->addElement(LastLink);
2398 }
2399 LastLink->setTag(dwarf::DW_TAG_rvalue_reference_type);
2400 LastLink->setIsRvalueReference();
2401 LastLink->setName("&&");
2402 }
2403
2404// When creating the pointer, check if it points to a reference.
2405 LastLink->setType(Pointee);
2406returnError::success();
2407}
2408
2409// LF_PROCEDURE (TPI)
2410ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,ProcedureRecord &Proc,
2411TypeIndex TI,LVElement *Element) {
2412LLVM_DEBUG({
2413printTypeBegin(Record, TI, Element,StreamTPI);
2414printTypeIndex("ReturnType", Proc.getReturnType(),StreamTPI);
2415 W.printNumber("NumParameters", Proc.getParameterCount());
2416printTypeIndex("ArgListType", Proc.getArgumentList(),StreamTPI);
2417printTypeEnd(Record);
2418 });
2419
2420// There is no need to traverse the argument list, as the CodeView format
2421// declares the parameters as a 'S_LOCAL' symbol tagged as parameter.
2422// Only process parameters when dealing with inline functions.
2423if (LVScope *FunctionDcl =static_cast<LVScope *>(Element)) {
2424 FunctionDcl->setType(getElement(StreamTPI, Proc.getReturnType()));
2425
2426if (ProcessArgumentList) {
2427 ProcessArgumentList =false;
2428// Create formal parameters.
2429LazyRandomTypeCollection &Types = types();
2430CVType CVArguments =Types.getType(Proc.getArgumentList());
2431if (Error Err =finishVisitation(CVArguments, Proc.getArgumentList(),
2432 FunctionDcl))
2433return Err;
2434 }
2435 }
2436
2437returnError::success();
2438}
2439
2440// LF_UNION (TPI)
2441ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,UnionRecord &Union,
2442TypeIndex TI,LVElement *Element) {
2443LLVM_DEBUG({
2444printTypeBegin(Record, TI, Element,StreamTPI);
2445 W.printNumber("MemberCount",Union.getMemberCount());
2446printTypeIndex("FieldList",Union.getFieldList(),StreamTPI);
2447 W.printNumber("SizeOf",Union.getSize());
2448 W.printString("Name",Union.getName());
2449if (Union.hasUniqueName())
2450 W.printString("UniqueName",Union.getUniqueName());
2451printTypeEnd(Record);
2452 });
2453
2454LVScopeAggregate *Scope =static_cast<LVScopeAggregate *>(Element);
2455if (!Scope)
2456returnError::success();
2457
2458if (Scope->getIsFinalized())
2459returnError::success();
2460 Scope->setIsFinalized();
2461
2462 Scope->setName(Union.getName());
2463if (Union.hasUniqueName())
2464 Scope->setLinkageName(Union.getUniqueName());
2465
2466if (Union.isNested()) {
2467 Scope->setIsNested();
2468 createParents(Union.getName(), Scope);
2469 }else {
2470if (LVScope *Namespace = Shared->NamespaceDeduction.get(Union.getName()))
2471 Namespace->addElement(Scope);
2472else
2473 Reader->getCompileUnit()->addElement(Scope);
2474 }
2475
2476if (!Union.getFieldList().isNoneType()) {
2477LazyRandomTypeCollection &Types = types();
2478// Pass down the TypeIndex 'TI' for the aggregate containing the field list.
2479CVType CVFieldList =Types.getType(Union.getFieldList());
2480if (Error Err =finishVisitation(CVFieldList, TI, Scope))
2481return Err;
2482 }
2483
2484returnError::success();
2485}
2486
2487// LF_TYPESERVER2 (TPI)
2488ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,TypeServer2Record &TS,
2489TypeIndex TI,LVElement *Element) {
2490LLVM_DEBUG({
2491printTypeBegin(Record, TI, Element,StreamTPI);
2492 W.printString("Guid",formatv("{0}", TS.getGuid()).str());
2493 W.printNumber("Age", TS.getAge());
2494 W.printString("Name", TS.getName());
2495printTypeEnd(Record);
2496 });
2497returnError::success();
2498}
2499
2500// LF_VFTABLE (TPI)
2501ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,VFTableRecord &VFT,
2502TypeIndex TI,LVElement *Element) {
2503LLVM_DEBUG({
2504printTypeBegin(Record, TI, Element,StreamTPI);
2505printTypeIndex("CompleteClass", VFT.getCompleteClass(),StreamTPI);
2506printTypeIndex("OverriddenVFTable", VFT.getOverriddenVTable(),StreamTPI);
2507 W.printHex("VFPtrOffset", VFT.getVFPtrOffset());
2508 W.printString("VFTableName", VFT.getName());
2509for (constStringRef &N : VFT.getMethodNames())
2510 W.printString("MethodName",N);
2511printTypeEnd(Record);
2512 });
2513returnError::success();
2514}
2515
2516// LF_VTSHAPE (TPI)
2517ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2518VFTableShapeRecord &Shape,
2519TypeIndex TI,LVElement *Element) {
2520LLVM_DEBUG({
2521printTypeBegin(Record, TI, Element,StreamTPI);
2522 W.printNumber("VFEntryCount", Shape.getEntryCount());
2523printTypeEnd(Record);
2524 });
2525returnError::success();
2526}
2527
2528// LF_SUBSTR_LIST (TPI)/(IPI)
2529ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2530StringListRecord &Strings,
2531TypeIndex TI,LVElement *Element) {
2532// All the indices are references into the TPI/IPI stream.
2533LLVM_DEBUG({
2534printTypeBegin(Record, TI, Element,StreamIPI);
2535ArrayRef<TypeIndex> Indices = Strings.getIndices();
2536uint32_tSize = Indices.size();
2537 W.printNumber("NumStrings",Size);
2538ListScopeArguments(W,"Strings");
2539for (uint32_tI = 0;I <Size; ++I)
2540printTypeIndex("String", Indices[I],StreamIPI);
2541printTypeEnd(Record);
2542 });
2543returnError::success();
2544}
2545
2546// LF_STRING_ID (TPI)/(IPI)
2547ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,StringIdRecord &String,
2548TypeIndex TI,LVElement *Element) {
2549// All args are references into the TPI/IPI stream.
2550LLVM_DEBUG({
2551printTypeIndex("\nTI", TI,StreamIPI);
2552printTypeIndex("Id",String.getId(),StreamIPI);
2553 W.printString("StringData",String.getString());
2554 });
2555
2556if (LVScope *Namespace = Shared->NamespaceDeduction.get(
2557String.getString(),/*CheckScope=*/false)) {
2558// The function is already at different scope. In order to reflect
2559// the correct parent, move it to the namespace.
2560if (LVScope *Scope = Element->getParentScope())
2561 Scope->removeElement(Element);
2562 Namespace->addElement(Element);
2563 }
2564
2565returnError::success();
2566}
2567
2568// LF_UDT_SRC_LINE (TPI)/(IPI)
2569ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2570UdtSourceLineRecord &SourceLine,
2571TypeIndex TI,LVElement *Element) {
2572// All args are references into the TPI/IPI stream.
2573LLVM_DEBUG({
2574printTypeIndex("\nTI", TI,StreamIPI);
2575printTypeIndex("UDT", SourceLine.getUDT(),StreamIPI);
2576printTypeIndex("SourceFile", SourceLine.getSourceFile(),StreamIPI);
2577 W.printNumber("LineNumber", SourceLine.getLineNumber());
2578 });
2579returnError::success();
2580}
2581
2582// LF_UDT_MOD_SRC_LINE (TPI)/(IPI)
2583ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2584UdtModSourceLineRecord &ModSourceLine,
2585TypeIndex TI,LVElement *Element) {
2586// All args are references into the TPI/IPI stream.
2587LLVM_DEBUG({
2588printTypeBegin(Record, TI, Element,StreamIPI);
2589printTypeIndex("\nTI", TI,StreamIPI);
2590printTypeIndex("UDT", ModSourceLine.getUDT(),StreamIPI);
2591printTypeIndex("SourceFile", ModSourceLine.getSourceFile(),StreamIPI);
2592 W.printNumber("LineNumber", ModSourceLine.getLineNumber());
2593 W.printNumber("Module", ModSourceLine.getModule());
2594printTypeEnd(Record);
2595 });
2596returnError::success();
2597}
2598
2599// LF_PRECOMP (TPI)
2600ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,PrecompRecord &Precomp,
2601TypeIndex TI,LVElement *Element) {
2602LLVM_DEBUG({
2603printTypeBegin(Record, TI, Element,StreamTPI);
2604 W.printHex("StartIndex", Precomp.getStartTypeIndex());
2605 W.printHex("Count", Precomp.getTypesCount());
2606 W.printHex("Signature", Precomp.getSignature());
2607 W.printString("PrecompFile", Precomp.getPrecompFilePath());
2608printTypeEnd(Record);
2609 });
2610returnError::success();
2611}
2612
2613// LF_ENDPRECOMP (TPI)
2614ErrorLVLogicalVisitor::visitKnownRecord(CVType &Record,
2615EndPrecompRecord &EndPrecomp,
2616TypeIndex TI,LVElement *Element) {
2617LLVM_DEBUG({
2618printTypeBegin(Record, TI, Element,StreamTPI);
2619 W.printHex("Signature", EndPrecomp.getSignature());
2620printTypeEnd(Record);
2621 });
2622returnError::success();
2623}
2624
2625ErrorLVLogicalVisitor::visitUnknownMember(CVMemberRecord &Record,
2626TypeIndex TI) {
2627LLVM_DEBUG({ W.printHex("UnknownMember",unsigned(Record.Kind)); });
2628returnError::success();
2629}
2630
2631// LF_BCLASS, LF_BINTERFACE
2632ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2633BaseClassRecord &Base,TypeIndex TI,
2634LVElement *Element) {
2635LLVM_DEBUG({
2636printMemberBegin(Record, TI, Element,StreamTPI);
2637printTypeIndex("BaseType",Base.getBaseType(),StreamTPI);
2638 W.printHex("BaseOffset",Base.getBaseOffset());
2639printMemberEnd(Record);
2640 });
2641
2642createElement(Record.Kind);
2643if (LVSymbol *Symbol =CurrentSymbol) {
2644LVElement *BaseClass =getElement(StreamTPI,Base.getBaseType());
2645 Symbol->setName(BaseClass->getName());
2646 Symbol->setType(BaseClass);
2647 Symbol->setAccessibilityCode(Base.getAccess());
2648static_cast<LVScope *>(Element)->addElement(Symbol);
2649 }
2650
2651returnError::success();
2652}
2653
2654// LF_MEMBER
2655ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2656DataMemberRecord &Field,TypeIndex TI,
2657LVElement *Element) {
2658LLVM_DEBUG({
2659printMemberBegin(Record, TI, Element,StreamTPI);
2660printTypeIndex("Type",Field.getType(),StreamTPI);
2661 W.printHex("FieldOffset",Field.getFieldOffset());
2662 W.printString("Name",Field.getName());
2663printMemberEnd(Record);
2664 });
2665
2666// Create the data member.
2667 createDataMember(Record,static_cast<LVScope *>(Element),Field.getName(),
2668Field.getType(),Field.getAccess());
2669returnError::success();
2670}
2671
2672// LF_ENUMERATE
2673ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2674EnumeratorRecord &Enum,TypeIndex TI,
2675LVElement *Element) {
2676LLVM_DEBUG({
2677printMemberBegin(Record, TI, Element,StreamTPI);
2678 W.printNumber("EnumValue",Enum.getValue());
2679 W.printString("Name",Enum.getName());
2680printMemberEnd(Record);
2681 });
2682
2683createElement(Record.Kind);
2684if (LVType *Type =CurrentType) {
2685Type->setName(Enum.getName());
2686SmallString<16>Value;
2687Enum.getValue().toString(Value, 16,true,true);
2688Type->setValue(Value);
2689static_cast<LVScope *>(Element)->addElement(CurrentType);
2690 }
2691
2692returnError::success();
2693}
2694
2695// LF_INDEX
2696ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2697ListContinuationRecord &Cont,
2698TypeIndex TI,LVElement *Element) {
2699LLVM_DEBUG({
2700printMemberBegin(Record, TI, Element,StreamTPI);
2701printTypeIndex("ContinuationIndex", Cont.getContinuationIndex(),StreamTPI);
2702printMemberEnd(Record);
2703 });
2704returnError::success();
2705}
2706
2707// LF_NESTTYPE
2708ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2709NestedTypeRecord &Nested,TypeIndex TI,
2710LVElement *Element) {
2711LLVM_DEBUG({
2712printMemberBegin(Record, TI, Element,StreamTPI);
2713printTypeIndex("Type",Nested.getNestedType(),StreamTPI);
2714 W.printString("Name",Nested.getName());
2715printMemberEnd(Record);
2716 });
2717
2718if (LVElement *Typedef =createElement(SymbolKind::S_UDT)) {
2719Typedef->setName(Nested.getName());
2720LVElement *NestedType =getElement(StreamTPI,Nested.getNestedType());
2721Typedef->setType(NestedType);
2722LVScope *Scope =static_cast<LVScope *>(Element);
2723 Scope->addElement(Typedef);
2724
2725if (NestedType && NestedType->getIsNested()) {
2726// 'Element' is an aggregate type that may contains this nested type
2727// definition. Used their scoped names, to decide on their relationship.
2728StringRef RecordName =getRecordName(types(), TI);
2729
2730StringRef NestedTypeName = NestedType->getName();
2731if (NestedTypeName.size() && RecordName.size()) {
2732StringRef OuterComponent;
2733 std::tie(OuterComponent, std::ignore) =
2734getInnerComponent(NestedTypeName);
2735// We have an already created nested type. Add it to the current scope
2736// and update all its children if any.
2737if (OuterComponent.size() && OuterComponent == RecordName) {
2738if (!NestedType->getIsScopedAlready()) {
2739 Scope->addElement(NestedType);
2740 NestedType->setIsScopedAlready();
2741 NestedType->updateLevel(Scope);
2742 }
2743Typedef->resetIncludeInPrint();
2744 }
2745 }
2746 }
2747 }
2748
2749returnError::success();
2750}
2751
2752// LF_ONEMETHOD
2753ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2754OneMethodRecord &Method,TypeIndex TI,
2755LVElement *Element) {
2756LLVM_DEBUG({
2757printMemberBegin(Record, TI, Element,StreamTPI);
2758printTypeIndex("Type", Method.getType(),StreamTPI);
2759// If virtual, then read the vftable offset.
2760if (Method.isIntroducingVirtual())
2761 W.printHex("VFTableOffset", Method.getVFTableOffset());
2762 W.printString("Name", Method.getName());
2763printMemberEnd(Record);
2764 });
2765
2766// All the LF_ONEMETHOD objects share the same type description.
2767// We have to create a scope object for each one and get the required
2768// information from the LF_MFUNCTION object.
2769 ProcessArgumentList =true;
2770if (LVElement *MemberFunction =createElement(TypeLeafKind::LF_ONEMETHOD)) {
2771 MemberFunction->setIsFinalized();
2772static_cast<LVScope *>(Element)->addElement(MemberFunction);
2773
2774 MemberFunction->setName(Method.getName());
2775 MemberFunction->setAccessibilityCode(Method.getAccess());
2776
2777MethodKindKind = Method.getMethodKind();
2778if (Kind == MethodKind::Static)
2779 MemberFunction->setIsStatic();
2780 MemberFunction->setVirtualityCode(Kind);
2781
2782MethodOptions Flags = Method.Attrs.getFlags();
2783if (MethodOptions::CompilerGenerated ==
2784 (Flags & MethodOptions::CompilerGenerated))
2785 MemberFunction->setIsArtificial();
2786
2787LazyRandomTypeCollection &Types = types();
2788CVType CVMethodType =Types.getType(Method.getType());
2789if (Error Err =
2790finishVisitation(CVMethodType, Method.getType(), MemberFunction))
2791return Err;
2792 }
2793 ProcessArgumentList =false;
2794
2795returnError::success();
2796}
2797
2798// LF_METHOD
2799ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2800OverloadedMethodRecord &Method,
2801TypeIndex TI,LVElement *Element) {
2802LLVM_DEBUG({
2803printMemberBegin(Record, TI, Element,StreamTPI);
2804 W.printHex("MethodCount", Method.getNumOverloads());
2805printTypeIndex("MethodListIndex", Method.getMethodList(),StreamTPI);
2806 W.printString("Name", Method.getName());
2807printMemberEnd(Record);
2808 });
2809
2810// Record the overloaded method name, which will be used during the
2811// traversal of the method list.
2812LazyRandomTypeCollection &Types = types();
2813 OverloadedMethodName = Method.getName();
2814CVType CVMethods =Types.getType(Method.getMethodList());
2815if (Error Err =finishVisitation(CVMethods, Method.getMethodList(), Element))
2816return Err;
2817
2818returnError::success();
2819}
2820
2821// LF_STMEMBER
2822ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2823StaticDataMemberRecord &Field,
2824TypeIndex TI,LVElement *Element) {
2825LLVM_DEBUG({
2826printMemberBegin(Record, TI, Element,StreamTPI);
2827printTypeIndex("Type",Field.getType(),StreamTPI);
2828 W.printString("Name",Field.getName());
2829printMemberEnd(Record);
2830 });
2831
2832// Create the data member.
2833 createDataMember(Record,static_cast<LVScope *>(Element),Field.getName(),
2834Field.getType(),Field.getAccess());
2835returnError::success();
2836}
2837
2838// LF_VFUNCTAB
2839ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2840VFPtrRecord &VFTable,TypeIndex TI,
2841LVElement *Element) {
2842LLVM_DEBUG({
2843printMemberBegin(Record, TI, Element,StreamTPI);
2844printTypeIndex("Type", VFTable.getType(),StreamTPI);
2845printMemberEnd(Record);
2846 });
2847returnError::success();
2848}
2849
2850// LF_VBCLASS, LF_IVBCLASS
2851ErrorLVLogicalVisitor::visitKnownMember(CVMemberRecord &Record,
2852VirtualBaseClassRecord &Base,
2853TypeIndex TI,LVElement *Element) {
2854LLVM_DEBUG({
2855printMemberBegin(Record, TI, Element,StreamTPI);
2856printTypeIndex("BaseType",Base.getBaseType(),StreamTPI);
2857printTypeIndex("VBPtrType",Base.getVBPtrType(),StreamTPI);
2858 W.printHex("VBPtrOffset",Base.getVBPtrOffset());
2859 W.printHex("VBTableIndex",Base.getVTableIndex());
2860printMemberEnd(Record);
2861 });
2862
2863createElement(Record.Kind);
2864if (LVSymbol *Symbol =CurrentSymbol) {
2865LVElement *BaseClass =getElement(StreamTPI,Base.getBaseType());
2866 Symbol->setName(BaseClass->getName());
2867 Symbol->setType(BaseClass);
2868 Symbol->setAccessibilityCode(Base.getAccess());
2869 Symbol->setVirtualityCode(MethodKind::Virtual);
2870static_cast<LVScope *>(Element)->addElement(Symbol);
2871 }
2872
2873returnError::success();
2874}
2875
2876ErrorLVLogicalVisitor::visitMemberRecord(CVMemberRecord &Record,
2877TypeVisitorCallbacks &Callbacks,
2878TypeIndex TI,LVElement *Element) {
2879if (Error Err = Callbacks.visitMemberBegin(Record))
2880return Err;
2881
2882switch (Record.Kind) {
2883default:
2884if (Error Err = Callbacks.visitUnknownMember(Record))
2885return Err;
2886break;
2887#define MEMBER_RECORD(EnumName, EnumVal, Name) \
2888 case EnumName: { \
2889 if (Error Err = \
2890 visitKnownMember<Name##Record>(Record, Callbacks, TI, Element)) \
2891 return Err; \
2892 break; \
2893 }
2894#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
2895 MEMBER_RECORD(EnumVal, EnumVal, AliasName)
2896#define TYPE_RECORD(EnumName, EnumVal, Name)
2897#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
2898#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
2899 }
2900
2901if (Error Err = Callbacks.visitMemberEnd(Record))
2902return Err;
2903
2904returnError::success();
2905}
2906
2907ErrorLVLogicalVisitor::finishVisitation(CVType &Record,TypeIndex TI,
2908LVElement *Element) {
2909switch (Record.kind()) {
2910default:
2911if (Error Err =visitUnknownType(Record, TI))
2912return Err;
2913break;
2914#define TYPE_RECORD(EnumName, EnumVal, Name) \
2915 case EnumName: { \
2916 if (Error Err = visitKnownRecord<Name##Record>(Record, TI, Element)) \
2917 return Err; \
2918 break; \
2919 }
2920#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
2921 TYPE_RECORD(EnumVal, EnumVal, AliasName)
2922#define MEMBER_RECORD(EnumName, EnumVal, Name)
2923#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
2924#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
2925 }
2926
2927returnError::success();
2928}
2929
2930// Customized version of 'FieldListVisitHelper'.
2931Error LVLogicalVisitor::visitFieldListMemberStream(
2932TypeIndex TI,LVElement *Element,ArrayRef<uint8_t>FieldList) {
2933BinaryByteStream Stream(FieldList,llvm::endianness::little);
2934BinaryStreamReader Reader(Stream);
2935FieldListDeserializer Deserializer(Reader);
2936TypeVisitorCallbackPipeline Pipeline;
2937 Pipeline.addCallbackToPipeline(Deserializer);
2938
2939TypeLeafKind Leaf;
2940while (!Reader.empty()) {
2941if (Error Err = Reader.readEnum(Leaf))
2942return Err;
2943
2944CVMemberRecordRecord;
2945Record.Kind = Leaf;
2946if (Error Err =visitMemberRecord(Record, Pipeline, TI, Element))
2947return Err;
2948 }
2949
2950returnError::success();
2951}
2952
2953voidLVLogicalVisitor::addElement(LVScope *Scope,boolIsCompileUnit) {
2954// The CodeView specifications does not treat S_COMPILE2 and S_COMPILE3
2955// as symbols that open a scope. The CodeView reader, treat them in a
2956// similar way as DWARF. As there is no a symbole S_END to close the
2957// compile unit, we need to check for the next compile unit.
2958if (IsCompileUnit) {
2959if (!ScopeStack.empty())
2960popScope();
2961 InCompileUnitScope =true;
2962 }
2963
2964pushScope(Scope);
2965 ReaderParent->addElement(Scope);
2966}
2967
2968voidLVLogicalVisitor::addElement(LVSymbol *Symbol) {
2969 ReaderScope->addElement(Symbol);
2970}
2971
2972voidLVLogicalVisitor::addElement(LVType *Type) {
2973 ReaderScope->addElement(Type);
2974}
2975
2976LVElement *LVLogicalVisitor::createElement(TypeLeafKindKind) {
2977CurrentScope =nullptr;
2978CurrentSymbol =nullptr;
2979CurrentType =nullptr;
2980
2981if (Kind <TypeIndex::FirstNonSimpleIndex) {
2982CurrentType = Reader->createType();
2983CurrentType->setIsBase();
2984CurrentType->setTag(dwarf::DW_TAG_base_type);
2985if (options().getAttributeBase())
2986CurrentType->setIncludeInPrint();
2987returnCurrentType;
2988 }
2989
2990switch (Kind) {
2991// Types.
2992case TypeLeafKind::LF_ENUMERATE:
2993CurrentType = Reader->createTypeEnumerator();
2994CurrentType->setTag(dwarf::DW_TAG_enumerator);
2995returnCurrentType;
2996case TypeLeafKind::LF_MODIFIER:
2997CurrentType = Reader->createType();
2998CurrentType->setIsModifier();
2999returnCurrentType;
3000case TypeLeafKind::LF_POINTER:
3001CurrentType = Reader->createType();
3002CurrentType->setIsPointer();
3003CurrentType->setName("*");
3004CurrentType->setTag(dwarf::DW_TAG_pointer_type);
3005returnCurrentType;
3006
3007// Symbols.
3008case TypeLeafKind::LF_BCLASS:
3009case TypeLeafKind::LF_IVBCLASS:
3010case TypeLeafKind::LF_VBCLASS:
3011CurrentSymbol = Reader->createSymbol();
3012CurrentSymbol->setTag(dwarf::DW_TAG_inheritance);
3013CurrentSymbol->setIsInheritance();
3014returnCurrentSymbol;
3015case TypeLeafKind::LF_MEMBER:
3016case TypeLeafKind::LF_STMEMBER:
3017CurrentSymbol = Reader->createSymbol();
3018CurrentSymbol->setIsMember();
3019CurrentSymbol->setTag(dwarf::DW_TAG_member);
3020returnCurrentSymbol;
3021
3022// Scopes.
3023case TypeLeafKind::LF_ARRAY:
3024CurrentScope = Reader->createScopeArray();
3025CurrentScope->setTag(dwarf::DW_TAG_array_type);
3026returnCurrentScope;
3027case TypeLeafKind::LF_CLASS:
3028CurrentScope = Reader->createScopeAggregate();
3029CurrentScope->setTag(dwarf::DW_TAG_class_type);
3030CurrentScope->setIsClass();
3031returnCurrentScope;
3032case TypeLeafKind::LF_ENUM:
3033CurrentScope = Reader->createScopeEnumeration();
3034CurrentScope->setTag(dwarf::DW_TAG_enumeration_type);
3035returnCurrentScope;
3036case TypeLeafKind::LF_METHOD:
3037case TypeLeafKind::LF_ONEMETHOD:
3038case TypeLeafKind::LF_PROCEDURE:
3039CurrentScope = Reader->createScopeFunction();
3040CurrentScope->setIsSubprogram();
3041CurrentScope->setTag(dwarf::DW_TAG_subprogram);
3042returnCurrentScope;
3043case TypeLeafKind::LF_STRUCTURE:
3044CurrentScope = Reader->createScopeAggregate();
3045CurrentScope->setIsStructure();
3046CurrentScope->setTag(dwarf::DW_TAG_structure_type);
3047returnCurrentScope;
3048case TypeLeafKind::LF_UNION:
3049CurrentScope = Reader->createScopeAggregate();
3050CurrentScope->setIsUnion();
3051CurrentScope->setTag(dwarf::DW_TAG_union_type);
3052returnCurrentScope;
3053default:
3054// If '--internal=tag' and '--print=warning' are specified in the command
3055// line, we record and print each seen 'TypeLeafKind'.
3056break;
3057 }
3058returnnullptr;
3059}
3060
3061LVElement *LVLogicalVisitor::createElement(SymbolKindKind) {
3062CurrentScope =nullptr;
3063CurrentSymbol =nullptr;
3064CurrentType =nullptr;
3065switch (Kind) {
3066// Types.
3067case SymbolKind::S_UDT:
3068CurrentType = Reader->createTypeDefinition();
3069CurrentType->setTag(dwarf::DW_TAG_typedef);
3070returnCurrentType;
3071
3072// Symbols.
3073case SymbolKind::S_CONSTANT:
3074CurrentSymbol = Reader->createSymbol();
3075CurrentSymbol->setIsConstant();
3076CurrentSymbol->setTag(dwarf::DW_TAG_constant);
3077returnCurrentSymbol;
3078
3079case SymbolKind::S_BPREL32:
3080case SymbolKind::S_REGREL32:
3081case SymbolKind::S_GDATA32:
3082case SymbolKind::S_LDATA32:
3083case SymbolKind::S_LOCAL:
3084// During the symbol traversal more information is available to
3085// determine if the symbol is a parameter or a variable. At this
3086// stage mark it as variable.
3087CurrentSymbol = Reader->createSymbol();
3088CurrentSymbol->setIsVariable();
3089CurrentSymbol->setTag(dwarf::DW_TAG_variable);
3090returnCurrentSymbol;
3091
3092// Scopes.
3093case SymbolKind::S_BLOCK32:
3094CurrentScope = Reader->createScope();
3095CurrentScope->setIsLexicalBlock();
3096CurrentScope->setTag(dwarf::DW_TAG_lexical_block);
3097returnCurrentScope;
3098case SymbolKind::S_COMPILE2:
3099case SymbolKind::S_COMPILE3:
3100CurrentScope = Reader->createScopeCompileUnit();
3101CurrentScope->setTag(dwarf::DW_TAG_compile_unit);
3102 Reader->setCompileUnit(static_cast<LVScopeCompileUnit *>(CurrentScope));
3103returnCurrentScope;
3104case SymbolKind::S_INLINESITE:
3105case SymbolKind::S_INLINESITE2:
3106CurrentScope = Reader->createScopeFunctionInlined();
3107CurrentScope->setIsInlinedFunction();
3108CurrentScope->setTag(dwarf::DW_TAG_inlined_subroutine);
3109returnCurrentScope;
3110case SymbolKind::S_LPROC32:
3111case SymbolKind::S_GPROC32:
3112case SymbolKind::S_LPROC32_ID:
3113case SymbolKind::S_GPROC32_ID:
3114case SymbolKind::S_SEPCODE:
3115case SymbolKind::S_THUNK32:
3116CurrentScope = Reader->createScopeFunction();
3117CurrentScope->setIsSubprogram();
3118CurrentScope->setTag(dwarf::DW_TAG_subprogram);
3119returnCurrentScope;
3120default:
3121// If '--internal=tag' and '--print=warning' are specified in the command
3122// line, we record and print each seen 'SymbolKind'.
3123break;
3124 }
3125returnnullptr;
3126}
3127
3128LVElement *LVLogicalVisitor::createElement(TypeIndex TI,TypeLeafKindKind) {
3129LVElement *Element = Shared->TypeRecords.find(StreamTPI, TI);
3130if (!Element) {
3131// We are dealing with a base type or pointer to a base type, which are
3132// not included explicitly in the CodeView format.
3133if (Kind <TypeIndex::FirstNonSimpleIndex) {
3134 Element =createElement(Kind);
3135 Element->setIsFinalized();
3136 Shared->TypeRecords.add(StreamTPI, (TypeIndex)Kind,Kind, Element);
3137 Element->setOffset(Kind);
3138return Element;
3139 }
3140// We are dealing with a pointer to a base type.
3141if (TI.getIndex() <TypeIndex::FirstNonSimpleIndex) {
3142 Element =createElement(Kind);
3143 Shared->TypeRecords.add(StreamTPI, TI,Kind, Element);
3144 Element->setOffset(TI.getIndex());
3145 Element->setOffsetFromTypeIndex();
3146return Element;
3147 }
3148
3149 W.printString("** Not implemented. **");
3150printTypeIndex("TypeIndex", TI,StreamTPI);
3151 W.printString("TypeLeafKind",formatTypeLeafKind(Kind));
3152returnnullptr;
3153 }
3154
3155 Element->setOffset(TI.getIndex());
3156 Element->setOffsetFromTypeIndex();
3157return Element;
3158}
3159
3160void LVLogicalVisitor::createDataMember(CVMemberRecord &Record,LVScope *Parent,
3161StringRefName,TypeIndex TI,
3162MemberAccessAccess) {
3163LLVM_DEBUG({
3164printTypeIndex("TypeIndex", TI,StreamTPI);
3165 W.printString("TypeName",Name);
3166 });
3167
3168createElement(Record.Kind);
3169if (LVSymbol *Symbol =CurrentSymbol) {
3170 Symbol->setName(Name);
3171if (TI.isNoneType() || TI.isSimple())
3172 Symbol->setType(getElement(StreamTPI, TI));
3173else {
3174LazyRandomTypeCollection &Types = types();
3175CVType CVMemberType =Types.getType(TI);
3176if (CVMemberType.kind() == LF_BITFIELD) {
3177if (Error Err =finishVisitation(CVMemberType, TI, Symbol)) {
3178consumeError(std::move(Err));
3179return;
3180 }
3181 }else
3182Symbol->setType(getElement(StreamTPI, TI));
3183 }
3184Symbol->setAccessibilityCode(Access);
3185 Parent->addElement(Symbol);
3186 }
3187}
3188
3189LVSymbol *LVLogicalVisitor::createParameter(LVElement *Element,StringRefName,
3190LVScope *Parent) {
3191LVSymbol *Parameter = Reader->createSymbol();
3192 Parent->addElement(Parameter);
3193 Parameter->setIsParameter();
3194 Parameter->setTag(dwarf::DW_TAG_formal_parameter);
3195 Parameter->setName(Name);
3196 Parameter->setType(Element);
3197return Parameter;
3198}
3199
3200LVSymbol *LVLogicalVisitor::createParameter(TypeIndex TI,StringRefName,
3201LVScope *Parent) {
3202return createParameter(getElement(StreamTPI, TI),Name, Parent);
3203}
3204
3205LVType *LVLogicalVisitor::createBaseType(TypeIndex TI,StringRef TypeName) {
3206TypeLeafKind SimpleKind = (TypeLeafKind)TI.getSimpleKind();
3207TypeIndex TIR = (TypeIndex)SimpleKind;
3208LLVM_DEBUG({
3209printTypeIndex("TypeIndex", TIR,StreamTPI);
3210 W.printString("TypeName", TypeName);
3211 });
3212
3213if (LVElement *Element = Shared->TypeRecords.find(StreamTPI, TIR))
3214returnstatic_cast<LVType *>(Element);
3215
3216if (createElement(TIR, SimpleKind)) {
3217CurrentType->setName(TypeName);
3218 Reader->getCompileUnit()->addElement(CurrentType);
3219 }
3220returnCurrentType;
3221}
3222
3223LVType *LVLogicalVisitor::createPointerType(TypeIndex TI,StringRef TypeName) {
3224LLVM_DEBUG({
3225printTypeIndex("TypeIndex", TI,StreamTPI);
3226 W.printString("TypeName", TypeName);
3227 });
3228
3229if (LVElement *Element = Shared->TypeRecords.find(StreamTPI, TI))
3230returnstatic_cast<LVType *>(Element);
3231
3232LVType *Pointee = createBaseType(TI,TypeName.drop_back(1));
3233if (createElement(TI, TypeLeafKind::LF_POINTER)) {
3234CurrentType->setIsFinalized();
3235CurrentType->setType(Pointee);
3236 Reader->getCompileUnit()->addElement(CurrentType);
3237 }
3238returnCurrentType;
3239}
3240
3241void LVLogicalVisitor::createParents(StringRef ScopedName,LVElement *Element) {
3242// For the given test case:
3243//
3244// struct S { enum E { ... }; };
3245// S::E V;
3246//
3247// 0 | S_LOCAL `V`
3248// type=0x1004 (S::E), flags = none
3249// 0x1004 | LF_ENUM `S::E`
3250// options: has unique name | is nested
3251// 0x1009 | LF_STRUCTURE `S`
3252// options: contains nested class
3253//
3254// When the local 'V' is processed, its type 'E' is created. But There is
3255// no direct reference to its parent 'S'. We use the scoped name for 'E',
3256// to create its parents.
3257
3258// The input scoped name must have at least parent and nested names.
3259// Drop the last element name, as it corresponds to the nested type.
3260LVStringRefs Components =getAllLexicalComponents(ScopedName);
3261if (Components.size() < 2)
3262return;
3263 Components.pop_back();
3264
3265 LVStringRefs::size_type FirstNamespace;
3266 LVStringRefs::size_type FirstAggregate;
3267 std::tie(FirstNamespace, FirstAggregate) =
3268 Shared->NamespaceDeduction.find(Components);
3269
3270LLVM_DEBUG({
3271 W.printString("First Namespace", Components[FirstNamespace]);
3272 W.printString("First NonNamespace", Components[FirstAggregate]);
3273 });
3274
3275// Create any referenced namespaces.
3276if (FirstNamespace < FirstAggregate) {
3277 Shared->NamespaceDeduction.get(
3278LVStringRefs(Components.begin() + FirstNamespace,
3279 Components.begin() + FirstAggregate));
3280 }
3281
3282// Traverse the enclosing scopes (aggregates) and create them. In the
3283// case of nested empty aggregates, MSVC does not emit a full record
3284// description. It emits only the reference record.
3285LVScope *Aggregate =nullptr;
3286TypeIndex TIAggregate;
3287 std::string AggregateName =getScopedName(
3288LVStringRefs(Components.begin(), Components.begin() + FirstAggregate));
3289
3290// This traversal is executed at least once.
3291for (LVStringRefs::size_type Index = FirstAggregate;
3292Index < Components.size(); ++Index) {
3293 AggregateName =getScopedName(LVStringRefs(Components.begin() + Index,
3294 Components.begin() + Index + 1),
3295 AggregateName);
3296 TIAggregate = Shared->ForwardReferences.remap(
3297 Shared->TypeRecords.find(StreamTPI, AggregateName));
3298 Aggregate =
3299 TIAggregate.isNoneType()
3300 ? nullptr
3301 :static_cast<LVScope *>(getElement(StreamTPI, TIAggregate));
3302 }
3303
3304// Workaround for cases where LF_NESTTYPE is missing for nested templates.
3305// If we manage to get parent information from the scoped name, we can add
3306// the nested type without relying on the LF_NESTTYPE.
3307if (Aggregate && !Element->getIsScopedAlready()) {
3308 Aggregate->addElement(Element);
3309 Element->setIsScopedAlready();
3310 }
3311}
3312
3313LVElement *LVLogicalVisitor::getElement(uint32_t StreamIdx,TypeIndex TI,
3314LVScope *Parent) {
3315LLVM_DEBUG({printTypeIndex("TypeIndex", TI,StreamTPI); });
3316 TI = Shared->ForwardReferences.remap(TI);
3317LLVM_DEBUG({printTypeIndex("TypeIndex Remap", TI,StreamTPI); });
3318
3319LVElement *Element = Shared->TypeRecords.find(StreamIdx, TI);
3320if (!Element) {
3321if (TI.isNoneType() || TI.isSimple()) {
3322StringRef TypeName =TypeIndex::simpleTypeName(TI);
3323// If the name ends with "*", create 2 logical types: a pointer and a
3324// pointee type. TypeIndex is composed of a SympleTypeMode byte followed
3325// by a SimpleTypeKind byte. The logical pointer will be identified by
3326// the full TypeIndex value and the pointee by the SimpleTypeKind.
3327return (TypeName.back() =='*') ? createPointerType(TI, TypeName)
3328 : createBaseType(TI, TypeName);
3329 }
3330
3331LLVM_DEBUG({ W.printHex("TypeIndex not implemented: ", TI.getIndex()); });
3332returnnullptr;
3333 }
3334
3335// The element has been finalized.
3336if (Element->getIsFinalized())
3337return Element;
3338
3339// Add the element in case of a given parent.
3340if (Parent)
3341 Parent->addElement(Element);
3342
3343// Check for a composite type.
3344LazyRandomTypeCollection &Types = types();
3345CVTypeCVRecord =Types.getType(TI);
3346if (Error Err =finishVisitation(CVRecord, TI, Element)) {
3347consumeError(std::move(Err));
3348returnnullptr;
3349 }
3350 Element->setIsFinalized();
3351return Element;
3352}
3353
3354voidLVLogicalVisitor::processLines() {
3355// Traverse the collected LF_UDT_SRC_LINE records and add the source line
3356// information to the logical elements.
3357for (constTypeIndex &Entry : Shared->LineRecords) {
3358CVTypeCVRecord = ids().getType(Entry);
3359UdtSourceLineRecordLine;
3360if (Error Err =TypeDeserializer::deserializeAs(
3361const_cast<CVType &>(CVRecord),Line))
3362consumeError(std::move(Err));
3363else {
3364LLVM_DEBUG({
3365printTypeIndex("UDT",Line.getUDT(),StreamIPI);
3366printTypeIndex("SourceFile",Line.getSourceFile(),StreamIPI);
3367 W.printNumber("LineNumber",Line.getLineNumber());
3368 });
3369
3370// The TypeIndex returned by 'getUDT()' must point to an already
3371// created logical element. If no logical element is found, it means
3372// the LF_UDT_SRC_LINE is associated with a system TypeIndex.
3373if (LVElement *Element = Shared->TypeRecords.find(
3374StreamTPI,Line.getUDT(),/*Create=*/false)) {
3375 Element->setLineNumber(Line.getLineNumber());
3376 Element->setFilenameIndex(
3377 Shared->StringRecords.findIndex(Line.getSourceFile()));
3378 }
3379 }
3380 }
3381}
3382
3383voidLVLogicalVisitor::processNamespaces() {
3384// Create namespaces.
3385 Shared->NamespaceDeduction.init();
3386}
3387
3388voidLVLogicalVisitor::processFiles() { Shared->StringRecords.addFilenames(); }
3389
3390voidLVLogicalVisitor::printRecords(raw_ostream &OS) const{
3391if (!options().getInternalTag())
3392return;
3393
3394unsigned Count = 0;
3395auto PrintItem = [&](StringRefName) {
3396auto NewLine = [&]() {
3397if (++Count == 4) {
3398 Count = 0;
3399OS <<"\n";
3400 }
3401 };
3402OS <<format("%20s",Name.str().c_str());
3403 NewLine();
3404 };
3405
3406OS <<"\nTypes:\n";
3407for (constTypeLeafKind &Kind : Shared->TypeKinds)
3408 PrintItem(formatTypeLeafKind(Kind));
3409 Shared->TypeKinds.clear();
3410
3411 Count = 0;
3412OS <<"\nSymbols:\n";
3413for (constSymbolKind &Kind : Shared->SymbolKinds)
3414 PrintItem(LVCodeViewReader::getSymbolKindName(Kind));
3415 Shared->SymbolKinds.clear();
3416
3417OS <<"\n";
3418}
3419
3420ErrorLVLogicalVisitor::inlineSiteAnnotation(LVScope *AbstractFunction,
3421LVScope *InlinedFunction,
3422InlineSiteSym &InlineSite) {
3423// Get the parent scope to update the address ranges of the nested
3424// scope representing the inlined function.
3425LVAddress ParentLowPC = 0;
3426LVScope *Parent = InlinedFunction->getParentScope();
3427if (constLVLocations *Locations = Parent->getRanges()) {
3428if (!Locations->empty())
3429 ParentLowPC = (*Locations->begin())->getLowerAddress();
3430 }
3431
3432// For the given inlinesite, get the initial line number and its
3433// source filename. Update the logical scope representing it.
3434uint32_t LineNumber = 0;
3435StringRefFilename;
3436 LVInlineeInfo::iterator Iter = InlineeInfo.find(InlineSite.Inlinee);
3437if (Iter != InlineeInfo.end()) {
3438 LineNumber = Iter->second.first;
3439Filename = Iter->second.second;
3440 AbstractFunction->setLineNumber(LineNumber);
3441// TODO: This part needs additional work in order to set properly the
3442// correct filename in order to detect changes between filenames.
3443// AbstractFunction->setFilename(Filename);
3444 }
3445
3446LLVM_DEBUG({
3447dbgs() <<"inlineSiteAnnotation\n"
3448 <<"Abstract: " << AbstractFunction->getName() <<"\n"
3449 <<"Inlined: " << InlinedFunction->getName() <<"\n"
3450 <<"Parent: " << Parent->getName() <<"\n"
3451 <<"Low PC: " <<hexValue(ParentLowPC) <<"\n";
3452 });
3453
3454// Get the source lines if requested by command line option.
3455if (!options().getPrintLines())
3456returnError::success();
3457
3458// Limitation: Currently we don't track changes in the FileOffset. The
3459// side effects are the caller that it is unable to differentiate the
3460// source filename for the inlined code.
3461uint64_tCodeOffset = ParentLowPC;
3462 int32_t LineOffset = LineNumber;
3463uint32_t FileOffset = 0;
3464
3465auto UpdateClose = [&]() {LLVM_DEBUG({dbgs() << ("\n"); }); };
3466auto UpdateCodeOffset = [&](uint32_t Delta) {
3467CodeOffset += Delta;
3468LLVM_DEBUG({
3469dbgs() <<formatv(" code 0x{0} (+0x{1})", utohexstr(CodeOffset),
3470 utohexstr(Delta));
3471 });
3472 };
3473auto UpdateLineOffset = [&](int32_t Delta) {
3474 LineOffset += Delta;
3475LLVM_DEBUG({
3476char Sign = Delta > 0 ?'+' :'-';
3477dbgs() <<formatv(" line {0} ({1}{2})", LineOffset, Sign,
3478 std::abs(Delta));
3479 });
3480 };
3481auto UpdateFileOffset = [&](int32_tOffset) {
3482 FileOffset =Offset;
3483LLVM_DEBUG({dbgs() <<formatv(" file {0}", FileOffset); });
3484 };
3485
3486LVLinesInlineeLines;
3487auto CreateLine = [&]() {
3488// Create the logical line record.
3489LVLineDebug *Line = Reader->createLineDebug();
3490Line->setAddress(CodeOffset);
3491Line->setLineNumber(LineOffset);
3492// TODO: This part needs additional work in order to set properly the
3493// correct filename in order to detect changes between filenames.
3494// Line->setFilename(Filename);
3495InlineeLines.push_back(Line);
3496 };
3497
3498bool SeenLowAddress =false;
3499bool SeenHighAddress =false;
3500uint64_t LowPC = 0;
3501uint64_t HighPC = 0;
3502
3503for (auto &Annot :InlineSite.annotations()) {
3504LLVM_DEBUG({
3505dbgs() <<formatv(" {0}",
3506fmt_align(toHex(Annot.Bytes),AlignStyle::Left, 9));
3507 });
3508
3509// Use the opcode to interpret the integer values.
3510switch (Annot.OpCode) {
3511case BinaryAnnotationsOpCode::ChangeCodeOffset:
3512case BinaryAnnotationsOpCode::CodeOffset:
3513case BinaryAnnotationsOpCode::ChangeCodeLength:
3514 UpdateCodeOffset(Annot.U1);
3515 UpdateClose();
3516if (Annot.OpCode == BinaryAnnotationsOpCode::ChangeCodeOffset) {
3517 CreateLine();
3518 LowPC =CodeOffset;
3519 SeenLowAddress =true;
3520break;
3521 }
3522if (Annot.OpCode == BinaryAnnotationsOpCode::ChangeCodeLength) {
3523 HighPC =CodeOffset - 1;
3524 SeenHighAddress =true;
3525 }
3526break;
3527case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
3528 UpdateCodeOffset(Annot.U2);
3529 UpdateClose();
3530break;
3531case BinaryAnnotationsOpCode::ChangeLineOffset:
3532case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
3533 UpdateCodeOffset(Annot.U1);
3534 UpdateLineOffset(Annot.S1);
3535 UpdateClose();
3536if (Annot.OpCode ==
3537 BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset)
3538 CreateLine();
3539break;
3540case BinaryAnnotationsOpCode::ChangeFile:
3541 UpdateFileOffset(Annot.U1);
3542 UpdateClose();
3543break;
3544default:
3545break;
3546 }
3547if (SeenLowAddress && SeenHighAddress) {
3548 SeenLowAddress =false;
3549 SeenHighAddress =false;
3550 InlinedFunction->addObject(LowPC, HighPC);
3551 }
3552 }
3553
3554 Reader->addInlineeLines(InlinedFunction,InlineeLines);
3555 UpdateClose();
3556
3557returnError::success();
3558}
for
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
Definition:AArch64ExpandPseudoInsts.cpp:115
Arguments
AMDGPU Lower Kernel Arguments
Definition:AMDGPULowerKernelArguments.cpp:504
EnumTables.h
Access
DXIL Resource Access
Definition:DXILResourceAccess.cpp:296
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
Demangle.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
FormatAdapters.h
FormatVariadic.h
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
InputFile.h
LVCodeViewReader.h
LVCodeViewVisitor.h
LVScope.h
LVSymbol.h
LVType.h
LazyRandomTypeCollection.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
Magic.h
COFF.h
PDBFile.h
PDBStringTable.h
if
if(PassOpts->AAPipeline)
Definition:PassBuilderBindings.cpp:64
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
SymbolRecordHelpers.h
Ptr
@ Ptr
Definition:TargetLibraryInfo.cpp:77
TpiStream.h
TypeRecordHelpers.h
TypeVisitorCallbackPipeline.h
bool
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::BinaryByteStream
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
Definition:BinaryByteStream.h:30
llvm::BinaryStreamReader
Provides read only access to a subclass of BinaryStream.
Definition:BinaryStreamReader.h:29
llvm::Constant
This is an important base class in LLVM.
Definition:Constant.h:42
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:Error.h:160
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition:Error.h:337
llvm::Expected
Tagged union holding either a T or a Error.
Definition:Error.h:481
llvm::Function
Definition:Function.h:63
llvm::Record
Definition:Record.h:1596
llvm::Record::getName
StringRef getName() const
Definition:Record.h:1676
llvm::ScopedPrinter
Definition:ScopedPrinter.h:100
llvm::ScopedPrinter::printString
virtual void printString(StringRef Value)
Definition:ScopedPrinter.h:361
llvm::ScopedPrinter::indent
void indent(int Levels=1)
Definition:ScopedPrinter.h:121
llvm::ScopedPrinter::unindent
void unindent(int Levels=1)
Definition:ScopedPrinter.h:123
llvm::ScopedPrinter::printEnum
void printEnum(StringRef Label, T Value, ArrayRef< EnumEntry< TEnum > > EnumValues)
Definition:ScopedPrinter.h:142
llvm::ScopedPrinter::getOStream
virtual raw_ostream & getOStream()
Definition:ScopedPrinter.h:433
llvm::ScopedPrinter::startLine
virtual raw_ostream & startLine()
Definition:ScopedPrinter.h:428
llvm::ScopedPrinter::printNumber
virtual void printNumber(StringRef Label, char Value)
Definition:ScopedPrinter.h:201
llvm::ScopedPrinter::printHex
void printHex(StringRef Label, T Value)
Definition:ScopedPrinter.h:348
llvm::ScopedPrinter::printFlags
void printFlags(StringRef Label, T Value, ArrayRef< EnumEntry< TFlag > > Flags, TFlag EnumMask1={}, TFlag EnumMask2={}, TFlag EnumMask3={}, ArrayRef< FlagEntry > ExtraFlags={})
Definition:ScopedPrinter.h:161
llvm::ScopedPrinter::printBoolean
virtual void printBoolean(StringRef Label, bool Value)
Definition:ScopedPrinter.h:262
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition:SmallString.h:26
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition:StringMapEntry.h:102
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition:StringRef.h:229
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition:StringRef.h:150
llvm::Target
Target - Wrapper for Target specific information.
Definition:TargetRegistry.h:144
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition:Value.cpp:53
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition:Value.cpp:377
llvm::codeview::ArgListRecord
Definition:TypeRecord.h:236
llvm::codeview::ArrayRecord
Definition:TypeRecord.h:396
llvm::codeview::ArrayRecord::getElementType
TypeIndex getElementType() const
Definition:TypeRecord.h:405
llvm::codeview::ArrayRecord::getIndexType
TypeIndex getIndexType() const
Definition:TypeRecord.h:406
llvm::codeview::ArrayRecord::getSize
uint64_t getSize() const
Definition:TypeRecord.h:407
llvm::codeview::ArrayRecord::getName
StringRef getName() const
Definition:TypeRecord.h:408
llvm::codeview::BPRelativeSym
Definition:SymbolRecord.h:910
llvm::codeview::BaseClassRecord
Definition:TypeRecord.h:863
llvm::codeview::BitFieldRecord
Definition:TypeRecord.h:535
llvm::codeview::BitFieldRecord::getBitSize
uint8_t getBitSize() const
Definition:TypeRecord.h:545
llvm::codeview::BitFieldRecord::getType
TypeIndex getType() const
Definition:TypeRecord.h:543
llvm::codeview::BitFieldRecord::getBitOffset
uint8_t getBitOffset() const
Definition:TypeRecord.h:544
llvm::codeview::BlockSym
Definition:SymbolRecord.h:621
llvm::codeview::BuildInfoRecord
Definition:TypeRecord.h:667
llvm::codeview::BuildInfoRecord::getArgs
ArrayRef< TypeIndex > getArgs() const
Definition:TypeRecord.h:674
llvm::codeview::BuildInfoSym
Definition:SymbolRecord.h:897
llvm::codeview::BuildInfoSym::BuildId
TypeIndex BuildId
Definition:SymbolRecord.h:904
llvm::codeview::CVRecord< TypeLeafKind >
llvm::codeview::CVRecord::kind
Kind kind() const
Definition:CVRecord.h:42
llvm::codeview::CallerSym
Definition:SymbolRecord.h:168
llvm::codeview::ClassRecord
Definition:TypeRecord.h:465
llvm::codeview::Compile2Sym
Definition:SymbolRecord.h:723
llvm::codeview::Compile2Sym::getLanguage
uint8_t getLanguage() const
Definition:SymbolRecord.h:741
llvm::codeview::Compile2Sym::getFlags
uint32_t getFlags() const
Definition:SymbolRecord.h:742
llvm::codeview::Compile2Sym::Version
StringRef Version
Definition:SymbolRecord.h:738
llvm::codeview::Compile2Sym::Machine
CPUType Machine
Definition:SymbolRecord.h:731
llvm::codeview::Compile3Sym
Definition:SymbolRecord.h:748
llvm::codeview::Compile3Sym::getFlags
CompileSym3Flags getFlags() const
Definition:SymbolRecord.h:775
llvm::codeview::Compile3Sym::getLanguage
SourceLanguage getLanguage() const
Definition:SymbolRecord.h:772
llvm::codeview::Compile3Sym::Version
StringRef Version
Definition:SymbolRecord.h:766
llvm::codeview::Compile3Sym::Machine
CPUType Machine
Definition:SymbolRecord.h:757
llvm::codeview::ConstantSym
Definition:SymbolRecord.h:941
llvm::codeview::DataMemberRecord
Definition:TypeRecord.h:783
llvm::codeview::DataSym
Definition:SymbolRecord.h:956
llvm::codeview::DebugStringTableSubsectionRef
Represents a read-only view of a CodeView string table.
Definition:DebugStringTableSubsection.h:31
llvm::codeview::DefRangeFramePointerRelFullScopeSym
Definition:SymbolRecord.h:607
llvm::codeview::DefRangeFramePointerRelFullScopeSym::Offset
int32_t Offset
Definition:SymbolRecord.h:615
llvm::codeview::DefRangeFramePointerRelSym
Definition:SymbolRecord.h:550
llvm::codeview::DefRangeFramePointerRelSym::Hdr
DefRangeFramePointerRelHeader Hdr
Definition:SymbolRecord.h:564
llvm::codeview::DefRangeFramePointerRelSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:565
llvm::codeview::DefRangeFramePointerRelSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:560
llvm::codeview::DefRangeFramePointerRelSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:566
llvm::codeview::DefRangeRegisterRelSym
Definition:SymbolRecord.h:578
llvm::codeview::DefRangeRegisterRelSym::Hdr
DefRangeRegisterRelHeader Hdr
Definition:SymbolRecord.h:599
llvm::codeview::DefRangeRegisterRelSym::hasSpilledUDTMember
bool hasSpilledUDTMember() const
Definition:SymbolRecord.h:594
llvm::codeview::DefRangeRegisterRelSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:597
llvm::codeview::DefRangeRegisterRelSym::offsetInParent
uint16_t offsetInParent() const
Definition:SymbolRecord.h:595
llvm::codeview::DefRangeRegisterRelSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:601
llvm::codeview::DefRangeRegisterRelSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:600
llvm::codeview::DefRangeRegisterSym
Definition:SymbolRecord.h:505
llvm::codeview::DefRangeRegisterSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:512
llvm::codeview::DefRangeRegisterSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:516
llvm::codeview::DefRangeRegisterSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:515
llvm::codeview::DefRangeRegisterSym::Hdr
DefRangeRegisterHeader Hdr
Definition:SymbolRecord.h:514
llvm::codeview::DefRangeSubfieldRegisterSym
Definition:SymbolRecord.h:528
llvm::codeview::DefRangeSubfieldRegisterSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:539
llvm::codeview::DefRangeSubfieldRegisterSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:536
llvm::codeview::DefRangeSubfieldRegisterSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:540
llvm::codeview::DefRangeSubfieldRegisterSym::Hdr
DefRangeSubfieldRegisterHeader Hdr
Definition:SymbolRecord.h:538
llvm::codeview::DefRangeSubfieldSym
Definition:SymbolRecord.h:478
llvm::codeview::DefRangeSubfieldSym::Program
uint32_t Program
Definition:SymbolRecord.h:491
llvm::codeview::DefRangeSubfieldSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:494
llvm::codeview::DefRangeSubfieldSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:493
llvm::codeview::DefRangeSubfieldSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:487
llvm::codeview::DefRangeSubfieldSym::OffsetInParent
uint16_t OffsetInParent
Definition:SymbolRecord.h:492
llvm::codeview::DefRangeSym
Definition:SymbolRecord.h:457
llvm::codeview::DefRangeSym::Gaps
std::vector< LocalVariableAddrGap > Gaps
Definition:SymbolRecord.h:472
llvm::codeview::DefRangeSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:466
llvm::codeview::DefRangeSym::Range
LocalVariableAddrRange Range
Definition:SymbolRecord.h:471
llvm::codeview::DefRangeSym::Program
uint32_t Program
Definition:SymbolRecord.h:470
llvm::codeview::EndPrecompRecord
Definition:TypeRecord.h:945
llvm::codeview::EndPrecompRecord::getSignature
uint32_t getSignature() const
Definition:TypeRecord.h:950
llvm::codeview::EnumRecord
Definition:TypeRecord.h:519
llvm::codeview::EnumeratorRecord
Definition:TypeRecord.h:829
llvm::codeview::FieldListDeserializer
Definition:TypeDeserializer.h:102
llvm::codeview::FieldListRecord
Definition:TypeRecord.h:385
llvm::codeview::FrameProcSym
Definition:SymbolRecord.h:788
llvm::codeview::FrameProcSym::getLocalFramePtrReg
RegisterId getLocalFramePtrReg(CPUType CPU) const
Extract the register this frame uses to refer to local variables.
Definition:SymbolRecord.h:804
llvm::codeview::FrameProcSym::getParamFramePtrReg
RegisterId getParamFramePtrReg(CPUType CPU) const
Extract the register this frame uses to refer to parameters.
Definition:SymbolRecord.h:810
llvm::codeview::FrameProcSym::Flags
FrameProcedureOptions Flags
Definition:SymbolRecord.h:801
llvm::codeview::FuncIdRecord
Definition:TypeRecord.h:610
llvm::codeview::InlineSiteSym
Definition:SymbolRecord.h:353
llvm::codeview::JumpTableSym
Definition:SymbolRecord.h:147
llvm::codeview::LabelRecord
Definition:TypeRecord.h:206
llvm::codeview::LazyRandomTypeCollection
Provides amortized O(1) random access to a CodeView type stream.
Definition:LazyRandomTypeCollection.h:48
llvm::codeview::LazyRandomTypeCollection::tryGetType
std::optional< CVType > tryGetType(TypeIndex Index)
Definition:LazyRandomTypeCollection.cpp:96
llvm::codeview::LazyRandomTypeCollection::getType
CVType getType(TypeIndex Index) override
Definition:LazyRandomTypeCollection.cpp:86
llvm::codeview::LazyRandomTypeCollection::size
uint32_t size() override
Definition:LazyRandomTypeCollection.cpp:142
llvm::codeview::LazyRandomTypeCollection::getTypeName
StringRef getTypeName(TypeIndex Index) override
Definition:LazyRandomTypeCollection.cpp:109
llvm::codeview::Line
Definition:Line.h:90
llvm::codeview::ListContinuationRecord
LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records together.
Definition:TypeRecord.h:914
llvm::codeview::ListContinuationRecord::getContinuationIndex
TypeIndex getContinuationIndex() const
Definition:TypeRecord.h:922
llvm::codeview::LocalSym
Definition:SymbolRecord.h:430
llvm::codeview::MemberFuncIdRecord
Definition:TypeRecord.h:217
llvm::codeview::MemberFunctionRecord
Definition:TypeRecord.h:171
llvm::codeview::MemberFunctionRecord::getReturnType
TypeIndex getReturnType() const
Definition:TypeRecord.h:186
llvm::codeview::MemberFunctionRecord::getThisPointerAdjustment
int32_t getThisPointerAdjustment() const
Definition:TypeRecord.h:193
llvm::codeview::MemberFunctionRecord::getArgumentList
TypeIndex getArgumentList() const
Definition:TypeRecord.h:192
llvm::codeview::MemberFunctionRecord::getParameterCount
uint16_t getParameterCount() const
Definition:TypeRecord.h:191
llvm::codeview::MemberFunctionRecord::getThisType
TypeIndex getThisType() const
Definition:TypeRecord.h:188
llvm::codeview::MemberFunctionRecord::getClassType
TypeIndex getClassType() const
Definition:TypeRecord.h:187
llvm::codeview::MemberPointerInfo
Definition:TypeRecord.h:100
llvm::codeview::MethodOverloadListRecord
Definition:TypeRecord.h:751
llvm::codeview::MethodOverloadListRecord::Methods
std::vector< OneMethodRecord > Methods
Definition:TypeRecord.h:760
llvm::codeview::ModifierRecord
Definition:TypeRecord.h:130
llvm::codeview::NestedTypeRecord
Definition:TypeRecord.h:370
llvm::codeview::ObjNameSym
Definition:SymbolRecord.h:665
llvm::codeview::ObjNameSym::Signature
uint32_t Signature
Definition:SymbolRecord.h:673
llvm::codeview::ObjNameSym::Name
StringRef Name
Definition:SymbolRecord.h:674
llvm::codeview::OneMethodRecord
Definition:TypeRecord.h:719
llvm::codeview::OneMethodRecord::getVFTableOffset
int32_t getVFTableOffset() const
Definition:TypeRecord.h:736
llvm::codeview::OneMethodRecord::getType
TypeIndex getType() const
Definition:TypeRecord.h:732
llvm::codeview::OneMethodRecord::Name
StringRef Name
Definition:TypeRecord.h:747
llvm::codeview::OneMethodRecord::isIntroducingVirtual
bool isIntroducingVirtual() const
Definition:TypeRecord.h:739
llvm::codeview::OneMethodRecord::getAccess
MemberAccess getAccess() const
Definition:TypeRecord.h:735
llvm::codeview::OneMethodRecord::getMethodKind
MethodKind getMethodKind() const
Definition:TypeRecord.h:733
llvm::codeview::OneMethodRecord::getName
StringRef getName() const
Definition:TypeRecord.h:737
llvm::codeview::OneMethodRecord::Attrs
MemberAttributes Attrs
Definition:TypeRecord.h:745
llvm::codeview::OverloadedMethodRecord
For method overload sets. LF_METHOD.
Definition:TypeRecord.h:764
llvm::codeview::OverloadedMethodRecord::getName
StringRef getName() const
Definition:TypeRecord.h:775
llvm::codeview::OverloadedMethodRecord::getNumOverloads
uint16_t getNumOverloads() const
Definition:TypeRecord.h:773
llvm::codeview::OverloadedMethodRecord::getMethodList
TypeIndex getMethodList() const
Definition:TypeRecord.h:774
llvm::codeview::PointerRecord
Definition:TypeRecord.h:264
llvm::codeview::PrecompRecord
Definition:TypeRecord.h:928
llvm::codeview::PrecompRecord::getSignature
uint32_t getSignature() const
Definition:TypeRecord.h:935
llvm::codeview::PrecompRecord::getPrecompFilePath
StringRef getPrecompFilePath() const
Definition:TypeRecord.h:936
llvm::codeview::PrecompRecord::getTypesCount
uint32_t getTypesCount() const
Definition:TypeRecord.h:934
llvm::codeview::PrecompRecord::getStartTypeIndex
uint32_t getStartTypeIndex() const
Definition:TypeRecord.h:933
llvm::codeview::ProcSym
Definition:SymbolRecord.h:41
llvm::codeview::ProcSym::FunctionType
TypeIndex FunctionType
Definition:SymbolRecord.h:59
llvm::codeview::ProcSym::CodeOffset
uint32_t CodeOffset
Definition:SymbolRecord.h:60
llvm::codeview::ProcSym::Name
StringRef Name
Definition:SymbolRecord.h:63
llvm::codeview::ProcSym::Segment
uint16_t Segment
Definition:SymbolRecord.h:61
llvm::codeview::ProcSym::getRelocationOffset
uint32_t getRelocationOffset() const
Definition:SymbolRecord.h:49
llvm::codeview::ProcSym::CodeSize
uint32_t CodeSize
Definition:SymbolRecord.h:56
llvm::codeview::ProcSym::Flags
ProcSymFlags Flags
Definition:SymbolRecord.h:62
llvm::codeview::ProcedureRecord
Definition:TypeRecord.h:146
llvm::codeview::ProcedureRecord::getReturnType
TypeIndex getReturnType() const
Definition:TypeRecord.h:157
llvm::codeview::ProcedureRecord::getArgumentList
TypeIndex getArgumentList() const
Definition:TypeRecord.h:161
llvm::codeview::ProcedureRecord::getParameterCount
uint16_t getParameterCount() const
Definition:TypeRecord.h:160
llvm::codeview::RegRelativeSym
Definition:SymbolRecord.h:925
llvm::codeview::ScopeEndSym
Definition:SymbolRecord.h:138
llvm::codeview::StaticDataMemberRecord
Definition:TypeRecord.h:808
llvm::codeview::StringIdRecord
Definition:TypeRecord.h:595
llvm::codeview::StringListRecord
Definition:TypeRecord.h:250
llvm::codeview::TagRecord::getFieldList
TypeIndex getFieldList() const
Definition:TypeRecord.h:453
llvm::codeview::Thunk32Sym
Definition:SymbolRecord.h:69
llvm::codeview::TypeDeserializer::deserializeAs
static Error deserializeAs(CVType &CVT, T &Record)
Definition:TypeDeserializer.h:42
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition:TypeIndex.h:96
llvm::codeview::TypeIndex::fromArrayIndex
static TypeIndex fromArrayIndex(uint32_t Index)
Definition:TypeIndex.h:123
llvm::codeview::TypeIndex::getSimpleKind
SimpleTypeKind getSimpleKind() const
Definition:TypeIndex.h:136
llvm::codeview::TypeIndex::None
static TypeIndex None()
Definition:TypeIndex.h:148
llvm::codeview::TypeIndex::setIndex
void setIndex(uint32_t I)
Definition:TypeIndex.h:112
llvm::codeview::TypeIndex::isSimple
bool isSimple() const
Definition:TypeIndex.h:113
llvm::codeview::TypeIndex::FirstNonSimpleIndex
static const uint32_t FirstNonSimpleIndex
Definition:TypeIndex.h:98
llvm::codeview::TypeIndex::simpleTypeName
static StringRef simpleTypeName(TypeIndex TI)
Definition:TypeIndex.cpp:71
llvm::codeview::TypeIndex::getIndex
uint32_t getIndex() const
Definition:TypeIndex.h:111
llvm::codeview::TypeIndex::isNoneType
bool isNoneType() const
Definition:TypeIndex.h:116
llvm::codeview::TypeServer2Record
Definition:TypeRecord.h:575
llvm::codeview::TypeServer2Record::getName
StringRef getName() const
Definition:TypeRecord.h:587
llvm::codeview::TypeServer2Record::getGuid
const GUID & getGuid() const
Definition:TypeRecord.h:585
llvm::codeview::TypeServer2Record::getAge
uint32_t getAge() const
Definition:TypeRecord.h:586
llvm::codeview::TypeVisitorCallbackPipeline
Definition:TypeVisitorCallbackPipeline.h:21
llvm::codeview::TypeVisitorCallbackPipeline::addCallbackToPipeline
void addCallbackToPipeline(TypeVisitorCallbacks &Callbacks)
Definition:TypeVisitorCallbackPipeline.h:81
llvm::codeview::TypeVisitorCallbacks
Definition:TypeVisitorCallbacks.h:18
llvm::codeview::TypeVisitorCallbacks::visitUnknownMember
virtual Error visitUnknownMember(CVMemberRecord &Record)
Definition:TypeVisitorCallbacks.h:37
llvm::codeview::TypeVisitorCallbacks::visitMemberEnd
virtual Error visitMemberEnd(CVMemberRecord &Record)
Definition:TypeVisitorCallbacks.h:45
llvm::codeview::TypeVisitorCallbacks::visitMemberBegin
virtual Error visitMemberBegin(CVMemberRecord &Record)
Definition:TypeVisitorCallbacks.h:41
llvm::codeview::UDTSym
Definition:SymbolRecord.h:884
llvm::codeview::UdtModSourceLineRecord
Definition:TypeRecord.h:646
llvm::codeview::UdtModSourceLineRecord::getSourceFile
TypeIndex getSourceFile() const
Definition:TypeRecord.h:656
llvm::codeview::UdtModSourceLineRecord::getModule
uint16_t getModule() const
Definition:TypeRecord.h:658
llvm::codeview::UdtModSourceLineRecord::getLineNumber
uint32_t getLineNumber() const
Definition:TypeRecord.h:657
llvm::codeview::UdtModSourceLineRecord::getUDT
TypeIndex getUDT() const
Definition:TypeRecord.h:655
llvm::codeview::UdtSourceLineRecord
Definition:TypeRecord.h:628
llvm::codeview::UdtSourceLineRecord::getLineNumber
uint32_t getLineNumber() const
Definition:TypeRecord.h:638
llvm::codeview::UdtSourceLineRecord::getUDT
TypeIndex getUDT() const
Definition:TypeRecord.h:636
llvm::codeview::UdtSourceLineRecord::getSourceFile
TypeIndex getSourceFile() const
Definition:TypeRecord.h:637
llvm::codeview::UsingNamespaceSym
Definition:SymbolRecord.h:999
llvm::codeview::UsingNamespaceSym::Name
StringRef Name
Definition:SymbolRecord.h:1006
llvm::codeview::VFPtrRecord
Definition:TypeRecord.h:850
llvm::codeview::VFPtrRecord::getType
TypeIndex getType() const
Definition:TypeRecord.h:857
llvm::codeview::VFTableRecord
Definition:TypeRecord.h:690
llvm::codeview::VFTableRecord::getVFPtrOffset
uint32_t getVFPtrOffset() const
Definition:TypeRecord.h:705
llvm::codeview::VFTableRecord::getOverriddenVTable
TypeIndex getOverriddenVTable() const
Definition:TypeRecord.h:704
llvm::codeview::VFTableRecord::getMethodNames
ArrayRef< StringRef > getMethodNames() const
Definition:TypeRecord.h:708
llvm::codeview::VFTableRecord::getName
StringRef getName() const
Definition:TypeRecord.h:706
llvm::codeview::VFTableRecord::getCompleteClass
TypeIndex getCompleteClass() const
Definition:TypeRecord.h:703
llvm::codeview::VFTableShapeRecord
Definition:TypeRecord.h:553
llvm::codeview::VFTableShapeRecord::getEntryCount
uint32_t getEntryCount() const
Definition:TypeRecord.h:568
llvm::codeview::VirtualBaseClassRecord
Definition:TypeRecord.h:884
llvm::dwarf_linker::classic::CompileUnit
Stores all information relating to a compile unit, be it in its original instance in the object file ...
Definition:DWARFLinkerCompileUnit.h:63
llvm::logicalview::LVBinaryReader::addInlineeLines
void addInlineeLines(LVScope *Scope, LVLines &Lines)
Definition:LVBinaryReader.h:207
llvm::logicalview::LVBinaryReader::getSymbolTableAddress
LVAddress getSymbolTableAddress(StringRef Name)
Definition:LVBinaryReader.cpp:137
llvm::logicalview::LVBinaryReader::linearAddress
LVAddress linearAddress(uint16_t Segment, uint32_t Offset, LVAddress Addendum=0)
Definition:LVBinaryReader.h:212
llvm::logicalview::LVBinaryReader::addToSymbolTable
void addToSymbolTable(StringRef Name, LVScope *Function, LVSectionIndex SectionIndex=0)
Definition:LVBinaryReader.cpp:121
llvm::logicalview::LVCodeViewReader
Definition:LVCodeViewReader.h:67
llvm::logicalview::LVCodeViewReader::addModule
void addModule(LVScope *Scope)
Definition:LVCodeViewReader.h:209
llvm::logicalview::LVCodeViewReader::getLinkageName
void getLinkageName(const llvm::object::coff_section *CoffSection, uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym)
Definition:LVCodeViewReader.cpp:113
llvm::logicalview::LVCodeViewReader::getSymbolKindName
static StringRef getSymbolKindName(SymbolKind Kind)
Definition:LVCodeViewReader.cpp:45
llvm::logicalview::LVElement
Definition:LVElement.h:67
llvm::logicalview::LVElement::setCount
virtual void setCount(int64_t Value)
Definition:LVElement.h:246
llvm::logicalview::LVElement::setBitSize
virtual void setBitSize(uint32_t Size)
Definition:LVElement.h:243
llvm::logicalview::LVElement::updateLevel
virtual void updateLevel(LVScope *Parent, bool Moved=false)
Definition:LVElement.cpp:266
llvm::logicalview::LVElement::getCount
virtual int64_t getCount() const
Definition:LVElement.h:245
llvm::logicalview::LVElement::setInlineCode
void setInlineCode(uint32_t Code)
Definition:LVElement.h:278
llvm::logicalview::LVElement::setReference
virtual void setReference(LVElement *Element)
Definition:LVElement.h:220
llvm::logicalview::LVElement::setName
void setName(StringRef ElementName) override
Definition:LVElement.cpp:95
llvm::logicalview::LVElement::getName
StringRef getName() const override
Definition:LVElement.h:184
llvm::logicalview::LVElement::setType
void setType(LVElement *Element=nullptr)
Definition:LVElement.h:301
llvm::logicalview::LVElement::setFilenameIndex
void setFilenameIndex(size_t Index)
Definition:LVElement.h:234
llvm::logicalview::LVLineDebug
Definition:LVLine.h:114
llvm::logicalview::LVLogicalVisitor
Definition:LVCodeViewVisitor.h:232
llvm::logicalview::LVLogicalVisitor::visitKnownRecord
Error visitKnownRecord(CVType &Record, ArgListRecord &Args, TypeIndex TI, LVElement *Element)
Definition:LVCodeViewVisitor.cpp:1790
llvm::logicalview::LVLogicalVisitor::CurrentScope
LVScope * CurrentScope
Definition:LVCodeViewVisitor.h:290
llvm::logicalview::LVLogicalVisitor::printRecords
void printRecords(raw_ostream &OS) const
Definition:LVCodeViewVisitor.cpp:3390
llvm::logicalview::LVLogicalVisitor::stopProcessArgumentList
void stopProcessArgumentList()
Definition:LVCodeViewVisitor.h:362
llvm::logicalview::LVLogicalVisitor::printTypeEnd
void printTypeEnd(CVType &Record)
Definition:LVCodeViewVisitor.cpp:1757
llvm::logicalview::LVLogicalVisitor::visitMemberRecord
Error visitMemberRecord(CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks, TypeIndex TI, LVElement *Element)
Definition:LVCodeViewVisitor.cpp:2876
llvm::logicalview::LVLogicalVisitor::visitKnownMember
Error visitKnownMember(CVMemberRecord &Record, BaseClassRecord &Base, TypeIndex TI, LVElement *Element)
Definition:LVCodeViewVisitor.cpp:2632
llvm::logicalview::LVLogicalVisitor::printMemberEnd
void printMemberEnd(CVMemberRecord &Record)
Definition:LVCodeViewVisitor.cpp:1776
llvm::logicalview::LVLogicalVisitor::setCompileUnitName
void setCompileUnitName(std::string Name)
Definition:LVCodeViewVisitor.h:344
llvm::logicalview::LVLogicalVisitor::popScope
void popScope()
Definition:LVCodeViewVisitor.h:326
llvm::logicalview::LVLogicalVisitor::CurrentSymbol
LVSymbol * CurrentSymbol
Definition:LVCodeViewVisitor.h:291
llvm::logicalview::LVLogicalVisitor::CurrentElement
LVElement * CurrentElement
Definition:LVCodeViewVisitor.h:289
llvm::logicalview::LVLogicalVisitor::CurrentType
LVType * CurrentType
Definition:LVCodeViewVisitor.h:292
llvm::logicalview::LVLogicalVisitor::inlineSiteAnnotation
Error inlineSiteAnnotation(LVScope *AbstractFunction, LVScope *InlinedFunction, InlineSiteSym &InlineSite)
Definition:LVCodeViewVisitor.cpp:3420
llvm::logicalview::LVLogicalVisitor::LVLogicalVisitor
LVLogicalVisitor(LVCodeViewReader *Reader, ScopedPrinter &W, llvm::pdb::InputFile &Input)
Definition:LVCodeViewVisitor.cpp:1730
llvm::logicalview::LVLogicalVisitor::printTypeIndex
void printTypeIndex(StringRef FieldName, TypeIndex TI, uint32_t StreamIdx)
Definition:LVCodeViewVisitor.cpp:1738
llvm::logicalview::LVLogicalVisitor::visitUnknownMember
Error visitUnknownMember(CVMemberRecord &Record, TypeIndex TI)
Definition:LVCodeViewVisitor.cpp:2625
llvm::logicalview::LVLogicalVisitor::pushScope
void pushScope(LVScope *Scope)
Definition:LVCodeViewVisitor.h:321
llvm::logicalview::LVLogicalVisitor::visitUnknownType
Error visitUnknownType(CVType &Record, TypeIndex TI)
Definition:LVCodeViewVisitor.cpp:1781
llvm::logicalview::LVLogicalVisitor::processNamespaces
void processNamespaces()
Definition:LVCodeViewVisitor.cpp:3383
llvm::logicalview::LVLogicalVisitor::startProcessArgumentList
void startProcessArgumentList()
Definition:LVCodeViewVisitor.h:361
llvm::logicalview::LVLogicalVisitor::addElement
void addElement(LVScope *Scope, bool IsCompileUnit)
Definition:LVCodeViewVisitor.cpp:2953
llvm::logicalview::LVLogicalVisitor::printTypeBegin
void printTypeBegin(CVType &Record, TypeIndex TI, LVElement *Element, uint32_t StreamIdx)
Definition:LVCodeViewVisitor.cpp:1744
llvm::logicalview::LVLogicalVisitor::processLines
void processLines()
Definition:LVCodeViewVisitor.cpp:3354
llvm::logicalview::LVLogicalVisitor::getElement
LVElement * getElement(uint32_t StreamIdx, TypeIndex TI, LVScope *Parent=nullptr)
Definition:LVCodeViewVisitor.cpp:3313
llvm::logicalview::LVLogicalVisitor::getReaderScope
LVScope * getReaderScope() const
Definition:LVCodeViewVisitor.h:352
llvm::logicalview::LVLogicalVisitor::printMemberBegin
void printMemberBegin(CVMemberRecord &Record, TypeIndex TI, LVElement *Element, uint32_t StreamIdx)
Definition:LVCodeViewVisitor.cpp:1762
llvm::logicalview::LVLogicalVisitor::finishVisitation
Error finishVisitation(CVType &Record, TypeIndex TI, LVElement *Element)
Definition:LVCodeViewVisitor.cpp:2907
llvm::logicalview::LVLogicalVisitor::createElement
LVElement * createElement(TypeLeafKind Kind)
Definition:LVCodeViewVisitor.cpp:2976
llvm::logicalview::LVLogicalVisitor::processFiles
void processFiles()
Definition:LVCodeViewVisitor.cpp:3388
llvm::logicalview::LVObject::getParentScope
LVScope * getParentScope() const
Definition:LVObject.h:253
llvm::logicalview::LVObject::setOffset
void setOffset(LVOffset DieOffset)
Definition:LVObject.h:239
llvm::logicalview::LVObject::getOffset
LVOffset getOffset() const
Definition:LVObject.h:238
llvm::logicalview::LVObject::setLineNumber
void setLineNumber(uint32_t Number)
Definition:LVObject.h:273
llvm::logicalview::LVObject::setTag
void setTag(dwarf::Tag Tag)
Definition:LVObject.h:231
llvm::logicalview::LVReader::getCompileUnitCPUType
codeview::CPUType getCompileUnitCPUType()
Definition:LVReader.h:254
llvm::logicalview::LVReader::setCompileUnitCPUType
void setCompileUnitCPUType(codeview::CPUType Type)
Definition:LVReader.h:251
llvm::logicalview::LVReader::isSystemEntry
virtual bool isSystemEntry(LVElement *Element, StringRef Name={}) const
Definition:LVReader.h:275
llvm::logicalview::LVReader::getCompileUnit
LVScopeCompileUnit * getCompileUnit() const
Definition:LVReader.h:246
llvm::logicalview::LVReader::setCompileUnit
void setCompileUnit(LVScope *Scope)
Definition:LVReader.h:247
llvm::logicalview::LVScopeAggregate
Definition:LVScope.h:326
llvm::logicalview::LVScopeArray
Definition:LVScope.h:381
llvm::logicalview::LVScopeCompileUnit
Definition:LVScope.h:397
llvm::logicalview::LVScopeCompileUnit::addPublicName
void addPublicName(LVScope *Scope, LVAddress LowPC, LVAddress HighPC)
Definition:LVScope.h:506
llvm::logicalview::LVScopeEnumeration
Definition:LVScope.h:617
llvm::logicalview::LVScope
Definition:LVScope.h:73
llvm::logicalview::LVScope::addElement
void addElement(LVElement *Element)
Definition:LVScope.cpp:112
llvm::logicalview::LVScope::addObject
void addObject(LVLocation *Location)
Definition:LVScope.cpp:151
llvm::logicalview::LVScope::getRanges
const LVLocations * getRanges() const
Definition:LVScope.h:206
llvm::logicalview::LVSymbolVisitorDelegate::getLinkageName
void getLinkageName(uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym=nullptr)
Definition:LVCodeViewVisitor.cpp:682
llvm::logicalview::LVSymbolVisitorDelegate::printRelocatedField
void printRelocatedField(StringRef Label, uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym=nullptr)
Definition:LVCodeViewVisitor.cpp:674
llvm::logicalview::LVSymbolVisitorDelegate::getStringTable
DebugStringTableSubsectionRef getStringTable() override
Definition:LVCodeViewVisitor.cpp:698
llvm::logicalview::LVSymbolVisitorDelegate::getFileNameForFileOffset
StringRef getFileNameForFileOffset(uint32_t FileOffset) override
Definition:LVCodeViewVisitor.cpp:689
llvm::logicalview::LVSymbolVisitor::visitSymbolEnd
Error visitSymbolEnd(CVSymbol &Record) override
Definition:LVCodeViewVisitor.cpp:766
llvm::logicalview::LVSymbolVisitor::visitKnownRecord
Error visitKnownRecord(CVSymbol &Record, BlockSym &Block) override
Definition:LVCodeViewVisitor.cpp:784
llvm::logicalview::LVSymbolVisitor::visitSymbolBegin
Error visitSymbolBegin(CVSymbol &Record) override
Definition:LVCodeViewVisitor.cpp:725
llvm::logicalview::LVSymbolVisitor::visitUnknownSymbol
Error visitUnknownSymbol(CVSymbol &Record) override
Action to take on unknown symbols. By default, they are ignored.
Definition:LVCodeViewVisitor.cpp:778
llvm::logicalview::LVSymbol
Definition:LVSymbol.h:36
llvm::logicalview::LVTypeVisitor::visitMemberEnd
Error visitMemberEnd(CVMemberRecord &Record) override
Definition:LVCodeViewVisitor.cpp:519
llvm::logicalview::LVTypeVisitor::visitUnknownMember
Error visitUnknownMember(CVMemberRecord &Record) override
Definition:LVCodeViewVisitor.cpp:527
llvm::logicalview::LVTypeVisitor::visitTypeBegin
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Definition:LVCodeViewVisitor.cpp:485
llvm::logicalview::LVTypeVisitor::visitMemberBegin
Error visitMemberBegin(CVMemberRecord &Record) override
Definition:LVCodeViewVisitor.cpp:510
llvm::logicalview::LVTypeVisitor::visitKnownRecord
Error visitKnownRecord(CVType &Record, BuildInfoRecord &Args) override
Definition:LVCodeViewVisitor.cpp:533
llvm::logicalview::LVTypeVisitor::visitUnknownType
Error visitUnknownType(CVType &Record) override
Action to take on unknown types. By default, they are ignored.
Definition:LVCodeViewVisitor.cpp:505
llvm::logicalview::LVType
Definition:LVType.h:51
llvm::pdb::InputFile
Definition:InputFile.h:39
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
uint16_t
uint32_t
uint64_t
uint8_t
Error.h
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::TypeName
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
Definition:AMDGPUMetadata.h:176
llvm::AMDGPU::VOPD::Component
Component
Definition:AMDGPUBaseInfo.h:643
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition:ARMBuildAttributes.h:83
llvm::ARM_AM::add
@ add
Definition:ARMAddressingModes.h:39
llvm::COFF::Entry
@ Entry
Definition:COFF.h:844
llvm::codeview
Definition:AppendingTypeTableBuilder.h:22
llvm::codeview::DebugSubsectionKind::InlineeLines
@ InlineeLines
llvm::codeview::BinaryAnnotationsOpCode::CodeOffset
@ CodeOffset
llvm::codeview::PointerMode
PointerMode
Equivalent to CV_ptrmode_e.
Definition:CodeView.h:363
llvm::codeview::PointerMode::Pointer
@ Pointer
llvm::codeview::PointerOptions::Restrict
@ Restrict
llvm::codeview::MethodKind
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition:CodeView.h:280
llvm::codeview::CPUType
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn....
Definition:CodeView.h:76
llvm::codeview::ClassOptions::Nested
@ Nested
llvm::codeview::getJumpTableEntrySizeNames
ArrayRef< EnumEntry< uint16_t > > getJumpTableEntrySizeNames()
Definition:EnumTables.cpp:580
llvm::codeview::symbolEndsScope
bool symbolEndsScope(SymbolKind Kind)
Return true if this ssymbol ends a scope.
Definition:SymbolRecordHelpers.h:39
llvm::codeview::MethodOptions
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition:CodeView.h:291
llvm::codeview::getSymbolTypeNames
ArrayRef< EnumEntry< SymbolKind > > getSymbolTypeNames()
Definition:EnumTables.cpp:458
llvm::codeview::VFTableSlotKind::This
@ This
llvm::codeview::ContinuationRecordKind::FieldList
@ FieldList
llvm::codeview::MemberAccess
MemberAccess
Source-level access specifier. (CV_access_e)
Definition:CodeView.h:272
llvm::codeview::symbolOpensScope
bool symbolOpensScope(SymbolKind Kind)
Return true if this symbol opens a scope.
Definition:SymbolRecordHelpers.h:20
llvm::codeview::TypeLeafKind
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition:CodeView.h:34
llvm::codeview::getLocalFlagNames
ArrayRef< EnumEntry< uint16_t > > getLocalFlagNames()
Definition:EnumTables.cpp:483
llvm::codeview::getRegisterNames
ArrayRef< EnumEntry< uint16_t > > getRegisterNames(CPUType Cpu)
Definition:EnumTables.cpp:466
llvm::codeview::isAggregate
bool isAggregate(CVType CVT)
Given an arbitrary codeview type, determine if it is an LF_STRUCTURE, LF_CLASS, LF_INTERFACE,...
Definition:TypeRecordHelpers.h:46
llvm::codeview::getProcSymFlagNames
ArrayRef< EnumEntry< uint8_t > > getProcSymFlagNames()
Definition:EnumTables.cpp:479
llvm::codeview::TypeRecordKind
TypeRecordKind
Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.
Definition:CodeView.h:27
llvm::codeview::SymbolKind
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition:CodeView.h:48
llvm::codeview::getSizeInBytesForTypeRecord
uint64_t getSizeInBytesForTypeRecord(CVType CVT)
Given an arbitrary codeview type, return the type's size in the case of aggregate (LF_STRUCTURE,...
Definition:TypeRecordHelpers.cpp:171
llvm::codeview::getCPUTypeNames
ArrayRef< EnumEntry< unsigned > > getCPUTypeNames()
Definition:EnumTables.cpp:507
llvm::codeview::ModifierOptions::Volatile
@ Volatile
llvm::codeview::ModifierOptions::Unaligned
@ Unaligned
llvm::codeview::FrameProcedureOptions
FrameProcedureOptions
Definition:CodeView.h:230
llvm::codeview::getSourceLanguageNames
ArrayRef< EnumEntry< SourceLanguage > > getSourceLanguageNames()
Definition:EnumTables.cpp:491
llvm::codeview::getSizeInBytesForTypeIndex
uint64_t getSizeInBytesForTypeIndex(TypeIndex TI)
Given an arbitrary codeview type index, determine its size.
Definition:TypeRecordHelpers.cpp:54
llvm::codeview::getModifiedType
TypeIndex getModifiedType(const CVType &CVT)
Given a CVType which is assumed to be an LF_MODIFIER, return the TypeIndex of the type that the LF_MO...
Definition:TypeRecordHelpers.cpp:47
llvm::codeview::getCompileSym3FlagNames
ArrayRef< EnumEntry< uint32_t > > getCompileSym3FlagNames()
Definition:EnumTables.cpp:499
llvm::codeview::printTypeIndex
void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, TypeCollection &Types)
Definition:TypeIndex.cpp:93
llvm::dwarf::DW_INL_inlined
@ DW_INL_inlined
Definition:Dwarf.h:756
llvm::dwarf::DW_INL_declared_inlined
@ DW_INL_declared_inlined
Definition:Dwarf.h:758
llvm::dwarf::Attribute
Attribute
Attributes.
Definition:Dwarf.h:123
llvm::dwarf::Index
Index
Definition:Dwarf.h:882
llvm::dwarf::DW_TAG_unaligned
constexpr Tag DW_TAG_unaligned
Definition:LVObject.h:28
llvm::jitlink::Scope
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
Definition:JITLink.h:412
llvm::logicalview
Definition:LVCompare.h:20
llvm::logicalview::hexValue
FormattedNumber hexValue(uint64_t N, unsigned Width=HEX_WIDTH, bool Upper=false)
Definition:LVSupport.h:103
llvm::logicalview::getReader
LVReader & getReader()
Definition:LVReader.h:333
llvm::logicalview::getTrueType
static TypeIndex getTrueType(TypeIndex &TI)
Definition:LVCodeViewVisitor.cpp:45
llvm::logicalview::LVStringRefs
std::vector< StringRef > LVStringRefs
Definition:LVSupport.h:33
llvm::logicalview::LVSmall
uint8_t LVSmall
Definition:LVObject.h:42
llvm::logicalview::getRecordName
static StringRef getRecordName(LazyRandomTypeCollection &Types, TypeIndex TI)
Definition:LVCodeViewVisitor.cpp:80
llvm::logicalview::LVLineRecords
std::vector< TypeIndex > LVLineRecords
Definition:LVCodeViewVisitor.cpp:115
llvm::logicalview::LVScopeKind::IsCompileUnit
@ IsCompileUnit
llvm::logicalview::getAllLexicalComponents
LVStringRefs getAllLexicalComponents(StringRef Name)
Definition:LVSupport.cpp:138
llvm::logicalview::LVWarningKind::Locations
@ Locations
llvm::logicalview::LVCompareKind::Types
@ Types
llvm::logicalview::transformPath
std::string transformPath(StringRef Path)
Definition:LVSupport.cpp:31
llvm::logicalview::getInnerComponent
LVLexicalComponent getInnerComponent(StringRef Name)
Definition:LVSupport.cpp:118
llvm::logicalview::LVAttributeKind::Base
@ Base
llvm::logicalview::LVAttributeKind::Filename
@ Filename
llvm::logicalview::LVAttributeKind::Gaps
@ Gaps
llvm::logicalview::LVAttributeKind::Local
@ Local
llvm::logicalview::LVAttributeKind::Range
@ Range
llvm::logicalview::LVAttributeKind::Subrange
@ Subrange
llvm::logicalview::LVAttributeKind::Offset
@ Offset
llvm::logicalview::LeafTypeNames
static const EnumEntry< TypeLeafKind > LeafTypeNames[]
Definition:LVCodeViewVisitor.cpp:73
llvm::logicalview::LVSymbolKinds
std::set< SymbolKind > LVSymbolKinds
Definition:LVCodeViewVisitor.cpp:300
llvm::logicalview::LVTypeKinds
std::set< TypeLeafKind > LVTypeKinds
Definition:LVCodeViewVisitor.cpp:299
llvm::logicalview::options
LVOptions & options()
Definition:LVOptions.h:445
llvm::logicalview::getScopedName
std::string getScopedName(const LVStringRefs &Components, StringRef BaseName={})
Definition:LVSupport.cpp:151
llvm::logicalview::LVSortMode::Name
@ Name
llvm::logicalview::LVLexicalIndex
std::tuple< LVStringRefs::size_type, LVStringRefs::size_type > LVLexicalIndex
Definition:LVSupport.h:36
llvm::object
Definition:DWARFDebugLoc.h:24
llvm::object::Kind
Kind
Definition:COFFModuleDefinition.cpp:31
llvm::pdb
Definition:LVCodeViewReader.h:44
llvm::pdb::PDB_UdtType::Class
@ Class
llvm::pdb::PDB_UdtType::Union
@ Union
llvm::pdb::StreamTPI
@ StreamTPI
Definition:RawConstants.h:79
llvm::pdb::StreamIPI
@ StreamIPI
Definition:RawConstants.h:81
llvm::pdb::PDB_SymType::Caller
@ Caller
llvm::pdb::PDB_SymType::UDT
@ UDT
llvm::pdb::PDB_SymType::BaseClass
@ BaseClass
llvm::pdb::PDB_SymType::Typedef
@ Typedef
llvm::pdb::PDB_SymType::Label
@ Label
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::pdb::PDB_SymType::Thunk
@ Thunk
llvm::pdb::String
@ String
Definition:PDBTypes.h:408
llvm::pdb::formatTypeLeafKind
std::string formatTypeLeafKind(codeview::TypeLeafKind K)
Definition:FormatUtil.cpp:115
llvm::rdf::Print
Print(const T &, const DataFlowGraph &) -> Print< T >
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::find
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1759
llvm::PseudoProbeType::Block
@ Block
llvm::AlignStyle::Left
@ Left
llvm::InlineSite
std::tuple< uint64_t, uint32_t > InlineSite
Definition:MCPseudoProbe.h:101
llvm::formatv
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
Definition:FormatVariadic.h:252
llvm::get
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
Definition:PointerIntPair.h:270
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::CaptureComponents::Address
@ Address
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition:Format.h:125
llvm::getTypeName
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
Definition:TypeName.h:63
llvm::ModRefInfo::Mod
@ Mod
The access may modify the value stored in memory.
llvm::fmt_repeat
support::detail::RepeatAdapter< T > fmt_repeat(T &&Item, size_t Count)
Definition:FormatAdapters.h:101
llvm::DINameKind::LinkageName
@ LinkageName
llvm::fmt_align
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
Definition:FormatAdapters.h:89
llvm::HighlightColor::String
@ String
llvm::erase_if
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
Definition:STLExtras.h:2099
llvm::endianness::little
@ little
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition:Error.h:1069
llvm::demangle
std::string demangle(std::string_view MangledName)
Attempt to demangle a string using different demangling schemes.
Definition:Demangle.cpp:20
N
#define N
llvm::DictScope
Definition:ScopedPrinter.h:849
llvm::EnumEntry
Definition:ScopedPrinter.h:24
llvm::HexNumber
Definition:ScopedPrinter.h:40
llvm::ListScope
Definition:ScopedPrinter.h:868
llvm::OptimizedStructLayoutField
A field in a structure.
Definition:OptimizedStructLayout.h:45
llvm::codeview::CVMemberRecord
Definition:TypeRecord.h:34
llvm::codeview::DefRangeFramePointerRelHeader::Offset
little32_t Offset
Definition:SymbolRecord.h:546
llvm::codeview::DefRangeRegisterHeader::Register
ulittle16_t Register
Definition:SymbolRecord.h:500
llvm::codeview::DefRangeRegisterHeader::MayHaveNoName
ulittle16_t MayHaveNoName
Definition:SymbolRecord.h:501
llvm::codeview::DefRangeRegisterRelHeader::Register
ulittle16_t Register
Definition:SymbolRecord.h:572
llvm::codeview::DefRangeRegisterRelHeader::BasePointerOffset
little32_t BasePointerOffset
Definition:SymbolRecord.h:574
llvm::codeview::DefRangeSubfieldRegisterHeader::MayHaveNoName
ulittle16_t MayHaveNoName
Definition:SymbolRecord.h:523
llvm::codeview::DefRangeSubfieldRegisterHeader::Register
ulittle16_t Register
Definition:SymbolRecord.h:522
llvm::codeview::DefRangeSubfieldRegisterHeader::OffsetInParent
ulittle32_t OffsetInParent
Definition:SymbolRecord.h:524
llvm::codeview::LocalVariableAddrGap
Definition:SymbolRecord.h:449
llvm::codeview::LocalVariableAddrRange
Definition:SymbolRecord.h:443
llvm::codeview::MemberAttributes::getFlags
MethodOptions getFlags() const
Get the flags that are not included in access control or method properties.
Definition:TypeRecord.h:72
llvm::codeview::UnionRecord
Definition:TypeRecord.h:498
llvm::logicalview::LVShared
Definition:LVCodeViewVisitor.cpp:306
llvm::logicalview::LVShared::LVShared
LVShared(LVCodeViewReader *Reader, LVLogicalVisitor *Visitor)
Definition:LVCodeViewVisitor.cpp:322
llvm::logicalview::LVShared::LineRecords
LVLineRecords LineRecords
Definition:LVCodeViewVisitor.cpp:310
llvm::logicalview::LVShared::TypeRecords
LVTypeRecords TypeRecords
Definition:LVCodeViewVisitor.cpp:313
llvm::logicalview::LVShared::Reader
LVCodeViewReader * Reader
Definition:LVCodeViewVisitor.cpp:307
llvm::logicalview::LVShared::Visitor
LVLogicalVisitor * Visitor
Definition:LVCodeViewVisitor.cpp:308
llvm::logicalview::LVShared::NamespaceDeduction
LVNamespaceDeduction NamespaceDeduction
Definition:LVCodeViewVisitor.cpp:311
llvm::logicalview::LVShared::TypeKinds
LVTypeKinds TypeKinds
Definition:LVCodeViewVisitor.cpp:319
llvm::logicalview::LVShared::~LVShared
~LVShared()=default
llvm::logicalview::LVShared::SymbolKinds
LVSymbolKinds SymbolKinds
Definition:LVCodeViewVisitor.cpp:320
llvm::logicalview::LVShared::StringRecords
LVStringRecords StringRecords
Definition:LVCodeViewVisitor.cpp:312
llvm::logicalview::LVShared::ForwardReferences
LVForwardReferences ForwardReferences
Definition:LVCodeViewVisitor.cpp:309

Generated on Fri Jul 18 2025 11:16:47 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp