Bug Summary

File:lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Warning:line 905, column 38
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-9/lib/clang/9.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-9~svn362543/lib/CodeGen/AsmPrinter -I /build/llvm-toolchain-snapshot-9~svn362543/build-llvm/include -I /build/llvm-toolchain-snapshot-9~svn362543/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/9.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-9/lib/clang/9.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-9~svn362543/build-llvm/lib/CodeGen/AsmPrinter -fdebug-prefix-map=/build/llvm-toolchain-snapshot-9~svn362543=. -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-2019-06-05-060531-1271-1 -x c++ /build/llvm-toolchain-snapshot-9~svn362543/lib/CodeGen/AsmPrinter/DwarfUnit.cpp -faddrsig

/build/llvm-toolchain-snapshot-9~svn362543/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

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

/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/IR/DebugInfoMetadata.h

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

/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h

1//===- llvm/Support/Casting.h - Allow flexible, checked, casts --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the isa<X>(), cast<X>(), dyn_cast<X>(), cast_or_null<X>(),
10// and dyn_cast_or_null<X>() templates.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_CASTING_H
15#define LLVM_SUPPORT_CASTING_H
16
17#include "llvm/Support/Compiler.h"
18#include "llvm/Support/type_traits.h"
19#include <cassert>
20#include <memory>
21#include <type_traits>
22
23namespace llvm {
24
25//===----------------------------------------------------------------------===//
26// isa<x> Support Templates
27//===----------------------------------------------------------------------===//
28
29// Define a template that can be specialized by smart pointers to reflect the
30// fact that they are automatically dereferenced, and are not involved with the
31// template selection process... the default implementation is a noop.
32//
33template<typename From> struct simplify_type {
34 using SimpleType = From; // The real type this represents...
35
36 // An accessor to get the real value...
37 static SimpleType &getSimplifiedValue(From &Val) { return Val; }
38};
39
40template<typename From> struct simplify_type<const From> {
41 using NonConstSimpleType = typename simplify_type<From>::SimpleType;
42 using SimpleType =
43 typename add_const_past_pointer<NonConstSimpleType>::type;
44 using RetType =
45 typename add_lvalue_reference_if_not_pointer<SimpleType>::type;
46
47 static RetType getSimplifiedValue(const From& Val) {
48 return simplify_type<From>::getSimplifiedValue(const_cast<From&>(Val));
49 }
50};
51
52// The core of the implementation of isa<X> is here; To and From should be
53// the names of classes. This template can be specialized to customize the
54// implementation of isa<> without rewriting it from scratch.
55template <typename To, typename From, typename Enabler = void>
56struct isa_impl {
57 static inline bool doit(const From &Val) {
58 return To::classof(&Val);
59 }
60};
61
62/// Always allow upcasts, and perform no dynamic check for them.
63template <typename To, typename From>
64struct isa_impl<
65 To, From, typename std::enable_if<std::is_base_of<To, From>::value>::type> {
66 static inline bool doit(const From &) { return true; }
67};
68
69template <typename To, typename From> struct isa_impl_cl {
70 static inline bool doit(const From &Val) {
71 return isa_impl<To, From>::doit(Val);
72 }
73};
74
75template <typename To, typename From> struct isa_impl_cl<To, const From> {
76 static inline bool doit(const From &Val) {
77 return isa_impl<To, From>::doit(Val);
78 }
79};
80
81template <typename To, typename From>
82struct isa_impl_cl<To, const std::unique_ptr<From>> {
83 static inline bool doit(const std::unique_ptr<From> &Val) {
84 assert(Val && "isa<> used on a null pointer")((Val && "isa<> used on a null pointer") ? static_cast
<void> (0) : __assert_fail ("Val && \"isa<> used on a null pointer\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 84, __PRETTY_FUNCTION__))
;
85 return isa_impl_cl<To, From>::doit(*Val);
86 }
87};
88
89template <typename To, typename From> struct isa_impl_cl<To, From*> {
90 static inline bool doit(const From *Val) {
91 assert(Val && "isa<> used on a null pointer")((Val && "isa<> used on a null pointer") ? static_cast
<void> (0) : __assert_fail ("Val && \"isa<> used on a null pointer\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 91, __PRETTY_FUNCTION__))
;
92 return isa_impl<To, From>::doit(*Val);
93 }
94};
95
96template <typename To, typename From> struct isa_impl_cl<To, From*const> {
97 static inline bool doit(const From *Val) {
98 assert(Val && "isa<> used on a null pointer")((Val && "isa<> used on a null pointer") ? static_cast
<void> (0) : __assert_fail ("Val && \"isa<> used on a null pointer\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 98, __PRETTY_FUNCTION__))
;
99 return isa_impl<To, From>::doit(*Val);
100 }
101};
102
103template <typename To, typename From> struct isa_impl_cl<To, const From*> {
104 static inline bool doit(const From *Val) {
105 assert(Val && "isa<> used on a null pointer")((Val && "isa<> used on a null pointer") ? static_cast
<void> (0) : __assert_fail ("Val && \"isa<> used on a null pointer\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 105, __PRETTY_FUNCTION__))
;
106 return isa_impl<To, From>::doit(*Val);
107 }
108};
109
110template <typename To, typename From> struct isa_impl_cl<To, const From*const> {
111 static inline bool doit(const From *Val) {
112 assert(Val && "isa<> used on a null pointer")((Val && "isa<> used on a null pointer") ? static_cast
<void> (0) : __assert_fail ("Val && \"isa<> used on a null pointer\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 112, __PRETTY_FUNCTION__))
;
113 return isa_impl<To, From>::doit(*Val);
114 }
115};
116
117template<typename To, typename From, typename SimpleFrom>
118struct isa_impl_wrap {
119 // When From != SimplifiedType, we can simplify the type some more by using
120 // the simplify_type template.
121 static bool doit(const From &Val) {
122 return isa_impl_wrap<To, SimpleFrom,
123 typename simplify_type<SimpleFrom>::SimpleType>::doit(
124 simplify_type<const From>::getSimplifiedValue(Val));
125 }
126};
127
128template<typename To, typename FromTy>
129struct isa_impl_wrap<To, FromTy, FromTy> {
130 // When From == SimpleType, we are as simple as we are going to get.
131 static bool doit(const FromTy &Val) {
132 return isa_impl_cl<To,FromTy>::doit(Val);
133 }
134};
135
136// isa<X> - Return true if the parameter to the template is an instance of the
137// template type argument. Used like this:
138//
139// if (isa<Type>(myVal)) { ... }
140//
141template <class X, class Y> LLVM_NODISCARD[[clang::warn_unused_result]] inline bool isa(const Y &Val) {
142 return isa_impl_wrap<X, const Y,
143 typename simplify_type<const Y>::SimpleType>::doit(Val);
144}
145
146// isa_and_nonnull<X> - Functionally identical to isa, except that a null value
147// is accepted.
148//
149template <class X, class Y>
150LLVM_NODISCARD[[clang::warn_unused_result]] inline bool isa_and_nonnull(const Y &Val) {
151 if (!Val)
152 return false;
153 return isa<X>(Val);
154}
155
156//===----------------------------------------------------------------------===//
157// cast<x> Support Templates
158//===----------------------------------------------------------------------===//
159
160template<class To, class From> struct cast_retty;
161
162// Calculate what type the 'cast' function should return, based on a requested
163// type of To and a source type of From.
164template<class To, class From> struct cast_retty_impl {
165 using ret_type = To &; // Normal case, return Ty&
166};
167template<class To, class From> struct cast_retty_impl<To, const From> {
168 using ret_type = const To &; // Normal case, return Ty&
169};
170
171template<class To, class From> struct cast_retty_impl<To, From*> {
172 using ret_type = To *; // Pointer arg case, return Ty*
173};
174
175template<class To, class From> struct cast_retty_impl<To, const From*> {
176 using ret_type = const To *; // Constant pointer arg case, return const Ty*
177};
178
179template<class To, class From> struct cast_retty_impl<To, const From*const> {
180 using ret_type = const To *; // Constant pointer arg case, return const Ty*
181};
182
183template <class To, class From>
184struct cast_retty_impl<To, std::unique_ptr<From>> {
185private:
186 using PointerType = typename cast_retty_impl<To, From *>::ret_type;
187 using ResultType = typename std::remove_pointer<PointerType>::type;
188
189public:
190 using ret_type = std::unique_ptr<ResultType>;
191};
192
193template<class To, class From, class SimpleFrom>
194struct cast_retty_wrap {
195 // When the simplified type and the from type are not the same, use the type
196 // simplifier to reduce the type, then reuse cast_retty_impl to get the
197 // resultant type.
198 using ret_type = typename cast_retty<To, SimpleFrom>::ret_type;
199};
200
201template<class To, class FromTy>
202struct cast_retty_wrap<To, FromTy, FromTy> {
203 // When the simplified type is equal to the from type, use it directly.
204 using ret_type = typename cast_retty_impl<To,FromTy>::ret_type;
205};
206
207template<class To, class From>
208struct cast_retty {
209 using ret_type = typename cast_retty_wrap<
210 To, From, typename simplify_type<From>::SimpleType>::ret_type;
211};
212
213// Ensure the non-simple values are converted using the simplify_type template
214// that may be specialized by smart pointers...
215//
216template<class To, class From, class SimpleFrom> struct cast_convert_val {
217 // This is not a simple type, use the template to simplify it...
218 static typename cast_retty<To, From>::ret_type doit(From &Val) {
219 return cast_convert_val<To, SimpleFrom,
220 typename simplify_type<SimpleFrom>::SimpleType>::doit(
221 simplify_type<From>::getSimplifiedValue(Val));
222 }
223};
224
225template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> {
226 // This _is_ a simple type, just cast it.
227 static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) {
228 typename cast_retty<To, FromTy>::ret_type Res2
229 = (typename cast_retty<To, FromTy>::ret_type)const_cast<FromTy&>(Val);
230 return Res2;
231 }
232};
233
234template <class X> struct is_simple_type {
235 static const bool value =
236 std::is_same<X, typename simplify_type<X>::SimpleType>::value;
237};
238
239// cast<X> - Return the argument parameter cast to the specified type. This
240// casting operator asserts that the type is correct, so it does not return null
241// on failure. It does not allow a null argument (use cast_or_null for that).
242// It is typically used like this:
243//
244// cast<Instruction>(myVal)->getParent()
245//
246template <class X, class Y>
247inline typename std::enable_if<!is_simple_type<Y>::value,
248 typename cast_retty<X, const Y>::ret_type>::type
249cast(const Y &Val) {
250 assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 250, __PRETTY_FUNCTION__))
;
251 return cast_convert_val<
252 X, const Y, typename simplify_type<const Y>::SimpleType>::doit(Val);
253}
254
255template <class X, class Y>
256inline typename cast_retty<X, Y>::ret_type cast(Y &Val) {
257 assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 257, __PRETTY_FUNCTION__))
;
258 return cast_convert_val<X, Y,
259 typename simplify_type<Y>::SimpleType>::doit(Val);
260}
261
262template <class X, class Y>
263inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) {
264 assert(isa<X>(Val) && "cast<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 264, __PRETTY_FUNCTION__))
;
265 return cast_convert_val<X, Y*,
266 typename simplify_type<Y*>::SimpleType>::doit(Val);
267}
268
269template <class X, class Y>
270inline typename cast_retty<X, std::unique_ptr<Y>>::ret_type
271cast(std::unique_ptr<Y> &&Val) {
272 assert(isa<X>(Val.get()) && "cast<Ty>() argument of incompatible type!")((isa<X>(Val.get()) && "cast<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val.get()) && \"cast<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 272, __PRETTY_FUNCTION__))
;
273 using ret_type = typename cast_retty<X, std::unique_ptr<Y>>::ret_type;
274 return ret_type(
275 cast_convert_val<X, Y *, typename simplify_type<Y *>::SimpleType>::doit(
276 Val.release()));
277}
278
279// cast_or_null<X> - Functionally identical to cast, except that a null value is
280// accepted.
281//
282template <class X, class Y>
283LLVM_NODISCARD[[clang::warn_unused_result]] inline
284 typename std::enable_if<!is_simple_type<Y>::value,
285 typename cast_retty<X, const Y>::ret_type>::type
286 cast_or_null(const Y &Val) {
287 if (!Val)
24
Assuming the condition is false
25
Taking false branch
288 return nullptr;
289 assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast_or_null<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 289, __PRETTY_FUNCTION__))
;
26
Assuming the condition is true
27
'?' condition is true
290 return cast<X>(Val);
28
Returning pointer
291}
292
293template <class X, class Y>
294LLVM_NODISCARD[[clang::warn_unused_result]] inline
295 typename std::enable_if<!is_simple_type<Y>::value,
296 typename cast_retty<X, Y>::ret_type>::type
297 cast_or_null(Y &Val) {
298 if (!Val)
299 return nullptr;
300 assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast_or_null<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 300, __PRETTY_FUNCTION__))
;
301 return cast<X>(Val);
302}
303
304template <class X, class Y>
305LLVM_NODISCARD[[clang::warn_unused_result]] inline typename cast_retty<X, Y *>::ret_type
306cast_or_null(Y *Val) {
307 if (!Val) return nullptr;
308 assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!")((isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"
) ? static_cast<void> (0) : __assert_fail ("isa<X>(Val) && \"cast_or_null<Ty>() argument of incompatible type!\""
, "/build/llvm-toolchain-snapshot-9~svn362543/include/llvm/Support/Casting.h"
, 308, __PRETTY_FUNCTION__))
;
309 return cast<X>(Val);
310}
311
312template <class X, class Y>
313inline typename cast_retty<X, std::unique_ptr<Y>>::ret_type
314cast_or_null(std::unique_ptr<Y> &&Val) {
315 if (!Val)
316 return nullptr;
317 return cast<X>(std::move(Val));
318}
319
320// dyn_cast<X> - Return the argument parameter cast to the specified type. This
321// casting operator returns null if the argument is of the wrong type, so it can
322// be used to test for a type as well as cast if successful. This should be
323// used in the context of an if statement like this:
324//
325// if (const Instruction *I = dyn_cast<Instruction>(myVal)) { ... }
326//
327
328template <class X, class Y>
329LLVM_NODISCARD[[clang::warn_unused_result]] inline
330 typename std::enable_if<!is_simple_type<Y>::value,
331 typename cast_retty<X, const Y>::ret_type>::type
332 dyn_cast(const Y &Val) {
333 return isa<X>(Val) ? cast<X>(Val) : nullptr;
334}
335
336template <class X, class Y>
337LLVM_NODISCARD[[clang::warn_unused_result]] inline typename cast_retty<X, Y>::ret_type dyn_cast(Y &Val) {
338 return isa<X>(Val) ? cast<X>(Val) : nullptr;
339}
340
341template <class X, class Y>
342LLVM_NODISCARD[[clang::warn_unused_result]] inline typename cast_retty<X, Y *>::ret_type dyn_cast(Y *Val) {
343 return isa<X>(Val) ? cast<X>(Val) : nullptr;
344}
345
346// dyn_cast_or_null<X> - Functionally identical to dyn_cast, except that a null
347// value is accepted.
348//
349template <class X, class Y>
350LLVM_NODISCARD[[clang::warn_unused_result]] inline
351 typename std::enable_if<!is_simple_type<Y>::value,
352 typename cast_retty<X, const Y>::ret_type>::type
353 dyn_cast_or_null(const Y &Val) {
354 return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr;
355}
356
357template <class X, class Y>
358LLVM_NODISCARD[[clang::warn_unused_result]] inline
359 typename std::enable_if<!is_simple_type<Y>::value,
360 typename cast_retty<X, Y>::ret_type>::type
361 dyn_cast_or_null(Y &Val) {
362 return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr;
363}
364
365template <class X, class Y>
366LLVM_NODISCARD[[clang::warn_unused_result]] inline typename cast_retty<X, Y *>::ret_type
367dyn_cast_or_null(Y *Val) {
368 return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr;
369}
370
371// unique_dyn_cast<X> - Given a unique_ptr<Y>, try to return a unique_ptr<X>,
372// taking ownership of the input pointer iff isa<X>(Val) is true. If the
373// cast is successful, From refers to nullptr on exit and the casted value
374// is returned. If the cast is unsuccessful, the function returns nullptr
375// and From is unchanged.
376template <class X, class Y>
377LLVM_NODISCARD[[clang::warn_unused_result]] inline auto unique_dyn_cast(std::unique_ptr<Y> &Val)
378 -> decltype(cast<X>(Val)) {
379 if (!isa<X>(Val))
380 return nullptr;
381 return cast<X>(std::move(Val));
382}
383
384template <class X, class Y>
385LLVM_NODISCARD[[clang::warn_unused_result]] inline auto unique_dyn_cast(std::unique_ptr<Y> &&Val)
386 -> decltype(cast<X>(Val)) {
387 return unique_dyn_cast<X, Y>(Val);
388}
389
390// dyn_cast_or_null<X> - Functionally identical to unique_dyn_cast, except that
391// a null value is accepted.
392template <class X, class Y>
393LLVM_NODISCARD[[clang::warn_unused_result]] inline auto unique_dyn_cast_or_null(std::unique_ptr<Y> &Val)
394 -> decltype(cast<X>(Val)) {
395 if (!Val)
396 return nullptr;
397 return unique_dyn_cast<X, Y>(Val);
398}
399
400template <class X, class Y>
401LLVM_NODISCARD[[clang::warn_unused_result]] inline auto unique_dyn_cast_or_null(std::unique_ptr<Y> &&Val)
402 -> decltype(cast<X>(Val)) {
403 return unique_dyn_cast_or_null<X, Y>(Val);
404}
405
406} // end namespace llvm
407
408#endif // LLVM_SUPPORT_CASTING_H