Bug Summary

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

Annotated Source Code

Press '?' to see keyboard shortcuts

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

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

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

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

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