Bug Summary

File:llvm/lib/IR/DebugInfoMetadata.cpp
Warning:line 137, column 16
The result of the left shift is undefined due to shifting by '42', which is greater or equal to the width of type 'unsigned int'

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 DebugInfoMetadata.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=none -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-11/lib/clang/11.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/build-llvm/lib/IR -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/build-llvm/include -I /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-11/lib/clang/11.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++14 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/build-llvm/lib/IR -fdebug-prefix-map=/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347=. -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -o /tmp/scan-build-2020-03-09-184146-41876-1 -x c++ /build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp

/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp

1//===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the debug info Metadata classes.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/DebugInfoMetadata.h"
14#include "LLVMContextImpl.h"
15#include "MetadataImpl.h"
16#include "llvm/ADT/SmallSet.h"
17#include "llvm/ADT/StringSwitch.h"
18#include "llvm/IR/DIBuilder.h"
19#include "llvm/IR/Function.h"
20#include "llvm/IR/Instructions.h"
21
22#include <numeric>
23
24using namespace llvm;
25
26const DIExpression::FragmentInfo DebugVariable::DefaultFragment = {
27 std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
28
29DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
30 unsigned Column, ArrayRef<Metadata *> MDs,
31 bool ImplicitCode)
32 : MDNode(C, DILocationKind, Storage, MDs) {
33 assert((MDs.size() == 1 || MDs.size() == 2) &&(((MDs.size() == 1 || MDs.size() == 2) && "Expected a scope and optional inlined-at"
) ? static_cast<void> (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 34, __PRETTY_FUNCTION__))
34 "Expected a scope and optional inlined-at")(((MDs.size() == 1 || MDs.size() == 2) && "Expected a scope and optional inlined-at"
) ? static_cast<void> (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 34, __PRETTY_FUNCTION__))
;
35
36 // Set line and column.
37 assert(Column < (1u << 16) && "Expected 16-bit column")((Column < (1u << 16) && "Expected 16-bit column"
) ? static_cast<void> (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 37, __PRETTY_FUNCTION__))
;
38
39 SubclassData32 = Line;
40 SubclassData16 = Column;
41
42 setImplicitCode(ImplicitCode);
43}
44
45static void adjustColumn(unsigned &Column) {
46 // Set to unknown on overflow. We only have 16 bits to play with here.
47 if (Column >= (1u << 16))
48 Column = 0;
49}
50
51DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
52 unsigned Column, Metadata *Scope,
53 Metadata *InlinedAt, bool ImplicitCode,
54 StorageType Storage, bool ShouldCreate) {
55 // Fixup column.
56 adjustColumn(Column);
57
58 if (Storage == Uniqued) {
59 if (auto *N = getUniqued(Context.pImpl->DILocations,
60 DILocationInfo::KeyTy(Line, Column, Scope,
61 InlinedAt, ImplicitCode)))
62 return N;
63 if (!ShouldCreate)
64 return nullptr;
65 } else {
66 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 66, __PRETTY_FUNCTION__))
;
67 }
68
69 SmallVector<Metadata *, 2> Ops;
70 Ops.push_back(Scope);
71 if (InlinedAt)
72 Ops.push_back(InlinedAt);
73 return storeImpl(new (Ops.size()) DILocation(Context, Storage, Line, Column,
74 Ops, ImplicitCode),
75 Storage, Context.pImpl->DILocations);
76}
77
78const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
79 const DILocation *LocB) {
80 if (!LocA || !LocB)
81 return nullptr;
82
83 if (LocA == LocB)
84 return LocA;
85
86 SmallPtrSet<DILocation *, 5> InlinedLocationsA;
87 for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
88 InlinedLocationsA.insert(L);
89 SmallSet<std::pair<DIScope *, DILocation *>, 5> Locations;
90 DIScope *S = LocA->getScope();
91 DILocation *L = LocA->getInlinedAt();
92 while (S) {
93 Locations.insert(std::make_pair(S, L));
94 S = S->getScope();
95 if (!S && L) {
96 S = L->getScope();
97 L = L->getInlinedAt();
98 }
99 }
100 const DILocation *Result = LocB;
101 S = LocB->getScope();
102 L = LocB->getInlinedAt();
103 while (S) {
104 if (Locations.count(std::make_pair(S, L)))
105 break;
106 S = S->getScope();
107 if (!S && L) {
108 S = L->getScope();
109 L = L->getInlinedAt();
110 }
111 }
112
113 // If the two locations are irreconsilable, just pick one. This is misleading,
114 // but on the other hand, it's a "line 0" location.
115 if (!S || !isa<DILocalScope>(S))
116 S = LocA->getScope();
117 return DILocation::get(Result->getContext(), 0, 0, S, L);
118}
119
120Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI) {
121 SmallVector<unsigned, 3> Components = {BD, DF, CI};
122 uint64_t RemainingWork = 0U;
123 // We use RemainingWork to figure out if we have no remaining components to
124 // encode. For example: if BD != 0 but DF == 0 && CI == 0, we don't need to
125 // encode anything for the latter 2.
126 // Since any of the input components is at most 32 bits, their sum will be
127 // less than 34 bits, and thus RemainingWork won't overflow.
128 RemainingWork = std::accumulate(Components.begin(), Components.end(), RemainingWork);
129
130 int I = 0;
131 unsigned Ret = 0;
132 unsigned NextBitInsertionIndex = 0;
133 while (RemainingWork > 0) {
1
Assuming 'RemainingWork' is > 0
2
Loop condition is true. Entering loop body
3
Assuming 'RemainingWork' is > 0
4
Loop condition is true. Entering loop body
5
Assuming 'RemainingWork' is > 0
6
Loop condition is true. Entering loop body
14
Assuming 'RemainingWork' is > 0
15
Loop condition is true. Entering loop body
134 unsigned C = Components[I++];
135 RemainingWork -= C;
136 unsigned EC = encodeComponent(C);
137 Ret |= (EC << NextBitInsertionIndex);
16
The result of the left shift is undefined due to shifting by '42', which is greater or equal to the width of type 'unsigned int'
138 NextBitInsertionIndex += encodingBits(C);
7
Calling 'DILocation::encodingBits'
12
Returning from 'DILocation::encodingBits'
13
The value 42 is assigned to 'NextBitInsertionIndex'
139 }
140
141 // Encoding may be unsuccessful because of overflow. We determine success by
142 // checking equivalence of components before & after encoding. Alternatively,
143 // we could determine Success during encoding, but the current alternative is
144 // simpler.
145 unsigned TBD, TDF, TCI = 0;
146 decodeDiscriminator(Ret, TBD, TDF, TCI);
147 if (TBD == BD && TDF == DF && TCI == CI)
148 return Ret;
149 return None;
150}
151
152void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
153 unsigned &CI) {
154 BD = getUnsignedFromPrefixEncoding(D);
155 DF = getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(D));
156 CI = getUnsignedFromPrefixEncoding(
157 getNextComponentInDiscriminator(getNextComponentInDiscriminator(D)));
158}
159
160
161DINode::DIFlags DINode::getFlag(StringRef Flag) {
162 return StringSwitch<DIFlags>(Flag)
163#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
164#include "llvm/IR/DebugInfoFlags.def"
165 .Default(DINode::FlagZero);
166}
167
168StringRef DINode::getFlagString(DIFlags Flag) {
169 switch (Flag) {
170#define HANDLE_DI_FLAG(ID, NAME) \
171 case Flag##NAME: \
172 return "DIFlag" #NAME;
173#include "llvm/IR/DebugInfoFlags.def"
174 }
175 return "";
176}
177
178DINode::DIFlags DINode::splitFlags(DIFlags Flags,
179 SmallVectorImpl<DIFlags> &SplitFlags) {
180 // Flags that are packed together need to be specially handled, so
181 // that, for example, we emit "DIFlagPublic" and not
182 // "DIFlagPrivate | DIFlagProtected".
183 if (DIFlags A = Flags & FlagAccessibility) {
184 if (A == FlagPrivate)
185 SplitFlags.push_back(FlagPrivate);
186 else if (A == FlagProtected)
187 SplitFlags.push_back(FlagProtected);
188 else
189 SplitFlags.push_back(FlagPublic);
190 Flags &= ~A;
191 }
192 if (DIFlags R = Flags & FlagPtrToMemberRep) {
193 if (R == FlagSingleInheritance)
194 SplitFlags.push_back(FlagSingleInheritance);
195 else if (R == FlagMultipleInheritance)
196 SplitFlags.push_back(FlagMultipleInheritance);
197 else
198 SplitFlags.push_back(FlagVirtualInheritance);
199 Flags &= ~R;
200 }
201 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
202 Flags &= ~FlagIndirectVirtualBase;
203 SplitFlags.push_back(FlagIndirectVirtualBase);
204 }
205
206#define HANDLE_DI_FLAG(ID, NAME) \
207 if (DIFlags Bit = Flags & Flag##NAME) { \
208 SplitFlags.push_back(Bit); \
209 Flags &= ~Bit; \
210 }
211#include "llvm/IR/DebugInfoFlags.def"
212 return Flags;
213}
214
215DIScope *DIScope::getScope() const {
216 if (auto *T = dyn_cast<DIType>(this))
217 return T->getScope();
218
219 if (auto *SP = dyn_cast<DISubprogram>(this))
220 return SP->getScope();
221
222 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
223 return LB->getScope();
224
225 if (auto *NS = dyn_cast<DINamespace>(this))
226 return NS->getScope();
227
228 if (auto *CB = dyn_cast<DICommonBlock>(this))
229 return CB->getScope();
230
231 if (auto *M = dyn_cast<DIModule>(this))
232 return M->getScope();
233
234 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&(((isa<DIFile>(this) || isa<DICompileUnit>(this))
&& "Unhandled type of scope.") ? static_cast<void
> (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 235, __PRETTY_FUNCTION__))
235 "Unhandled type of scope.")(((isa<DIFile>(this) || isa<DICompileUnit>(this))
&& "Unhandled type of scope.") ? static_cast<void
> (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 235, __PRETTY_FUNCTION__))
;
236 return nullptr;
237}
238
239StringRef DIScope::getName() const {
240 if (auto *T = dyn_cast<DIType>(this))
241 return T->getName();
242 if (auto *SP = dyn_cast<DISubprogram>(this))
243 return SP->getName();
244 if (auto *NS = dyn_cast<DINamespace>(this))
245 return NS->getName();
246 if (auto *CB = dyn_cast<DICommonBlock>(this))
247 return CB->getName();
248 if (auto *M = dyn_cast<DIModule>(this))
249 return M->getName();
250 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 252, __PRETTY_FUNCTION__))
251 isa<DICompileUnit>(this)) &&(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 252, __PRETTY_FUNCTION__))
252 "Unhandled type of scope.")(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 252, __PRETTY_FUNCTION__))
;
253 return "";
254}
255
256#ifndef NDEBUG
257static bool isCanonical(const MDString *S) {
258 return !S || !S->getString().empty();
259}
260#endif
261
262GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
263 MDString *Header,
264 ArrayRef<Metadata *> DwarfOps,
265 StorageType Storage, bool ShouldCreate) {
266 unsigned Hash = 0;
267 if (Storage == Uniqued) {
268 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
269 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
270 return N;
271 if (!ShouldCreate)
272 return nullptr;
273 Hash = Key.getHash();
274 } else {
275 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 275, __PRETTY_FUNCTION__))
;
276 }
277
278 // Use a nullptr for empty headers.
279 assert(isCanonical(Header) && "Expected canonical MDString")((isCanonical(Header) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Header) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 279, __PRETTY_FUNCTION__))
;
280 Metadata *PreOps[] = {Header};
281 return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
282 Context, Storage, Hash, Tag, PreOps, DwarfOps),
283 Storage, Context.pImpl->GenericDINodes);
284}
285
286void GenericDINode::recalculateHash() {
287 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
288}
289
290#define UNWRAP_ARGS_IMPL(...)... __VA_ARGS__
291#define UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS UNWRAP_ARGS_IMPL ARGS
292#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->CLASSs, CLASSInfo::KeyTy(UNWRAP_ARGS_IMPL ARGS))) return
N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 292, __PRETTY_FUNCTION__)); } } while (false)
\
293 do { \
294 if (Storage == Uniqued) { \
295 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
296 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS))) \
297 return N; \
298 if (!ShouldCreate) \
299 return nullptr; \
300 } else { \
301 assert(ShouldCreate && \((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 302, __PRETTY_FUNCTION__))
302 "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 302, __PRETTY_FUNCTION__))
; \
303 } \
304 } while (false)
305#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, UNWRAP_ARGS_IMPL ARGS, OPS), Storage, Context.pImpl->CLASSs
)
\
306 return storeImpl(new (array_lengthof(OPS)) \
307 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
308 Storage, Context.pImpl->CLASS##s)
309#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS), Storage, Context.pImpl->CLASSs)
\
310 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS), \
311 Storage, Context.pImpl->CLASS##s)
312#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, OPS), Storage, Context.pImpl->CLASSs)
\
313 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
314 Storage, Context.pImpl->CLASS##s)
315#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)return storeImpl(new (NUM_OPS) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS, OPS), Storage, Context.pImpl->CLASSs)
\
316 return storeImpl(new (NUM_OPS) \
317 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
318 Storage, Context.pImpl->CLASS##s)
319
320DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
321 StorageType Storage, bool ShouldCreate) {
322 auto *CountNode = ConstantAsMetadata::get(
323 ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
324 return getImpl(Context, CountNode, Lo, Storage, ShouldCreate);
325}
326
327DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
328 int64_t Lo, StorageType Storage,
329 bool ShouldCreate) {
330 DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, Lo))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubranges, DISubrangeInfo::KeyTy(CountNode, Lo))
) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 330, __PRETTY_FUNCTION__)); } } while (false)
;
331 Metadata *Ops[] = { CountNode };
332 DEFINE_GETIMPL_STORE(DISubrange, (CountNode, Lo), Ops)return storeImpl(new (array_lengthof(Ops)) DISubrange(Context
, Storage, CountNode, Lo, Ops), Storage, Context.pImpl->DISubranges
)
;
333}
334
335DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
336 bool IsUnsigned, MDString *Name,
337 StorageType Storage, bool ShouldCreate) {
338 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 338, __PRETTY_FUNCTION__))
;
339 DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, IsUnsigned, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIEnumerators, DIEnumeratorInfo::KeyTy(Value, IsUnsigned
, Name))) return N; if (!ShouldCreate) return nullptr; } else
{ ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 339, __PRETTY_FUNCTION__)); } } while (false)
;
340 Metadata *Ops[] = {Name};
341 DEFINE_GETIMPL_STORE(DIEnumerator, (Value, IsUnsigned), Ops)return storeImpl(new (array_lengthof(Ops)) DIEnumerator(Context
, Storage, Value, IsUnsigned, Ops), Storage, Context.pImpl->
DIEnumerators)
;
342}
343
344DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
345 MDString *Name, uint64_t SizeInBits,
346 uint32_t AlignInBits, unsigned Encoding,
347 DIFlags Flags, StorageType Storage,
348 bool ShouldCreate) {
349 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 349, __PRETTY_FUNCTION__))
;
350 DEFINE_GETIMPL_LOOKUP(DIBasicType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding, Flags))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 351, __PRETTY_FUNCTION__)); } } while (false)
351 (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding, Flags))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 351, __PRETTY_FUNCTION__)); } } while (false)
;
352 Metadata *Ops[] = {nullptr, nullptr, Name};
353 DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding,return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Flags, Ops
), Storage, Context.pImpl->DIBasicTypes)
354 Flags), Ops)return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Flags, Ops
), Storage, Context.pImpl->DIBasicTypes)
;
355}
356
357Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
358 switch (getEncoding()) {
359 case dwarf::DW_ATE_signed:
360 case dwarf::DW_ATE_signed_char:
361 return Signedness::Signed;
362 case dwarf::DW_ATE_unsigned:
363 case dwarf::DW_ATE_unsigned_char:
364 return Signedness::Unsigned;
365 default:
366 return None;
367 }
368}
369
370DIDerivedType *DIDerivedType::getImpl(
371 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
372 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
373 uint32_t AlignInBits, uint64_t OffsetInBits,
374 Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
375 StorageType Storage, bool ShouldCreate) {
376 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 376, __PRETTY_FUNCTION__))
;
377 DEFINE_GETIMPL_LOOKUP(DIDerivedType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 380, __PRETTY_FUNCTION__)); } } while (false)
378 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 380, __PRETTY_FUNCTION__)); } } while (false)
379 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 380, __PRETTY_FUNCTION__)); } } while (false)
380 ExtraData))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 380, __PRETTY_FUNCTION__)); } } while (false)
;
381 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
382 DEFINE_GETIMPL_STORE(return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
383 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
384 DWARFAddressSpace, Flags), Ops)return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
;
385}
386
387DICompositeType *DICompositeType::getImpl(
388 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
389 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
390 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
391 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
392 Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
393 StorageType Storage, bool ShouldCreate) {
394 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 394, __PRETTY_FUNCTION__))
;
395
396 // Keep this in sync with buildODRType.
397 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 400, __PRETTY_FUNCTION__)); } } while (false)
398 DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 400, __PRETTY_FUNCTION__)); } } while (false)
399 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 400, __PRETTY_FUNCTION__)); } } while (false)
400 VTableHolder, TemplateParams, Identifier, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 400, __PRETTY_FUNCTION__)); } } while (false)
;
401 Metadata *Ops[] = {File, Scope, Name, BaseType,
402 Elements, VTableHolder, TemplateParams, Identifier,
403 Discriminator};
404 DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
405 AlignInBits, OffsetInBits, Flags),return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
406 Ops)return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
;
407}
408
409DICompositeType *DICompositeType::buildODRType(
410 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
411 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
412 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
413 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
414 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
415 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 415, __PRETTY_FUNCTION__))
;
416 if (!Context.isODRUniquingDebugTypes())
417 return nullptr;
418 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
419 if (!CT)
420 return CT = DICompositeType::getDistinct(
421 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
422 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
423 VTableHolder, TemplateParams, &Identifier, Discriminator);
424
425 // Only mutate CT if it's a forward declaration and the new operands aren't.
426 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?")((CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?"
) ? static_cast<void> (0) : __assert_fail ("CT->getRawIdentifier() == &Identifier && \"Wrong ODR identifier?\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 426, __PRETTY_FUNCTION__))
;
427 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
428 return CT;
429
430 // Mutate CT in place. Keep this in sync with getImpl.
431 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
432 Flags);
433 Metadata *Ops[] = {File, Scope, Name, BaseType,
434 Elements, VTableHolder, TemplateParams, &Identifier,
435 Discriminator};
436 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&(((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands
() && "Mismatched number of operands") ? static_cast<
void> (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 437, __PRETTY_FUNCTION__))
437 "Mismatched number of operands")(((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands
() && "Mismatched number of operands") ? static_cast<
void> (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 437, __PRETTY_FUNCTION__))
;
438 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
439 if (Ops[I] != CT->getOperand(I))
440 CT->setOperand(I, Ops[I]);
441 return CT;
442}
443
444DICompositeType *DICompositeType::getODRType(
445 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
446 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
447 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
448 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
449 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
450 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 450, __PRETTY_FUNCTION__))
;
451 if (!Context.isODRUniquingDebugTypes())
452 return nullptr;
453 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
454 if (!CT)
455 CT = DICompositeType::getDistinct(
456 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
457 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
458 TemplateParams, &Identifier, Discriminator);
459 return CT;
460}
461
462DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
463 MDString &Identifier) {
464 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 464, __PRETTY_FUNCTION__))
;
465 if (!Context.isODRUniquingDebugTypes())
466 return nullptr;
467 return Context.pImpl->DITypeMap->lookup(&Identifier);
468}
469
470DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
471 uint8_t CC, Metadata *TypeArray,
472 StorageType Storage,
473 bool ShouldCreate) {
474 DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubroutineTypes, DISubroutineTypeInfo::KeyTy(Flags
, CC, TypeArray))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 474, __PRETTY_FUNCTION__)); } } while (false)
;
475 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
476 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops)return storeImpl(new (array_lengthof(Ops)) DISubroutineType(Context
, Storage, Flags, CC, Ops), Storage, Context.pImpl->DISubroutineTypes
)
;
477}
478
479// FIXME: Implement this string-enum correspondence with a .def file and macros,
480// so that the association is explicit rather than implied.
481static const char *ChecksumKindName[DIFile::CSK_Last] = {
482 "CSK_MD5",
483 "CSK_SHA1"
484};
485
486StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
487 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind")((CSKind <= DIFile::CSK_Last && "Invalid checksum kind"
) ? static_cast<void> (0) : __assert_fail ("CSKind <= DIFile::CSK_Last && \"Invalid checksum kind\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 487, __PRETTY_FUNCTION__))
;
488 // The first space was originally the CSK_None variant, which is now
489 // obsolete, but the space is still reserved in ChecksumKind, so we account
490 // for it here.
491 return ChecksumKindName[CSKind - 1];
492}
493
494Optional<DIFile::ChecksumKind> DIFile::getChecksumKind(StringRef CSKindStr) {
495 return StringSwitch<Optional<DIFile::ChecksumKind>>(CSKindStr)
496 .Case("CSK_MD5", DIFile::CSK_MD5)
497 .Case("CSK_SHA1", DIFile::CSK_SHA1)
498 .Default(None);
499}
500
501DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
502 MDString *Directory,
503 Optional<DIFile::ChecksumInfo<MDString *>> CS,
504 Optional<MDString *> Source, StorageType Storage,
505 bool ShouldCreate) {
506 assert(isCanonical(Filename) && "Expected canonical MDString")((isCanonical(Filename) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Filename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 506, __PRETTY_FUNCTION__))
;
507 assert(isCanonical(Directory) && "Expected canonical MDString")((isCanonical(Directory) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Directory) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 507, __PRETTY_FUNCTION__))
;
508 assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString")(((!CS || isCanonical(CS->Value)) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("(!CS || isCanonical(CS->Value)) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 508, __PRETTY_FUNCTION__))
;
509 assert((!Source || isCanonical(*Source)) && "Expected canonical MDString")(((!Source || isCanonical(*Source)) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("(!Source || isCanonical(*Source)) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 509, __PRETTY_FUNCTION__))
;
510 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS, Source))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIFiles, DIFileInfo::KeyTy(Filename, Directory, CS
, Source))) return N; if (!ShouldCreate) return nullptr; } else
{ ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 510, __PRETTY_FUNCTION__)); } } while (false)
;
511 Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr,
512 Source.getValueOr(nullptr)};
513 DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops)return storeImpl(new (array_lengthof(Ops)) DIFile(Context, Storage
, CS, Source, Ops), Storage, Context.pImpl->DIFiles)
;
514}
515
516DICompileUnit *DICompileUnit::getImpl(
517 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
518 MDString *Producer, bool IsOptimized, MDString *Flags,
519 unsigned RuntimeVersion, MDString *SplitDebugFilename,
520 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
521 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
522 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
523 unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
524 StorageType Storage, bool ShouldCreate) {
525 assert(Storage != Uniqued && "Cannot unique DICompileUnit")((Storage != Uniqued && "Cannot unique DICompileUnit"
) ? static_cast<void> (0) : __assert_fail ("Storage != Uniqued && \"Cannot unique DICompileUnit\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 525, __PRETTY_FUNCTION__))
;
526 assert(isCanonical(Producer) && "Expected canonical MDString")((isCanonical(Producer) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Producer) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 526, __PRETTY_FUNCTION__))
;
527 assert(isCanonical(Flags) && "Expected canonical MDString")((isCanonical(Flags) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Flags) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 527, __PRETTY_FUNCTION__))
;
528 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString")((isCanonical(SplitDebugFilename) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(SplitDebugFilename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 528, __PRETTY_FUNCTION__))
;
529
530 Metadata *Ops[] = {
531 File, Producer, Flags, SplitDebugFilename,
532 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
533 Macros, SysRoot};
534 return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
535 Context, Storage, SourceLanguage, IsOptimized,
536 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
537 DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
538 Ops),
539 Storage);
540}
541
542Optional<DICompileUnit::DebugEmissionKind>
543DICompileUnit::getEmissionKind(StringRef Str) {
544 return StringSwitch<Optional<DebugEmissionKind>>(Str)
545 .Case("NoDebug", NoDebug)
546 .Case("FullDebug", FullDebug)
547 .Case("LineTablesOnly", LineTablesOnly)
548 .Case("DebugDirectivesOnly", DebugDirectivesOnly)
549 .Default(None);
550}
551
552Optional<DICompileUnit::DebugNameTableKind>
553DICompileUnit::getNameTableKind(StringRef Str) {
554 return StringSwitch<Optional<DebugNameTableKind>>(Str)
555 .Case("Default", DebugNameTableKind::Default)
556 .Case("GNU", DebugNameTableKind::GNU)
557 .Case("None", DebugNameTableKind::None)
558 .Default(None);
559}
560
561const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
562 switch (EK) {
563 case NoDebug: return "NoDebug";
564 case FullDebug: return "FullDebug";
565 case LineTablesOnly: return "LineTablesOnly";
566 case DebugDirectivesOnly: return "DebugDirectivesOnly";
567 }
568 return nullptr;
569}
570
571const char *DICompileUnit::nameTableKindString(DebugNameTableKind NTK) {
572 switch (NTK) {
573 case DebugNameTableKind::Default:
574 return nullptr;
575 case DebugNameTableKind::GNU:
576 return "GNU";
577 case DebugNameTableKind::None:
578 return "None";
579 }
580 return nullptr;
581}
582
583DISubprogram *DILocalScope::getSubprogram() const {
584 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
585 return Block->getScope()->getSubprogram();
586 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
587}
588
589DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
590 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
591 return File->getScope()->getNonLexicalBlockFileScope();
592 return const_cast<DILocalScope *>(this);
593}
594
595DISubprogram::DISPFlags DISubprogram::getFlag(StringRef Flag) {
596 return StringSwitch<DISPFlags>(Flag)
597#define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
598#include "llvm/IR/DebugInfoFlags.def"
599 .Default(SPFlagZero);
600}
601
602StringRef DISubprogram::getFlagString(DISPFlags Flag) {
603 switch (Flag) {
604 // Appease a warning.
605 case SPFlagVirtuality:
606 return "";
607#define HANDLE_DISP_FLAG(ID, NAME) \
608 case SPFlag##NAME: \
609 return "DISPFlag" #NAME;
610#include "llvm/IR/DebugInfoFlags.def"
611 }
612 return "";
613}
614
615DISubprogram::DISPFlags
616DISubprogram::splitFlags(DISPFlags Flags,
617 SmallVectorImpl<DISPFlags> &SplitFlags) {
618 // Multi-bit fields can require special handling. In our case, however, the
619 // only multi-bit field is virtuality, and all its values happen to be
620 // single-bit values, so the right behavior just falls out.
621#define HANDLE_DISP_FLAG(ID, NAME) \
622 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
623 SplitFlags.push_back(Bit); \
624 Flags &= ~Bit; \
625 }
626#include "llvm/IR/DebugInfoFlags.def"
627 return Flags;
628}
629
630DISubprogram *DISubprogram::getImpl(
631 LLVMContext &Context, Metadata *Scope, MDString *Name,
632 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
633 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
634 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
635 Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
636 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
637 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 637, __PRETTY_FUNCTION__))
;
638 assert(isCanonical(LinkageName) && "Expected canonical MDString")((isCanonical(LinkageName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 638, __PRETTY_FUNCTION__))
;
639 DEFINE_GETIMPL_LOOKUP(DISubprogram,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex
, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration
, RetainedNodes, ThrownTypes))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 643, __PRETTY_FUNCTION__)); } } while (false)
640 (Scope, Name, LinkageName, File, Line, Type, ScopeLine,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex
, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration
, RetainedNodes, ThrownTypes))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 643, __PRETTY_FUNCTION__)); } } while (false)
641 ContainingType, VirtualIndex, ThisAdjustment, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex
, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration
, RetainedNodes, ThrownTypes))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 643, __PRETTY_FUNCTION__)); } } while (false)
642 SPFlags, Unit, TemplateParams, Declaration,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex
, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration
, RetainedNodes, ThrownTypes))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 643, __PRETTY_FUNCTION__)); } } while (false)
643 RetainedNodes, ThrownTypes))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, ScopeLine, ContainingType, VirtualIndex
, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams, Declaration
, RetainedNodes, ThrownTypes))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 643, __PRETTY_FUNCTION__)); } } while (false)
;
644 SmallVector<Metadata *, 11> Ops = {
645 File, Scope, Name, LinkageName, Type, Unit,
646 Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes};
647 if (!ThrownTypes) {
648 Ops.pop_back();
649 if (!TemplateParams) {
650 Ops.pop_back();
651 if (!ContainingType)
652 Ops.pop_back();
653 }
654 }
655 DEFINE_GETIMPL_STORE_N(return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags
, Ops), Storage, Context.pImpl->DISubprograms)
656 DISubprogram,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags
, Ops), Storage, Context.pImpl->DISubprograms)
657 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags), Ops,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags
, Ops), Storage, Context.pImpl->DISubprograms)
658 Ops.size())return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags
, Ops), Storage, Context.pImpl->DISubprograms)
;
659}
660
661bool DISubprogram::describes(const Function *F) const {
662 assert(F && "Invalid function")((F && "Invalid function") ? static_cast<void> (
0) : __assert_fail ("F && \"Invalid function\"", "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 662, __PRETTY_FUNCTION__))
;
663 return F->getSubprogram() == this;
664}
665
666DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
667 Metadata *File, unsigned Line,
668 unsigned Column, StorageType Storage,
669 bool ShouldCreate) {
670 // Fixup column.
671 adjustColumn(Column);
672
673 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 673, __PRETTY_FUNCTION__))
;
674 DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlocks, DILexicalBlockInfo::KeyTy(Scope, File
, Line, Column))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 674, __PRETTY_FUNCTION__)); } } while (false)
;
675 Metadata *Ops[] = {File, Scope};
676 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlock(Context
, Storage, Line, Column, Ops), Storage, Context.pImpl->DILexicalBlocks
)
;
677}
678
679DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
680 Metadata *Scope, Metadata *File,
681 unsigned Discriminator,
682 StorageType Storage,
683 bool ShouldCreate) {
684 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 684, __PRETTY_FUNCTION__))
;
685 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlockFiles, DILexicalBlockFileInfo::KeyTy
(Scope, File, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 685, __PRETTY_FUNCTION__)); } } while (false)
;
686 Metadata *Ops[] = {File, Scope};
687 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlockFile
(Context, Storage, Discriminator, Ops), Storage, Context.pImpl
->DILexicalBlockFiles)
;
688}
689
690DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
691 MDString *Name, bool ExportSymbols,
692 StorageType Storage, bool ShouldCreate) {
693 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 693, __PRETTY_FUNCTION__))
;
694 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DINamespaces, DINamespaceInfo::KeyTy(Scope, Name, ExportSymbols
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 694, __PRETTY_FUNCTION__)); } } while (false)
;
695 // The nullptr is for DIScope's File operand. This should be refactored.
696 Metadata *Ops[] = {nullptr, Scope, Name};
697 DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops)return storeImpl(new (array_lengthof(Ops)) DINamespace(Context
, Storage, ExportSymbols, Ops), Storage, Context.pImpl->DINamespaces
)
;
698}
699
700DICommonBlock *DICommonBlock::getImpl(LLVMContext &Context, Metadata *Scope,
701 Metadata *Decl, MDString *Name,
702 Metadata *File, unsigned LineNo,
703 StorageType Storage, bool ShouldCreate) {
704 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 704, __PRETTY_FUNCTION__))
;
705 DEFINE_GETIMPL_LOOKUP(DICommonBlock, (Scope, Decl, Name, File, LineNo))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICommonBlocks, DICommonBlockInfo::KeyTy(Scope, Decl
, Name, File, LineNo))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 705, __PRETTY_FUNCTION__)); } } while (false)
;
706 // The nullptr is for DIScope's File operand. This should be refactored.
707 Metadata *Ops[] = {Scope, Decl, Name, File};
708 DEFINE_GETIMPL_STORE(DICommonBlock, (LineNo), Ops)return storeImpl(new (array_lengthof(Ops)) DICommonBlock(Context
, Storage, LineNo, Ops), Storage, Context.pImpl->DICommonBlocks
)
;
709}
710
711DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
712 MDString *Name, MDString *ConfigurationMacros,
713 MDString *IncludePath, StorageType Storage,
714 bool ShouldCreate) {
715 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 715, __PRETTY_FUNCTION__))
;
716 DEFINE_GETIMPL_LOOKUP(DIModule,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 717, __PRETTY_FUNCTION__)); } } while (false)
717 (Scope, Name, ConfigurationMacros, IncludePath))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 717, __PRETTY_FUNCTION__)); } } while (false)
;
718 Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath};
719 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops)return storeImpl(new (array_lengthof(Ops)) DIModule(Context, Storage
, Ops), Storage, Context.pImpl->DIModules)
;
720}
721
722DITemplateTypeParameter *
723DITemplateTypeParameter::getImpl(LLVMContext &Context, MDString *Name,
724 Metadata *Type, bool isDefault,
725 StorageType Storage, bool ShouldCreate) {
726 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 726, __PRETTY_FUNCTION__))
;
727 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type, isDefault))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateTypeParameters, DITemplateTypeParameterInfo
::KeyTy(Name, Type, isDefault))) return N; if (!ShouldCreate)
return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 727, __PRETTY_FUNCTION__)); } } while (false)
;
728 Metadata *Ops[] = {Name, Type};
729 DEFINE_GETIMPL_STORE(DITemplateTypeParameter, (isDefault), Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateTypeParameter
(Context, Storage, isDefault, Ops), Storage, Context.pImpl->
DITemplateTypeParameters)
;
730}
731
732DITemplateValueParameter *DITemplateValueParameter::getImpl(
733 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
734 bool isDefault, Metadata *Value, StorageType Storage, bool ShouldCreate) {
735 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 735, __PRETTY_FUNCTION__))
;
736 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateValueParameters, DITemplateValueParameterInfo
::KeyTy(Tag, Name, Type, isDefault, Value))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 737, __PRETTY_FUNCTION__)); } } while (false)
737 (Tag, Name, Type, isDefault, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateValueParameters, DITemplateValueParameterInfo
::KeyTy(Tag, Name, Type, isDefault, Value))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 737, __PRETTY_FUNCTION__)); } } while (false)
;
738 Metadata *Ops[] = {Name, Type, Value};
739 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag, isDefault), Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateValueParameter
(Context, Storage, Tag, isDefault, Ops), Storage, Context.pImpl
->DITemplateValueParameters)
;
740}
741
742DIGlobalVariable *
743DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
744 MDString *LinkageName, Metadata *File, unsigned Line,
745 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
746 Metadata *StaticDataMemberDeclaration,
747 Metadata *TemplateParams, uint32_t AlignInBits,
748 StorageType Storage, bool ShouldCreate) {
749 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 749, __PRETTY_FUNCTION__))
;
750 assert(isCanonical(LinkageName) && "Expected canonical MDString")((isCanonical(LinkageName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 750, __PRETTY_FUNCTION__))
;
751 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable, (Scope, Name, LinkageName, File, Line,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 754, __PRETTY_FUNCTION__)); } } while (false)
752 Type, IsLocalToUnit, IsDefinition,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 754, __PRETTY_FUNCTION__)); } } while (false)
753 StaticDataMemberDeclaration,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 754, __PRETTY_FUNCTION__)); } } while (false)
754 TemplateParams, AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 754, __PRETTY_FUNCTION__)); } } while (false)
;
755 Metadata *Ops[] = {Scope,
756 Name,
757 File,
758 Type,
759 Name,
760 LinkageName,
761 StaticDataMemberDeclaration,
762 TemplateParams};
763 DEFINE_GETIMPL_STORE(DIGlobalVariable,return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
764 (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
;
765}
766
767DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
768 MDString *Name, Metadata *File,
769 unsigned Line, Metadata *Type,
770 unsigned Arg, DIFlags Flags,
771 uint32_t AlignInBits,
772 StorageType Storage,
773 bool ShouldCreate) {
774 // 64K ought to be enough for any frontend.
775 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits")((Arg <= (65535) && "Expected argument number to fit in 16-bits"
) ? static_cast<void> (0) : __assert_fail ("Arg <= UINT16_MAX && \"Expected argument number to fit in 16-bits\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 775, __PRETTY_FUNCTION__))
;
776
777 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 777, __PRETTY_FUNCTION__))
;
778 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 778, __PRETTY_FUNCTION__))
;
779 DEFINE_GETIMPL_LOOKUP(DILocalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 781, __PRETTY_FUNCTION__)); } } while (false)
780 (Scope, Name, File, Line, Type, Arg, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 781, __PRETTY_FUNCTION__)); } } while (false)
781 AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 781, __PRETTY_FUNCTION__)); } } while (false)
;
782 Metadata *Ops[] = {Scope, Name, File, Type};
783 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops)return storeImpl(new (array_lengthof(Ops)) DILocalVariable(Context
, Storage, Line, Arg, Flags, AlignInBits, Ops), Storage, Context
.pImpl->DILocalVariables)
;
784}
785
786Optional<uint64_t> DIVariable::getSizeInBits() const {
787 // This is used by the Verifier so be mindful of broken types.
788 const Metadata *RawType = getRawType();
789 while (RawType) {
790 // Try to get the size directly.
791 if (auto *T = dyn_cast<DIType>(RawType))
792 if (uint64_t Size = T->getSizeInBits())
793 return Size;
794
795 if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
796 // Look at the base type.
797 RawType = DT->getRawBaseType();
798 continue;
799 }
800
801 // Missing type or size.
802 break;
803 }
804
805 // Fail gracefully.
806 return None;
807}
808
809DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope,
810 MDString *Name, Metadata *File, unsigned Line,
811 StorageType Storage,
812 bool ShouldCreate) {
813 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 813, __PRETTY_FUNCTION__))
;
814 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 814, __PRETTY_FUNCTION__))
;
815 DEFINE_GETIMPL_LOOKUP(DILabel,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILabels, DILabelInfo::KeyTy(Scope, Name, File, Line
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 816, __PRETTY_FUNCTION__)); } } while (false)
816 (Scope, Name, File, Line))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILabels, DILabelInfo::KeyTy(Scope, Name, File, Line
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 816, __PRETTY_FUNCTION__)); } } while (false)
;
817 Metadata *Ops[] = {Scope, Name, File};
818 DEFINE_GETIMPL_STORE(DILabel, (Line), Ops)return storeImpl(new (array_lengthof(Ops)) DILabel(Context, Storage
, Line, Ops), Storage, Context.pImpl->DILabels)
;
819}
820
821DIExpression *DIExpression::getImpl(LLVMContext &Context,
822 ArrayRef<uint64_t> Elements,
823 StorageType Storage, bool ShouldCreate) {
824 DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIExpressions, DIExpressionInfo::KeyTy(Elements)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 824, __PRETTY_FUNCTION__)); } } while (false)
;
825 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements))return storeImpl(new (0u) DIExpression(Context, Storage, Elements
), Storage, Context.pImpl->DIExpressions)
;
826}
827
828unsigned DIExpression::ExprOperand::getSize() const {
829 uint64_t Op = getOp();
830
831 if (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31)
832 return 2;
833
834 switch (Op) {
835 case dwarf::DW_OP_LLVM_convert:
836 case dwarf::DW_OP_LLVM_fragment:
837 case dwarf::DW_OP_bregx:
838 return 3;
839 case dwarf::DW_OP_constu:
840 case dwarf::DW_OP_consts:
841 case dwarf::DW_OP_deref_size:
842 case dwarf::DW_OP_plus_uconst:
843 case dwarf::DW_OP_LLVM_tag_offset:
844 case dwarf::DW_OP_LLVM_entry_value:
845 case dwarf::DW_OP_regx:
846 return 2;
847 default:
848 return 1;
849 }
850}
851
852bool DIExpression::isValid() const {
853 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
854 // Check that there's space for the operand.
855 if (I->get() + I->getSize() > E->get())
856 return false;
857
858 uint64_t Op = I->getOp();
859 if ((Op >= dwarf::DW_OP_reg0 && Op <= dwarf::DW_OP_reg31) ||
860 (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31))
861 return true;
862
863 // Check that the operand is valid.
864 switch (Op) {
865 default:
866 return false;
867 case dwarf::DW_OP_LLVM_fragment:
868 // A fragment operator must appear at the end.
869 return I->get() + I->getSize() == E->get();
870 case dwarf::DW_OP_stack_value: {
871 // Must be the last one or followed by a DW_OP_LLVM_fragment.
872 if (I->get() + I->getSize() == E->get())
873 break;
874 auto J = I;
875 if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
876 return false;
877 break;
878 }
879 case dwarf::DW_OP_swap: {
880 // Must be more than one implicit element on the stack.
881
882 // FIXME: A better way to implement this would be to add a local variable
883 // that keeps track of the stack depth and introduce something like a
884 // DW_LLVM_OP_implicit_location as a placeholder for the location this
885 // DIExpression is attached to, or else pass the number of implicit stack
886 // elements into isValid.
887 if (getNumElements() == 1)
888 return false;
889 break;
890 }
891 case dwarf::DW_OP_LLVM_entry_value: {
892 // An entry value operator must appear at the beginning and the number of
893 // operations it cover can currently only be 1, because we support only
894 // entry values of a simple register location. One reason for this is that
895 // we currently can't calculate the size of the resulting DWARF block for
896 // other expressions.
897 return I->get() == expr_op_begin()->get() && I->getArg(0) == 1 &&
898 getNumElements() == 2;
899 }
900 case dwarf::DW_OP_LLVM_convert:
901 case dwarf::DW_OP_LLVM_tag_offset:
902 case dwarf::DW_OP_constu:
903 case dwarf::DW_OP_plus_uconst:
904 case dwarf::DW_OP_plus:
905 case dwarf::DW_OP_minus:
906 case dwarf::DW_OP_mul:
907 case dwarf::DW_OP_div:
908 case dwarf::DW_OP_mod:
909 case dwarf::DW_OP_or:
910 case dwarf::DW_OP_and:
911 case dwarf::DW_OP_xor:
912 case dwarf::DW_OP_shl:
913 case dwarf::DW_OP_shr:
914 case dwarf::DW_OP_shra:
915 case dwarf::DW_OP_deref:
916 case dwarf::DW_OP_deref_size:
917 case dwarf::DW_OP_xderef:
918 case dwarf::DW_OP_lit0:
919 case dwarf::DW_OP_not:
920 case dwarf::DW_OP_dup:
921 case dwarf::DW_OP_regx:
922 case dwarf::DW_OP_bregx:
923 break;
924 }
925 }
926 return true;
927}
928
929bool DIExpression::isImplicit() const {
930 if (!isValid())
931 return false;
932
933 if (getNumElements() == 0)
934 return false;
935
936 for (const auto &It : expr_ops()) {
937 switch (It.getOp()) {
938 default:
939 break;
940 case dwarf::DW_OP_stack_value:
941 case dwarf::DW_OP_LLVM_tag_offset:
942 return true;
943 }
944 }
945
946 return false;
947}
948
949bool DIExpression::isComplex() const {
950 if (!isValid())
951 return false;
952
953 if (getNumElements() == 0)
954 return false;
955
956 // If there are any elements other than fragment or tag_offset, then some
957 // kind of complex computation occurs.
958 for (const auto &It : expr_ops()) {
959 switch (It.getOp()) {
960 case dwarf::DW_OP_LLVM_tag_offset:
961 case dwarf::DW_OP_LLVM_fragment:
962 continue;
963 default: return true;
964 }
965 }
966
967 return false;
968}
969
970Optional<DIExpression::FragmentInfo>
971DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
972 for (auto I = Start; I != End; ++I)
973 if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
974 DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
975 return Info;
976 }
977 return None;
978}
979
980void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
981 int64_t Offset) {
982 if (Offset > 0) {
983 Ops.push_back(dwarf::DW_OP_plus_uconst);
984 Ops.push_back(Offset);
985 } else if (Offset < 0) {
986 Ops.push_back(dwarf::DW_OP_constu);
987 Ops.push_back(-Offset);
988 Ops.push_back(dwarf::DW_OP_minus);
989 }
990}
991
992bool DIExpression::extractIfOffset(int64_t &Offset) const {
993 if (getNumElements() == 0) {
994 Offset = 0;
995 return true;
996 }
997
998 if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
999 Offset = Elements[1];
1000 return true;
1001 }
1002
1003 if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
1004 if (Elements[2] == dwarf::DW_OP_plus) {
1005 Offset = Elements[1];
1006 return true;
1007 }
1008 if (Elements[2] == dwarf::DW_OP_minus) {
1009 Offset = -Elements[1];
1010 return true;
1011 }
1012 }
1013
1014 return false;
1015}
1016
1017const DIExpression *DIExpression::extractAddressClass(const DIExpression *Expr,
1018 unsigned &AddrClass) {
1019 // FIXME: This seems fragile. Nothing that verifies that these elements
1020 // actually map to ops and not operands.
1021 const unsigned PatternSize = 4;
1022 if (Expr->Elements.size() >= PatternSize &&
1023 Expr->Elements[PatternSize - 4] == dwarf::DW_OP_constu &&
1024 Expr->Elements[PatternSize - 2] == dwarf::DW_OP_swap &&
1025 Expr->Elements[PatternSize - 1] == dwarf::DW_OP_xderef) {
1026 AddrClass = Expr->Elements[PatternSize - 3];
1027
1028 if (Expr->Elements.size() == PatternSize)
1029 return nullptr;
1030 return DIExpression::get(Expr->getContext(),
1031 makeArrayRef(&*Expr->Elements.begin(),
1032 Expr->Elements.size() - PatternSize));
1033 }
1034 return Expr;
1035}
1036
1037DIExpression *DIExpression::prepend(const DIExpression *Expr, uint8_t Flags,
1038 int64_t Offset) {
1039 SmallVector<uint64_t, 8> Ops;
1040 if (Flags & DIExpression::DerefBefore)
1041 Ops.push_back(dwarf::DW_OP_deref);
1042
1043 appendOffset(Ops, Offset);
1044 if (Flags & DIExpression::DerefAfter)
1045 Ops.push_back(dwarf::DW_OP_deref);
1046
1047 bool StackValue = Flags & DIExpression::StackValue;
1048 bool EntryValue = Flags & DIExpression::EntryValue;
1049
1050 return prependOpcodes(Expr, Ops, StackValue, EntryValue);
1051}
1052
1053DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
1054 SmallVectorImpl<uint64_t> &Ops,
1055 bool StackValue,
1056 bool EntryValue) {
1057 assert(Expr && "Can't prepend ops to this expression")((Expr && "Can't prepend ops to this expression") ? static_cast
<void> (0) : __assert_fail ("Expr && \"Can't prepend ops to this expression\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1057, __PRETTY_FUNCTION__))
;
1058
1059 if (EntryValue) {
1060 Ops.push_back(dwarf::DW_OP_LLVM_entry_value);
1061 // Add size info needed for entry value expression.
1062 // Add plus one for target register operand.
1063 Ops.push_back(Expr->getNumElements() + 1);
1064 }
1065
1066 // If there are no ops to prepend, do not even add the DW_OP_stack_value.
1067 if (Ops.empty())
1068 StackValue = false;
1069 for (auto Op : Expr->expr_ops()) {
1070 // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
1071 if (StackValue) {
1072 if (Op.getOp() == dwarf::DW_OP_stack_value)
1073 StackValue = false;
1074 else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
1075 Ops.push_back(dwarf::DW_OP_stack_value);
1076 StackValue = false;
1077 }
1078 }
1079 Op.appendToVector(Ops);
1080 }
1081 if (StackValue)
1082 Ops.push_back(dwarf::DW_OP_stack_value);
1083 return DIExpression::get(Expr->getContext(), Ops);
1084}
1085
1086DIExpression *DIExpression::append(const DIExpression *Expr,
1087 ArrayRef<uint64_t> Ops) {
1088 assert(Expr && !Ops.empty() && "Can't append ops to this expression")((Expr && !Ops.empty() && "Can't append ops to this expression"
) ? static_cast<void> (0) : __assert_fail ("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1088, __PRETTY_FUNCTION__))
;
1089
1090 // Copy Expr's current op list.
1091 SmallVector<uint64_t, 16> NewOps;
1092 for (auto Op : Expr->expr_ops()) {
1093 // Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
1094 if (Op.getOp() == dwarf::DW_OP_stack_value ||
1095 Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
1096 NewOps.append(Ops.begin(), Ops.end());
1097
1098 // Ensure that the new opcodes are only appended once.
1099 Ops = None;
1100 }
1101 Op.appendToVector(NewOps);
1102 }
1103
1104 NewOps.append(Ops.begin(), Ops.end());
1105 return DIExpression::get(Expr->getContext(), NewOps);
1106}
1107
1108DIExpression *DIExpression::appendToStack(const DIExpression *Expr,
1109 ArrayRef<uint64_t> Ops) {
1110 assert(Expr && !Ops.empty() && "Can't append ops to this expression")((Expr && !Ops.empty() && "Can't append ops to this expression"
) ? static_cast<void> (0) : __assert_fail ("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1110, __PRETTY_FUNCTION__))
;
1111 assert(none_of(Ops,((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
1112 [](uint64_t Op) {((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
1113 return Op == dwarf::DW_OP_stack_value ||((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
1114 Op == dwarf::DW_OP_LLVM_fragment;((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
1115 }) &&((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
1116 "Can't append this op")((none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value
|| Op == dwarf::DW_OP_LLVM_fragment; }) && "Can't append this op"
) ? static_cast<void> (0) : __assert_fail ("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1116, __PRETTY_FUNCTION__))
;
1117
1118 // Append a DW_OP_deref after Expr's current op list if it's non-empty and
1119 // has no DW_OP_stack_value.
1120 //
1121 // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
1122 Optional<FragmentInfo> FI = Expr->getFragmentInfo();
1123 unsigned DropUntilStackValue = FI.hasValue() ? 3 : 0;
1124 ArrayRef<uint64_t> ExprOpsBeforeFragment =
1125 Expr->getElements().drop_back(DropUntilStackValue);
1126 bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
1127 (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
1128 bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
1129
1130 // Append a DW_OP_deref after Expr's current op list if needed, then append
1131 // the new ops, and finally ensure that a single DW_OP_stack_value is present.
1132 SmallVector<uint64_t, 16> NewOps;
1133 if (NeedsDeref)
1134 NewOps.push_back(dwarf::DW_OP_deref);
1135 NewOps.append(Ops.begin(), Ops.end());
1136 if (NeedsStackValue)
1137 NewOps.push_back(dwarf::DW_OP_stack_value);
1138 return DIExpression::append(Expr, NewOps);
1139}
1140
1141Optional<DIExpression *> DIExpression::createFragmentExpression(
1142 const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
1143 SmallVector<uint64_t, 8> Ops;
1144 // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
1145 if (Expr) {
1146 for (auto Op : Expr->expr_ops()) {
1147 switch (Op.getOp()) {
1148 default: break;
1149 case dwarf::DW_OP_shr:
1150 case dwarf::DW_OP_shra:
1151 case dwarf::DW_OP_shl:
1152 case dwarf::DW_OP_plus:
1153 case dwarf::DW_OP_plus_uconst:
1154 case dwarf::DW_OP_minus:
1155 // We can't safely split arithmetic or shift operations into multiple
1156 // fragments because we can't express carry-over between fragments.
1157 //
1158 // FIXME: We *could* preserve the lowest fragment of a constant offset
1159 // operation if the offset fits into SizeInBits.
1160 return None;
1161 case dwarf::DW_OP_LLVM_fragment: {
1162 // Make the new offset point into the existing fragment.
1163 uint64_t FragmentOffsetInBits = Op.getArg(0);
1164 uint64_t FragmentSizeInBits = Op.getArg(1);
1165 (void)FragmentSizeInBits;
1166 assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&(((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
"new fragment outside of original fragment") ? static_cast<
void> (0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1167, __PRETTY_FUNCTION__))
1167 "new fragment outside of original fragment")(((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
"new fragment outside of original fragment") ? static_cast<
void> (0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1167, __PRETTY_FUNCTION__))
;
1168 OffsetInBits += FragmentOffsetInBits;
1169 continue;
1170 }
1171 }
1172 Op.appendToVector(Ops);
1173 }
1174 }
1175 assert(Expr && "Unknown DIExpression")((Expr && "Unknown DIExpression") ? static_cast<void
> (0) : __assert_fail ("Expr && \"Unknown DIExpression\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1175, __PRETTY_FUNCTION__))
;
1176 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
1177 Ops.push_back(OffsetInBits);
1178 Ops.push_back(SizeInBits);
1179 return DIExpression::get(Expr->getContext(), Ops);
1180}
1181
1182bool DIExpression::isConstant() const {
1183 // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
1184 if (getNumElements() != 3 && getNumElements() != 6)
1185 return false;
1186 if (getElement(0) != dwarf::DW_OP_constu ||
1187 getElement(2) != dwarf::DW_OP_stack_value)
1188 return false;
1189 if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment)
1190 return false;
1191 return true;
1192}
1193
1194DIExpression::ExtOps DIExpression::getExtOps(unsigned FromSize, unsigned ToSize,
1195 bool Signed) {
1196 dwarf::TypeKind TK = Signed ? dwarf::DW_ATE_signed : dwarf::DW_ATE_unsigned;
1197 DIExpression::ExtOps Ops{{dwarf::DW_OP_LLVM_convert, FromSize, TK,
1198 dwarf::DW_OP_LLVM_convert, ToSize, TK}};
1199 return Ops;
1200}
1201
1202DIExpression *DIExpression::appendExt(const DIExpression *Expr,
1203 unsigned FromSize, unsigned ToSize,
1204 bool Signed) {
1205 return appendToStack(Expr, getExtOps(FromSize, ToSize, Signed));
1206}
1207
1208DIGlobalVariableExpression *
1209DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
1210 Metadata *Expression, StorageType Storage,
1211 bool ShouldCreate) {
1212 DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariableExpressions, DIGlobalVariableExpressionInfo
::KeyTy(Variable, Expression))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1212, __PRETTY_FUNCTION__)); } } while (false)
;
1213 Metadata *Ops[] = {Variable, Expression};
1214 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariableExpression
(Context, Storage, Ops), Storage, Context.pImpl->DIGlobalVariableExpressions
)
;
1215}
1216
1217DIObjCProperty *DIObjCProperty::getImpl(
1218 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
1219 MDString *GetterName, MDString *SetterName, unsigned Attributes,
1220 Metadata *Type, StorageType Storage, bool ShouldCreate) {
1221 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1221, __PRETTY_FUNCTION__))
;
1222 assert(isCanonical(GetterName) && "Expected canonical MDString")((isCanonical(GetterName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(GetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1222, __PRETTY_FUNCTION__))
;
1223 assert(isCanonical(SetterName) && "Expected canonical MDString")((isCanonical(SetterName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(SetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1223, __PRETTY_FUNCTION__))
;
1224 DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1225, __PRETTY_FUNCTION__)); } } while (false)
1225 SetterName, Attributes, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1225, __PRETTY_FUNCTION__)); } } while (false)
;
1226 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
1227 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops)return storeImpl(new (array_lengthof(Ops)) DIObjCProperty(Context
, Storage, Line, Attributes, Ops), Storage, Context.pImpl->
DIObjCPropertys)
;
1228}
1229
1230DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
1231 Metadata *Scope, Metadata *Entity,
1232 Metadata *File, unsigned Line,
1233 MDString *Name, StorageType Storage,
1234 bool ShouldCreate) {
1235 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1235, __PRETTY_FUNCTION__))
;
1236 DEFINE_GETIMPL_LOOKUP(DIImportedEntity,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1237, __PRETTY_FUNCTION__)); } } while (false)
1237 (Tag, Scope, Entity, File, Line, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1237, __PRETTY_FUNCTION__)); } } while (false)
;
1238 Metadata *Ops[] = {Scope, Entity, Name, File};
1239 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIImportedEntity(Context
, Storage, Tag, Line, Ops), Storage, Context.pImpl->DIImportedEntitys
)
;
1240}
1241
1242DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
1243 unsigned Line, MDString *Name, MDString *Value,
1244 StorageType Storage, bool ShouldCreate) {
1245 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1245, __PRETTY_FUNCTION__))
;
1246 DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacros, DIMacroInfo::KeyTy(MIType, Line, Name, Value
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1246, __PRETTY_FUNCTION__)); } } while (false)
;
1247 Metadata *Ops[] = { Name, Value };
1248 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacro(Context, Storage
, MIType, Line, Ops), Storage, Context.pImpl->DIMacros)
;
1249}
1250
1251DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
1252 unsigned Line, Metadata *File,
1253 Metadata *Elements, StorageType Storage,
1254 bool ShouldCreate) {
1255 DEFINE_GETIMPL_LOOKUP(DIMacroFile,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1256, __PRETTY_FUNCTION__)); } } while (false)
1256 (MIType, Line, File, Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/lib/IR/DebugInfoMetadata.cpp"
, 1256, __PRETTY_FUNCTION__)); } } while (false)
;
1257 Metadata *Ops[] = { File, Elements };
1258 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacroFile(Context
, Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacroFiles
)
;
1259}

/build/llvm-toolchain-snapshot-11~++20200309111110+2c36c23f347/llvm/include/llvm/IR/DebugInfoMetadata.h

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