Bug Summary

File:lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Warning:line 998, column 46
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name DwarfUnit.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn329677/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/lib/CodeGen/AsmPrinter -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-04-11-031539-24776-1 -x c++ /build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

1//===-- llvm/CodeGen/DwarfUnit.cpp - Dwarf Type and Compile Units ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains support for constructing a dwarf compile unit.
11//
12//===----------------------------------------------------------------------===//
13
14#include "DwarfUnit.h"
15#include "AddressPool.h"
16#include "DwarfCompileUnit.h"
17#include "DwarfDebug.h"
18#include "DwarfExpression.h"
19#include "llvm/ADT/APFloat.h"
20#include "llvm/ADT/APInt.h"
21#include "llvm/ADT/None.h"
22#include "llvm/ADT/StringExtras.h"
23#include "llvm/ADT/iterator_range.h"
24#include "llvm/CodeGen/MachineFunction.h"
25#include "llvm/CodeGen/MachineOperand.h"
26#include "llvm/CodeGen/TargetRegisterInfo.h"
27#include "llvm/CodeGen/TargetSubtargetInfo.h"
28#include "llvm/IR/Constants.h"
29#include "llvm/IR/DataLayout.h"
30#include "llvm/IR/GlobalValue.h"
31#include "llvm/IR/Metadata.h"
32#include "llvm/MC/MCAsmInfo.h"
33#include "llvm/MC/MCContext.h"
34#include "llvm/MC/MCDwarf.h"
35#include "llvm/MC/MCSection.h"
36#include "llvm/MC/MCStreamer.h"
37#include "llvm/MC/MachineLocation.h"
38#include "llvm/Support/Casting.h"
39#include "llvm/Support/CommandLine.h"
40#include "llvm/Target/TargetLoweringObjectFile.h"
41#include <cassert>
42#include <cstdint>
43#include <string>
44#include <utility>
45
46using namespace llvm;
47
48#define DEBUG_TYPE"dwarfdebug" "dwarfdebug"
49
50static cl::opt<bool>
51GenerateDwarfTypeUnits("generate-type-units", cl::Hidden,
52 cl::desc("Generate DWARF4 type units."),
53 cl::init(false));
54
55DIEDwarfExpression::DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU,
56 DIELoc &DIE)
57 : DwarfExpression(AP.getDwarfVersion()), AP(AP), DU(DU),
58 DIE(DIE) {}
59
60void DIEDwarfExpression::emitOp(uint8_t Op, const char* Comment) {
61 DU.addUInt(DIE, dwarf::DW_FORM_data1, Op);
62}
63
64void DIEDwarfExpression::emitSigned(int64_t Value) {
65 DU.addSInt(DIE, dwarf::DW_FORM_sdata, Value);
66}
67
68void DIEDwarfExpression::emitUnsigned(uint64_t Value) {
69 DU.addUInt(DIE, dwarf::DW_FORM_udata, Value);
70}
71
72bool DIEDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI,
73 unsigned MachineReg) {
74 return MachineReg == TRI.getFrameRegister(*AP.MF);
75}
76
77DwarfUnit::DwarfUnit(dwarf::Tag UnitTag, const DICompileUnit *Node,
78 AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
79 : DIEUnit(A->getDwarfVersion(), A->MAI->getCodePointerSize(), UnitTag),
80 CUNode(Node), Asm(A), DD(DW), DU(DWU), IndexTyDie(nullptr) {
81}
82
83DwarfTypeUnit::DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A,
84 DwarfDebug *DW, DwarfFile *DWU,
85 MCDwarfDwoLineTable *SplitLineTable)
86 : DwarfUnit(dwarf::DW_TAG_type_unit, CU.getCUNode(), A, DW, DWU), CU(CU),
87 SplitLineTable(SplitLineTable) {
88}
89
90DwarfUnit::~DwarfUnit() {
91 for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j)
92 DIEBlocks[j]->~DIEBlock();
93 for (unsigned j = 0, M = DIELocs.size(); j < M; ++j)
94 DIELocs[j]->~DIELoc();
95}
96
97int64_t DwarfUnit::getDefaultLowerBound() const {
98 switch (getLanguage()) {
99 default:
100 break;
101
102 // The languages below have valid values in all DWARF versions.
103 case dwarf::DW_LANG_C:
104 case dwarf::DW_LANG_C89:
105 case dwarf::DW_LANG_C_plus_plus:
106 return 0;
107
108 case dwarf::DW_LANG_Fortran77:
109 case dwarf::DW_LANG_Fortran90:
110 return 1;
111
112 // The languages below have valid values only if the DWARF version >= 3.
113 case dwarf::DW_LANG_C99:
114 case dwarf::DW_LANG_ObjC:
115 case dwarf::DW_LANG_ObjC_plus_plus:
116 if (DD->getDwarfVersion() >= 3)
117 return 0;
118 break;
119
120 case dwarf::DW_LANG_Fortran95:
121 if (DD->getDwarfVersion() >= 3)
122 return 1;
123 break;
124
125 // Starting with DWARF v4, all defined languages have valid values.
126 case dwarf::DW_LANG_D:
127 case dwarf::DW_LANG_Java:
128 case dwarf::DW_LANG_Python:
129 case dwarf::DW_LANG_UPC:
130 if (DD->getDwarfVersion() >= 4)
131 return 0;
132 break;
133
134 case dwarf::DW_LANG_Ada83:
135 case dwarf::DW_LANG_Ada95:
136 case dwarf::DW_LANG_Cobol74:
137 case dwarf::DW_LANG_Cobol85:
138 case dwarf::DW_LANG_Modula2:
139 case dwarf::DW_LANG_Pascal83:
140 case dwarf::DW_LANG_PLI:
141 if (DD->getDwarfVersion() >= 4)
142 return 1;
143 break;
144
145 // The languages below are new in DWARF v5.
146 case dwarf::DW_LANG_BLISS:
147 case dwarf::DW_LANG_C11:
148 case dwarf::DW_LANG_C_plus_plus_03:
149 case dwarf::DW_LANG_C_plus_plus_11:
150 case dwarf::DW_LANG_C_plus_plus_14:
151 case dwarf::DW_LANG_Dylan:
152 case dwarf::DW_LANG_Go:
153 case dwarf::DW_LANG_Haskell:
154 case dwarf::DW_LANG_OCaml:
155 case dwarf::DW_LANG_OpenCL:
156 case dwarf::DW_LANG_RenderScript:
157 case dwarf::DW_LANG_Rust:
158 case dwarf::DW_LANG_Swift:
159 if (DD->getDwarfVersion() >= 5)
160 return 0;
161 break;
162
163 case dwarf::DW_LANG_Fortran03:
164 case dwarf::DW_LANG_Fortran08:
165 case dwarf::DW_LANG_Julia:
166 case dwarf::DW_LANG_Modula3:
167 if (DD->getDwarfVersion() >= 5)
168 return 1;
169 break;
170 }
171
172 return -1;
173}
174
175/// Check whether the DIE for this MDNode can be shared across CUs.
176bool DwarfUnit::isShareableAcrossCUs(const DINode *D) const {
177 // When the MDNode can be part of the type system, the DIE can be shared
178 // across CUs.
179 // Combining type units and cross-CU DIE sharing is lower value (since
180 // cross-CU DIE sharing is used in LTO and removes type redundancy at that
181 // level already) but may be implementable for some value in projects
182 // building multiple independent libraries with LTO and then linking those
183 // together.
184 if (isDwoUnit() && !DD->shareAcrossDWOCUs())
185 return false;
186 return (isa<DIType>(D) ||
187 (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) &&
188 !GenerateDwarfTypeUnits;
189}
190
191DIE *DwarfUnit::getDIE(const DINode *D) const {
192 if (isShareableAcrossCUs(D))
193 return DU->getDIE(D);
194 return MDNodeToDieMap.lookup(D);
195}
196
197void DwarfUnit::insertDIE(const DINode *Desc, DIE *D) {
198 if (isShareableAcrossCUs(Desc)) {
199 DU->insertDIE(Desc, D);
200 return;
201 }
202 MDNodeToDieMap.insert(std::make_pair(Desc, D));
203}
204
205void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
206 if (DD->getDwarfVersion() >= 4)
207 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_flag_present,
208 DIEInteger(1));
209 else
210 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_flag,
211 DIEInteger(1));
212}
213
214void DwarfUnit::addUInt(DIEValueList &Die, dwarf::Attribute Attribute,
215 Optional<dwarf::Form> Form, uint64_t Integer) {
216 if (!Form)
217 Form = DIEInteger::BestForm(false, Integer);
218 assert(Form != dwarf::DW_FORM_implicit_const &&(static_cast <bool> (Form != dwarf::DW_FORM_implicit_const
&& "DW_FORM_implicit_const is used only for signed integers"
) ? void (0) : __assert_fail ("Form != dwarf::DW_FORM_implicit_const && \"DW_FORM_implicit_const is used only for signed integers\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 219, __extension__ __PRETTY_FUNCTION__))
219 "DW_FORM_implicit_const is used only for signed integers")(static_cast <bool> (Form != dwarf::DW_FORM_implicit_const
&& "DW_FORM_implicit_const is used only for signed integers"
) ? void (0) : __assert_fail ("Form != dwarf::DW_FORM_implicit_const && \"DW_FORM_implicit_const is used only for signed integers\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 219, __extension__ __PRETTY_FUNCTION__))
;
220 Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
221}
222
223void DwarfUnit::addUInt(DIEValueList &Block, dwarf::Form Form,
224 uint64_t Integer) {
225 addUInt(Block, (dwarf::Attribute)0, Form, Integer);
226}
227
228void DwarfUnit::addSInt(DIEValueList &Die, dwarf::Attribute Attribute,
229 Optional<dwarf::Form> Form, int64_t Integer) {
230 if (!Form)
231 Form = DIEInteger::BestForm(true, Integer);
232 Die.addValue(DIEValueAllocator, Attribute, *Form, DIEInteger(Integer));
233}
234
235void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
236 int64_t Integer) {
237 addSInt(Die, (dwarf::Attribute)0, Form, Integer);
238}
239
240void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
241 StringRef String) {
242 if (DD->useInlineStrings()) {
243 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_string,
244 new (DIEValueAllocator)
245 DIEInlineString(String, DIEValueAllocator));
246 return;
247 }
248 auto StringPoolEntry = DU->getStringPool().getEntry(*Asm, String);
249 dwarf::Form IxForm =
250 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
251 // For DWARF v5 and beyond, use the smallest strx? form possible.
252 if (useSegmentedStringOffsetsTable()) {
253 IxForm = dwarf::DW_FORM_strx1;
254 unsigned Index = StringPoolEntry.getIndex();
255 if (Index > 0xffffff)
256 IxForm = dwarf::DW_FORM_strx4;
257 else if (Index > 0xffff)
258 IxForm = dwarf::DW_FORM_strx3;
259 else if (Index > 0xff)
260 IxForm = dwarf::DW_FORM_strx2;
261 }
262 Die.addValue(DIEValueAllocator, Attribute, IxForm,
263 DIEString(StringPoolEntry));
264}
265
266DIEValueList::value_iterator DwarfUnit::addLabel(DIEValueList &Die,
267 dwarf::Attribute Attribute,
268 dwarf::Form Form,
269 const MCSymbol *Label) {
270 return Die.addValue(DIEValueAllocator, Attribute, Form, DIELabel(Label));
271}
272
273void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label) {
274 addLabel(Die, (dwarf::Attribute)0, Form, Label);
275}
276
277void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
278 uint64_t Integer) {
279 if (DD->getDwarfVersion() >= 4)
280 addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer);
281 else
282 addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
283}
284
285MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) const {
286 assert(File)(static_cast <bool> (File) ? void (0) : __assert_fail (
"File", "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 286, __extension__ __PRETTY_FUNCTION__))
;
287 if (DD->getDwarfVersion() < 5)
288 return nullptr;
289 Optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum();
290 if (!Checksum || Checksum->Kind != DIFile::CSK_MD5)
291 return nullptr;
292
293 // Convert the string checksum to an MD5Result for the streamer.
294 // The verifier validates the checksum so we assume it's okay.
295 // An MD5 checksum is 16 bytes.
296 std::string ChecksumString = fromHex(Checksum->Value);
297 void *CKMem = Asm->OutStreamer->getContext().allocate(16, 1);
298 memcpy(CKMem, ChecksumString.data(), 16);
299 return reinterpret_cast<MD5::MD5Result *>(CKMem);
300}
301
302unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) {
303 if (!SplitLineTable)
304 return getCU().getOrCreateSourceID(File);
305 if (!UsedLineTable) {
306 UsedLineTable = true;
307 // This is a split type unit that needs a line table.
308 addSectionOffset(getUnitDie(), dwarf::DW_AT_stmt_list, 0);
309 }
310 return SplitLineTable->getFile(File->getDirectory(), File->getFilename(),
311 getMD5AsBytes(File), File->getSource());
312}
313
314void DwarfUnit::addOpAddress(DIELoc &Die, const MCSymbol *Sym) {
315 if (!DD->useSplitDwarf()) {
316 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
317 addLabel(Die, dwarf::DW_FORM_udata, Sym);
318 } else {
319 addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
320 addUInt(Die, dwarf::DW_FORM_GNU_addr_index,
321 DD->getAddressPool().getIndex(Sym));
322 }
323}
324
325void DwarfUnit::addLabelDelta(DIE &Die, dwarf::Attribute Attribute,
326 const MCSymbol *Hi, const MCSymbol *Lo) {
327 Die.addValue(DIEValueAllocator, Attribute, dwarf::DW_FORM_data4,
328 new (DIEValueAllocator) DIEDelta(Hi, Lo));
329}
330
331void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry) {
332 addDIEEntry(Die, Attribute, DIEEntry(Entry));
333}
334
335void DwarfUnit::addDIETypeSignature(DIE &Die, uint64_t Signature) {
336 // Flag the type unit reference as a declaration so that if it contains
337 // members (implicit special members, static data member definitions, member
338 // declarations for definitions in this CU, etc) consumers don't get confused
339 // and think this is a full definition.
340 addFlag(Die, dwarf::DW_AT_declaration);
341
342 Die.addValue(DIEValueAllocator, dwarf::DW_AT_signature,
343 dwarf::DW_FORM_ref_sig8, DIEInteger(Signature));
344}
345
346void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
347 DIEEntry Entry) {
348 const DIEUnit *CU = Die.getUnit();
349 const DIEUnit *EntryCU = Entry.getEntry().getUnit();
350 if (!CU)
351 // We assume that Die belongs to this CU, if it is not linked to any CU yet.
352 CU = getUnitDie().getUnit();
353 if (!EntryCU)
354 EntryCU = getUnitDie().getUnit();
355 Die.addValue(DIEValueAllocator, Attribute,
356 EntryCU == CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
357 Entry);
358}
359
360DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
361 DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
362 if (N)
363 insertDIE(N, &Die);
364 return Die;
365}
366
367void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc) {
368 Loc->ComputeSize(Asm);
369 DIELocs.push_back(Loc); // Memoize so we can call the destructor later on.
370 Die.addValue(DIEValueAllocator, Attribute,
371 Loc->BestForm(DD->getDwarfVersion()), Loc);
372}
373
374void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute,
375 DIEBlock *Block) {
376 Block->ComputeSize(Asm);
377 DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on.
378 Die.addValue(DIEValueAllocator, Attribute, Block->BestForm(), Block);
379}
380
381void DwarfUnit::addSourceLine(DIE &Die, unsigned Line, const DIFile *File) {
382 if (Line == 0)
383 return;
384
385 unsigned FileID = getOrCreateSourceID(File);
386 assert(FileID && "Invalid file id")(static_cast <bool> (FileID && "Invalid file id"
) ? void (0) : __assert_fail ("FileID && \"Invalid file id\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 386, __extension__ __PRETTY_FUNCTION__))
;
387 addUInt(Die, dwarf::DW_AT_decl_file, None, FileID);
388 addUInt(Die, dwarf::DW_AT_decl_line, None, Line);
389}
390
391void DwarfUnit::addSourceLine(DIE &Die, const DILocalVariable *V) {
392 assert(V)(static_cast <bool> (V) ? void (0) : __assert_fail ("V"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 392, __extension__ __PRETTY_FUNCTION__))
;
393
394 addSourceLine(Die, V->getLine(), V->getFile());
395}
396
397void DwarfUnit::addSourceLine(DIE &Die, const DIGlobalVariable *G) {
398 assert(G)(static_cast <bool> (G) ? void (0) : __assert_fail ("G"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 398, __extension__ __PRETTY_FUNCTION__))
;
399
400 addSourceLine(Die, G->getLine(), G->getFile());
401}
402
403void DwarfUnit::addSourceLine(DIE &Die, const DISubprogram *SP) {
404 assert(SP)(static_cast <bool> (SP) ? void (0) : __assert_fail ("SP"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 404, __extension__ __PRETTY_FUNCTION__))
;
405
406 addSourceLine(Die, SP->getLine(), SP->getFile());
407}
408
409void DwarfUnit::addSourceLine(DIE &Die, const DIType *Ty) {
410 assert(Ty)(static_cast <bool> (Ty) ? void (0) : __assert_fail ("Ty"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 410, __extension__ __PRETTY_FUNCTION__))
;
411
412 addSourceLine(Die, Ty->getLine(), Ty->getFile());
413}
414
415void DwarfUnit::addSourceLine(DIE &Die, const DIObjCProperty *Ty) {
416 assert(Ty)(static_cast <bool> (Ty) ? void (0) : __assert_fail ("Ty"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 416, __extension__ __PRETTY_FUNCTION__))
;
417
418 addSourceLine(Die, Ty->getLine(), Ty->getFile());
419}
420
421/* Byref variables, in Blocks, are declared by the programmer as "SomeType
422 VarName;", but the compiler creates a __Block_byref_x_VarName struct, and
423 gives the variable VarName either the struct, or a pointer to the struct, as
424 its type. This is necessary for various behind-the-scenes things the
425 compiler needs to do with by-reference variables in Blocks.
426
427 However, as far as the original *programmer* is concerned, the variable
428 should still have type 'SomeType', as originally declared.
429
430 The function getBlockByrefType dives into the __Block_byref_x_VarName
431 struct to find the original type of the variable, which is then assigned to
432 the variable's Debug Information Entry as its real type. So far, so good.
433 However now the debugger will expect the variable VarName to have the type
434 SomeType. So we need the location attribute for the variable to be an
435 expression that explains to the debugger how to navigate through the
436 pointers and struct to find the actual variable of type SomeType.
437
438 The following function does just that. We start by getting
439 the "normal" location for the variable. This will be the location
440 of either the struct __Block_byref_x_VarName or the pointer to the
441 struct __Block_byref_x_VarName.
442
443 The struct will look something like:
444
445 struct __Block_byref_x_VarName {
446 ... <various fields>
447 struct __Block_byref_x_VarName *forwarding;
448 ... <various other fields>
449 SomeType VarName;
450 ... <maybe more fields>
451 };
452
453 If we are given the struct directly (as our starting point) we
454 need to tell the debugger to:
455
456 1). Add the offset of the forwarding field.
457
458 2). Follow that pointer to get the real __Block_byref_x_VarName
459 struct to use (the real one may have been copied onto the heap).
460
461 3). Add the offset for the field VarName, to find the actual variable.
462
463 If we started with a pointer to the struct, then we need to
464 dereference that pointer first, before the other steps.
465 Translating this into DWARF ops, we will need to append the following
466 to the current location description for the variable:
467
468 DW_OP_deref -- optional, if we start with a pointer
469 DW_OP_plus_uconst <forward_fld_offset>
470 DW_OP_deref
471 DW_OP_plus_uconst <varName_fld_offset>
472
473 That is what this function does. */
474
475void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die,
476 dwarf::Attribute Attribute,
477 const MachineLocation &Location) {
478 const DIType *Ty = DV.getType();
479 const DIType *TmpTy = Ty;
480 uint16_t Tag = Ty->getTag();
481 bool isPointer = false;
482
483 StringRef varName = DV.getName();
484
485 if (Tag == dwarf::DW_TAG_pointer_type) {
486 auto *DTy = cast<DIDerivedType>(Ty);
487 TmpTy = resolve(DTy->getBaseType());
488 isPointer = true;
489 }
490
491 // Find the __forwarding field and the variable field in the __Block_byref
492 // struct.
493 DINodeArray Fields = cast<DICompositeType>(TmpTy)->getElements();
494 const DIDerivedType *varField = nullptr;
495 const DIDerivedType *forwardingField = nullptr;
496
497 for (unsigned i = 0, N = Fields.size(); i < N; ++i) {
498 auto *DT = cast<DIDerivedType>(Fields[i]);
499 StringRef fieldName = DT->getName();
500 if (fieldName == "__forwarding")
501 forwardingField = DT;
502 else if (fieldName == varName)
503 varField = DT;
504 }
505
506 // Get the offsets for the forwarding field and the variable field.
507 unsigned forwardingFieldOffset = forwardingField->getOffsetInBits() >> 3;
508 unsigned varFieldOffset = varField->getOffsetInBits() >> 2;
509
510 // Decode the original location, and use that as the start of the byref
511 // variable's location.
512 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
513 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
514 if (Location.isIndirect())
515 DwarfExpr.setMemoryLocationKind();
516
517 SmallVector<uint64_t, 6> Ops;
518 // If we started with a pointer to the __Block_byref... struct, then
519 // the first thing we need to do is dereference the pointer (DW_OP_deref).
520 if (isPointer)
521 Ops.push_back(dwarf::DW_OP_deref);
522
523 // Next add the offset for the '__forwarding' field:
524 // DW_OP_plus_uconst ForwardingFieldOffset. Note there's no point in
525 // adding the offset if it's 0.
526 if (forwardingFieldOffset > 0) {
527 Ops.push_back(dwarf::DW_OP_plus_uconst);
528 Ops.push_back(forwardingFieldOffset);
529 }
530
531 // Now dereference the __forwarding field to get to the real __Block_byref
532 // struct: DW_OP_deref.
533 Ops.push_back(dwarf::DW_OP_deref);
534
535 // Now that we've got the real __Block_byref... struct, add the offset
536 // for the variable's field to get to the location of the actual variable:
537 // DW_OP_plus_uconst varFieldOffset. Again, don't add if it's 0.
538 if (varFieldOffset > 0) {
539 Ops.push_back(dwarf::DW_OP_plus_uconst);
540 Ops.push_back(varFieldOffset);
541 }
542
543 DIExpressionCursor Cursor(Ops);
544 const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo();
545 if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Location.getReg()))
546 return;
547 DwarfExpr.addExpression(std::move(Cursor));
548
549 // Now attach the location information to the DIE.
550 addBlock(Die, Attribute, DwarfExpr.finalize());
551}
552
553/// Return true if type encoding is unsigned.
554static bool isUnsignedDIType(DwarfDebug *DD, const DIType *Ty) {
555 if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
556 // FIXME: Enums without a fixed underlying type have unknown signedness
557 // here, leading to incorrectly emitted constants.
558 if (CTy->getTag() == dwarf::DW_TAG_enumeration_type)
559 return false;
560
561 // (Pieces of) aggregate types that get hacked apart by SROA may be
562 // represented by a constant. Encode them as unsigned bytes.
563 return true;
564 }
565
566 if (auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
567 dwarf::Tag T = (dwarf::Tag)Ty->getTag();
568 // Encode pointer constants as unsigned bytes. This is used at least for
569 // null pointer constant emission.
570 // FIXME: reference and rvalue_reference /probably/ shouldn't be allowed
571 // here, but accept them for now due to a bug in SROA producing bogus
572 // dbg.values.
573 if (T == dwarf::DW_TAG_pointer_type ||
574 T == dwarf::DW_TAG_ptr_to_member_type ||
575 T == dwarf::DW_TAG_reference_type ||
576 T == dwarf::DW_TAG_rvalue_reference_type)
577 return true;
578 assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||(static_cast <bool> (T == dwarf::DW_TAG_typedef || T ==
dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type
|| T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type
) ? void (0) : __assert_fail ("T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type || T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 580, __extension__ __PRETTY_FUNCTION__))
579 T == dwarf::DW_TAG_volatile_type ||(static_cast <bool> (T == dwarf::DW_TAG_typedef || T ==
dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type
|| T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type
) ? void (0) : __assert_fail ("T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type || T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 580, __extension__ __PRETTY_FUNCTION__))
580 T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type)(static_cast <bool> (T == dwarf::DW_TAG_typedef || T ==
dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type
|| T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type
) ? void (0) : __assert_fail ("T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type || T == dwarf::DW_TAG_volatile_type || T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type"
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 580, __extension__ __PRETTY_FUNCTION__))
;
581 DITypeRef Deriv = DTy->getBaseType();
582 assert(Deriv && "Expected valid base type")(static_cast <bool> (Deriv && "Expected valid base type"
) ? void (0) : __assert_fail ("Deriv && \"Expected valid base type\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 582, __extension__ __PRETTY_FUNCTION__))
;
583 return isUnsignedDIType(DD, DD->resolve(Deriv));
584 }
585
586 auto *BTy = cast<DIBasicType>(Ty);
587 unsigned Encoding = BTy->getEncoding();
588 assert((Encoding == dwarf::DW_ATE_unsigned ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
589 Encoding == dwarf::DW_ATE_unsigned_char ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
590 Encoding == dwarf::DW_ATE_signed ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
591 Encoding == dwarf::DW_ATE_signed_char ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
592 Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
593 Encoding == dwarf::DW_ATE_boolean ||(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
594 (Ty->getTag() == dwarf::DW_TAG_unspecified_type &&(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
595 Ty->getName() == "decltype(nullptr)")) &&(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
596 "Unsupported encoding")(static_cast <bool> ((Encoding == dwarf::DW_ATE_unsigned
|| Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf
::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding
== dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding
== dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type
&& Ty->getName() == "decltype(nullptr)")) &&
"Unsupported encoding") ? void (0) : __assert_fail ("(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || Encoding == dwarf::DW_ATE_signed || Encoding == dwarf::DW_ATE_signed_char || Encoding == dwarf::DW_ATE_float || Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean || (Ty->getTag() == dwarf::DW_TAG_unspecified_type && Ty->getName() == \"decltype(nullptr)\")) && \"Unsupported encoding\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 596, __extension__ __PRETTY_FUNCTION__))
;
597 return Encoding == dwarf::DW_ATE_unsigned ||
598 Encoding == dwarf::DW_ATE_unsigned_char ||
599 Encoding == dwarf::DW_ATE_UTF || Encoding == dwarf::DW_ATE_boolean ||
600 Ty->getTag() == dwarf::DW_TAG_unspecified_type;
601}
602
603void DwarfUnit::addConstantFPValue(DIE &Die, const MachineOperand &MO) {
604 assert(MO.isFPImm() && "Invalid machine operand!")(static_cast <bool> (MO.isFPImm() && "Invalid machine operand!"
) ? void (0) : __assert_fail ("MO.isFPImm() && \"Invalid machine operand!\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 604, __extension__ __PRETTY_FUNCTION__))
;
605 DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
606 APFloat FPImm = MO.getFPImm()->getValueAPF();
607
608 // Get the raw data form of the floating point.
609 const APInt FltVal = FPImm.bitcastToAPInt();
610 const char *FltPtr = (const char *)FltVal.getRawData();
611
612 int NumBytes = FltVal.getBitWidth() / 8; // 8 bits per byte.
613 bool LittleEndian = Asm->getDataLayout().isLittleEndian();
614 int Incr = (LittleEndian ? 1 : -1);
615 int Start = (LittleEndian ? 0 : NumBytes - 1);
616 int Stop = (LittleEndian ? NumBytes : -1);
617
618 // Output the constant to DWARF one byte at a time.
619 for (; Start != Stop; Start += Incr)
620 addUInt(*Block, dwarf::DW_FORM_data1, (unsigned char)0xFF & FltPtr[Start]);
621
622 addBlock(Die, dwarf::DW_AT_const_value, Block);
623}
624
625void DwarfUnit::addConstantFPValue(DIE &Die, const ConstantFP *CFP) {
626 // Pass this down to addConstantValue as an unsigned bag of bits.
627 addConstantValue(Die, CFP->getValueAPF().bitcastToAPInt(), true);
628}
629
630void DwarfUnit::addConstantValue(DIE &Die, const ConstantInt *CI,
631 const DIType *Ty) {
632 addConstantValue(Die, CI->getValue(), Ty);
633}
634
635void DwarfUnit::addConstantValue(DIE &Die, const MachineOperand &MO,
636 const DIType *Ty) {
637 assert(MO.isImm() && "Invalid machine operand!")(static_cast <bool> (MO.isImm() && "Invalid machine operand!"
) ? void (0) : __assert_fail ("MO.isImm() && \"Invalid machine operand!\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 637, __extension__ __PRETTY_FUNCTION__))
;
638
639 addConstantValue(Die, isUnsignedDIType(DD, Ty), MO.getImm());
640}
641
642void DwarfUnit::addConstantValue(DIE &Die, bool Unsigned, uint64_t Val) {
643 // FIXME: This is a bit conservative/simple - it emits negative values always
644 // sign extended to 64 bits rather than minimizing the number of bytes.
645 addUInt(Die, dwarf::DW_AT_const_value,
646 Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
647}
648
649void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty) {
650 addConstantValue(Die, Val, isUnsignedDIType(DD, Ty));
651}
652
653void DwarfUnit::addConstantValue(DIE &Die, const APInt &Val, bool Unsigned) {
654 unsigned CIBitWidth = Val.getBitWidth();
655 if (CIBitWidth <= 64) {
656 addConstantValue(Die, Unsigned,
657 Unsigned ? Val.getZExtValue() : Val.getSExtValue());
658 return;
659 }
660
661 DIEBlock *Block = new (DIEValueAllocator) DIEBlock;
662
663 // Get the raw data form of the large APInt.
664 const uint64_t *Ptr64 = Val.getRawData();
665
666 int NumBytes = Val.getBitWidth() / 8; // 8 bits per byte.
667 bool LittleEndian = Asm->getDataLayout().isLittleEndian();
668
669 // Output the constant to DWARF one byte at a time.
670 for (int i = 0; i < NumBytes; i++) {
671 uint8_t c;
672 if (LittleEndian)
673 c = Ptr64[i / 8] >> (8 * (i & 7));
674 else
675 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
676 addUInt(*Block, dwarf::DW_FORM_data1, c);
677 }
678
679 addBlock(Die, dwarf::DW_AT_const_value, Block);
680}
681
682void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
683 if (!LinkageName.empty())
684 addString(Die,
685 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
686 : dwarf::DW_AT_MIPS_linkage_name,
687 GlobalValue::dropLLVMManglingEscape(LinkageName));
688}
689
690void DwarfUnit::addTemplateParams(DIE &Buffer, DINodeArray TParams) {
691 // Add template parameters.
692 for (const auto *Element : TParams) {
693 if (auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
1
Taking false branch
694 constructTemplateTypeParameterDIE(Buffer, TTP);
695 else if (auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
2
Assuming 'TVP' is non-null
3
Taking true branch
696 constructTemplateValueParameterDIE(Buffer, TVP);
4
Calling 'DwarfUnit::constructTemplateValueParameterDIE'
697 }
698}
699
700/// Add thrown types.
701void DwarfUnit::addThrownTypes(DIE &Die, DINodeArray ThrownTypes) {
702 for (const auto *Ty : ThrownTypes) {
703 DIE &TT = createAndAddDIE(dwarf::DW_TAG_thrown_type, Die);
704 addType(TT, cast<DIType>(Ty));
705 }
706}
707
708DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
709 if (!Context || isa<DIFile>(Context))
710 return &getUnitDie();
711 if (auto *T = dyn_cast<DIType>(Context))
712 return getOrCreateTypeDIE(T);
713 if (auto *NS = dyn_cast<DINamespace>(Context))
714 return getOrCreateNameSpace(NS);
715 if (auto *SP = dyn_cast<DISubprogram>(Context))
716 return getOrCreateSubprogramDIE(SP);
717 if (auto *M = dyn_cast<DIModule>(Context))
718 return getOrCreateModule(M);
719 return getDIE(Context);
720}
721
722DIE *DwarfTypeUnit::createTypeDIE(const DICompositeType *Ty) {
723 auto *Context = resolve(Ty->getScope());
724 DIE *ContextDIE = getOrCreateContextDIE(Context);
725
726 if (DIE *TyDIE = getDIE(Ty))
727 return TyDIE;
728
729 // Create new type.
730 DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
731
732 constructTypeDIE(TyDIE, cast<DICompositeType>(Ty));
733
734 updateAcceleratorTables(Context, Ty, TyDIE);
735 return &TyDIE;
736}
737
738DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
739 if (!TyNode)
9
Taking false branch
740 return nullptr;
741
742 auto *Ty = cast<DIType>(TyNode);
743
744 // DW_TAG_restrict_type is not supported in DWARF2
745 if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)
10
Assuming the condition is false
746 return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
747
748 // DW_TAG_atomic_type is not supported in DWARF < 5
749 if (Ty->getTag() == dwarf::DW_TAG_atomic_type && DD->getDwarfVersion() < 5)
11
Assuming the condition is false
750 return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));
751
752 // Construct the context before querying for the existence of the DIE in case
753 // such construction creates the DIE.
754 auto *Context = resolve(Ty->getScope());
755 DIE *ContextDIE = getOrCreateContextDIE(Context);
756 assert(ContextDIE)(static_cast <bool> (ContextDIE) ? void (0) : __assert_fail
("ContextDIE", "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 756, __extension__ __PRETTY_FUNCTION__))
;
757
758 if (DIE *TyDIE = getDIE(Ty))
12
Assuming 'TyDIE' is null
13
Taking false branch
759 return TyDIE;
760
761 // Create new type.
762 DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
763
764 updateAcceleratorTables(Context, Ty, TyDIE);
765
766 if (auto *BT = dyn_cast<DIBasicType>(Ty))
14
Taking false branch
767 constructTypeDIE(TyDIE, BT);
768 else if (auto *STy = dyn_cast<DISubroutineType>(Ty))
15
Taking false branch
769 constructTypeDIE(TyDIE, STy);
770 else if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
16
Assuming 'CTy' is non-null
17
Taking true branch
771 if (GenerateDwarfTypeUnits && !Ty->isForwardDecl())
18
Assuming the condition is false
772 if (MDString *TypeId = CTy->getRawIdentifier()) {
773 DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
774 // Skip updating the accelerator tables since this is not the full type.
775 return &TyDIE;
776 }
777 constructTypeDIE(TyDIE, CTy);
19
Calling 'DwarfUnit::constructTypeDIE'
778 } else {
779 constructTypeDIE(TyDIE, cast<DIDerivedType>(Ty));
780 }
781
782 return &TyDIE;
783}
784
785void DwarfUnit::updateAcceleratorTables(const DIScope *Context,
786 const DIType *Ty, const DIE &TyDIE) {
787 if (!Ty->getName().empty() && !Ty->isForwardDecl()) {
788 bool IsImplementation = false;
789 if (auto *CT = dyn_cast<DICompositeType>(Ty)) {
790 // A runtime language of 0 actually means C/C++ and that any
791 // non-negative value is some version of Objective-C/C++.
792 IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete();
793 }
794 unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
795 DD->addAccelType(Ty->getName(), TyDIE, Flags);
796
797 if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
798 isa<DINamespace>(Context))
799 addGlobalType(Ty, TyDIE, Context);
800 }
801}
802
803void DwarfUnit::addType(DIE &Entity, const DIType *Ty,
804 dwarf::Attribute Attribute) {
805 assert(Ty && "Trying to add a type that doesn't exist?")(static_cast <bool> (Ty && "Trying to add a type that doesn't exist?"
) ? void (0) : __assert_fail ("Ty && \"Trying to add a type that doesn't exist?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 805, __extension__ __PRETTY_FUNCTION__))
;
806 addDIEEntry(Entity, Attribute, DIEEntry(*getOrCreateTypeDIE(Ty)));
8
Calling 'DwarfUnit::getOrCreateTypeDIE'
807}
808
809std::string DwarfUnit::getParentContextString(const DIScope *Context) const {
810 if (!Context)
811 return "";
812
813 // FIXME: Decide whether to implement this for non-C++ languages.
814 if (getLanguage() != dwarf::DW_LANG_C_plus_plus)
815 return "";
816
817 std::string CS;
818 SmallVector<const DIScope *, 1> Parents;
819 while (!isa<DICompileUnit>(Context)) {
820 Parents.push_back(Context);
821 if (Context->getScope())
822 Context = resolve(Context->getScope());
823 else
824 // Structure, etc types will have a NULL context if they're at the top
825 // level.
826 break;
827 }
828
829 // Reverse iterate over our list to go from the outermost construct to the
830 // innermost.
831 for (const DIScope *Ctx : make_range(Parents.rbegin(), Parents.rend())) {
832 StringRef Name = Ctx->getName();
833 if (Name.empty() && isa<DINamespace>(Ctx))
834 Name = "(anonymous namespace)";
835 if (!Name.empty()) {
836 CS += Name;
837 CS += "::";
838 }
839 }
840 return CS;
841}
842
843void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) {
844 // Get core information.
845 StringRef Name = BTy->getName();
846 // Add name if not anonymous or intermediate type.
847 if (!Name.empty())
848 addString(Buffer, dwarf::DW_AT_name, Name);
849
850 // An unspecified type only has a name attribute.
851 if (BTy->getTag() == dwarf::DW_TAG_unspecified_type)
852 return;
853
854 addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
855 BTy->getEncoding());
856
857 uint64_t Size = BTy->getSizeInBits() >> 3;
858 addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
859}
860
861void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
862 // Get core information.
863 StringRef Name = DTy->getName();
864 uint64_t Size = DTy->getSizeInBits() >> 3;
865 uint16_t Tag = Buffer.getTag();
866
867 // Map to main type, void will not have a type.
868 const DIType *FromTy = resolve(DTy->getBaseType());
869 if (FromTy)
870 addType(Buffer, FromTy);
871
872 // Add name if not anonymous or intermediate type.
873 if (!Name.empty())
874 addString(Buffer, dwarf::DW_AT_name, Name);
875
876 // Add size if non-zero (derived types might be zero-sized.)
877 if (Size && Tag != dwarf::DW_TAG_pointer_type
878 && Tag != dwarf::DW_TAG_ptr_to_member_type
879 && Tag != dwarf::DW_TAG_reference_type
880 && Tag != dwarf::DW_TAG_rvalue_reference_type)
881 addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
882
883 if (Tag == dwarf::DW_TAG_ptr_to_member_type)
884 addDIEEntry(
885 Buffer, dwarf::DW_AT_containing_type,
886 *getOrCreateTypeDIE(resolve(cast<DIDerivedType>(DTy)->getClassType())));
887 // Add source line info if available and TyDesc is not a forward declaration.
888 if (!DTy->isForwardDecl())
889 addSourceLine(Buffer, DTy);
890
891 // If DWARF address space value is other than None, add it for pointer and
892 // reference types as DW_AT_address_class.
893 if (DTy->getDWARFAddressSpace() && (Tag == dwarf::DW_TAG_pointer_type ||
894 Tag == dwarf::DW_TAG_reference_type))
895 addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
896 DTy->getDWARFAddressSpace().getValue());
897}
898
899void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) {
900 for (unsigned i = 1, N = Args.size(); i < N; ++i) {
901 const DIType *Ty = resolve(Args[i]);
902 if (!Ty) {
903 assert(i == N-1 && "Unspecified parameter must be the last argument")(static_cast <bool> (i == N-1 && "Unspecified parameter must be the last argument"
) ? void (0) : __assert_fail ("i == N-1 && \"Unspecified parameter must be the last argument\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 903, __extension__ __PRETTY_FUNCTION__))
;
904 createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
905 } else {
906 DIE &Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
907 addType(Arg, Ty);
908 if (Ty->isArtificial())
909 addFlag(Arg, dwarf::DW_AT_artificial);
910 }
911 }
912}
913
914void DwarfUnit::constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy) {
915 // Add return type. A void return won't have a type.
916 auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
917 if (Elements.size())
918 if (auto RTy = resolve(Elements[0]))
919 addType(Buffer, RTy);
920
921 bool isPrototyped = true;
922 if (Elements.size() == 2 && !Elements[1])
923 isPrototyped = false;
924
925 constructSubprogramArguments(Buffer, Elements);
926
927 // Add prototype flag if we're dealing with a C language and the function has
928 // been prototyped.
929 uint16_t Language = getLanguage();
930 if (isPrototyped &&
931 (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
932 Language == dwarf::DW_LANG_ObjC))
933 addFlag(Buffer, dwarf::DW_AT_prototyped);
934
935 // Add a DW_AT_calling_convention if this has an explicit convention.
936 if (CTy->getCC() && CTy->getCC() != dwarf::DW_CC_normal)
937 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
938 CTy->getCC());
939
940 if (CTy->isLValueReference())
941 addFlag(Buffer, dwarf::DW_AT_reference);
942
943 if (CTy->isRValueReference())
944 addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
945}
946
947void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
948 // Add name if not anonymous or intermediate type.
949 StringRef Name = CTy->getName();
950
951 uint64_t Size = CTy->getSizeInBits() >> 3;
952 uint16_t Tag = Buffer.getTag();
953
954 switch (Tag) {
20
Control jumps to 'case DW_TAG_variant_part:' at line 961
955 case dwarf::DW_TAG_array_type:
956 constructArrayTypeDIE(Buffer, CTy);
957 break;
958 case dwarf::DW_TAG_enumeration_type:
959 constructEnumTypeDIE(Buffer, CTy);
960 break;
961 case dwarf::DW_TAG_variant_part:
962 case dwarf::DW_TAG_structure_type:
963 case dwarf::DW_TAG_union_type:
964 case dwarf::DW_TAG_class_type: {
965 // Emit the discriminator for a variant part.
966 DIDerivedType *Discriminator = nullptr;
967 if (Tag == dwarf::DW_TAG_variant_part) {
21
Taking true branch
968 Discriminator = CTy->getDiscriminator();
22
Calling 'DICompositeType::getDiscriminator'
25
Returning from 'DICompositeType::getDiscriminator'
26
Value assigned to 'Discriminator'
969 if (Discriminator) {
27
Assuming 'Discriminator' is null
28
Assuming pointer value is null
29
Taking false branch
970 // DWARF says:
971 // If the variant part has a discriminant, the discriminant is
972 // represented by a separate debugging information entry which is
973 // a child of the variant part entry.
974 DIE &DiscMember = constructMemberDIE(Buffer, Discriminator);
975 addDIEEntry(Buffer, dwarf::DW_AT_discr, DiscMember);
976 }
977 }
978
979 // Add elements to structure type.
980 DINodeArray Elements = CTy->getElements();
981 for (const auto *Element : Elements) {
982 if (!Element)
30
Assuming 'Element' is non-null
31
Taking false branch
983 continue;
984 if (auto *SP = dyn_cast<DISubprogram>(Element))
32
Assuming 'SP' is null
33
Taking false branch
985 getOrCreateSubprogramDIE(SP);
986 else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
34
Assuming 'DDTy' is non-null
35
Taking true branch
987 if (DDTy->getTag() == dwarf::DW_TAG_friend) {
36
Assuming the condition is false
37
Taking false branch
988 DIE &ElemDie = createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
989 addType(ElemDie, resolve(DDTy->getBaseType()), dwarf::DW_AT_friend);
990 } else if (DDTy->isStaticMember()) {
38
Taking false branch
991 getOrCreateStaticMemberDIE(DDTy);
992 } else if (Tag == dwarf::DW_TAG_variant_part) {
39
Taking true branch
993 // When emitting a variant part, wrap each member in
994 // DW_TAG_variant.
995 DIE &Variant = createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
996 if (const ConstantInt *CI =
40
Assuming 'CI' is non-null
41
Taking true branch
997 dyn_cast_or_null<ConstantInt>(DDTy->getDiscriminantValue())) {
998 if (isUnsignedDIType(DD, resolve(Discriminator->getBaseType())))
42
Called C++ object pointer is null
999 addUInt(Variant, dwarf::DW_AT_discr_value, None, CI->getZExtValue());
1000 else
1001 addSInt(Variant, dwarf::DW_AT_discr_value, None, CI->getSExtValue());
1002 }
1003 constructMemberDIE(Variant, DDTy);
1004 } else {
1005 constructMemberDIE(Buffer, DDTy);
1006 }
1007 } else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
1008 DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
1009 StringRef PropertyName = Property->getName();
1010 addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
1011 if (Property->getType())
1012 addType(ElemDie, resolve(Property->getType()));
1013 addSourceLine(ElemDie, Property);
1014 StringRef GetterName = Property->getGetterName();
1015 if (!GetterName.empty())
1016 addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1017 StringRef SetterName = Property->getSetterName();
1018 if (!SetterName.empty())
1019 addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1020 if (unsigned PropertyAttributes = Property->getAttributes())
1021 addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, None,
1022 PropertyAttributes);
1023 } else if (auto *Composite = dyn_cast<DICompositeType>(Element)) {
1024 if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1025 DIE &VariantPart = createAndAddDIE(Composite->getTag(), Buffer);
1026 constructTypeDIE(VariantPart, Composite);
1027 }
1028 }
1029 }
1030
1031 if (CTy->isAppleBlockExtension())
1032 addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1033
1034 // This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
1035 // inside C++ composite types to point to the base class with the vtable.
1036 // Rust uses DW_AT_containing_type to link a vtable to the type
1037 // for which it was created.
1038 if (auto *ContainingType = resolve(CTy->getVTableHolder()))
1039 addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
1040 *getOrCreateTypeDIE(ContainingType));
1041
1042 if (CTy->isObjcClassComplete())
1043 addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1044
1045 // Add template parameters to a class, structure or union types.
1046 // FIXME: The support isn't in the metadata for this yet.
1047 if (Tag == dwarf::DW_TAG_class_type ||
1048 Tag == dwarf::DW_TAG_structure_type || Tag == dwarf::DW_TAG_union_type)
1049 addTemplateParams(Buffer, CTy->getTemplateParams());
1050
1051 // Add the type's non-standard calling convention.
1052 uint8_t CC = 0;
1053 if (CTy->isTypePassByValue())
1054 CC = dwarf::DW_CC_pass_by_value;
1055 else if (CTy->isTypePassByReference())
1056 CC = dwarf::DW_CC_pass_by_reference;
1057 if (CC)
1058 addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1059 CC);
1060 break;
1061 }
1062 default:
1063 break;
1064 }
1065
1066 // Add name if not anonymous or intermediate type.
1067 if (!Name.empty())
1068 addString(Buffer, dwarf::DW_AT_name, Name);
1069
1070 if (Tag == dwarf::DW_TAG_enumeration_type ||
1071 Tag == dwarf::DW_TAG_class_type || Tag == dwarf::DW_TAG_structure_type ||
1072 Tag == dwarf::DW_TAG_union_type) {
1073 // Add size if non-zero (derived types might be zero-sized.)
1074 // TODO: Do we care about size for enum forward declarations?
1075 if (Size)
1076 addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
1077 else if (!CTy->isForwardDecl())
1078 // Add zero size if it is not a forward declaration.
1079 addUInt(Buffer, dwarf::DW_AT_byte_size, None, 0);
1080
1081 // If we're a forward decl, say so.
1082 if (CTy->isForwardDecl())
1083 addFlag(Buffer, dwarf::DW_AT_declaration);
1084
1085 // Add source line info if available.
1086 if (!CTy->isForwardDecl())
1087 addSourceLine(Buffer, CTy);
1088
1089 // No harm in adding the runtime language to the declaration.
1090 unsigned RLang = CTy->getRuntimeLang();
1091 if (RLang)
1092 addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1093 RLang);
1094
1095 // Add align info if available.
1096 if (uint32_t AlignInBytes = CTy->getAlignInBytes())
1097 addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1098 AlignInBytes);
1099 }
1100}
1101
1102void DwarfUnit::constructTemplateTypeParameterDIE(
1103 DIE &Buffer, const DITemplateTypeParameter *TP) {
1104 DIE &ParamDIE =
1105 createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
1106 // Add the type if it exists, it could be void and therefore no type.
1107 if (TP->getType())
1108 addType(ParamDIE, resolve(TP->getType()));
1109 if (!TP->getName().empty())
1110 addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
1111}
1112
1113void DwarfUnit::constructTemplateValueParameterDIE(
1114 DIE &Buffer, const DITemplateValueParameter *VP) {
1115 DIE &ParamDIE = createAndAddDIE(VP->getTag(), Buffer);
1116
1117 // Add the type if there is one, template template and template parameter
1118 // packs will not have a type.
1119 if (VP->getTag() == dwarf::DW_TAG_template_value_parameter)
5
Assuming the condition is true
6
Taking true branch
1120 addType(ParamDIE, resolve(VP->getType()));
7
Calling 'DwarfUnit::addType'
1121 if (!VP->getName().empty())
1122 addString(ParamDIE, dwarf::DW_AT_name, VP->getName());
1123 if (Metadata *Val = VP->getValue()) {
1124 if (ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
1125 addConstantValue(ParamDIE, CI, resolve(VP->getType()));
1126 else if (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
1127 // We cannot describe the location of dllimport'd entities: the
1128 // computation of their address requires loads from the IAT.
1129 if (!GV->hasDLLImportStorageClass()) {
1130 // For declaration non-type template parameters (such as global values
1131 // and functions)
1132 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
1133 addOpAddress(*Loc, Asm->getSymbol(GV));
1134 // Emit DW_OP_stack_value to use the address as the immediate value of
1135 // the parameter, rather than a pointer to it.
1136 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1137 addBlock(ParamDIE, dwarf::DW_AT_location, Loc);
1138 }
1139 } else if (VP->getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1140 assert(isa<MDString>(Val))(static_cast <bool> (isa<MDString>(Val)) ? void (
0) : __assert_fail ("isa<MDString>(Val)", "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1140, __extension__ __PRETTY_FUNCTION__))
;
1141 addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1142 cast<MDString>(Val)->getString());
1143 } else if (VP->getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1144 addTemplateParams(ParamDIE, cast<MDTuple>(Val));
1145 }
1146 }
1147}
1148
1149DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) {
1150 // Construct the context before querying for the existence of the DIE in case
1151 // such construction creates the DIE.
1152 DIE *ContextDIE = getOrCreateContextDIE(NS->getScope());
1153
1154 if (DIE *NDie = getDIE(NS))
1155 return NDie;
1156 DIE &NDie = createAndAddDIE(dwarf::DW_TAG_namespace, *ContextDIE, NS);
1157
1158 StringRef Name = NS->getName();
1159 if (!Name.empty())
1160 addString(NDie, dwarf::DW_AT_name, NS->getName());
1161 else
1162 Name = "(anonymous namespace)";
1163 DD->addAccelNamespace(Name, NDie);
1164 addGlobalName(Name, NDie, NS->getScope());
1165 if (NS->getExportSymbols())
1166 addFlag(NDie, dwarf::DW_AT_export_symbols);
1167 return &NDie;
1168}
1169
1170DIE *DwarfUnit::getOrCreateModule(const DIModule *M) {
1171 // Construct the context before querying for the existence of the DIE in case
1172 // such construction creates the DIE.
1173 DIE *ContextDIE = getOrCreateContextDIE(M->getScope());
1174
1175 if (DIE *MDie = getDIE(M))
1176 return MDie;
1177 DIE &MDie = createAndAddDIE(dwarf::DW_TAG_module, *ContextDIE, M);
1178
1179 if (!M->getName().empty()) {
1180 addString(MDie, dwarf::DW_AT_name, M->getName());
1181 addGlobalName(M->getName(), MDie, M->getScope());
1182 }
1183 if (!M->getConfigurationMacros().empty())
1184 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1185 M->getConfigurationMacros());
1186 if (!M->getIncludePath().empty())
1187 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1188 if (!M->getISysRoot().empty())
1189 addString(MDie, dwarf::DW_AT_LLVM_isysroot, M->getISysRoot());
1190
1191 return &MDie;
1192}
1193
1194DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
1195 // Construct the context before querying for the existence of the DIE in case
1196 // such construction creates the DIE (as is the case for member function
1197 // declarations).
1198 DIE *ContextDIE =
1199 Minimal ? &getUnitDie() : getOrCreateContextDIE(resolve(SP->getScope()));
1200
1201 if (DIE *SPDie = getDIE(SP))
1202 return SPDie;
1203
1204 if (auto *SPDecl = SP->getDeclaration()) {
1205 if (!Minimal) {
1206 // Add subprogram definitions to the CU die directly.
1207 ContextDIE = &getUnitDie();
1208 // Build the decl now to ensure it precedes the definition.
1209 getOrCreateSubprogramDIE(SPDecl);
1210 }
1211 }
1212
1213 // DW_TAG_inlined_subroutine may refer to this DIE.
1214 DIE &SPDie = createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP);
1215
1216 // Stop here and fill this in later, depending on whether or not this
1217 // subprogram turns out to have inlined instances or not.
1218 if (SP->isDefinition())
1219 return &SPDie;
1220
1221 applySubprogramAttributes(SP, SPDie);
1222 return &SPDie;
1223}
1224
1225bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP,
1226 DIE &SPDie) {
1227 DIE *DeclDie = nullptr;
1228 StringRef DeclLinkageName;
1229 if (auto *SPDecl = SP->getDeclaration()) {
1230 DeclDie = getDIE(SPDecl);
1231 assert(DeclDie && "This DIE should've already been constructed when the "(static_cast <bool> (DeclDie && "This DIE should've already been constructed when the "
"definition DIE was created in " "getOrCreateSubprogramDIE")
? void (0) : __assert_fail ("DeclDie && \"This DIE should've already been constructed when the \" \"definition DIE was created in \" \"getOrCreateSubprogramDIE\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1233, __extension__ __PRETTY_FUNCTION__))
1232 "definition DIE was created in "(static_cast <bool> (DeclDie && "This DIE should've already been constructed when the "
"definition DIE was created in " "getOrCreateSubprogramDIE")
? void (0) : __assert_fail ("DeclDie && \"This DIE should've already been constructed when the \" \"definition DIE was created in \" \"getOrCreateSubprogramDIE\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1233, __extension__ __PRETTY_FUNCTION__))
1233 "getOrCreateSubprogramDIE")(static_cast <bool> (DeclDie && "This DIE should've already been constructed when the "
"definition DIE was created in " "getOrCreateSubprogramDIE")
? void (0) : __assert_fail ("DeclDie && \"This DIE should've already been constructed when the \" \"definition DIE was created in \" \"getOrCreateSubprogramDIE\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1233, __extension__ __PRETTY_FUNCTION__))
;
1234 // Look at the Decl's linkage name only if we emitted it.
1235 if (DD->useAllLinkageNames())
1236 DeclLinkageName = SPDecl->getLinkageName();
1237 unsigned DeclID = getOrCreateSourceID(SPDecl->getFile());
1238 unsigned DefID = getOrCreateSourceID(SP->getFile());
1239 if (DeclID != DefID)
1240 addUInt(SPDie, dwarf::DW_AT_decl_file, None, DefID);
1241
1242 if (SP->getLine() != SPDecl->getLine())
1243 addUInt(SPDie, dwarf::DW_AT_decl_line, None, SP->getLine());
1244 }
1245
1246 // Add function template parameters.
1247 addTemplateParams(SPDie, SP->getTemplateParams());
1248
1249 // Add the linkage name if we have one and it isn't in the Decl.
1250 StringRef LinkageName = SP->getLinkageName();
1251 assert(((LinkageName.empty() || DeclLinkageName.empty()) ||(static_cast <bool> (((LinkageName.empty() || DeclLinkageName
.empty()) || LinkageName == DeclLinkageName) && "decl has a linkage name and it is different"
) ? void (0) : __assert_fail ("((LinkageName.empty() || DeclLinkageName.empty()) || LinkageName == DeclLinkageName) && \"decl has a linkage name and it is different\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1253, __extension__ __PRETTY_FUNCTION__))
1252 LinkageName == DeclLinkageName) &&(static_cast <bool> (((LinkageName.empty() || DeclLinkageName
.empty()) || LinkageName == DeclLinkageName) && "decl has a linkage name and it is different"
) ? void (0) : __assert_fail ("((LinkageName.empty() || DeclLinkageName.empty()) || LinkageName == DeclLinkageName) && \"decl has a linkage name and it is different\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1253, __extension__ __PRETTY_FUNCTION__))
1253 "decl has a linkage name and it is different")(static_cast <bool> (((LinkageName.empty() || DeclLinkageName
.empty()) || LinkageName == DeclLinkageName) && "decl has a linkage name and it is different"
) ? void (0) : __assert_fail ("((LinkageName.empty() || DeclLinkageName.empty()) || LinkageName == DeclLinkageName) && \"decl has a linkage name and it is different\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1253, __extension__ __PRETTY_FUNCTION__))
;
1254 if (DeclLinkageName.empty() &&
1255 // Always emit it for abstract subprograms.
1256 (DD->useAllLinkageNames() || DU->getAbstractSPDies().lookup(SP)))
1257 addLinkageName(SPDie, LinkageName);
1258
1259 if (!DeclDie)
1260 return false;
1261
1262 // Refer to the function declaration where all the other attributes will be
1263 // found.
1264 addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1265 return true;
1266}
1267
1268void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
1269 bool SkipSPAttributes) {
1270 // If -fdebug-info-for-profiling is enabled, need to emit the subprogram
1271 // and its source location.
1272 bool SkipSPSourceLocation = SkipSPAttributes &&
1273 !CUNode->getDebugInfoForProfiling();
1274 if (!SkipSPSourceLocation)
1275 if (applySubprogramDefinitionAttributes(SP, SPDie))
1276 return;
1277
1278 // Constructors and operators for anonymous aggregates do not have names.
1279 if (!SP->getName().empty())
1280 addString(SPDie, dwarf::DW_AT_name, SP->getName());
1281
1282 if (!SkipSPSourceLocation)
1283 addSourceLine(SPDie, SP);
1284
1285 // Skip the rest of the attributes under -gmlt to save space.
1286 if (SkipSPAttributes)
1287 return;
1288
1289 // Add the prototype if we have a prototype and we have a C like
1290 // language.
1291 uint16_t Language = getLanguage();
1292 if (SP->isPrototyped() &&
1293 (Language == dwarf::DW_LANG_C89 || Language == dwarf::DW_LANG_C99 ||
1294 Language == dwarf::DW_LANG_ObjC))
1295 addFlag(SPDie, dwarf::DW_AT_prototyped);
1296
1297 unsigned CC = 0;
1298 DITypeRefArray Args;
1299 if (const DISubroutineType *SPTy = SP->getType()) {
1300 Args = SPTy->getTypeArray();
1301 CC = SPTy->getCC();
1302 }
1303
1304 // Add a DW_AT_calling_convention if this has an explicit convention.
1305 if (CC && CC != dwarf::DW_CC_normal)
1306 addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1, CC);
1307
1308 // Add a return type. If this is a type like a C/C++ void type we don't add a
1309 // return type.
1310 if (Args.size())
1311 if (auto Ty = resolve(Args[0]))
1312 addType(SPDie, Ty);
1313
1314 unsigned VK = SP->getVirtuality();
1315 if (VK) {
1316 addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1317 if (SP->getVirtualIndex() != -1u) {
1318 DIELoc *Block = getDIELoc();
1319 addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1320 addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1321 addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, Block);
1322 }
1323 ContainingTypeMap.insert(
1324 std::make_pair(&SPDie, resolve(SP->getContainingType())));
1325 }
1326
1327 if (!SP->isDefinition()) {
1328 addFlag(SPDie, dwarf::DW_AT_declaration);
1329
1330 // Add arguments. Do not add arguments for subprogram definition. They will
1331 // be handled while processing variables.
1332 constructSubprogramArguments(SPDie, Args);
1333 }
1334
1335 addThrownTypes(SPDie, SP->getThrownTypes());
1336
1337 if (SP->isArtificial())
1338 addFlag(SPDie, dwarf::DW_AT_artificial);
1339
1340 if (!SP->isLocalToUnit())
1341 addFlag(SPDie, dwarf::DW_AT_external);
1342
1343 if (DD->useAppleExtensionAttributes()) {
1344 if (SP->isOptimized())
1345 addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1346
1347 if (unsigned isa = Asm->getISAEncoding())
1348 addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag, isa);
1349 }
1350
1351 if (SP->isLValueReference())
1352 addFlag(SPDie, dwarf::DW_AT_reference);
1353
1354 if (SP->isRValueReference())
1355 addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1356
1357 if (SP->isNoReturn())
1358 addFlag(SPDie, dwarf::DW_AT_noreturn);
1359
1360 if (SP->isProtected())
1361 addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1362 dwarf::DW_ACCESS_protected);
1363 else if (SP->isPrivate())
1364 addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1365 dwarf::DW_ACCESS_private);
1366 else if (SP->isPublic())
1367 addUInt(SPDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1368 dwarf::DW_ACCESS_public);
1369
1370 if (SP->isExplicit())
1371 addFlag(SPDie, dwarf::DW_AT_explicit);
1372
1373 if (SP->isMainSubprogram())
1374 addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1375}
1376
1377void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
1378 DIE *IndexTy) {
1379 DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1380 addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
1381
1382 // The LowerBound value defines the lower bounds which is typically zero for
1383 // C/C++. The Count value is the number of elements. Values are 64 bit. If
1384 // Count == -1 then the array is unbounded and we do not emit
1385 // DW_AT_lower_bound and DW_AT_count attributes.
1386 int64_t LowerBound = SR->getLowerBound();
1387 int64_t DefaultLowerBound = getDefaultLowerBound();
1388 int64_t Count = -1;
1389 if (auto *CI = SR->getCount().dyn_cast<ConstantInt*>())
1390 Count = CI->getSExtValue();
1391
1392 if (DefaultLowerBound == -1 || LowerBound != DefaultLowerBound)
1393 addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound);
1394
1395 if (auto *CV = SR->getCount().dyn_cast<DIVariable*>()) {
1396 if (auto *CountVarDIE = getDIE(CV))
1397 addDIEEntry(DW_Subrange, dwarf::DW_AT_count, *CountVarDIE);
1398 } else if (Count != -1)
1399 addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
1400}
1401
1402DIE *DwarfUnit::getIndexTyDie() {
1403 if (IndexTyDie)
1404 return IndexTyDie;
1405 // Construct an integer type to use for indexes.
1406 IndexTyDie = &createAndAddDIE(dwarf::DW_TAG_base_type, getUnitDie());
1407 addString(*IndexTyDie, dwarf::DW_AT_name, "sizetype");
1408 addUInt(*IndexTyDie, dwarf::DW_AT_byte_size, None, sizeof(int64_t));
1409 addUInt(*IndexTyDie, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
1410 dwarf::DW_ATE_unsigned);
1411 return IndexTyDie;
1412}
1413
1414/// Returns true if the vector's size differs from the sum of sizes of elements
1415/// the user specified. This can occur if the vector has been rounded up to
1416/// fit memory alignment constraints.
1417static bool hasVectorBeenPadded(const DICompositeType *CTy) {
1418 assert(CTy && CTy->isVector() && "Composite type is not a vector")(static_cast <bool> (CTy && CTy->isVector() &&
"Composite type is not a vector") ? void (0) : __assert_fail
("CTy && CTy->isVector() && \"Composite type is not a vector\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1418, __extension__ __PRETTY_FUNCTION__))
;
1419 const uint64_t ActualSize = CTy->getSizeInBits();
1420
1421 // Obtain the size of each element in the vector.
1422 DIType *BaseTy = CTy->getBaseType().resolve();
1423 assert(BaseTy && "Unknown vector element type.")(static_cast <bool> (BaseTy && "Unknown vector element type."
) ? void (0) : __assert_fail ("BaseTy && \"Unknown vector element type.\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1423, __extension__ __PRETTY_FUNCTION__))
;
1424 const uint64_t ElementSize = BaseTy->getSizeInBits();
1425
1426 // Locate the number of elements in the vector.
1427 const DINodeArray Elements = CTy->getElements();
1428 assert(Elements.size() == 1 &&(static_cast <bool> (Elements.size() == 1 && Elements
[0]->getTag() == dwarf::DW_TAG_subrange_type && "Invalid vector element array, expected one element of type subrange"
) ? void (0) : __assert_fail ("Elements.size() == 1 && Elements[0]->getTag() == dwarf::DW_TAG_subrange_type && \"Invalid vector element array, expected one element of type subrange\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1430, __extension__ __PRETTY_FUNCTION__))
1429 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&(static_cast <bool> (Elements.size() == 1 && Elements
[0]->getTag() == dwarf::DW_TAG_subrange_type && "Invalid vector element array, expected one element of type subrange"
) ? void (0) : __assert_fail ("Elements.size() == 1 && Elements[0]->getTag() == dwarf::DW_TAG_subrange_type && \"Invalid vector element array, expected one element of type subrange\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1430, __extension__ __PRETTY_FUNCTION__))
1430 "Invalid vector element array, expected one element of type subrange")(static_cast <bool> (Elements.size() == 1 && Elements
[0]->getTag() == dwarf::DW_TAG_subrange_type && "Invalid vector element array, expected one element of type subrange"
) ? void (0) : __assert_fail ("Elements.size() == 1 && Elements[0]->getTag() == dwarf::DW_TAG_subrange_type && \"Invalid vector element array, expected one element of type subrange\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1430, __extension__ __PRETTY_FUNCTION__))
;
1431 const auto Subrange = cast<DISubrange>(Elements[0]);
1432 const auto CI = Subrange->getCount().get<ConstantInt *>();
1433 const int32_t NumVecElements = CI->getSExtValue();
1434
1435 // Ensure we found the element count and that the actual size is wide
1436 // enough to contain the requested size.
1437 assert(ActualSize >= (NumVecElements * ElementSize) && "Invalid vector size")(static_cast <bool> (ActualSize >= (NumVecElements *
ElementSize) && "Invalid vector size") ? void (0) : __assert_fail
("ActualSize >= (NumVecElements * ElementSize) && \"Invalid vector size\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1437, __extension__ __PRETTY_FUNCTION__))
;
1438 return ActualSize != (NumVecElements * ElementSize);
1439}
1440
1441void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
1442 if (CTy->isVector()) {
1443 addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1444 if (hasVectorBeenPadded(CTy))
1445 addUInt(Buffer, dwarf::DW_AT_byte_size, None,
1446 CTy->getSizeInBits() / CHAR_BIT8);
1447 }
1448
1449 // Emit the element type.
1450 addType(Buffer, resolve(CTy->getBaseType()));
1451
1452 // Get an anonymous type for index type.
1453 // FIXME: This type should be passed down from the front end
1454 // as different languages may have different sizes for indexes.
1455 DIE *IdxTy = getIndexTyDie();
1456
1457 // Add subranges to array type.
1458 DINodeArray Elements = CTy->getElements();
1459 for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
1460 // FIXME: Should this really be such a loose cast?
1461 if (auto *Element = dyn_cast_or_null<DINode>(Elements[i]))
1462 if (Element->getTag() == dwarf::DW_TAG_subrange_type)
1463 constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
1464 }
1465}
1466
1467void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
1468 const DIType *DTy = resolve(CTy->getBaseType());
1469 bool IsUnsigned = DTy && isUnsignedDIType(DD, DTy);
1470 if (DTy) {
1471 if (DD->getDwarfVersion() >= 3)
1472 addType(Buffer, DTy);
1473 if (DD->getDwarfVersion() >= 4 && (CTy->getFlags() & DINode::FlagFixedEnum))
1474 addFlag(Buffer, dwarf::DW_AT_enum_class);
1475 }
1476
1477 DINodeArray Elements = CTy->getElements();
1478
1479 // Add enumerators to enumeration type.
1480 for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
1481 auto *Enum = dyn_cast_or_null<DIEnumerator>(Elements[i]);
1482 if (Enum) {
1483 DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
1484 StringRef Name = Enum->getName();
1485 addString(Enumerator, dwarf::DW_AT_name, Name);
1486 auto Value = static_cast<uint64_t>(Enum->getValue());
1487 addConstantValue(Enumerator, IsUnsigned, Value);
1488 }
1489 }
1490}
1491
1492void DwarfUnit::constructContainingTypeDIEs() {
1493 for (auto CI = ContainingTypeMap.begin(), CE = ContainingTypeMap.end();
1494 CI != CE; ++CI) {
1495 DIE &SPDie = *CI->first;
1496 const DINode *D = CI->second;
1497 if (!D)
1498 continue;
1499 DIE *NDie = getDIE(D);
1500 if (!NDie)
1501 continue;
1502 addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1503 }
1504}
1505
1506DIE &DwarfUnit::constructMemberDIE(DIE &Buffer, const DIDerivedType *DT) {
1507 DIE &MemberDie = createAndAddDIE(DT->getTag(), Buffer);
1508 StringRef Name = DT->getName();
1509 if (!Name.empty())
1510 addString(MemberDie, dwarf::DW_AT_name, Name);
1511
1512 if (DIType *Resolved = resolve(DT->getBaseType()))
1513 addType(MemberDie, Resolved);
1514
1515 addSourceLine(MemberDie, DT);
1516
1517 if (DT->getTag() == dwarf::DW_TAG_inheritance && DT->isVirtual()) {
1518
1519 // For C++, virtual base classes are not at fixed offset. Use following
1520 // expression to extract appropriate offset from vtable.
1521 // BaseAddr = ObAddr + *((*ObAddr) - Offset)
1522
1523 DIELoc *VBaseLocationDie = new (DIEValueAllocator) DIELoc;
1524 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1525 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1526 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1527 addUInt(*VBaseLocationDie, dwarf::DW_FORM_udata, DT->getOffsetInBits());
1528 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1529 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1530 addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1531
1532 addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1533 } else {
1534 uint64_t Size = DT->getSizeInBits();
1535 uint64_t FieldSize = DD->getBaseTypeSize(DT);
1536 uint32_t AlignInBytes = DT->getAlignInBytes();
1537 uint64_t OffsetInBytes;
1538
1539 bool IsBitfield = FieldSize && Size != FieldSize;
1540 if (IsBitfield) {
1541 // Handle bitfield, assume bytes are 8 bits.
1542 if (DD->useDWARF2Bitfields())
1543 addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
1544 addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
1545
1546 uint64_t Offset = DT->getOffsetInBits();
1547 // We can't use DT->getAlignInBits() here: AlignInBits for member type
1548 // is non-zero if and only if alignment was forced (e.g. _Alignas()),
1549 // which can't be done with bitfields. Thus we use FieldSize here.
1550 uint32_t AlignInBits = FieldSize;
1551 uint32_t AlignMask = ~(AlignInBits - 1);
1552 // The bits from the start of the storage unit to the start of the field.
1553 uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1554 // The byte offset of the field's aligned storage unit inside the struct.
1555 OffsetInBytes = (Offset - StartBitOffset) / 8;
1556
1557 if (DD->useDWARF2Bitfields()) {
1558 uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1559 uint64_t FieldOffset = (HiMark - FieldSize);
1560 Offset -= FieldOffset;
1561
1562 // Maybe we need to work from the other end.
1563 if (Asm->getDataLayout().isLittleEndian())
1564 Offset = FieldSize - (Offset + Size);
1565
1566 addUInt(MemberDie, dwarf::DW_AT_bit_offset, None, Offset);
1567 OffsetInBytes = FieldOffset >> 3;
1568 } else {
1569 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
1570 }
1571 } else {
1572 // This is not a bitfield.
1573 OffsetInBytes = DT->getOffsetInBits() / 8;
1574 if (AlignInBytes)
1575 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1576 AlignInBytes);
1577 }
1578
1579 if (DD->getDwarfVersion() <= 2) {
1580 DIELoc *MemLocationDie = new (DIEValueAllocator) DIELoc;
1581 addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
1582 addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
1583 addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1584 } else if (!IsBitfield || DD->useDWARF2Bitfields())
1585 addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
1586 OffsetInBytes);
1587 }
1588
1589 if (DT->isProtected())
1590 addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1591 dwarf::DW_ACCESS_protected);
1592 else if (DT->isPrivate())
1593 addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1594 dwarf::DW_ACCESS_private);
1595 // Otherwise C++ member and base classes are considered public.
1596 else if (DT->isPublic())
1597 addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1598 dwarf::DW_ACCESS_public);
1599 if (DT->isVirtual())
1600 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
1601 dwarf::DW_VIRTUALITY_virtual);
1602
1603 // Objective-C properties.
1604 if (DINode *PNode = DT->getObjCProperty())
1605 if (DIE *PDie = getDIE(PNode))
1606 MemberDie.addValue(DIEValueAllocator, dwarf::DW_AT_APPLE_property,
1607 dwarf::DW_FORM_ref4, DIEEntry(*PDie));
1608
1609 if (DT->isArtificial())
1610 addFlag(MemberDie, dwarf::DW_AT_artificial);
1611
1612 return MemberDie;
1613}
1614
1615DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
1616 if (!DT)
1617 return nullptr;
1618
1619 // Construct the context before querying for the existence of the DIE in case
1620 // such construction creates the DIE.
1621 DIE *ContextDIE = getOrCreateContextDIE(resolve(DT->getScope()));
1622 assert(dwarf::isType(ContextDIE->getTag()) &&(static_cast <bool> (dwarf::isType(ContextDIE->getTag
()) && "Static member should belong to a type.") ? void
(0) : __assert_fail ("dwarf::isType(ContextDIE->getTag()) && \"Static member should belong to a type.\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1623, __extension__ __PRETTY_FUNCTION__))
1623 "Static member should belong to a type.")(static_cast <bool> (dwarf::isType(ContextDIE->getTag
()) && "Static member should belong to a type.") ? void
(0) : __assert_fail ("dwarf::isType(ContextDIE->getTag()) && \"Static member should belong to a type.\""
, "/build/llvm-toolchain-snapshot-7~svn329677/lib/CodeGen/AsmPrinter/DwarfUnit.cpp"
, 1623, __extension__ __PRETTY_FUNCTION__))
;
1624
1625 if (DIE *StaticMemberDIE = getDIE(DT))
1626 return StaticMemberDIE;
1627
1628 DIE &StaticMemberDIE = createAndAddDIE(DT->getTag(), *ContextDIE, DT);
1629
1630 const DIType *Ty = resolve(DT->getBaseType());
1631
1632 addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
1633 addType(StaticMemberDIE, Ty);
1634 addSourceLine(StaticMemberDIE, DT);
1635 addFlag(StaticMemberDIE, dwarf::DW_AT_external);
1636 addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
1637
1638 // FIXME: We could omit private if the parent is a class_type, and
1639 // public if the parent is something else.
1640 if (DT->isProtected())
1641 addUInt(StaticMemberDIE, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1642 dwarf::DW_ACCESS_protected);
1643 else if (DT->isPrivate())
1644 addUInt(StaticMemberDIE, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1645 dwarf::DW_ACCESS_private);
1646 else if (DT->isPublic())
1647 addUInt(StaticMemberDIE, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
1648 dwarf::DW_ACCESS_public);
1649
1650 if (const ConstantInt *CI = dyn_cast_or_null<ConstantInt>(DT->getConstant()))
1651 addConstantValue(StaticMemberDIE, CI, Ty);
1652 if (const ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT->getConstant()))
1653 addConstantFPValue(StaticMemberDIE, CFP);
1654
1655 if (uint32_t AlignInBytes = DT->getAlignInBytes())
1656 addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1657 AlignInBytes);
1658
1659 return &StaticMemberDIE;
1660}
1661
1662void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) {
1663 // Emit size of content not including length itself
1664 Asm->OutStreamer->AddComment("Length of Unit");
1665 Asm->emitInt32(getHeaderSize() + getUnitDie().getSize());
1666
1667 Asm->OutStreamer->AddComment("DWARF version number");
1668 unsigned Version = DD->getDwarfVersion();
1669 Asm->emitInt16(Version);
1670
1671 // DWARF v5 reorders the address size and adds a unit type.
1672 if (Version >= 5) {
1673 Asm->OutStreamer->AddComment("DWARF Unit Type");
1674 Asm->emitInt8(UT);
1675 Asm->OutStreamer->AddComment("Address Size (in bytes)");
1676 Asm->emitInt8(Asm->MAI->getCodePointerSize());
1677 }
1678
1679 // We share one abbreviations table across all units so it's always at the
1680 // start of the section. Use a relocatable offset where needed to ensure
1681 // linking doesn't invalidate that offset.
1682 Asm->OutStreamer->AddComment("Offset Into Abbrev. Section");
1683 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
1684 if (UseOffsets)
1685 Asm->emitInt32(0);
1686 else
1687 Asm->emitDwarfSymbolReference(
1688 TLOF.getDwarfAbbrevSection()->getBeginSymbol(), false);
1689
1690 if (Version <= 4) {
1691 Asm->OutStreamer->AddComment("Address Size (in bytes)");
1692 Asm->emitInt8(Asm->MAI->getCodePointerSize());
1693 }
1694}
1695
1696void DwarfTypeUnit::emitHeader(bool UseOffsets) {
1697 DwarfUnit::emitCommonHeader(UseOffsets,
1698 DD->useSplitDwarf() ? dwarf::DW_UT_split_type
1699 : dwarf::DW_UT_type);
1700 Asm->OutStreamer->AddComment("Type Signature");
1701 Asm->OutStreamer->EmitIntValue(TypeSignature, sizeof(TypeSignature));
1702 Asm->OutStreamer->AddComment("Type DIE Offset");
1703 // In a skeleton type unit there is no type DIE so emit a zero offset.
1704 Asm->OutStreamer->EmitIntValue(Ty ? Ty->getOffset() : 0,
1705 sizeof(Ty->getOffset()));
1706}
1707
1708DIE::value_iterator
1709DwarfUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
1710 const MCSymbol *Hi, const MCSymbol *Lo) {
1711 return Die.addValue(DIEValueAllocator, Attribute,
1712 DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
1713 : dwarf::DW_FORM_data4,
1714 new (DIEValueAllocator) DIEDelta(Hi, Lo));
1715}
1716
1717DIE::value_iterator
1718DwarfUnit::addSectionLabel(DIE &Die, dwarf::Attribute Attribute,
1719 const MCSymbol *Label, const MCSymbol *Sec) {
1720 if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
1721 return addLabel(Die, Attribute,
1722 DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
1723 : dwarf::DW_FORM_data4,
1724 Label);
1725 return addSectionDelta(Die, Attribute, Label, Sec);
1726}
1727
1728bool DwarfTypeUnit::isDwoUnit() const {
1729 // Since there are no skeleton type units, all type units are dwo type units
1730 // when split DWARF is being used.
1731 return DD->useSplitDwarf();
1732}
1733
1734void DwarfTypeUnit::addGlobalName(StringRef Name, const DIE &Die,
1735 const DIScope *Context) {
1736 getCU().addGlobalNameForTypeUnit(Name, Context);
1737}
1738
1739void DwarfTypeUnit::addGlobalType(const DIType *Ty, const DIE &Die,
1740 const DIScope *Context) {
1741 getCU().addGlobalTypeUnitType(Ty, Context);
1742}
1743
1744const MCSymbol *DwarfUnit::getCrossSectionRelativeBaseAddress() const {
1745 if (!Asm->MAI->doesDwarfUseRelocationsAcrossSections())
1746 return nullptr;
1747 if (isDwoUnit())
1748 return nullptr;
1749 return getSection()->getBeginSymbol();
1750}
1751
1752void DwarfUnit::addStringOffsetsStart() {
1753 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
1754 addSectionLabel(getUnitDie(), dwarf::DW_AT_str_offsets_base,
1755 DU->getStringOffsetsStartSym(),
1756 TLOF.getDwarfStrOffSection()->getBeginSymbol());
1757}

/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h

1//===- llvm/IR/DebugInfoMetadata.h - Debug info metadata --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Declarations for metadata specific to debug info.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_DEBUGINFOMETADATA_H
15#define LLVM_IR_DEBUGINFOMETADATA_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/BitmaskEnum.h"
19#include "llvm/ADT/None.h"
20#include "llvm/ADT/Optional.h"
21#include "llvm/ADT/PointerUnion.h"
22#include "llvm/ADT/STLExtras.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringRef.h"
25#include "llvm/ADT/iterator_range.h"
26#include "llvm/BinaryFormat/Dwarf.h"
27#include "llvm/IR/Constants.h"
28#include "llvm/IR/Metadata.h"
29#include "llvm/Support/Casting.h"
30#include <cassert>
31#include <climits>
32#include <cstddef>
33#include <cstdint>
34#include <iterator>
35#include <type_traits>
36#include <vector>
37
38// Helper macros for defining get() overrides.
39#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
40#define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
41#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)static CLASS *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
(FORMAL)) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(
ARGS), Distinct); } static TempCLASS getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { return TempCLASS
( getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)
); }
\
42 static CLASS *getDistinct(LLVMContext &Context, \
43 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
44 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct); \
45 } \
46 static Temp##CLASS getTemporary(LLVMContext &Context, \
47 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
48 return Temp##CLASS( \
49 getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)); \
50 }
51#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS) \
52 static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
53 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued); \
54 } \
55 static CLASS *getIfExists(LLVMContext &Context, \
56 DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
57 return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued, \
58 /* ShouldCreate */ false); \
59 } \
60 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)static CLASS *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
(FORMAL)) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(
ARGS), Distinct); } static TempCLASS getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { return TempCLASS
( getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)
); }
61
62namespace llvm {
63
64/// Holds a subclass of DINode.
65///
66/// FIXME: This class doesn't currently make much sense. Previously it was a
67/// union beteen MDString (for ODR-uniqued types) and things like DIType. To
68/// support CodeView work, it wasn't deleted outright when MDString-based type
69/// references were deleted; we'll soon need a similar concept for CodeView
70/// DITypeIndex.
71template <class T> class TypedDINodeRef {
72 const Metadata *MD = nullptr;
73
74public:
75 TypedDINodeRef() = default;
76 TypedDINodeRef(std::nullptr_t) {}
77 TypedDINodeRef(const T *MD) : MD(MD) {}
78
79 explicit TypedDINodeRef(const Metadata *MD) : MD(MD) {
80 assert((!MD || isa<T>(MD)) && "Expected valid type ref")(static_cast <bool> ((!MD || isa<T>(MD)) &&
"Expected valid type ref") ? void (0) : __assert_fail ("(!MD || isa<T>(MD)) && \"Expected valid type ref\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 80, __extension__ __PRETTY_FUNCTION__))
;
81 }
82
83 template <class U>
84 TypedDINodeRef(
85 const TypedDINodeRef<U> &X,
86 typename std::enable_if<std::is_convertible<U *, T *>::value>::type * =
87 nullptr)
88 : MD(X) {}
89
90 operator Metadata *() const { return const_cast<Metadata *>(MD); }
91
92 T *resolve() const { return const_cast<T *>(cast_or_null<T>(MD)); }
93
94 bool operator==(const TypedDINodeRef<T> &X) const { return MD == X.MD; }
95 bool operator!=(const TypedDINodeRef<T> &X) const { return MD != X.MD; }
96};
97
98using DINodeRef = TypedDINodeRef<DINode>;
99using DIScopeRef = TypedDINodeRef<DIScope>;
100using DITypeRef = TypedDINodeRef<DIType>;
101
102class DITypeRefArray {
103 const MDTuple *N = nullptr;
104
105public:
106 DITypeRefArray() = default;
107 DITypeRefArray(const MDTuple *N) : N(N) {}
108
109 explicit operator bool() const { return get(); }
110 explicit operator MDTuple *() const { return get(); }
111
112 MDTuple *get() const { return const_cast<MDTuple *>(N); }
113 MDTuple *operator->() const { return get(); }
114 MDTuple &operator*() const { return *get(); }
115
116 // FIXME: Fix callers and remove condition on N.
117 unsigned size() const { return N ? N->getNumOperands() : 0u; }
118 DITypeRef operator[](unsigned I) const { return DITypeRef(N->getOperand(I)); }
119
120 class iterator : std::iterator<std::input_iterator_tag, DITypeRef,
121 std::ptrdiff_t, void, DITypeRef> {
122 MDNode::op_iterator I = nullptr;
123
124 public:
125 iterator() = default;
126 explicit iterator(MDNode::op_iterator I) : I(I) {}
127
128 DITypeRef operator*() const { return DITypeRef(*I); }
129
130 iterator &operator++() {
131 ++I;
132 return *this;
133 }
134
135 iterator operator++(int) {
136 iterator Temp(*this);
137 ++I;
138 return Temp;
139 }
140
141 bool operator==(const iterator &X) const { return I == X.I; }
142 bool operator!=(const iterator &X) const { return I != X.I; }
143 };
144
145 // FIXME: Fix callers and remove condition on N.
146 iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
147 iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
148};
149
150/// Tagged DWARF-like metadata node.
151///
152/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
153/// defined in llvm/BinaryFormat/Dwarf.h). Called \a DINode because it's
154/// potentially used for non-DWARF output.
155class DINode : public MDNode {
156 friend class LLVMContextImpl;
157 friend class MDNode;
158
159protected:
160 DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
161 ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
162 : MDNode(C, ID, Storage, Ops1, Ops2) {
163 assert(Tag < 1u << 16)(static_cast <bool> (Tag < 1u << 16) ? void (0
) : __assert_fail ("Tag < 1u << 16", "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 163, __extension__ __PRETTY_FUNCTION__))
;
164 SubclassData16 = Tag;
165 }
166 ~DINode() = default;
167
168 template <class Ty> Ty *getOperandAs(unsigned I) const {
169 return cast_or_null<Ty>(getOperand(I));
170 }
171
172 StringRef getStringOperand(unsigned I) const {
173 if (auto *S = getOperandAs<MDString>(I))
174 return S->getString();
175 return StringRef();
176 }
177
178 static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
179 if (S.empty())
180 return nullptr;
181 return MDString::get(Context, S);
182 }
183
184 /// Allow subclasses to mutate the tag.
185 void setTag(unsigned Tag) { SubclassData16 = Tag; }
186
187public:
188 unsigned getTag() const { return SubclassData16; }
189
190 /// Debug info flags.
191 ///
192 /// The three accessibility flags are mutually exclusive and rolled together
193 /// in the first two bits.
194 enum DIFlags : uint32_t {
195#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
196#define DI_FLAG_LARGEST_NEEDED
197#include "llvm/IR/DebugInfoFlags.def"
198 FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic,
199 FlagPtrToMemberRep = FlagSingleInheritance | FlagMultipleInheritance |
200 FlagVirtualInheritance,
201 LLVM_MARK_AS_BITMASK_ENUM(FlagLargest)LLVM_BITMASK_LARGEST_ENUMERATOR = FlagLargest
202 };
203
204 static DIFlags getFlag(StringRef Flag);
205 static StringRef getFlagString(DIFlags Flag);
206
207 /// Split up a flags bitfield.
208 ///
209 /// Split \c Flags into \c SplitFlags, a vector of its components. Returns
210 /// any remaining (unrecognized) bits.
211 static DIFlags splitFlags(DIFlags Flags,
212 SmallVectorImpl<DIFlags> &SplitFlags);
213
214 static bool classof(const Metadata *MD) {
215 switch (MD->getMetadataID()) {
216 default:
217 return false;
218 case GenericDINodeKind:
219 case DISubrangeKind:
220 case DIEnumeratorKind:
221 case DIBasicTypeKind:
222 case DIDerivedTypeKind:
223 case DICompositeTypeKind:
224 case DISubroutineTypeKind:
225 case DIFileKind:
226 case DICompileUnitKind:
227 case DISubprogramKind:
228 case DILexicalBlockKind:
229 case DILexicalBlockFileKind:
230 case DINamespaceKind:
231 case DITemplateTypeParameterKind:
232 case DITemplateValueParameterKind:
233 case DIGlobalVariableKind:
234 case DILocalVariableKind:
235 case DIObjCPropertyKind:
236 case DIImportedEntityKind:
237 case DIModuleKind:
238 return true;
239 }
240 }
241};
242
243template <class T> struct simplify_type<const TypedDINodeRef<T>> {
244 using SimpleType = Metadata *;
245
246 static SimpleType getSimplifiedValue(const TypedDINodeRef<T> &MD) {
247 return MD;
248 }
249};
250
251template <class T>
252struct simplify_type<TypedDINodeRef<T>>
253 : simplify_type<const TypedDINodeRef<T>> {};
254
255/// Generic tagged DWARF-like metadata node.
256///
257/// An un-specialized DWARF-like metadata node. The first operand is a
258/// (possibly empty) null-separated \a MDString header that contains arbitrary
259/// fields. The remaining operands are \a dwarf_operands(), and are pointers
260/// to other metadata.
261class GenericDINode : public DINode {
262 friend class LLVMContextImpl;
263 friend class MDNode;
264
265 GenericDINode(LLVMContext &C, StorageType Storage, unsigned Hash,
266 unsigned Tag, ArrayRef<Metadata *> Ops1,
267 ArrayRef<Metadata *> Ops2)
268 : DINode(C, GenericDINodeKind, Storage, Tag, Ops1, Ops2) {
269 setHash(Hash);
270 }
271 ~GenericDINode() { dropAllReferences(); }
272
273 void setHash(unsigned Hash) { SubclassData32 = Hash; }
274 void recalculateHash();
275
276 static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
277 StringRef Header, ArrayRef<Metadata *> DwarfOps,
278 StorageType Storage, bool ShouldCreate = true) {
279 return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
280 DwarfOps, Storage, ShouldCreate);
281 }
282
283 static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
284 MDString *Header, ArrayRef<Metadata *> DwarfOps,
285 StorageType Storage, bool ShouldCreate = true);
286
287 TempGenericDINode cloneImpl() const {
288 return getTemporary(
289 getContext(), getTag(), getHeader(),
290 SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
291 }
292
293public:
294 unsigned getHash() const { return SubclassData32; }
295
296 DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, StringRef Header,
297 ArrayRef<Metadata *> DwarfOps),
298 (Tag, Header, DwarfOps))
299 DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, MDString *Header,
300 ArrayRef<Metadata *> DwarfOps),
301 (Tag, Header, DwarfOps))
302
303 /// Return a (temporary) clone of this.
304 TempGenericDINode clone() const { return cloneImpl(); }
305
306 unsigned getTag() const { return SubclassData16; }
307 StringRef getHeader() const { return getStringOperand(0); }
308 MDString *getRawHeader() const { return getOperandAs<MDString>(0); }
309
310 op_iterator dwarf_op_begin() const { return op_begin() + 1; }
311 op_iterator dwarf_op_end() const { return op_end(); }
312 op_range dwarf_operands() const {
313 return op_range(dwarf_op_begin(), dwarf_op_end());
314 }
315
316 unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
317 const MDOperand &getDwarfOperand(unsigned I) const {
318 return getOperand(I + 1);
319 }
320 void replaceDwarfOperandWith(unsigned I, Metadata *New) {
321 replaceOperandWith(I + 1, New);
322 }
323
324 static bool classof(const Metadata *MD) {
325 return MD->getMetadataID() == GenericDINodeKind;
326 }
327};
328
329/// Array subrange.
330///
331/// TODO: Merge into node for DW_TAG_array_type, which should have a custom
332/// type.
333class DISubrange : public DINode {
334 friend class LLVMContextImpl;
335 friend class MDNode;
336
337 int64_t LowerBound;
338
339 DISubrange(LLVMContext &C, StorageType Storage, Metadata *Node,
340 int64_t LowerBound, ArrayRef<Metadata *> Ops)
341 : DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops),
342 LowerBound(LowerBound) {}
343
344 ~DISubrange() = default;
345
346 static DISubrange *getImpl(LLVMContext &Context, int64_t Count,
347 int64_t LowerBound, StorageType Storage,
348 bool ShouldCreate = true);
349
350 static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
351 int64_t LowerBound, StorageType Storage,
352 bool ShouldCreate = true);
353
354 TempDISubrange cloneImpl() const {
355 return getTemporary(getContext(), getRawCountNode(), getLowerBound());
356 }
357
358public:
359 DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
360 (Count, LowerBound))
361
362 DEFINE_MDNODE_GET(DISubrange, (Metadata *CountNode, int64_t LowerBound = 0),
363 (CountNode, LowerBound))
364
365 TempDISubrange clone() const { return cloneImpl(); }
366
367 int64_t getLowerBound() const { return LowerBound; }
368
369 Metadata *getRawCountNode() const {
370 return getOperand(0).get();
371 }
372
373 typedef PointerUnion<ConstantInt*, DIVariable*> CountType;
374
375 CountType getCount() const {
376 if (auto *MD = dyn_cast<ConstantAsMetadata>(getRawCountNode()))
377 return CountType(cast<ConstantInt>(MD->getValue()));
378
379 if (auto *DV = dyn_cast<DIVariable>(getRawCountNode()))
380 return CountType(DV);
381
382 return CountType();
383 }
384
385 static bool classof(const Metadata *MD) {
386 return MD->getMetadataID() == DISubrangeKind;
387 }
388};
389
390/// Enumeration value.
391///
392/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
393/// longer creates a type cycle.
394class DIEnumerator : public DINode {
395 friend class LLVMContextImpl;
396 friend class MDNode;
397
398 int64_t Value;
399 DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
400 bool IsUnsigned, ArrayRef<Metadata *> Ops)
401 : DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
402 Value(Value) {
403 SubclassData32 = IsUnsigned;
404 }
405 ~DIEnumerator() = default;
406
407 static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
408 bool IsUnsigned, StringRef Name,
409 StorageType Storage, bool ShouldCreate = true) {
410 return getImpl(Context, Value, IsUnsigned,
411 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
412 }
413 static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
414 bool IsUnsigned, MDString *Name,
415 StorageType Storage, bool ShouldCreate = true);
416
417 TempDIEnumerator cloneImpl() const {
418 return getTemporary(getContext(), getValue(), isUnsigned(), getName());
419 }
420
421public:
422 DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, StringRef Name),
423 (Value, IsUnsigned, Name))
424 DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, MDString *Name),
425 (Value, IsUnsigned, Name))
426
427 TempDIEnumerator clone() const { return cloneImpl(); }
428
429 int64_t getValue() const { return Value; }
430 bool isUnsigned() const { return SubclassData32; }
431 StringRef getName() const { return getStringOperand(0); }
432
433 MDString *getRawName() const { return getOperandAs<MDString>(0); }
434
435 static bool classof(const Metadata *MD) {
436 return MD->getMetadataID() == DIEnumeratorKind;
437 }
438};
439
440/// Base class for scope-like contexts.
441///
442/// Base class for lexical scopes and types (which are also declaration
443/// contexts).
444///
445/// TODO: Separate the concepts of declaration contexts and lexical scopes.
446class DIScope : public DINode {
447protected:
448 DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
449 ArrayRef<Metadata *> Ops)
450 : DINode(C, ID, Storage, Tag, Ops) {}
451 ~DIScope() = default;
452
453public:
454 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
455
456 inline StringRef getFilename() const;
457 inline StringRef getDirectory() const;
458 inline Optional<StringRef> getSource() const;
459
460 StringRef getName() const;
461 DIScopeRef getScope() const;
462
463 /// Return the raw underlying file.
464 ///
465 /// A \a DIFile is a \a DIScope, but it doesn't point at a separate file (it
466 /// \em is the file). If \c this is an \a DIFile, we need to return \c this.
467 /// Otherwise, return the first operand, which is where all other subclasses
468 /// store their file pointer.
469 Metadata *getRawFile() const {
470 return isa<DIFile>(this) ? const_cast<DIScope *>(this)
471 : static_cast<Metadata *>(getOperand(0));
472 }
473
474 static bool classof(const Metadata *MD) {
475 switch (MD->getMetadataID()) {
476 default:
477 return false;
478 case DIBasicTypeKind:
479 case DIDerivedTypeKind:
480 case DICompositeTypeKind:
481 case DISubroutineTypeKind:
482 case DIFileKind:
483 case DICompileUnitKind:
484 case DISubprogramKind:
485 case DILexicalBlockKind:
486 case DILexicalBlockFileKind:
487 case DINamespaceKind:
488 case DIModuleKind:
489 return true;
490 }
491 }
492};
493
494/// File.
495///
496/// TODO: Merge with directory/file node (including users).
497/// TODO: Canonicalize paths on creation.
498class DIFile : public DIScope {
499 friend class LLVMContextImpl;
500 friend class MDNode;
501
502public:
503 /// Which algorithm (e.g. MD5) a checksum was generated with.
504 ///
505 /// The encoding is explicit because it is used directly in Bitcode. The
506 /// value 0 is reserved to indicate the absence of a checksum in Bitcode.
507 enum ChecksumKind {
508 // The first variant was originally CSK_None, encoded as 0. The new
509 // internal representation removes the need for this by wrapping the
510 // ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
511 // encoding is reserved.
512 CSK_MD5 = 1,
513 CSK_SHA1 = 2,
514 CSK_Last = CSK_SHA1 // Should be last enumeration.
515 };
516
517 /// A single checksum, represented by a \a Kind and a \a Value (a string).
518 template <typename T>
519 struct ChecksumInfo {
520 /// The kind of checksum which \a Value encodes.
521 ChecksumKind Kind;
522 /// The string value of the checksum.
523 T Value;
524
525 ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
526 ~ChecksumInfo() = default;
527 bool operator==(const ChecksumInfo<T> &X) const {
528 return Kind == X.Kind && Value == X.Value;
529 }
530 bool operator!=(const ChecksumInfo<T> &X) const { return !(*this == X); }
531 StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
532 };
533
534private:
535 Optional<ChecksumInfo<MDString *>> Checksum;
536 Optional<MDString *> Source;
537
538 DIFile(LLVMContext &C, StorageType Storage,
539 Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
540 ArrayRef<Metadata *> Ops)
541 : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
542 Checksum(CS), Source(Src) {}
543 ~DIFile() = default;
544
545 static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
546 StringRef Directory,
547 Optional<ChecksumInfo<StringRef>> CS,
548 Optional<StringRef> Source,
549 StorageType Storage, bool ShouldCreate = true) {
550 Optional<ChecksumInfo<MDString *>> MDChecksum;
551 if (CS)
552 MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
553 return getImpl(Context, getCanonicalMDString(Context, Filename),
554 getCanonicalMDString(Context, Directory), MDChecksum,
555 Source ? Optional<MDString *>(getCanonicalMDString(Context, *Source)) : None,
556 Storage, ShouldCreate);
557 }
558 static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
559 MDString *Directory,
560 Optional<ChecksumInfo<MDString *>> CS,
561 Optional<MDString *> Source, StorageType Storage,
562 bool ShouldCreate = true);
563
564 TempDIFile cloneImpl() const {
565 return getTemporary(getContext(), getFilename(), getDirectory(),
566 getChecksum(), getSource());
567 }
568
569public:
570 DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory,
571 Optional<ChecksumInfo<StringRef>> CS = None,
572 Optional<StringRef> Source = None),
573 (Filename, Directory, CS, Source))
574 DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory,
575 Optional<ChecksumInfo<MDString *>> CS = None,
576 Optional<MDString *> Source = None),
577 (Filename, Directory, CS, Source))
578
579 TempDIFile clone() const { return cloneImpl(); }
580
581 StringRef getFilename() const { return getStringOperand(0); }
582 StringRef getDirectory() const { return getStringOperand(1); }
583 Optional<ChecksumInfo<StringRef>> getChecksum() const {
584 Optional<ChecksumInfo<StringRef>> StringRefChecksum;
585 if (Checksum)
586 StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
587 return StringRefChecksum;
588 }
589 Optional<StringRef> getSource() const {
590 return Source ? Optional<StringRef>((*Source)->getString()) : None;
591 }
592
593 MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
594 MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
595 Optional<ChecksumInfo<MDString *>> getRawChecksum() const { return Checksum; }
596 Optional<MDString *> getRawSource() const { return Source; }
597
598 static StringRef getChecksumKindAsString(ChecksumKind CSKind);
599 static Optional<ChecksumKind> getChecksumKind(StringRef CSKindStr);
600
601 static bool classof(const Metadata *MD) {
602 return MD->getMetadataID() == DIFileKind;
603 }
604};
605
606StringRef DIScope::getFilename() const {
607 if (auto *F = getFile())
608 return F->getFilename();
609 return "";
610}
611
612StringRef DIScope::getDirectory() const {
613 if (auto *F = getFile())
614 return F->getDirectory();
615 return "";
616}
617
618Optional<StringRef> DIScope::getSource() const {
619 if (auto *F = getFile())
620 return F->getSource();
621 return None;
622}
623
624/// Base class for types.
625///
626/// TODO: Remove the hardcoded name and context, since many types don't use
627/// them.
628/// TODO: Split up flags.
629class DIType : public DIScope {
630 unsigned Line;
631 DIFlags Flags;
632 uint64_t SizeInBits;
633 uint64_t OffsetInBits;
634 uint32_t AlignInBits;
635
636protected:
637 DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
638 unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
639 uint64_t OffsetInBits, DIFlags Flags, ArrayRef<Metadata *> Ops)
640 : DIScope(C, ID, Storage, Tag, Ops) {
641 init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
642 }
643 ~DIType() = default;
644
645 void init(unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
646 uint64_t OffsetInBits, DIFlags Flags) {
647 this->Line = Line;
648 this->Flags = Flags;
649 this->SizeInBits = SizeInBits;
650 this->AlignInBits = AlignInBits;
651 this->OffsetInBits = OffsetInBits;
652 }
653
654 /// Change fields in place.
655 void mutate(unsigned Tag, unsigned Line, uint64_t SizeInBits,
656 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags) {
657 assert(isDistinct() && "Only distinct nodes can mutate")(static_cast <bool> (isDistinct() && "Only distinct nodes can mutate"
) ? void (0) : __assert_fail ("isDistinct() && \"Only distinct nodes can mutate\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 657, __extension__ __PRETTY_FUNCTION__))
;
658 setTag(Tag);
659 init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
660 }
661
662public:
663 TempDIType clone() const {
664 return TempDIType(cast<DIType>(MDNode::clone().release()));
665 }
666
667 unsigned getLine() const { return Line; }
668 uint64_t getSizeInBits() const { return SizeInBits; }
669 uint32_t getAlignInBits() const { return AlignInBits; }
670 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT8; }
671 uint64_t getOffsetInBits() const { return OffsetInBits; }
672 DIFlags getFlags() const { return Flags; }
673
674 DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
675 StringRef getName() const { return getStringOperand(2); }
676
677
678 Metadata *getRawScope() const { return getOperand(1); }
679 MDString *getRawName() const { return getOperandAs<MDString>(2); }
680
681 void setFlags(DIFlags NewFlags) {
682 assert(!isUniqued() && "Cannot set flags on uniqued nodes")(static_cast <bool> (!isUniqued() && "Cannot set flags on uniqued nodes"
) ? void (0) : __assert_fail ("!isUniqued() && \"Cannot set flags on uniqued nodes\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 682, __extension__ __PRETTY_FUNCTION__))
;
683 Flags = NewFlags;
684 }
685
686 bool isPrivate() const {
687 return (getFlags() & FlagAccessibility) == FlagPrivate;
688 }
689 bool isProtected() const {
690 return (getFlags() & FlagAccessibility) == FlagProtected;
691 }
692 bool isPublic() const {
693 return (getFlags() & FlagAccessibility) == FlagPublic;
694 }
695 bool isForwardDecl() const { return getFlags() & FlagFwdDecl; }
696 bool isAppleBlockExtension() const { return getFlags() & FlagAppleBlock; }
697 bool isBlockByrefStruct() const { return getFlags() & FlagBlockByrefStruct; }
698 bool isVirtual() const { return getFlags() & FlagVirtual; }
699 bool isArtificial() const { return getFlags() & FlagArtificial; }
700 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
701 bool isObjcClassComplete() const {
702 return getFlags() & FlagObjcClassComplete;
703 }
704 bool isVector() const { return getFlags() & FlagVector; }
705 bool isBitField() const { return getFlags() & FlagBitField; }
706 bool isStaticMember() const { return getFlags() & FlagStaticMember; }
707 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
708 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
709 bool isTypePassByValue() const { return getFlags() & FlagTypePassByValue; }
710 bool isTypePassByReference() const {
711 return getFlags() & FlagTypePassByReference;
712 }
713
714 static bool classof(const Metadata *MD) {
715 switch (MD->getMetadataID()) {
716 default:
717 return false;
718 case DIBasicTypeKind:
719 case DIDerivedTypeKind:
720 case DICompositeTypeKind:
721 case DISubroutineTypeKind:
722 return true;
723 }
724 }
725};
726
727/// Basic type, like 'int' or 'float'.
728///
729/// TODO: Split out DW_TAG_unspecified_type.
730/// TODO: Drop unused accessors.
731class DIBasicType : public DIType {
732 friend class LLVMContextImpl;
733 friend class MDNode;
734
735 unsigned Encoding;
736
737 DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
738 uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
739 ArrayRef<Metadata *> Ops)
740 : DIType(C, DIBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
741 FlagZero, Ops),
742 Encoding(Encoding) {}
743 ~DIBasicType() = default;
744
745 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
746 StringRef Name, uint64_t SizeInBits,
747 uint32_t AlignInBits, unsigned Encoding,
748 StorageType Storage, bool ShouldCreate = true) {
749 return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
750 SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
751 }
752 static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
753 MDString *Name, uint64_t SizeInBits,
754 uint32_t AlignInBits, unsigned Encoding,
755 StorageType Storage, bool ShouldCreate = true);
756
757 TempDIBasicType cloneImpl() const {
758 return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
759 getAlignInBits(), getEncoding());
760 }
761
762public:
763 DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
764 (Tag, Name, 0, 0, 0))
765 DEFINE_MDNODE_GET(DIBasicType,
766 (unsigned Tag, StringRef Name, uint64_t SizeInBits,
767 uint32_t AlignInBits, unsigned Encoding),
768 (Tag, Name, SizeInBits, AlignInBits, Encoding))
769 DEFINE_MDNODE_GET(DIBasicType,
770 (unsigned Tag, MDString *Name, uint64_t SizeInBits,
771 uint32_t AlignInBits, unsigned Encoding),
772 (Tag, Name, SizeInBits, AlignInBits, Encoding))
773
774 TempDIBasicType clone() const { return cloneImpl(); }
775
776 unsigned getEncoding() const { return Encoding; }
777
778 static bool classof(const Metadata *MD) {
779 return MD->getMetadataID() == DIBasicTypeKind;
780 }
781};
782
783/// Derived types.
784///
785/// This includes qualified types, pointers, references, friends, typedefs, and
786/// class members.
787///
788/// TODO: Split out members (inheritance, fields, methods, etc.).
789class DIDerivedType : public DIType {
790 friend class LLVMContextImpl;
791 friend class MDNode;
792
793 /// \brief The DWARF address space of the memory pointed to or referenced by a
794 /// pointer or reference type respectively.
795 Optional<unsigned> DWARFAddressSpace;
796
797 DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
798 unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
799 uint64_t OffsetInBits, Optional<unsigned> DWARFAddressSpace,
800 DIFlags Flags, ArrayRef<Metadata *> Ops)
801 : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits,
802 AlignInBits, OffsetInBits, Flags, Ops),
803 DWARFAddressSpace(DWARFAddressSpace) {}
804 ~DIDerivedType() = default;
805
806 static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
807 StringRef Name, DIFile *File, unsigned Line,
808 DIScopeRef Scope, DITypeRef BaseType,
809 uint64_t SizeInBits, uint32_t AlignInBits,
810 uint64_t OffsetInBits,
811 Optional<unsigned> DWARFAddressSpace,
812 DIFlags Flags, Metadata *ExtraData,
813 StorageType Storage, bool ShouldCreate = true) {
814 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
815 Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
816 DWARFAddressSpace, Flags, ExtraData, Storage, ShouldCreate);
817 }
818 static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
819 MDString *Name, Metadata *File, unsigned Line,
820 Metadata *Scope, Metadata *BaseType,
821 uint64_t SizeInBits, uint32_t AlignInBits,
822 uint64_t OffsetInBits,
823 Optional<unsigned> DWARFAddressSpace,
824 DIFlags Flags, Metadata *ExtraData,
825 StorageType Storage, bool ShouldCreate = true);
826
827 TempDIDerivedType cloneImpl() const {
828 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
829 getScope(), getBaseType(), getSizeInBits(),
830 getAlignInBits(), getOffsetInBits(),
831 getDWARFAddressSpace(), getFlags(), getExtraData());
832 }
833
834public:
835 DEFINE_MDNODE_GET(DIDerivedType,
836 (unsigned Tag, MDString *Name, Metadata *File,
837 unsigned Line, Metadata *Scope, Metadata *BaseType,
838 uint64_t SizeInBits, uint32_t AlignInBits,
839 uint64_t OffsetInBits,
840 Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
841 Metadata *ExtraData = nullptr),
842 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
843 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
844 ExtraData))
845 DEFINE_MDNODE_GET(DIDerivedType,
846 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
847 DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
848 uint32_t AlignInBits, uint64_t OffsetInBits,
849 Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
850 Metadata *ExtraData = nullptr),
851 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
852 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
853 ExtraData))
854
855 TempDIDerivedType clone() const { return cloneImpl(); }
856
857 /// Get the base type this is derived from.
858 DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
859 Metadata *getRawBaseType() const { return getOperand(3); }
860
861 /// \returns The DWARF address space of the memory pointed to or referenced by
862 /// a pointer or reference type respectively.
863 Optional<unsigned> getDWARFAddressSpace() const { return DWARFAddressSpace; }
864
865 /// Get extra data associated with this derived type.
866 ///
867 /// Class type for pointer-to-members, objective-c property node for ivars,
868 /// or global constant wrapper for static members.
869 ///
870 /// TODO: Separate out types that need this extra operand: pointer-to-member
871 /// types and member fields (static members and ivars).
872 Metadata *getExtraData() const { return getRawExtraData(); }
873 Metadata *getRawExtraData() const { return getOperand(4); }
874
875 /// Get casted version of extra data.
876 /// @{
877 DITypeRef getClassType() const {
878 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type)(static_cast <bool> (getTag() == dwarf::DW_TAG_ptr_to_member_type
) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_ptr_to_member_type"
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 878, __extension__ __PRETTY_FUNCTION__))
;
879 return DITypeRef(getExtraData());
880 }
881
882 DIObjCProperty *getObjCProperty() const {
883 return dyn_cast_or_null<DIObjCProperty>(getExtraData());
884 }
885
886 Constant *getStorageOffsetInBits() const {
887 assert(getTag() == dwarf::DW_TAG_member && isBitField())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
isBitField()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && isBitField()"
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 887, __extension__ __PRETTY_FUNCTION__))
;
888 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
889 return C->getValue();
890 return nullptr;
891 }
892
893 Constant *getConstant() const {
894 assert(getTag() == dwarf::DW_TAG_member && isStaticMember())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
isStaticMember()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && isStaticMember()"
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 894, __extension__ __PRETTY_FUNCTION__))
;
895 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
896 return C->getValue();
897 return nullptr;
898 }
899 Constant *getDiscriminantValue() const {
900 assert(getTag() == dwarf::DW_TAG_member && !isStaticMember())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
!isStaticMember()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && !isStaticMember()"
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 900, __extension__ __PRETTY_FUNCTION__))
;
901 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
902 return C->getValue();
903 return nullptr;
904 }
905 /// @}
906
907 static bool classof(const Metadata *MD) {
908 return MD->getMetadataID() == DIDerivedTypeKind;
909 }
910};
911
912/// Composite types.
913///
914/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
915/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
916class DICompositeType : public DIType {
917 friend class LLVMContextImpl;
918 friend class MDNode;
919
920 unsigned RuntimeLang;
921
922 DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
923 unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
924 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
925 ArrayRef<Metadata *> Ops)
926 : DIType(C, DICompositeTypeKind, Storage, Tag, Line, SizeInBits,
927 AlignInBits, OffsetInBits, Flags, Ops),
928 RuntimeLang(RuntimeLang) {}
929 ~DICompositeType() = default;
930
931 /// Change fields in place.
932 void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
933 uint64_t SizeInBits, uint32_t AlignInBits,
934 uint64_t OffsetInBits, DIFlags Flags) {
935 assert(isDistinct() && "Only distinct nodes can mutate")(static_cast <bool> (isDistinct() && "Only distinct nodes can mutate"
) ? void (0) : __assert_fail ("isDistinct() && \"Only distinct nodes can mutate\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 935, __extension__ __PRETTY_FUNCTION__))
;
936 assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate")(static_cast <bool> (getRawIdentifier() && "Only ODR-uniqued nodes should mutate"
) ? void (0) : __assert_fail ("getRawIdentifier() && \"Only ODR-uniqued nodes should mutate\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 936, __extension__ __PRETTY_FUNCTION__))
;
937 this->RuntimeLang = RuntimeLang;
938 DIType::mutate(Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
939 }
940
941 static DICompositeType *
942 getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
943 unsigned Line, DIScopeRef Scope, DITypeRef BaseType,
944 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
945 DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
946 DITypeRef VTableHolder, DITemplateParameterArray TemplateParams,
947 StringRef Identifier, DIDerivedType *Discriminator,
948 StorageType Storage, bool ShouldCreate = true) {
949 return getImpl(
950 Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
951 BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
952 RuntimeLang, VTableHolder, TemplateParams.get(),
953 getCanonicalMDString(Context, Identifier), Discriminator, Storage, ShouldCreate);
954 }
955 static DICompositeType *
956 getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
957 unsigned Line, Metadata *Scope, Metadata *BaseType,
958 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
959 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
960 Metadata *VTableHolder, Metadata *TemplateParams,
961 MDString *Identifier, Metadata *Discriminator,
962 StorageType Storage, bool ShouldCreate = true);
963
964 TempDICompositeType cloneImpl() const {
965 return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
966 getScope(), getBaseType(), getSizeInBits(),
967 getAlignInBits(), getOffsetInBits(), getFlags(),
968 getElements(), getRuntimeLang(), getVTableHolder(),
969 getTemplateParams(), getIdentifier(), getDiscriminator());
970 }
971
972public:
973 DEFINE_MDNODE_GET(DICompositeType,
974 (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
975 DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
976 uint32_t AlignInBits, uint64_t OffsetInBits,
977 DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
978 DITypeRef VTableHolder,
979 DITemplateParameterArray TemplateParams = nullptr,
980 StringRef Identifier = "", DIDerivedType *Discriminator = nullptr),
981 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
982 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
983 VTableHolder, TemplateParams, Identifier, Discriminator))
984 DEFINE_MDNODE_GET(DICompositeType,
985 (unsigned Tag, MDString *Name, Metadata *File,
986 unsigned Line, Metadata *Scope, Metadata *BaseType,
987 uint64_t SizeInBits, uint32_t AlignInBits,
988 uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
989 unsigned RuntimeLang, Metadata *VTableHolder,
990 Metadata *TemplateParams = nullptr,
991 MDString *Identifier = nullptr,
992 Metadata *Discriminator = nullptr),
993 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
994 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
995 VTableHolder, TemplateParams, Identifier, Discriminator))
996
997 TempDICompositeType clone() const { return cloneImpl(); }
998
999 /// Get a DICompositeType with the given ODR identifier.
1000 ///
1001 /// If \a LLVMContext::isODRUniquingDebugTypes(), gets the mapped
1002 /// DICompositeType for the given ODR \c Identifier. If none exists, creates
1003 /// a new node.
1004 ///
1005 /// Else, returns \c nullptr.
1006 static DICompositeType *
1007 getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1008 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1009 Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
1010 uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
1011 unsigned RuntimeLang, Metadata *VTableHolder,
1012 Metadata *TemplateParams, Metadata *Discriminator);
1013 static DICompositeType *getODRTypeIfExists(LLVMContext &Context,
1014 MDString &Identifier);
1015
1016 /// Build a DICompositeType with the given ODR identifier.
1017 ///
1018 /// Looks up the mapped DICompositeType for the given ODR \c Identifier. If
1019 /// it doesn't exist, creates a new one. If it does exist and \a
1020 /// isForwardDecl(), and the new arguments would be a definition, mutates the
1021 /// the type in place. In either case, returns the type.
1022 ///
1023 /// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns
1024 /// nullptr.
1025 static DICompositeType *
1026 buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
1027 MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
1028 Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
1029 uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
1030 unsigned RuntimeLang, Metadata *VTableHolder,
1031 Metadata *TemplateParams, Metadata *Discriminator);
1032
1033 DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
1034 DINodeArray getElements() const {
1035 return cast_or_null<MDTuple>(getRawElements());
1036 }
1037 DITypeRef getVTableHolder() const { return DITypeRef(getRawVTableHolder()); }
1038 DITemplateParameterArray getTemplateParams() const {
1039 return cast_or_null<MDTuple>(getRawTemplateParams());
1040 }
1041 StringRef getIdentifier() const { return getStringOperand(7); }
1042 unsigned getRuntimeLang() const { return RuntimeLang; }
1043
1044 Metadata *getRawBaseType() const { return getOperand(3); }
1045 Metadata *getRawElements() const { return getOperand(4); }
1046 Metadata *getRawVTableHolder() const { return getOperand(5); }
1047 Metadata *getRawTemplateParams() const { return getOperand(6); }
1048 MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
1049 Metadata *getRawDiscriminator() const { return getOperand(8); }
1050 DIDerivedType *getDiscriminator() const { return getOperandAs<DIDerivedType>(8); }
23
Calling 'DINode::getOperandAs'
24
Returning from 'DINode::getOperandAs'
1051
1052 /// Replace operands.
1053 ///
1054 /// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
1055 /// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
1056 /// of its movement if necessary.
1057 /// @{
1058 void replaceElements(DINodeArray Elements) {
1059#ifndef NDEBUG
1060 for (DINode *Op : getElements())
1061 assert(is_contained(Elements->operands(), Op) &&(static_cast <bool> (is_contained(Elements->operands
(), Op) && "Lost a member during member list replacement"
) ? void (0) : __assert_fail ("is_contained(Elements->operands(), Op) && \"Lost a member during member list replacement\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 1062, __extension__ __PRETTY_FUNCTION__))
1062 "Lost a member during member list replacement")(static_cast <bool> (is_contained(Elements->operands
(), Op) && "Lost a member during member list replacement"
) ? void (0) : __assert_fail ("is_contained(Elements->operands(), Op) && \"Lost a member during member list replacement\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 1062, __extension__ __PRETTY_FUNCTION__))
;
1063#endif
1064 replaceOperandWith(4, Elements.get());
1065 }
1066
1067 void replaceVTableHolder(DITypeRef VTableHolder) {
1068 replaceOperandWith(5, VTableHolder);
1069 }
1070
1071 void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
1072 replaceOperandWith(6, TemplateParams.get());
1073 }
1074 /// @}
1075
1076 static bool classof(const Metadata *MD) {
1077 return MD->getMetadataID() == DICompositeTypeKind;
1078 }
1079};
1080
1081/// Type array for a subprogram.
1082///
1083/// TODO: Fold the array of types in directly as operands.
1084class DISubroutineType : public DIType {
1085 friend class LLVMContextImpl;
1086 friend class MDNode;
1087
1088 /// The calling convention used with DW_AT_calling_convention. Actually of
1089 /// type dwarf::CallingConvention.
1090 uint8_t CC;
1091
1092 DISubroutineType(LLVMContext &C, StorageType Storage, DIFlags Flags,
1093 uint8_t CC, ArrayRef<Metadata *> Ops)
1094 : DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type,
1095 0, 0, 0, 0, Flags, Ops),
1096 CC(CC) {}
1097 ~DISubroutineType() = default;
1098
1099 static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
1100 uint8_t CC, DITypeRefArray TypeArray,
1101 StorageType Storage,
1102 bool ShouldCreate = true) {
1103 return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate);
1104 }
1105 static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
1106 uint8_t CC, Metadata *TypeArray,
1107 StorageType Storage,
1108 bool ShouldCreate = true);
1109
1110 TempDISubroutineType cloneImpl() const {
1111 return getTemporary(getContext(), getFlags(), getCC(), getTypeArray());
1112 }
1113
1114public:
1115 DEFINE_MDNODE_GET(DISubroutineType,
1116 (DIFlags Flags, uint8_t CC, DITypeRefArray TypeArray),
1117 (Flags, CC, TypeArray))
1118 DEFINE_MDNODE_GET(DISubroutineType,
1119 (DIFlags Flags, uint8_t CC, Metadata *TypeArray),
1120 (Flags, CC, TypeArray))
1121
1122 TempDISubroutineType clone() const { return cloneImpl(); }
1123
1124 uint8_t getCC() const { return CC; }
1125
1126 DITypeRefArray getTypeArray() const {
1127 return cast_or_null<MDTuple>(getRawTypeArray());
1128 }
1129
1130 Metadata *getRawTypeArray() const { return getOperand(3); }
1131
1132 static bool classof(const Metadata *MD) {
1133 return MD->getMetadataID() == DISubroutineTypeKind;
1134 }
1135};
1136
1137/// Compile unit.
1138class DICompileUnit : public DIScope {
1139 friend class LLVMContextImpl;
1140 friend class MDNode;
1141
1142public:
1143 enum DebugEmissionKind : unsigned {
1144 NoDebug = 0,
1145 FullDebug,
1146 LineTablesOnly,
1147 LastEmissionKind = LineTablesOnly
1148 };
1149
1150 static Optional<DebugEmissionKind> getEmissionKind(StringRef Str);
1151 static const char *EmissionKindString(DebugEmissionKind EK);
1152
1153private:
1154 unsigned SourceLanguage;
1155 bool IsOptimized;
1156 unsigned RuntimeVersion;
1157 unsigned EmissionKind;
1158 uint64_t DWOId;
1159 bool SplitDebugInlining;
1160 bool DebugInfoForProfiling;
1161 bool GnuPubnames;
1162
1163 DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
1164 bool IsOptimized, unsigned RuntimeVersion,
1165 unsigned EmissionKind, uint64_t DWOId, bool SplitDebugInlining,
1166 bool DebugInfoForProfiling, bool GnuPubnames, ArrayRef<Metadata *> Ops)
1167 : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
1168 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
1169 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind),
1170 DWOId(DWOId), SplitDebugInlining(SplitDebugInlining),
1171 DebugInfoForProfiling(DebugInfoForProfiling), GnuPubnames(GnuPubnames) {
1172 assert(Storage != Uniqued)(static_cast <bool> (Storage != Uniqued) ? void (0) : __assert_fail
("Storage != Uniqued", "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 1172, __extension__ __PRETTY_FUNCTION__))
;
1173 }
1174 ~DICompileUnit() = default;
1175
1176 static DICompileUnit *
1177 getImpl(LLVMContext &Context, unsigned SourceLanguage, DIFile *File,
1178 StringRef Producer, bool IsOptimized, StringRef Flags,
1179 unsigned RuntimeVersion, StringRef SplitDebugFilename,
1180 unsigned EmissionKind, DICompositeTypeArray EnumTypes,
1181 DIScopeArray RetainedTypes,
1182 DIGlobalVariableExpressionArray GlobalVariables,
1183 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
1184 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
1185 bool GnuPubnames, StorageType Storage, bool ShouldCreate = true) {
1186 return getImpl(
1187 Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
1188 IsOptimized, getCanonicalMDString(Context, Flags), RuntimeVersion,
1189 getCanonicalMDString(Context, SplitDebugFilename), EmissionKind,
1190 EnumTypes.get(), RetainedTypes.get(), GlobalVariables.get(),
1191 ImportedEntities.get(), Macros.get(), DWOId, SplitDebugInlining,
1192 DebugInfoForProfiling, GnuPubnames, Storage, ShouldCreate);
1193 }
1194 static DICompileUnit *
1195 getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
1196 MDString *Producer, bool IsOptimized, MDString *Flags,
1197 unsigned RuntimeVersion, MDString *SplitDebugFilename,
1198 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
1199 Metadata *GlobalVariables, Metadata *ImportedEntities,
1200 Metadata *Macros, uint64_t DWOId, bool SplitDebugInlining,
1201 bool DebugInfoForProfiling, bool GnuPubnames, StorageType Storage,
1202 bool ShouldCreate = true);
1203
1204 TempDICompileUnit cloneImpl() const {
1205 return getTemporary(getContext(), getSourceLanguage(), getFile(),
1206 getProducer(), isOptimized(), getFlags(),
1207 getRuntimeVersion(), getSplitDebugFilename(),
1208 getEmissionKind(), getEnumTypes(), getRetainedTypes(),
1209 getGlobalVariables(), getImportedEntities(),
1210 getMacros(), DWOId, getSplitDebugInlining(),
1211 getDebugInfoForProfiling(), getGnuPubnames());
1212 }
1213
1214public:
1215 static void get() = delete;
1216 static void getIfExists() = delete;
1217
1218 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1219 DICompileUnit,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1220 (unsigned SourceLanguage, DIFile *File, StringRef Producer,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1221 bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1222 StringRef SplitDebugFilename, DebugEmissionKind EmissionKind,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1223 DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1224 DIGlobalVariableExpressionArray GlobalVariables,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1225 DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1226 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1227 bool GnuPubnames),static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1228 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1229 SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1230 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1231 DebugInfoForProfiling, GnuPubnames))static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK
((SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion
, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining
, DebugInfoForProfiling, GnuPubnames)), Distinct); } static TempDICompileUnit
getTemporary(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, DIFile *File, StringRef Producer, bool
IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef
SplitDebugFilename, DebugEmissionKind EmissionKind, DICompositeTypeArray
EnumTypes, DIScopeArray RetainedTypes, DIGlobalVariableExpressionArray
GlobalVariables, DIImportedEntityArray ImportedEntities, DIMacroNodeArray
Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1232 DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1233 DICompileUnit,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1234 (unsigned SourceLanguage, Metadata *File, MDString *Producer,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1235 bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1236 MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1237 Metadata *RetainedTypes, Metadata *GlobalVariables,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1238 Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1239 bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames),static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1240 (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1241 SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1242 GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1243 DebugInfoForProfiling, GnuPubnames))static DICompileUnit *getDistinct(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK
((unsigned SourceLanguage, Metadata *File, MDString *Producer
, bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata
*EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables
, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId
, bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames
))) { return getImpl(Context, DEFINE_MDNODE_GET_UNPACK((SourceLanguage
, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename
, EmissionKind, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities
, Macros, DWOId, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames
)), Distinct); } static TempDICompileUnit getTemporary(LLVMContext
&Context, DEFINE_MDNODE_GET_UNPACK((unsigned SourceLanguage
, Metadata *File, MDString *Producer, bool IsOptimized, MDString
*Flags, unsigned RuntimeVersion, MDString *SplitDebugFilename
, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes
, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata
*Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling
, bool GnuPubnames))) { return TempDICompileUnit( getImpl(Context
, DEFINE_MDNODE_GET_UNPACK((SourceLanguage, File, Producer, IsOptimized
, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes
, RetainedTypes, GlobalVariables, ImportedEntities, Macros, DWOId
, SplitDebugInlining, DebugInfoForProfiling, GnuPubnames)), Temporary
)); }
1244
1245 TempDICompileUnit clone() const { return cloneImpl(); }
1246
1247 unsigned getSourceLanguage() const { return SourceLanguage; }
1248 bool isOptimized() const { return IsOptimized; }
1249 unsigned getRuntimeVersion() const { return RuntimeVersion; }
1250 DebugEmissionKind getEmissionKind() const {
1251 return (DebugEmissionKind)EmissionKind;
1252 }
1253 bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
1254 bool getGnuPubnames() const { return GnuPubnames; }
1255 StringRef getProducer() const { return getStringOperand(1); }
1256 StringRef getFlags() const { return getStringOperand(2); }
1257 StringRef getSplitDebugFilename() const { return getStringOperand(3); }
1258 DICompositeTypeArray getEnumTypes() const {
1259 return cast_or_null<MDTuple>(getRawEnumTypes());
1260 }
1261 DIScopeArray getRetainedTypes() const {
1262 return cast_or_null<MDTuple>(getRawRetainedTypes());
1263 }
1264 DIGlobalVariableExpressionArray getGlobalVariables() const {
1265 return cast_or_null<MDTuple>(getRawGlobalVariables());
1266 }
1267 DIImportedEntityArray getImportedEntities() const {
1268 return cast_or_null<MDTuple>(getRawImportedEntities());
1269 }
1270 DIMacroNodeArray getMacros() const {
1271 return cast_or_null<MDTuple>(getRawMacros());
1272 }
1273 uint64_t getDWOId() const { return DWOId; }
1274 void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
1275 bool getSplitDebugInlining() const { return SplitDebugInlining; }
1276 void setSplitDebugInlining(bool SplitDebugInlining) {
1277 this->SplitDebugInlining = SplitDebugInlining;
1278 }
1279
1280 MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
1281 MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
1282 MDString *getRawSplitDebugFilename() const {
1283 return getOperandAs<MDString>(3);
1284 }
1285 Metadata *getRawEnumTypes() const { return getOperand(4); }
1286 Metadata *getRawRetainedTypes() const { return getOperand(5); }
1287 Metadata *getRawGlobalVariables() const { return getOperand(6); }
1288 Metadata *getRawImportedEntities() const { return getOperand(7); }
1289 Metadata *getRawMacros() const { return getOperand(8); }
1290
1291 /// Replace arrays.
1292 ///
1293 /// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
1294 /// deleted on a uniquing collision. In practice, uniquing collisions on \a
1295 /// DICompileUnit should be fairly rare.
1296 /// @{
1297 void replaceEnumTypes(DICompositeTypeArray N) {
1298 replaceOperandWith(4, N.get());
1299 }
1300 void replaceRetainedTypes(DITypeArray N) {
1301 replaceOperandWith(5, N.get());
1302 }
1303 void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
1304 replaceOperandWith(6, N.get());
1305 }
1306 void replaceImportedEntities(DIImportedEntityArray N) {
1307 replaceOperandWith(7, N.get());
1308 }
1309 void replaceMacros(DIMacroNodeArray N) { replaceOperandWith(8, N.get()); }
1310 /// @}
1311
1312 static bool classof(const Metadata *MD) {
1313 return MD->getMetadataID() == DICompileUnitKind;
1314 }
1315};
1316
1317/// A scope for locals.
1318///
1319/// A legal scope for lexical blocks, local variables, and debug info
1320/// locations. Subclasses are \a DISubprogram, \a DILexicalBlock, and \a
1321/// DILexicalBlockFile.
1322class DILocalScope : public DIScope {
1323protected:
1324 DILocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
1325 ArrayRef<Metadata *> Ops)
1326 : DIScope(C, ID, Storage, Tag, Ops) {}
1327 ~DILocalScope() = default;
1328
1329public:
1330 /// Get the subprogram for this scope.
1331 ///
1332 /// Return this if it's an \a DISubprogram; otherwise, look up the scope
1333 /// chain.
1334 DISubprogram *getSubprogram() const;
1335
1336 /// Get the first non DILexicalBlockFile scope of this scope.
1337 ///
1338 /// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the
1339 /// scope chain.
1340 DILocalScope *getNonLexicalBlockFileScope() const;
1341
1342 static bool classof(const Metadata *MD) {
1343 return MD->getMetadataID() == DISubprogramKind ||
1344 MD->getMetadataID() == DILexicalBlockKind ||
1345 MD->getMetadataID() == DILexicalBlockFileKind;
1346 }
1347};
1348
1349/// Debug location.
1350///
1351/// A debug location in source code, used for debug info and otherwise.
1352class DILocation : public MDNode {
1353 friend class LLVMContextImpl;
1354 friend class MDNode;
1355
1356 DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
1357 unsigned Column, ArrayRef<Metadata *> MDs);
1358 ~DILocation() { dropAllReferences(); }
1359
1360 static DILocation *getImpl(LLVMContext &Context, unsigned Line,
1361 unsigned Column, Metadata *Scope,
1362 Metadata *InlinedAt, StorageType Storage,
1363 bool ShouldCreate = true);
1364 static DILocation *getImpl(LLVMContext &Context, unsigned Line,
1365 unsigned Column, DILocalScope *Scope,
1366 DILocation *InlinedAt, StorageType Storage,
1367 bool ShouldCreate = true) {
1368 return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
1369 static_cast<Metadata *>(InlinedAt), Storage, ShouldCreate);
1370 }
1371
1372 /// With a given unsigned int \p U, use up to 13 bits to represent it.
1373 /// old_bit 1~5 --> new_bit 1~5
1374 /// old_bit 6~12 --> new_bit 7~13
1375 /// new_bit_6 is 0 if higher bits (7~13) are all 0
1376 static unsigned getPrefixEncodingFromUnsigned(unsigned U) {
1377 U &= 0xfff;
1378 return U > 0x1f ? (((U & 0xfe0) << 1) | (U & 0x1f) | 0x20) : U;
1379 }
1380
1381 /// Reverse transformation as getPrefixEncodingFromUnsigned.
1382 static unsigned getUnsignedFromPrefixEncoding(unsigned U) {
1383 return (U & 0x20) ? (((U >> 1) & 0xfe0) | (U & 0x1f)) : (U & 0x1f);
1384 }
1385
1386 /// Returns the next component stored in discriminator.
1387 static unsigned getNextComponentInDiscriminator(unsigned D) {
1388 if ((D & 1) == 0)
1389 return D >> ((D & 0x40) ? 14 : 7);
1390 else
1391 return D >> 1;
1392 }
1393
1394 TempDILocation cloneImpl() const {
1395 // Get the raw scope/inlinedAt since it is possible to invoke this on
1396 // a DILocation containing temporary metadata.
1397 return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
1398 getRawInlinedAt());
1399 }
1400
1401public:
1402 // Disallow replacing operands.
1403 void replaceOperandWith(unsigned I, Metadata *New) = delete;
1404
1405 DEFINE_MDNODE_GET(DILocation,
1406 (unsigned Line, unsigned Column, Metadata *Scope,
1407 Metadata *InlinedAt = nullptr),
1408 (Line, Column, Scope, InlinedAt))
1409 DEFINE_MDNODE_GET(DILocation,
1410 (unsigned Line, unsigned Column, DILocalScope *Scope,
1411 DILocation *InlinedAt = nullptr),
1412 (Line, Column, Scope, InlinedAt))
1413
1414 /// Return a (temporary) clone of this.
1415 TempDILocation clone() const { return cloneImpl(); }
1416
1417 unsigned getLine() const { return SubclassData32; }
1418 unsigned getColumn() const { return SubclassData16; }
1419 DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
1420
1421 DILocation *getInlinedAt() const {
1422 return cast_or_null<DILocation>(getRawInlinedAt());
1423 }
1424
1425 DIFile *getFile() const { return getScope()->getFile(); }
1426 StringRef getFilename() const { return getScope()->getFilename(); }
1427 StringRef getDirectory() const { return getScope()->getDirectory(); }
1428 Optional<StringRef> getSource() const { return getScope()->getSource(); }
1429
1430 /// Get the scope where this is inlined.
1431 ///
1432 /// Walk through \a getInlinedAt() and return \a getScope() from the deepest
1433 /// location.
1434 DILocalScope *getInlinedAtScope() const {
1435 if (auto *IA = getInlinedAt())
1436 return IA->getInlinedAtScope();
1437 return getScope();
1438 }
1439
1440 /// Check whether this can be discriminated from another location.
1441 ///
1442 /// Check \c this can be discriminated from \c RHS in a linetable entry.
1443 /// Scope and inlined-at chains are not recorded in the linetable, so they
1444 /// cannot be used to distinguish basic blocks.
1445 bool canDiscriminate(const DILocation &RHS) const {
1446 return getLine() != RHS.getLine() ||
1447 getColumn() != RHS.getColumn() ||
1448 getDiscriminator() != RHS.getDiscriminator() ||
1449 getFilename() != RHS.getFilename() ||
1450 getDirectory() != RHS.getDirectory();
1451 }
1452
1453 /// Get the DWARF discriminator.
1454 ///
1455 /// DWARF discriminators distinguish identical file locations between
1456 /// instructions that are on different basic blocks.
1457 ///
1458 /// There are 3 components stored in discriminator, from lower bits:
1459 ///
1460 /// Base discriminator: assigned by AddDiscriminators pass to identify IRs
1461 /// that are defined by the same source line, but
1462 /// different basic blocks.
1463 /// Duplication factor: assigned by optimizations that will scale down
1464 /// the execution frequency of the original IR.
1465 /// Copy Identifier: assigned by optimizations that clones the IR.
1466 /// Each copy of the IR will be assigned an identifier.
1467 ///
1468 /// Encoding:
1469 ///
1470 /// The above 3 components are encoded into a 32bit unsigned integer in
1471 /// order. If the lowest bit is 1, the current component is empty, and the
1472 /// next component will start in the next bit. Otherwise, the current
1473 /// component is non-empty, and its content starts in the next bit. The
1474 /// length of each components is either 5 bit or 12 bit: if the 7th bit
1475 /// is 0, the bit 2~6 (5 bits) are used to represent the component; if the
1476 /// 7th bit is 1, the bit 2~6 (5 bits) and 8~14 (7 bits) are combined to
1477 /// represent the component.
1478
1479 inline unsigned getDiscriminator() const;
1480
1481 /// Returns a new DILocation with updated \p Discriminator.
1482 inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
1483
1484 /// Returns a new DILocation with updated base discriminator \p BD.
1485 inline const DILocation *setBaseDiscriminator(unsigned BD) const;
1486
1487 /// Returns the duplication factor stored in the discriminator.
1488 inline unsigned getDuplicationFactor() const;
1489
1490 /// Returns the copy identifier stored in the discriminator.
1491 inline unsigned getCopyIdentifier() const;
1492
1493 /// Returns the base discriminator stored in the discriminator.
1494 inline unsigned getBaseDiscriminator() const;
1495
1496 /// Returns a new DILocation with duplication factor \p DF encoded in the
1497 /// discriminator.
1498 inline const DILocation *cloneWithDuplicationFactor(unsigned DF) const;
1499
1500 /// When two instructions are combined into a single instruction we also
1501 /// need to combine the original locations into a single location.
1502 ///
1503 /// When the locations are the same we can use either location. When they
1504 /// differ, we need a third location which is distinct from either. If
1505 /// they have the same file/line but have a different discriminator we
1506 /// could create a location with a new discriminator. If they are from
1507 /// different files/lines the location is ambiguous and can't be
1508 /// represented in a single line entry. In this case, no location
1509 /// should be set, unless the merged instruction is a call, which we will
1510 /// set the merged debug location as line 0 of the nearest common scope
1511 /// where 2 locations are inlined from. This only applies to Instruction;
1512 /// for MachineInstruction, as it is post-inline, we will treat the call
1513 /// instruction the same way as other instructions.
1514 ///
1515 /// \p ForInst: The Instruction the merged DILocation is for. If the
1516 /// Instruction is unavailable or non-existent, use nullptr.
1517 static const DILocation *
1518 getMergedLocation(const DILocation *LocA, const DILocation *LocB,
1519 const Instruction *ForInst = nullptr);
1520
1521 /// Returns the base discriminator for a given encoded discriminator \p D.
1522 static unsigned getBaseDiscriminatorFromDiscriminator(unsigned D) {
1523 if ((D & 1) == 0)
1524 return getUnsignedFromPrefixEncoding(D >> 1);
1525 else
1526 return 0;
1527 }
1528
1529 /// Returns the duplication factor for a given encoded discriminator \p D.
1530 static unsigned getDuplicationFactorFromDiscriminator(unsigned D) {
1531 D = getNextComponentInDiscriminator(D);
1532 if (D == 0 || (D & 1))
1533 return 1;
1534 else
1535 return getUnsignedFromPrefixEncoding(D >> 1);
1536 }
1537
1538 /// Returns the copy identifier for a given encoded discriminator \p D.
1539 static unsigned getCopyIdentifierFromDiscriminator(unsigned D) {
1540 return getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(
1541 getNextComponentInDiscriminator(D)));
1542 }
1543
1544
1545 Metadata *getRawScope() const { return getOperand(0); }
1546 Metadata *getRawInlinedAt() const {
1547 if (getNumOperands() == 2)
1548 return getOperand(1);
1549 return nullptr;
1550 }
1551
1552 static bool classof(const Metadata *MD) {
1553 return MD->getMetadataID() == DILocationKind;
1554 }
1555};
1556
1557/// Subprogram description.
1558///
1559/// TODO: Remove DisplayName. It's always equal to Name.
1560/// TODO: Split up flags.
1561class DISubprogram : public DILocalScope {
1562 friend class LLVMContextImpl;
1563 friend class MDNode;
1564
1565 unsigned Line;
1566 unsigned ScopeLine;
1567 unsigned VirtualIndex;
1568
1569 /// In the MS ABI, the implicit 'this' parameter is adjusted in the prologue
1570 /// of method overrides from secondary bases by this amount. It may be
1571 /// negative.
1572 int ThisAdjustment;
1573
1574 // Virtuality can only assume three values, so we can pack
1575 // in 2 bits (none/pure/pure_virtual).
1576 unsigned Virtuality : 2;
1577
1578 // These are boolean flags so one bit is enough.
1579 // MSVC starts a new container field every time the base
1580 // type changes so we can't use 'bool' to ensure these bits
1581 // are packed.
1582 unsigned IsLocalToUnit : 1;
1583 unsigned IsDefinition : 1;
1584 unsigned IsOptimized : 1;
1585
1586 unsigned Padding : 3;
1587
1588 DIFlags Flags;
1589
1590 DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
1591 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
1592 int ThisAdjustment, DIFlags Flags, bool IsLocalToUnit,
1593 bool IsDefinition, bool IsOptimized, ArrayRef<Metadata *> Ops)
1594 : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
1595 Ops),
1596 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1597 ThisAdjustment(ThisAdjustment), Virtuality(Virtuality),
1598 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition),
1599 IsOptimized(IsOptimized), Flags(Flags) {
1600 static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
1601 assert(Virtuality < 4 && "Virtuality out of range")(static_cast <bool> (Virtuality < 4 && "Virtuality out of range"
) ? void (0) : __assert_fail ("Virtuality < 4 && \"Virtuality out of range\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 1601, __extension__ __PRETTY_FUNCTION__))
;
1602 }
1603 ~DISubprogram() = default;
1604
1605 static DISubprogram *
1606 getImpl(LLVMContext &Context, DIScopeRef Scope, StringRef Name,
1607 StringRef LinkageName, DIFile *File, unsigned Line,
1608 DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
1609 unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality,
1610 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1611 bool IsOptimized, DICompileUnit *Unit,
1612 DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
1613 DILocalVariableArray Variables, DITypeArray ThrownTypes,
1614 StorageType Storage, bool ShouldCreate = true) {
1615 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1616 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1617 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1618 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1619 Unit, TemplateParams.get(), Declaration, Variables.get(),
1620 ThrownTypes.get(), Storage, ShouldCreate);
1621 }
1622 static DISubprogram *
1623 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1624 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1625 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1626 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
1627 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
1628 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
1629 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate = true);
1630
1631 TempDISubprogram cloneImpl() const {
1632 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1633 getFile(), getLine(), getType(), isLocalToUnit(),
1634 isDefinition(), getScopeLine(), getContainingType(),
1635 getVirtuality(), getVirtualIndex(), getThisAdjustment(),
1636 getFlags(), isOptimized(), getUnit(),
1637 getTemplateParams(), getDeclaration(), getVariables(),
1638 getThrownTypes());
1639 }
1640
1641public:
1642 DEFINE_MDNODE_GET(DISubprogram,
1643 (DIScopeRef Scope, StringRef Name, StringRef LinkageName,
1644 DIFile *File, unsigned Line, DISubroutineType *Type,
1645 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1646 DITypeRef ContainingType, unsigned Virtuality,
1647 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1648 bool IsOptimized, DICompileUnit *Unit,
1649 DITemplateParameterArray TemplateParams = nullptr,
1650 DISubprogram *Declaration = nullptr,
1651 DILocalVariableArray Variables = nullptr,
1652 DITypeArray ThrownTypes = nullptr),
1653 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1654 IsDefinition, ScopeLine, ContainingType, Virtuality,
1655 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
1656 TemplateParams, Declaration, Variables, ThrownTypes))
1657 DEFINE_MDNODE_GET(
1658 DISubprogram,
1659 (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1660 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1661 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1662 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1663 bool IsOptimized, Metadata *Unit, Metadata *TemplateParams = nullptr,
1664 Metadata *Declaration = nullptr, Metadata *Variables = nullptr,
1665 Metadata *ThrownTypes = nullptr),
1666 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1667 ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
1668 Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables,
1669 ThrownTypes))
1670
1671 TempDISubprogram clone() const { return cloneImpl(); }
1672
1673public:
1674 unsigned getLine() const { return Line; }
1675 unsigned getVirtuality() const { return Virtuality; }
1676 unsigned getVirtualIndex() const { return VirtualIndex; }
1677 int getThisAdjustment() const { return ThisAdjustment; }
1678 unsigned getScopeLine() const { return ScopeLine; }
1679 DIFlags getFlags() const { return Flags; }
1680 bool isLocalToUnit() const { return IsLocalToUnit; }
1681 bool isDefinition() const { return IsDefinition; }
1682 bool isOptimized() const { return IsOptimized; }
1683
1684 bool isArtificial() const { return getFlags() & FlagArtificial; }
1685 bool isPrivate() const {
1686 return (getFlags() & FlagAccessibility) == FlagPrivate;
1687 }
1688 bool isProtected() const {
1689 return (getFlags() & FlagAccessibility) == FlagProtected;
1690 }
1691 bool isPublic() const {
1692 return (getFlags() & FlagAccessibility) == FlagPublic;
1693 }
1694 bool isExplicit() const { return getFlags() & FlagExplicit; }
1695 bool isPrototyped() const { return getFlags() & FlagPrototyped; }
1696 bool isMainSubprogram() const { return getFlags() & FlagMainSubprogram; }
1697
1698 /// Check if this is reference-qualified.
1699 ///
1700 /// Return true if this subprogram is a C++11 reference-qualified non-static
1701 /// member function (void foo() &).
1702 bool isLValueReference() const { return getFlags() & FlagLValueReference; }
1703
1704 /// Check if this is rvalue-reference-qualified.
1705 ///
1706 /// Return true if this subprogram is a C++11 rvalue-reference-qualified
1707 /// non-static member function (void foo() &&).
1708 bool isRValueReference() const { return getFlags() & FlagRValueReference; }
1709
1710 /// Check if this is marked as noreturn.
1711 ///
1712 /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
1713 bool isNoReturn() const { return getFlags() & FlagNoReturn; }
1714
1715 DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
1716
1717 StringRef getName() const { return getStringOperand(2); }
1718 StringRef getLinkageName() const { return getStringOperand(3); }
1719
1720 DISubroutineType *getType() const {
1721 return cast_or_null<DISubroutineType>(getRawType());
1722 }
1723 DITypeRef getContainingType() const {
1724 return DITypeRef(getRawContainingType());
1725 }
1726
1727 DICompileUnit *getUnit() const {
1728 return cast_or_null<DICompileUnit>(getRawUnit());
1729 }
1730 void replaceUnit(DICompileUnit *CU) { replaceOperandWith(5, CU); }
1731 DITemplateParameterArray getTemplateParams() const {
1732 return cast_or_null<MDTuple>(getRawTemplateParams());
1733 }
1734 DISubprogram *getDeclaration() const {
1735 return cast_or_null<DISubprogram>(getRawDeclaration());
1736 }
1737 DILocalVariableArray getVariables() const {
1738 return cast_or_null<MDTuple>(getRawVariables());
1739 }
1740 DITypeArray getThrownTypes() const {
1741 return cast_or_null<MDTuple>(getRawThrownTypes());
1742 }
1743
1744 Metadata *getRawScope() const { return getOperand(1); }
1745 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1746 MDString *getRawLinkageName() const { return getOperandAs<MDString>(3); }
1747 Metadata *getRawType() const { return getOperand(4); }
1748 Metadata *getRawUnit() const { return getOperand(5); }
1749 Metadata *getRawDeclaration() const { return getOperand(6); }
1750 Metadata *getRawVariables() const { return getOperand(7); }
1751 Metadata *getRawContainingType() const {
1752 return getNumOperands() > 8 ? getOperandAs<Metadata>(8) : nullptr;
1753 }
1754 Metadata *getRawTemplateParams() const {
1755 return getNumOperands() > 9 ? getOperandAs<Metadata>(9) : nullptr;
1756 }
1757 Metadata *getRawThrownTypes() const {
1758 return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
1759 }
1760
1761 /// Check if this subprogram describes the given function.
1762 ///
1763 /// FIXME: Should this be looking through bitcasts?
1764 bool describes(const Function *F) const;
1765
1766 static bool classof(const Metadata *MD) {
1767 return MD->getMetadataID() == DISubprogramKind;
1768 }
1769};
1770
1771class DILexicalBlockBase : public DILocalScope {
1772protected:
1773 DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
1774 ArrayRef<Metadata *> Ops)
1775 : DILocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1776 ~DILexicalBlockBase() = default;
1777
1778public:
1779 DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
1780
1781 Metadata *getRawScope() const { return getOperand(1); }
1782
1783 static bool classof(const Metadata *MD) {
1784 return MD->getMetadataID() == DILexicalBlockKind ||
1785 MD->getMetadataID() == DILexicalBlockFileKind;
1786 }
1787};
1788
1789class DILexicalBlock : public DILexicalBlockBase {
1790 friend class LLVMContextImpl;
1791 friend class MDNode;
1792
1793 unsigned Line;
1794 uint16_t Column;
1795
1796 DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
1797 unsigned Column, ArrayRef<Metadata *> Ops)
1798 : DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops), Line(Line),
1799 Column(Column) {
1800 assert(Column < (1u << 16) && "Expected 16-bit column")(static_cast <bool> (Column < (1u << 16) &&
"Expected 16-bit column") ? void (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 1800, __extension__ __PRETTY_FUNCTION__))
;
1801 }
1802 ~DILexicalBlock() = default;
1803
1804 static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,
1805 DIFile *File, unsigned Line, unsigned Column,
1806 StorageType Storage,
1807 bool ShouldCreate = true) {
1808 return getImpl(Context, static_cast<Metadata *>(Scope),
1809 static_cast<Metadata *>(File), Line, Column, Storage,
1810 ShouldCreate);
1811 }
1812
1813 static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
1814 Metadata *File, unsigned Line, unsigned Column,
1815 StorageType Storage, bool ShouldCreate = true);
1816
1817 TempDILexicalBlock cloneImpl() const {
1818 return getTemporary(getContext(), getScope(), getFile(), getLine(),
1819 getColumn());
1820 }
1821
1822public:
1823 DEFINE_MDNODE_GET(DILexicalBlock, (DILocalScope * Scope, DIFile *File,
1824 unsigned Line, unsigned Column),
1825 (Scope, File, Line, Column))
1826 DEFINE_MDNODE_GET(DILexicalBlock, (Metadata * Scope, Metadata *File,
1827 unsigned Line, unsigned Column),
1828 (Scope, File, Line, Column))
1829
1830 TempDILexicalBlock clone() const { return cloneImpl(); }
1831
1832 unsigned getLine() const { return Line; }
1833 unsigned getColumn() const { return Column; }
1834
1835 static bool classof(const Metadata *MD) {
1836 return MD->getMetadataID() == DILexicalBlockKind;
1837 }
1838};
1839
1840class DILexicalBlockFile : public DILexicalBlockBase {
1841 friend class LLVMContextImpl;
1842 friend class MDNode;
1843
1844 unsigned Discriminator;
1845
1846 DILexicalBlockFile(LLVMContext &C, StorageType Storage,
1847 unsigned Discriminator, ArrayRef<Metadata *> Ops)
1848 : DILexicalBlockBase(C, DILexicalBlockFileKind, Storage, Ops),
1849 Discriminator(Discriminator) {}
1850 ~DILexicalBlockFile() = default;
1851
1852 static DILexicalBlockFile *getImpl(LLVMContext &Context, DILocalScope *Scope,
1853 DIFile *File, unsigned Discriminator,
1854 StorageType Storage,
1855 bool ShouldCreate = true) {
1856 return getImpl(Context, static_cast<Metadata *>(Scope),
1857 static_cast<Metadata *>(File), Discriminator, Storage,
1858 ShouldCreate);
1859 }
1860
1861 static DILexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
1862 Metadata *File, unsigned Discriminator,
1863 StorageType Storage,
1864 bool ShouldCreate = true);
1865
1866 TempDILexicalBlockFile cloneImpl() const {
1867 return getTemporary(getContext(), getScope(), getFile(),
1868 getDiscriminator());
1869 }
1870
1871public:
1872 DEFINE_MDNODE_GET(DILexicalBlockFile, (DILocalScope * Scope, DIFile *File,
1873 unsigned Discriminator),
1874 (Scope, File, Discriminator))
1875 DEFINE_MDNODE_GET(DILexicalBlockFile,
1876 (Metadata * Scope, Metadata *File, unsigned Discriminator),
1877 (Scope, File, Discriminator))
1878
1879 TempDILexicalBlockFile clone() const { return cloneImpl(); }
1880
1881 // TODO: Remove these once they're gone from DILexicalBlockBase.
1882 unsigned getLine() const = delete;
1883 unsigned getColumn() const = delete;
1884
1885 unsigned getDiscriminator() const { return Discriminator; }
1886
1887 static bool classof(const Metadata *MD) {
1888 return MD->getMetadataID() == DILexicalBlockFileKind;
1889 }
1890};
1891
1892unsigned DILocation::getDiscriminator() const {
1893 if (auto *F = dyn_cast<DILexicalBlockFile>(getScope()))
1894 return F->getDiscriminator();
1895 return 0;
1896}
1897
1898const DILocation *
1899DILocation::cloneWithDiscriminator(unsigned Discriminator) const {
1900 DIScope *Scope = getScope();
1901 // Skip all parent DILexicalBlockFile that already have a discriminator
1902 // assigned. We do not want to have nested DILexicalBlockFiles that have
1903 // mutliple discriminators because only the leaf DILexicalBlockFile's
1904 // dominator will be used.
1905 for (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope);
1906 LBF && LBF->getDiscriminator() != 0;
1907 LBF = dyn_cast<DILexicalBlockFile>(Scope))
1908 Scope = LBF->getScope();
1909 DILexicalBlockFile *NewScope =
1910 DILexicalBlockFile::get(getContext(), Scope, getFile(), Discriminator);
1911 return DILocation::get(getContext(), getLine(), getColumn(), NewScope,
1912 getInlinedAt());
1913}
1914
1915unsigned DILocation::getBaseDiscriminator() const {
1916 return getBaseDiscriminatorFromDiscriminator(getDiscriminator());
1917}
1918
1919unsigned DILocation::getDuplicationFactor() const {
1920 return getDuplicationFactorFromDiscriminator(getDiscriminator());
1921}
1922
1923unsigned DILocation::getCopyIdentifier() const {
1924 return getCopyIdentifierFromDiscriminator(getDiscriminator());
1925}
1926
1927const DILocation *DILocation::setBaseDiscriminator(unsigned D) const {
1928 if (D == 0)
1929 return this;
1930 else
1931 return cloneWithDiscriminator(getPrefixEncodingFromUnsigned(D) << 1);
1932}
1933
1934const DILocation *DILocation::cloneWithDuplicationFactor(unsigned DF) const {
1935 DF *= getDuplicationFactor();
1936 if (DF <= 1)
1937 return this;
1938
1939 unsigned BD = getBaseDiscriminator();
1940 unsigned CI = getCopyIdentifier() << (DF > 0x1f ? 14 : 7);
1941 unsigned D = CI | (getPrefixEncodingFromUnsigned(DF) << 1);
1942
1943 if (BD == 0)
1944 D = (D << 1) | 1;
1945 else
1946 D = (D << (BD > 0x1f ? 14 : 7)) | (getPrefixEncodingFromUnsigned(BD) << 1);
1947
1948 return cloneWithDiscriminator(D);
1949}
1950
1951class DINamespace : public DIScope {
1952 friend class LLVMContextImpl;
1953 friend class MDNode;
1954
1955 unsigned ExportSymbols : 1;
1956
1957 DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
1958 ArrayRef<Metadata *> Ops)
1959 : DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace,
1960 Ops),
1961 ExportSymbols(ExportSymbols) {}
1962 ~DINamespace() = default;
1963
1964 static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
1965 StringRef Name, bool ExportSymbols,
1966 StorageType Storage, bool ShouldCreate = true) {
1967 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1968 ExportSymbols, Storage, ShouldCreate);
1969 }
1970 static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1971 MDString *Name, bool ExportSymbols,
1972 StorageType Storage, bool ShouldCreate = true);
1973
1974 TempDINamespace cloneImpl() const {
1975 return getTemporary(getContext(), getScope(), getName(),
1976 getExportSymbols());
1977 }
1978
1979public:
1980 DEFINE_MDNODE_GET(DINamespace,
1981 (DIScope *Scope, StringRef Name, bool ExportSymbols),
1982 (Scope, Name, ExportSymbols))
1983 DEFINE_MDNODE_GET(DINamespace,
1984 (Metadata *Scope, MDString *Name, bool ExportSymbols),
1985 (Scope, Name, ExportSymbols))
1986
1987 TempDINamespace clone() const { return cloneImpl(); }
1988
1989 bool getExportSymbols() const { return ExportSymbols; }
1990 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
1991 StringRef getName() const { return getStringOperand(2); }
1992
1993 Metadata *getRawScope() const { return getOperand(1); }
1994 MDString *getRawName() const { return getOperandAs<MDString>(2); }
1995
1996 static bool classof(const Metadata *MD) {
1997 return MD->getMetadataID() == DINamespaceKind;
1998 }
1999};
2000
2001/// A (clang) module that has been imported by the compile unit.
2002///
2003class DIModule : public DIScope {
2004 friend class LLVMContextImpl;
2005 friend class MDNode;
2006
2007 DIModule(LLVMContext &Context, StorageType Storage, ArrayRef<Metadata *> Ops)
2008 : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {}
2009 ~DIModule() = default;
2010
2011 static DIModule *getImpl(LLVMContext &Context, DIScope *Scope,
2012 StringRef Name, StringRef ConfigurationMacros,
2013 StringRef IncludePath, StringRef ISysRoot,
2014 StorageType Storage, bool ShouldCreate = true) {
2015 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2016 getCanonicalMDString(Context, ConfigurationMacros),
2017 getCanonicalMDString(Context, IncludePath),
2018 getCanonicalMDString(Context, ISysRoot),
2019 Storage, ShouldCreate);
2020 }
2021 static DIModule *getImpl(LLVMContext &Context, Metadata *Scope,
2022 MDString *Name, MDString *ConfigurationMacros,
2023 MDString *IncludePath, MDString *ISysRoot,
2024 StorageType Storage, bool ShouldCreate = true);
2025
2026 TempDIModule cloneImpl() const {
2027 return getTemporary(getContext(), getScope(), getName(),
2028 getConfigurationMacros(), getIncludePath(),
2029 getISysRoot());
2030 }
2031
2032public:
2033 DEFINE_MDNODE_GET(DIModule, (DIScope *Scope, StringRef Name,
2034 StringRef ConfigurationMacros, StringRef IncludePath,
2035 StringRef ISysRoot),
2036 (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
2037 DEFINE_MDNODE_GET(DIModule,
2038 (Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
2039 MDString *IncludePath, MDString *ISysRoot),
2040 (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
2041
2042 TempDIModule clone() const { return cloneImpl(); }
2043
2044 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2045 StringRef getName() const { return getStringOperand(1); }
2046 StringRef getConfigurationMacros() const { return getStringOperand(2); }
2047 StringRef getIncludePath() const { return getStringOperand(3); }
2048 StringRef getISysRoot() const { return getStringOperand(4); }
2049
2050 Metadata *getRawScope() const { return getOperand(0); }
2051 MDString *getRawName() const { return getOperandAs<MDString>(1); }
2052 MDString *getRawConfigurationMacros() const { return getOperandAs<MDString>(2); }
2053 MDString *getRawIncludePath() const { return getOperandAs<MDString>(3); }
2054 MDString *getRawISysRoot() const { return getOperandAs<MDString>(4); }
2055
2056 static bool classof(const Metadata *MD) {
2057 return MD->getMetadataID() == DIModuleKind;
2058 }
2059};
2060
2061/// Base class for template parameters.
2062class DITemplateParameter : public DINode {
2063protected:
2064 DITemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
2065 unsigned Tag, ArrayRef<Metadata *> Ops)
2066 : DINode(Context, ID, Storage, Tag, Ops) {}
2067 ~DITemplateParameter() = default;
2068
2069public:
2070 StringRef getName() const { return getStringOperand(0); }
2071 DITypeRef getType() const { return DITypeRef(getRawType()); }
2072
2073 MDString *getRawName() const { return getOperandAs<MDString>(0); }
2074 Metadata *getRawType() const { return getOperand(1); }
2075
2076 static bool classof(const Metadata *MD) {
2077 return MD->getMetadataID() == DITemplateTypeParameterKind ||
2078 MD->getMetadataID() == DITemplateValueParameterKind;
2079 }
2080};
2081
2082class DITemplateTypeParameter : public DITemplateParameter {
2083 friend class LLVMContextImpl;
2084 friend class MDNode;
2085
2086 DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
2087 ArrayRef<Metadata *> Ops)
2088 : DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
2089 dwarf::DW_TAG_template_type_parameter, Ops) {}
2090 ~DITemplateTypeParameter() = default;
2091
2092 static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
2093 DITypeRef Type, StorageType Storage,
2094 bool ShouldCreate = true) {
2095 return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
2096 ShouldCreate);
2097 }
2098 static DITemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
2099 Metadata *Type, StorageType Storage,
2100 bool ShouldCreate = true);
2101
2102 TempDITemplateTypeParameter cloneImpl() const {
2103 return getTemporary(getContext(), getName(), getType());
2104 }
2105
2106public:
2107 DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DITypeRef Type),
2108 (Name, Type))
2109 DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
2110 (Name, Type))
2111
2112 TempDITemplateTypeParameter clone() const { return cloneImpl(); }
2113
2114 static bool classof(const Metadata *MD) {
2115 return MD->getMetadataID() == DITemplateTypeParameterKind;
2116 }
2117};
2118
2119class DITemplateValueParameter : public DITemplateParameter {
2120 friend class LLVMContextImpl;
2121 friend class MDNode;
2122
2123 DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
2124 unsigned Tag, ArrayRef<Metadata *> Ops)
2125 : DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
2126 Ops) {}
2127 ~DITemplateValueParameter() = default;
2128
2129 static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
2130 StringRef Name, DITypeRef Type,
2131 Metadata *Value, StorageType Storage,
2132 bool ShouldCreate = true) {
2133 return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
2134 Value, Storage, ShouldCreate);
2135 }
2136 static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
2137 MDString *Name, Metadata *Type,
2138 Metadata *Value, StorageType Storage,
2139 bool ShouldCreate = true);
2140
2141 TempDITemplateValueParameter cloneImpl() const {
2142 return getTemporary(getContext(), getTag(), getName(), getType(),
2143 getValue());
2144 }
2145
2146public:
2147 DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, StringRef Name,
2148 DITypeRef Type, Metadata *Value),
2149 (Tag, Name, Type, Value))
2150 DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
2151 Metadata *Type, Metadata *Value),
2152 (Tag, Name, Type, Value))
2153
2154 TempDITemplateValueParameter clone() const { return cloneImpl(); }
2155
2156 Metadata *getValue() const { return getOperand(2); }
2157
2158 static bool classof(const Metadata *MD) {
2159 return MD->getMetadataID() == DITemplateValueParameterKind;
2160 }
2161};
2162
2163/// Base class for variables.
2164class DIVariable : public DINode {
2165 unsigned Line;
2166 uint32_t AlignInBits;
2167
2168protected:
2169 DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
2170 ArrayRef<Metadata *> Ops, uint32_t AlignInBits = 0)
2171 : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
2172 AlignInBits(AlignInBits) {}
2173 ~DIVariable() = default;
2174
2175public:
2176 unsigned getLine() const { return Line; }
2177 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2178 StringRef getName() const { return getStringOperand(1); }
2179 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2180 DITypeRef getType() const { return DITypeRef(getRawType()); }
2181 uint32_t getAlignInBits() const { return AlignInBits; }
2182 uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT8; }
2183 /// Determines the size of the variable's type.
2184 Optional<uint64_t> getSizeInBits() const;
2185
2186 StringRef getFilename() const {
2187 if (auto *F = getFile())
2188 return F->getFilename();
2189 return "";
2190 }
2191
2192 StringRef getDirectory() const {
2193 if (auto *F = getFile())
2194 return F->getDirectory();
2195 return "";
2196 }
2197
2198 Optional<StringRef> getSource() const {
2199 if (auto *F = getFile())
2200 return F->getSource();
2201 return None;
2202 }
2203
2204 Metadata *getRawScope() const { return getOperand(0); }
2205 MDString *getRawName() const { return getOperandAs<MDString>(1); }
2206 Metadata *getRawFile() const { return getOperand(2); }
2207 Metadata *getRawType() const { return getOperand(3); }
2208
2209 static bool classof(const Metadata *MD) {
2210 return MD->getMetadataID() == DILocalVariableKind ||
2211 MD->getMetadataID() == DIGlobalVariableKind;
2212 }
2213};
2214
2215/// DWARF expression.
2216///
2217/// This is (almost) a DWARF expression that modifies the location of a
2218/// variable, or the location of a single piece of a variable, or (when using
2219/// DW_OP_stack_value) is the constant variable value.
2220///
2221/// TODO: Co-allocate the expression elements.
2222/// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
2223/// storage types.
2224class DIExpression : public MDNode {
2225 friend class LLVMContextImpl;
2226 friend class MDNode;
2227
2228 std::vector<uint64_t> Elements;
2229
2230 DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
2231 : MDNode(C, DIExpressionKind, Storage, None),
2232 Elements(Elements.begin(), Elements.end()) {}
2233 ~DIExpression() = default;
2234
2235 static DIExpression *getImpl(LLVMContext &Context,
2236 ArrayRef<uint64_t> Elements, StorageType Storage,
2237 bool ShouldCreate = true);
2238
2239 TempDIExpression cloneImpl() const {
2240 return getTemporary(getContext(), getElements());
2241 }
2242
2243public:
2244 DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
2245
2246 TempDIExpression clone() const { return cloneImpl(); }
2247
2248 ArrayRef<uint64_t> getElements() const { return Elements; }
2249
2250 unsigned getNumElements() const { return Elements.size(); }
2251
2252 uint64_t getElement(unsigned I) const {
2253 assert(I < Elements.size() && "Index out of range")(static_cast <bool> (I < Elements.size() && "Index out of range"
) ? void (0) : __assert_fail ("I < Elements.size() && \"Index out of range\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 2253, __extension__ __PRETTY_FUNCTION__))
;
2254 return Elements[I];
2255 }
2256
2257 /// Determine whether this represents a standalone constant value.
2258 bool isConstant() const;
2259
2260 using element_iterator = ArrayRef<uint64_t>::iterator;
2261
2262 element_iterator elements_begin() const { return getElements().begin(); }
2263 element_iterator elements_end() const { return getElements().end(); }
2264
2265 /// A lightweight wrapper around an expression operand.
2266 ///
2267 /// TODO: Store arguments directly and change \a DIExpression to store a
2268 /// range of these.
2269 class ExprOperand {
2270 const uint64_t *Op = nullptr;
2271
2272 public:
2273 ExprOperand() = default;
2274 explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
2275
2276 const uint64_t *get() const { return Op; }
2277
2278 /// Get the operand code.
2279 uint64_t getOp() const { return *Op; }
2280
2281 /// Get an argument to the operand.
2282 ///
2283 /// Never returns the operand itself.
2284 uint64_t getArg(unsigned I) const { return Op[I + 1]; }
2285
2286 unsigned getNumArgs() const { return getSize() - 1; }
2287
2288 /// Return the size of the operand.
2289 ///
2290 /// Return the number of elements in the operand (1 + args).
2291 unsigned getSize() const;
2292 };
2293
2294 /// An iterator for expression operands.
2295 class expr_op_iterator
2296 : public std::iterator<std::input_iterator_tag, ExprOperand> {
2297 ExprOperand Op;
2298
2299 public:
2300 expr_op_iterator() = default;
2301 explicit expr_op_iterator(element_iterator I) : Op(I) {}
2302
2303 element_iterator getBase() const { return Op.get(); }
2304 const ExprOperand &operator*() const { return Op; }
2305 const ExprOperand *operator->() const { return &Op; }
2306
2307 expr_op_iterator &operator++() {
2308 increment();
2309 return *this;
2310 }
2311 expr_op_iterator operator++(int) {
2312 expr_op_iterator T(*this);
2313 increment();
2314 return T;
2315 }
2316
2317 /// Get the next iterator.
2318 ///
2319 /// \a std::next() doesn't work because this is technically an
2320 /// input_iterator, but it's a perfectly valid operation. This is an
2321 /// accessor to provide the same functionality.
2322 expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
2323
2324 bool operator==(const expr_op_iterator &X) const {
2325 return getBase() == X.getBase();
2326 }
2327 bool operator!=(const expr_op_iterator &X) const {
2328 return getBase() != X.getBase();
2329 }
2330
2331 private:
2332 void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
2333 };
2334
2335 /// Visit the elements via ExprOperand wrappers.
2336 ///
2337 /// These range iterators visit elements through \a ExprOperand wrappers.
2338 /// This is not guaranteed to be a valid range unless \a isValid() gives \c
2339 /// true.
2340 ///
2341 /// \pre \a isValid() gives \c true.
2342 /// @{
2343 expr_op_iterator expr_op_begin() const {
2344 return expr_op_iterator(elements_begin());
2345 }
2346 expr_op_iterator expr_op_end() const {
2347 return expr_op_iterator(elements_end());
2348 }
2349 iterator_range<expr_op_iterator> expr_ops() const {
2350 return {expr_op_begin(), expr_op_end()};
2351 }
2352 /// @}
2353
2354 bool isValid() const;
2355
2356 static bool classof(const Metadata *MD) {
2357 return MD->getMetadataID() == DIExpressionKind;
2358 }
2359
2360 /// Return whether the first element a DW_OP_deref.
2361 bool startsWithDeref() const {
2362 return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref;
2363 }
2364
2365 /// Holds the characteristics of one fragment of a larger variable.
2366 struct FragmentInfo {
2367 uint64_t SizeInBits;
2368 uint64_t OffsetInBits;
2369 };
2370
2371 /// Retrieve the details of this fragment expression.
2372 static Optional<FragmentInfo> getFragmentInfo(expr_op_iterator Start,
2373 expr_op_iterator End);
2374
2375 /// Retrieve the details of this fragment expression.
2376 Optional<FragmentInfo> getFragmentInfo() const {
2377 return getFragmentInfo(expr_op_begin(), expr_op_end());
2378 }
2379
2380 /// Return whether this is a piece of an aggregate variable.
2381 bool isFragment() const { return getFragmentInfo().hasValue(); }
2382
2383 /// Append \p Ops with operations to apply the \p Offset.
2384 static void appendOffset(SmallVectorImpl<uint64_t> &Ops, int64_t Offset);
2385
2386 /// If this is a constant offset, extract it. If there is no expression,
2387 /// return true with an offset of zero.
2388 bool extractIfOffset(int64_t &Offset) const;
2389
2390 /// Constants for DIExpression::prepend.
2391 enum { NoDeref = false, WithDeref = true, WithStackValue = true };
2392
2393 /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
2394 /// into a stack value.
2395 static DIExpression *prepend(const DIExpression *DIExpr, bool DerefBefore,
2396 int64_t Offset = 0, bool DerefAfter = false,
2397 bool StackValue = false);
2398
2399 /// Prepend \p DIExpr with the given opcodes and optionally turn it into a
2400 /// stack value.
2401 static DIExpression *doPrepend(const DIExpression *DIExpr,
2402 SmallVectorImpl<uint64_t> &Ops,
2403 bool StackValue = false);
2404
2405 /// Create a DIExpression to describe one part of an aggregate variable that
2406 /// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
2407 /// will be appended to the elements of \c Expr. If \c Expr already contains
2408 /// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
2409 /// into the existing fragment.
2410 ///
2411 /// \param OffsetInBits Offset of the piece in bits.
2412 /// \param SizeInBits Size of the piece in bits.
2413 /// \return Creating a fragment expression may fail if \c Expr
2414 /// contains arithmetic operations that would be truncated.
2415 static Optional<DIExpression *>
2416 createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
2417 unsigned SizeInBits);
2418
2419 /// Determine the relative position of the fragments described by this
2420 /// DIExpression and \p Other.
2421 /// Returns -1 if this is entirely before Other, 0 if this and Other overlap,
2422 /// 1 if this is entirely after Other.
2423 int fragmentCmp(const DIExpression *Other) const {
2424 auto Fragment1 = *getFragmentInfo();
2425 auto Fragment2 = *Other->getFragmentInfo();
2426 unsigned l1 = Fragment1.OffsetInBits;
2427 unsigned l2 = Fragment2.OffsetInBits;
2428 unsigned r1 = l1 + Fragment1.SizeInBits;
2429 unsigned r2 = l2 + Fragment2.SizeInBits;
2430 if (r1 <= l2)
2431 return -1;
2432 else if (r2 <= l1)
2433 return 1;
2434 else
2435 return 0;
2436 }
2437
2438 /// Check if fragments overlap between this DIExpression and \p Other.
2439 bool fragmentsOverlap(const DIExpression *Other) const {
2440 if (!isFragment() || !Other->isFragment())
2441 return true;
2442 return fragmentCmp(Other) == 0;
2443 }
2444};
2445
2446/// Global variables.
2447///
2448/// TODO: Remove DisplayName. It's always equal to Name.
2449class DIGlobalVariable : public DIVariable {
2450 friend class LLVMContextImpl;
2451 friend class MDNode;
2452
2453 bool IsLocalToUnit;
2454 bool IsDefinition;
2455
2456 DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2457 bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
2458 ArrayRef<Metadata *> Ops)
2459 : DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
2460 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
2461 ~DIGlobalVariable() = default;
2462
2463 static DIGlobalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
2464 StringRef Name, StringRef LinkageName,
2465 DIFile *File, unsigned Line, DITypeRef Type,
2466 bool IsLocalToUnit, bool IsDefinition,
2467 DIDerivedType *StaticDataMemberDeclaration,
2468 uint32_t AlignInBits, StorageType Storage,
2469 bool ShouldCreate = true) {
2470 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
2471 getCanonicalMDString(Context, LinkageName), File, Line, Type,
2472 IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration,
2473 AlignInBits, Storage, ShouldCreate);
2474 }
2475 static DIGlobalVariable *
2476 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
2477 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
2478 bool IsLocalToUnit, bool IsDefinition,
2479 Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits,
2480 StorageType Storage, bool ShouldCreate = true);
2481
2482 TempDIGlobalVariable cloneImpl() const {
2483 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
2484 getFile(), getLine(), getType(), isLocalToUnit(),
2485 isDefinition(), getStaticDataMemberDeclaration(),
2486 getAlignInBits());
2487 }
2488
2489public:
2490 DEFINE_MDNODE_GET(DIGlobalVariable,
2491 (DIScope * Scope, StringRef Name, StringRef LinkageName,
2492 DIFile *File, unsigned Line, DITypeRef Type,
2493 bool IsLocalToUnit, bool IsDefinition,
2494 DIDerivedType *StaticDataMemberDeclaration,
2495 uint32_t AlignInBits),
2496 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2497 IsDefinition, StaticDataMemberDeclaration, AlignInBits))
2498 DEFINE_MDNODE_GET(DIGlobalVariable,
2499 (Metadata * Scope, MDString *Name, MDString *LinkageName,
2500 Metadata *File, unsigned Line, Metadata *Type,
2501 bool IsLocalToUnit, bool IsDefinition,
2502 Metadata *StaticDataMemberDeclaration,
2503 uint32_t AlignInBits),
2504 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
2505 IsDefinition, StaticDataMemberDeclaration, AlignInBits))
2506
2507 TempDIGlobalVariable clone() const { return cloneImpl(); }
2508
2509 bool isLocalToUnit() const { return IsLocalToUnit; }
2510 bool isDefinition() const { return IsDefinition; }
2511 StringRef getDisplayName() const { return getStringOperand(4); }
2512 StringRef getLinkageName() const { return getStringOperand(5); }
2513 DIDerivedType *getStaticDataMemberDeclaration() const {
2514 return cast_or_null<DIDerivedType>(getRawStaticDataMemberDeclaration());
2515 }
2516
2517 MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
2518 Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(6); }
2519
2520 static bool classof(const Metadata *MD) {
2521 return MD->getMetadataID() == DIGlobalVariableKind;
2522 }
2523};
2524
2525/// Local variable.
2526///
2527/// TODO: Split up flags.
2528class DILocalVariable : public DIVariable {
2529 friend class LLVMContextImpl;
2530 friend class MDNode;
2531
2532 unsigned Arg : 16;
2533 DIFlags Flags;
2534
2535 DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
2536 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
2537 ArrayRef<Metadata *> Ops)
2538 : DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
2539 Arg(Arg), Flags(Flags) {
2540 assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range")(static_cast <bool> (Arg < (1 << 16) &&
"DILocalVariable: Arg out of range") ? void (0) : __assert_fail
("Arg < (1 << 16) && \"DILocalVariable: Arg out of range\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 2540, __extension__ __PRETTY_FUNCTION__))
;
2541 }
2542 ~DILocalVariable() = default;
2543
2544 static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
2545 StringRef Name, DIFile *File, unsigned Line,
2546 DITypeRef Type, unsigned Arg, DIFlags Flags,
2547 uint32_t AlignInBits, StorageType Storage,
2548 bool ShouldCreate = true) {
2549 return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
2550 Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
2551 }
2552 static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
2553 MDString *Name, Metadata *File, unsigned Line,
2554 Metadata *Type, unsigned Arg, DIFlags Flags,
2555 uint32_t AlignInBits, StorageType Storage,
2556 bool ShouldCreate = true);
2557
2558 TempDILocalVariable cloneImpl() const {
2559 return getTemporary(getContext(), getScope(), getName(), getFile(),
2560 getLine(), getType(), getArg(), getFlags(),
2561 getAlignInBits());
2562 }
2563
2564public:
2565 DEFINE_MDNODE_GET(DILocalVariable,
2566 (DILocalScope * Scope, StringRef Name, DIFile *File,
2567 unsigned Line, DITypeRef Type, unsigned Arg,
2568 DIFlags Flags, uint32_t AlignInBits),
2569 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
2570 DEFINE_MDNODE_GET(DILocalVariable,
2571 (Metadata * Scope, MDString *Name, Metadata *File,
2572 unsigned Line, Metadata *Type, unsigned Arg,
2573 DIFlags Flags, uint32_t AlignInBits),
2574 (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
2575
2576 TempDILocalVariable clone() const { return cloneImpl(); }
2577
2578 /// Get the local scope for this variable.
2579 ///
2580 /// Variables must be defined in a local scope.
2581 DILocalScope *getScope() const {
2582 return cast<DILocalScope>(DIVariable::getScope());
2583 }
2584
2585 bool isParameter() const { return Arg; }
2586 unsigned getArg() const { return Arg; }
2587 DIFlags getFlags() const { return Flags; }
2588
2589 bool isArtificial() const { return getFlags() & FlagArtificial; }
2590 bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
2591
2592 /// Check that a location is valid for this variable.
2593 ///
2594 /// Check that \c DL exists, is in the same subprogram, and has the same
2595 /// inlined-at location as \c this. (Otherwise, it's not a valid attachment
2596 /// to a \a DbgInfoIntrinsic.)
2597 bool isValidLocationForIntrinsic(const DILocation *DL) const {
2598 return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
2599 }
2600
2601 static bool classof(const Metadata *MD) {
2602 return MD->getMetadataID() == DILocalVariableKind;
2603 }
2604};
2605
2606class DIObjCProperty : public DINode {
2607 friend class LLVMContextImpl;
2608 friend class MDNode;
2609
2610 unsigned Line;
2611 unsigned Attributes;
2612
2613 DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
2614 unsigned Attributes, ArrayRef<Metadata *> Ops)
2615 : DINode(C, DIObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
2616 Ops),
2617 Line(Line), Attributes(Attributes) {}
2618 ~DIObjCProperty() = default;
2619
2620 static DIObjCProperty *
2621 getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
2622 StringRef GetterName, StringRef SetterName, unsigned Attributes,
2623 DITypeRef Type, StorageType Storage, bool ShouldCreate = true) {
2624 return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
2625 getCanonicalMDString(Context, GetterName),
2626 getCanonicalMDString(Context, SetterName), Attributes, Type,
2627 Storage, ShouldCreate);
2628 }
2629 static DIObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
2630 Metadata *File, unsigned Line,
2631 MDString *GetterName, MDString *SetterName,
2632 unsigned Attributes, Metadata *Type,
2633 StorageType Storage, bool ShouldCreate = true);
2634
2635 TempDIObjCProperty cloneImpl() const {
2636 return getTemporary(getContext(), getName(), getFile(), getLine(),
2637 getGetterName(), getSetterName(), getAttributes(),
2638 getType());
2639 }
2640
2641public:
2642 DEFINE_MDNODE_GET(DIObjCProperty,
2643 (StringRef Name, DIFile *File, unsigned Line,
2644 StringRef GetterName, StringRef SetterName,
2645 unsigned Attributes, DITypeRef Type),
2646 (Name, File, Line, GetterName, SetterName, Attributes,
2647 Type))
2648 DEFINE_MDNODE_GET(DIObjCProperty,
2649 (MDString * Name, Metadata *File, unsigned Line,
2650 MDString *GetterName, MDString *SetterName,
2651 unsigned Attributes, Metadata *Type),
2652 (Name, File, Line, GetterName, SetterName, Attributes,
2653 Type))
2654
2655 TempDIObjCProperty clone() const { return cloneImpl(); }
2656
2657 unsigned getLine() const { return Line; }
2658 unsigned getAttributes() const { return Attributes; }
2659 StringRef getName() const { return getStringOperand(0); }
2660 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2661 StringRef getGetterName() const { return getStringOperand(2); }
2662 StringRef getSetterName() const { return getStringOperand(3); }
2663 DITypeRef getType() const { return DITypeRef(getRawType()); }
2664
2665 StringRef getFilename() const {
2666 if (auto *F = getFile())
2667 return F->getFilename();
2668 return "";
2669 }
2670
2671 StringRef getDirectory() const {
2672 if (auto *F = getFile())
2673 return F->getDirectory();
2674 return "";
2675 }
2676
2677 Optional<StringRef> getSource() const {
2678 if (auto *F = getFile())
2679 return F->getSource();
2680 return None;
2681 }
2682
2683 MDString *getRawName() const { return getOperandAs<MDString>(0); }
2684 Metadata *getRawFile() const { return getOperand(1); }
2685 MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
2686 MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
2687 Metadata *getRawType() const { return getOperand(4); }
2688
2689 static bool classof(const Metadata *MD) {
2690 return MD->getMetadataID() == DIObjCPropertyKind;
2691 }
2692};
2693
2694/// An imported module (C++ using directive or similar).
2695class DIImportedEntity : public DINode {
2696 friend class LLVMContextImpl;
2697 friend class MDNode;
2698
2699 unsigned Line;
2700
2701 DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
2702 unsigned Line, ArrayRef<Metadata *> Ops)
2703 : DINode(C, DIImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
2704 ~DIImportedEntity() = default;
2705
2706 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
2707 DIScope *Scope, DINodeRef Entity,
2708 DIFile *File, unsigned Line, StringRef Name,
2709 StorageType Storage,
2710 bool ShouldCreate = true) {
2711 return getImpl(Context, Tag, Scope, Entity, File, Line,
2712 getCanonicalMDString(Context, Name), Storage, ShouldCreate);
2713 }
2714 static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
2715 Metadata *Scope, Metadata *Entity,
2716 Metadata *File, unsigned Line,
2717 MDString *Name, StorageType Storage,
2718 bool ShouldCreate = true);
2719
2720 TempDIImportedEntity cloneImpl() const {
2721 return getTemporary(getContext(), getTag(), getScope(), getEntity(),
2722 getFile(), getLine(), getName());
2723 }
2724
2725public:
2726 DEFINE_MDNODE_GET(DIImportedEntity,
2727 (unsigned Tag, DIScope *Scope, DINodeRef Entity,
2728 DIFile *File, unsigned Line, StringRef Name = ""),
2729 (Tag, Scope, Entity, File, Line, Name))
2730 DEFINE_MDNODE_GET(DIImportedEntity,
2731 (unsigned Tag, Metadata *Scope, Metadata *Entity,
2732 Metadata *File, unsigned Line, MDString *Name),
2733 (Tag, Scope, Entity, File, Line, Name))
2734
2735 TempDIImportedEntity clone() const { return cloneImpl(); }
2736
2737 unsigned getLine() const { return Line; }
2738 DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
2739 DINodeRef getEntity() const { return DINodeRef(getRawEntity()); }
2740 StringRef getName() const { return getStringOperand(2); }
2741 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2742
2743 Metadata *getRawScope() const { return getOperand(0); }
2744 Metadata *getRawEntity() const { return getOperand(1); }
2745 MDString *getRawName() const { return getOperandAs<MDString>(2); }
2746 Metadata *getRawFile() const { return getOperand(3); }
2747
2748 static bool classof(const Metadata *MD) {
2749 return MD->getMetadataID() == DIImportedEntityKind;
2750 }
2751};
2752
2753/// A pair of DIGlobalVariable and DIExpression.
2754class DIGlobalVariableExpression : public MDNode {
2755 friend class LLVMContextImpl;
2756 friend class MDNode;
2757
2758 DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
2759 ArrayRef<Metadata *> Ops)
2760 : MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
2761 ~DIGlobalVariableExpression() = default;
2762
2763 static DIGlobalVariableExpression *
2764 getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
2765 StorageType Storage, bool ShouldCreate = true);
2766
2767 TempDIGlobalVariableExpression cloneImpl() const {
2768 return getTemporary(getContext(), getVariable(), getExpression());
2769 }
2770
2771public:
2772 DEFINE_MDNODE_GET(DIGlobalVariableExpression,
2773 (Metadata * Variable, Metadata *Expression),
2774 (Variable, Expression))
2775
2776 TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
2777
2778 Metadata *getRawVariable() const { return getOperand(0); }
2779
2780 DIGlobalVariable *getVariable() const {
2781 return cast_or_null<DIGlobalVariable>(getRawVariable());
2782 }
2783
2784 Metadata *getRawExpression() const { return getOperand(1); }
2785
2786 DIExpression *getExpression() const {
2787 return cast<DIExpression>(getRawExpression());
2788 }
2789
2790 static bool classof(const Metadata *MD) {
2791 return MD->getMetadataID() == DIGlobalVariableExpressionKind;
2792 }
2793};
2794
2795/// Macro Info DWARF-like metadata node.
2796///
2797/// A metadata node with a DWARF macro info (i.e., a constant named
2798/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h). Called \a
2799/// DIMacroNode
2800/// because it's potentially used for non-DWARF output.
2801class DIMacroNode : public MDNode {
2802 friend class LLVMContextImpl;
2803 friend class MDNode;
2804
2805protected:
2806 DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
2807 ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
2808 : MDNode(C, ID, Storage, Ops1, Ops2) {
2809 assert(MIType < 1u << 16)(static_cast <bool> (MIType < 1u << 16) ? void
(0) : __assert_fail ("MIType < 1u << 16", "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 2809, __extension__ __PRETTY_FUNCTION__))
;
2810 SubclassData16 = MIType;
2811 }
2812 ~DIMacroNode() = default;
2813
2814 template <class Ty> Ty *getOperandAs(unsigned I) const {
2815 return cast_or_null<Ty>(getOperand(I));
2816 }
2817
2818 StringRef getStringOperand(unsigned I) const {
2819 if (auto *S = getOperandAs<MDString>(I))
2820 return S->getString();
2821 return StringRef();
2822 }
2823
2824 static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
2825 if (S.empty())
2826 return nullptr;
2827 return MDString::get(Context, S);
2828 }
2829
2830public:
2831 unsigned getMacinfoType() const { return SubclassData16; }
2832
2833 static bool classof(const Metadata *MD) {
2834 switch (MD->getMetadataID()) {
2835 default:
2836 return false;
2837 case DIMacroKind:
2838 case DIMacroFileKind:
2839 return true;
2840 }
2841 }
2842};
2843
2844class DIMacro : public DIMacroNode {
2845 friend class LLVMContextImpl;
2846 friend class MDNode;
2847
2848 unsigned Line;
2849
2850 DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
2851 ArrayRef<Metadata *> Ops)
2852 : DIMacroNode(C, DIMacroKind, Storage, MIType, Ops), Line(Line) {}
2853 ~DIMacro() = default;
2854
2855 static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
2856 StringRef Name, StringRef Value, StorageType Storage,
2857 bool ShouldCreate = true) {
2858 return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
2859 getCanonicalMDString(Context, Value), Storage, ShouldCreate);
2860 }
2861 static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
2862 MDString *Name, MDString *Value, StorageType Storage,
2863 bool ShouldCreate = true);
2864
2865 TempDIMacro cloneImpl() const {
2866 return getTemporary(getContext(), getMacinfoType(), getLine(), getName(),
2867 getValue());
2868 }
2869
2870public:
2871 DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, StringRef Name,
2872 StringRef Value = ""),
2873 (MIType, Line, Name, Value))
2874 DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, MDString *Name,
2875 MDString *Value),
2876 (MIType, Line, Name, Value))
2877
2878 TempDIMacro clone() const { return cloneImpl(); }
2879
2880 unsigned getLine() const { return Line; }
2881
2882 StringRef getName() const { return getStringOperand(0); }
2883 StringRef getValue() const { return getStringOperand(1); }
2884
2885 MDString *getRawName() const { return getOperandAs<MDString>(0); }
2886 MDString *getRawValue() const { return getOperandAs<MDString>(1); }
2887
2888 static bool classof(const Metadata *MD) {
2889 return MD->getMetadataID() == DIMacroKind;
2890 }
2891};
2892
2893class DIMacroFile : public DIMacroNode {
2894 friend class LLVMContextImpl;
2895 friend class MDNode;
2896
2897 unsigned Line;
2898
2899 DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
2900 unsigned Line, ArrayRef<Metadata *> Ops)
2901 : DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops), Line(Line) {}
2902 ~DIMacroFile() = default;
2903
2904 static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
2905 unsigned Line, DIFile *File,
2906 DIMacroNodeArray Elements, StorageType Storage,
2907 bool ShouldCreate = true) {
2908 return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
2909 Elements.get(), Storage, ShouldCreate);
2910 }
2911
2912 static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
2913 unsigned Line, Metadata *File, Metadata *Elements,
2914 StorageType Storage, bool ShouldCreate = true);
2915
2916 TempDIMacroFile cloneImpl() const {
2917 return getTemporary(getContext(), getMacinfoType(), getLine(), getFile(),
2918 getElements());
2919 }
2920
2921public:
2922 DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DIFile *File,
2923 DIMacroNodeArray Elements),
2924 (MIType, Line, File, Elements))
2925 DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line,
2926 Metadata *File, Metadata *Elements),
2927 (MIType, Line, File, Elements))
2928
2929 TempDIMacroFile clone() const { return cloneImpl(); }
2930
2931 void replaceElements(DIMacroNodeArray Elements) {
2932#ifndef NDEBUG
2933 for (DIMacroNode *Op : getElements())
2934 assert(is_contained(Elements->operands(), Op) &&(static_cast <bool> (is_contained(Elements->operands
(), Op) && "Lost a macro node during macro node list replacement"
) ? void (0) : __assert_fail ("is_contained(Elements->operands(), Op) && \"Lost a macro node during macro node list replacement\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 2935, __extension__ __PRETTY_FUNCTION__))
2935 "Lost a macro node during macro node list replacement")(static_cast <bool> (is_contained(Elements->operands
(), Op) && "Lost a macro node during macro node list replacement"
) ? void (0) : __assert_fail ("is_contained(Elements->operands(), Op) && \"Lost a macro node during macro node list replacement\""
, "/build/llvm-toolchain-snapshot-7~svn329677/include/llvm/IR/DebugInfoMetadata.h"
, 2935, __extension__ __PRETTY_FUNCTION__))
;
2936#endif
2937 replaceOperandWith(1, Elements.get());
2938 }
2939
2940 unsigned getLine() const { return Line; }
2941 DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
2942
2943 DIMacroNodeArray getElements() const {
2944 return cast_or_null<MDTuple>(getRawElements());
2945 }
2946
2947 Metadata *getRawFile() const { return getOperand(0); }
2948 Metadata *getRawElements() const { return getOperand(1); }
2949
2950 static bool classof(const Metadata *MD) {
2951 return MD->getMetadataID() == DIMacroFileKind;
2952 }
2953};
2954
2955} // end namespace llvm
2956
2957#undef DEFINE_MDNODE_GET_UNPACK_IMPL
2958#undef DEFINE_MDNODE_GET_UNPACK
2959#undef DEFINE_MDNODE_GET
2960
2961#endif // LLVM_IR_DEBUGINFOMETADATA_H