Bug Summary

File:lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Warning:line 887, 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-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 -analyzer-config-compatibility-mode=true -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-8/lib/clang/8.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-8~svn350071/build-llvm/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-8~svn350071/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-8~svn350071/build-llvm/include -I /build/llvm-toolchain-snapshot-8~svn350071/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/8.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.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-8~svn350071/build-llvm/lib/CodeGen/AsmPrinter -fdebug-prefix-map=/build/llvm-toolchain-snapshot-8~svn350071=. -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 2 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-12-27-042839-1215-1 -x c++ /build/llvm-toolchain-snapshot-8~svn350071/lib/CodeGen/AsmPrinter/DwarfUnit.cpp -faddrsig

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

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