Bug Summary

File:build/source/llvm/lib/IR/DebugInfoMetadata.cpp
Warning:line 1698, column 3
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name DebugInfoMetadata.cpp -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 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/source/build-llvm -resource-dir /usr/lib/llvm-16/lib/clang/16.0.0 -I lib/IR -I /build/source/llvm/lib/IR -I include -I /build/source/llvm/include -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/source/build-llvm=build-llvm -fmacro-prefix-map=/build/source/= -fcoverage-prefix-map=/build/source/build-llvm=build-llvm -fcoverage-prefix-map=/build/source/= -source-date-epoch 1670066131 -O3 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/source/build-llvm -fdebug-prefix-map=/build/source/build-llvm=build-llvm -fdebug-prefix-map=/build/source/= -fdebug-prefix-map=/build/source/build-llvm=build-llvm -fdebug-prefix-map=/build/source/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-12-03-132955-15984-1 -x c++ /build/source/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/BinaryFormat/Dwarf.h"
19#include "llvm/IR/Function.h"
20#include "llvm/IR/IntrinsicInst.h"
21#include "llvm/IR/Type.h"
22#include "llvm/IR/Value.h"
23
24#include <numeric>
25
26using namespace llvm;
27
28namespace llvm {
29// Use FS-AFDO discriminator.
30cl::opt<bool> EnableFSDiscriminator(
31 "enable-fs-discriminator", cl::Hidden,
32 cl::desc("Enable adding flow sensitive discriminators"));
33} // namespace llvm
34
35const DIExpression::FragmentInfo DebugVariable::DefaultFragment = {
36 std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
37
38DebugVariable::DebugVariable(const DbgVariableIntrinsic *DII)
39 : Variable(DII->getVariable()),
40 Fragment(DII->getExpression()->getFragmentInfo()),
41 InlinedAt(DII->getDebugLoc().getInlinedAt()) {}
42
43DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
44 unsigned Column, ArrayRef<Metadata *> MDs,
45 bool ImplicitCode)
46 : MDNode(C, DILocationKind, Storage, MDs) {
47 assert((MDs.size() == 1 || MDs.size() == 2) &&(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2
) && "Expected a scope and optional inlined-at") ? void
(0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 48, __extension__ __PRETTY_FUNCTION__
))
48 "Expected a scope and optional inlined-at")(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2
) && "Expected a scope and optional inlined-at") ? void
(0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 48, __extension__ __PRETTY_FUNCTION__
))
;
49
50 // Set line and column.
51 assert(Column < (1u << 16) && "Expected 16-bit column")(static_cast <bool> (Column < (1u << 16) &&
"Expected 16-bit column") ? void (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 51, __extension__ __PRETTY_FUNCTION__
))
;
52
53 SubclassData32 = Line;
54 SubclassData16 = Column;
55
56 setImplicitCode(ImplicitCode);
57}
58
59static void adjustColumn(unsigned &Column) {
60 // Set to unknown on overflow. We only have 16 bits to play with here.
61 if (Column >= (1u << 16))
62 Column = 0;
63}
64
65DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
66 unsigned Column, Metadata *Scope,
67 Metadata *InlinedAt, bool ImplicitCode,
68 StorageType Storage, bool ShouldCreate) {
69 // Fixup column.
70 adjustColumn(Column);
71
72 if (Storage == Uniqued) {
73 if (auto *N = getUniqued(Context.pImpl->DILocations,
74 DILocationInfo::KeyTy(Line, Column, Scope,
75 InlinedAt, ImplicitCode)))
76 return N;
77 if (!ShouldCreate)
78 return nullptr;
79 } else {
80 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 80, __extension__ __PRETTY_FUNCTION__
))
;
81 }
82
83 SmallVector<Metadata *, 2> Ops;
84 Ops.push_back(Scope);
85 if (InlinedAt)
86 Ops.push_back(InlinedAt);
87 return storeImpl(new (Ops.size(), Storage) DILocation(
88 Context, Storage, Line, Column, Ops, ImplicitCode),
89 Storage, Context.pImpl->DILocations);
90}
91
92const DILocation *
93DILocation::getMergedLocations(ArrayRef<const DILocation *> Locs) {
94 if (Locs.empty())
95 return nullptr;
96 if (Locs.size() == 1)
97 return Locs[0];
98 auto *Merged = Locs[0];
99 for (const DILocation *L : llvm::drop_begin(Locs)) {
100 Merged = getMergedLocation(Merged, L);
101 if (Merged == nullptr)
102 break;
103 }
104 return Merged;
105}
106
107const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
108 const DILocation *LocB) {
109 if (!LocA || !LocB)
110 return nullptr;
111
112 if (LocA == LocB)
113 return LocA;
114
115 LLVMContext &C = LocA->getContext();
116 SmallDenseMap<std::pair<DILocalScope *, DILocation *>,
117 std::pair<unsigned, unsigned>, 4>
118 Locations;
119
120 DIScope *S = LocA->getScope();
121 DILocation *L = LocA->getInlinedAt();
122 unsigned Line = LocA->getLine();
123 unsigned Col = LocA->getColumn();
124
125 // Walk from the current source locaiton until the file scope;
126 // then, do the same for the inlined-at locations.
127 auto AdvanceToParentLoc = [&S, &L, &Line, &Col]() {
128 S = S->getScope();
129 if (!S && L) {
130 Line = L->getLine();
131 Col = L->getColumn();
132 S = L->getScope();
133 L = L->getInlinedAt();
134 }
135 };
136
137 while (S) {
138 if (auto *LS = dyn_cast<DILocalScope>(S))
139 Locations.try_emplace(std::make_pair(LS, L), std::make_pair(Line, Col));
140 AdvanceToParentLoc();
141 }
142
143 // Walk the source locations of LocB until a match with LocA is found.
144 S = LocB->getScope();
145 L = LocB->getInlinedAt();
146 Line = LocB->getLine();
147 Col = LocB->getColumn();
148 while (S) {
149 if (auto *LS = dyn_cast<DILocalScope>(S)) {
150 auto MatchLoc = Locations.find(std::make_pair(LS, L));
151 if (MatchLoc != Locations.end()) {
152 // If the lines match, keep the line, but set the column to '0'
153 // If the lines don't match, pick a "line 0" location but keep
154 // the current scope and inlined-at.
155 bool SameLine = Line == MatchLoc->second.first;
156 bool SameCol = Col == MatchLoc->second.second;
157 Line = SameLine ? Line : 0;
158 Col = SameLine && SameCol ? Col : 0;
159 break;
160 }
161 }
162 AdvanceToParentLoc();
163 }
164
165 if (!S) {
166 // If the two locations are irreconsilable, pick any scope,
167 // and return a "line 0" location.
168 Line = Col = 0;
169 S = LocA->getScope();
170 }
171
172 return DILocation::get(C, Line, Col, S, L);
173}
174
175Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF,
176 unsigned CI) {
177 std::array<unsigned, 3> Components = {BD, DF, CI};
178 uint64_t RemainingWork = 0U;
179 // We use RemainingWork to figure out if we have no remaining components to
180 // encode. For example: if BD != 0 but DF == 0 && CI == 0, we don't need to
181 // encode anything for the latter 2.
182 // Since any of the input components is at most 32 bits, their sum will be
183 // less than 34 bits, and thus RemainingWork won't overflow.
184 RemainingWork =
185 std::accumulate(Components.begin(), Components.end(), RemainingWork);
186
187 int I = 0;
188 unsigned Ret = 0;
189 unsigned NextBitInsertionIndex = 0;
190 while (RemainingWork > 0) {
191 unsigned C = Components[I++];
192 RemainingWork -= C;
193 unsigned EC = encodeComponent(C);
194 Ret |= (EC << NextBitInsertionIndex);
195 NextBitInsertionIndex += encodingBits(C);
196 }
197
198 // Encoding may be unsuccessful because of overflow. We determine success by
199 // checking equivalence of components before & after encoding. Alternatively,
200 // we could determine Success during encoding, but the current alternative is
201 // simpler.
202 unsigned TBD, TDF, TCI = 0;
203 decodeDiscriminator(Ret, TBD, TDF, TCI);
204 if (TBD == BD && TDF == DF && TCI == CI)
205 return Ret;
206 return std::nullopt;
207}
208
209void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
210 unsigned &CI) {
211 BD = getUnsignedFromPrefixEncoding(D);
212 DF = getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(D));
213 CI = getUnsignedFromPrefixEncoding(
214 getNextComponentInDiscriminator(getNextComponentInDiscriminator(D)));
215}
216dwarf::Tag DINode::getTag() const { return (dwarf::Tag)SubclassData16; }
217
218DINode::DIFlags DINode::getFlag(StringRef Flag) {
219 return StringSwitch<DIFlags>(Flag)
220#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
221#include "llvm/IR/DebugInfoFlags.def"
222 .Default(DINode::FlagZero);
223}
224
225StringRef DINode::getFlagString(DIFlags Flag) {
226 switch (Flag) {
227#define HANDLE_DI_FLAG(ID, NAME) \
228 case Flag##NAME: \
229 return "DIFlag" #NAME;
230#include "llvm/IR/DebugInfoFlags.def"
231 }
232 return "";
233}
234
235DINode::DIFlags DINode::splitFlags(DIFlags Flags,
236 SmallVectorImpl<DIFlags> &SplitFlags) {
237 // Flags that are packed together need to be specially handled, so
238 // that, for example, we emit "DIFlagPublic" and not
239 // "DIFlagPrivate | DIFlagProtected".
240 if (DIFlags A = Flags & FlagAccessibility) {
241 if (A == FlagPrivate)
242 SplitFlags.push_back(FlagPrivate);
243 else if (A == FlagProtected)
244 SplitFlags.push_back(FlagProtected);
245 else
246 SplitFlags.push_back(FlagPublic);
247 Flags &= ~A;
248 }
249 if (DIFlags R = Flags & FlagPtrToMemberRep) {
250 if (R == FlagSingleInheritance)
251 SplitFlags.push_back(FlagSingleInheritance);
252 else if (R == FlagMultipleInheritance)
253 SplitFlags.push_back(FlagMultipleInheritance);
254 else
255 SplitFlags.push_back(FlagVirtualInheritance);
256 Flags &= ~R;
257 }
258 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
259 Flags &= ~FlagIndirectVirtualBase;
260 SplitFlags.push_back(FlagIndirectVirtualBase);
261 }
262
263#define HANDLE_DI_FLAG(ID, NAME) \
264 if (DIFlags Bit = Flags & Flag##NAME) { \
265 SplitFlags.push_back(Bit); \
266 Flags &= ~Bit; \
267 }
268#include "llvm/IR/DebugInfoFlags.def"
269 return Flags;
270}
271
272DIScope *DIScope::getScope() const {
273 if (auto *T = dyn_cast<DIType>(this))
274 return T->getScope();
275
276 if (auto *SP = dyn_cast<DISubprogram>(this))
277 return SP->getScope();
278
279 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
280 return LB->getScope();
281
282 if (auto *NS = dyn_cast<DINamespace>(this))
283 return NS->getScope();
284
285 if (auto *CB = dyn_cast<DICommonBlock>(this))
286 return CB->getScope();
287
288 if (auto *M = dyn_cast<DIModule>(this))
289 return M->getScope();
290
291 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&(static_cast <bool> ((isa<DIFile>(this) || isa<
DICompileUnit>(this)) && "Unhandled type of scope."
) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 292, __extension__ __PRETTY_FUNCTION__
))
292 "Unhandled type of scope.")(static_cast <bool> ((isa<DIFile>(this) || isa<
DICompileUnit>(this)) && "Unhandled type of scope."
) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 292, __extension__ __PRETTY_FUNCTION__
))
;
293 return nullptr;
294}
295
296StringRef DIScope::getName() const {
297 if (auto *T = dyn_cast<DIType>(this))
298 return T->getName();
299 if (auto *SP = dyn_cast<DISubprogram>(this))
300 return SP->getName();
301 if (auto *NS = dyn_cast<DINamespace>(this))
302 return NS->getName();
303 if (auto *CB = dyn_cast<DICommonBlock>(this))
304 return CB->getName();
305 if (auto *M = dyn_cast<DIModule>(this))
306 return M->getName();
307 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 309, __extension__ __PRETTY_FUNCTION__
))
308 isa<DICompileUnit>(this)) &&(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 309, __extension__ __PRETTY_FUNCTION__
))
309 "Unhandled type of scope.")(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 309, __extension__ __PRETTY_FUNCTION__
))
;
310 return "";
311}
312
313#ifndef NDEBUG
314static bool isCanonical(const MDString *S) {
315 return !S || !S->getString().empty();
316}
317#endif
318
319dwarf::Tag GenericDINode::getTag() const { return (dwarf::Tag)SubclassData16; }
320GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
321 MDString *Header,
322 ArrayRef<Metadata *> DwarfOps,
323 StorageType Storage, bool ShouldCreate) {
324 unsigned Hash = 0;
325 if (Storage == Uniqued) {
326 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
327 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
328 return N;
329 if (!ShouldCreate)
330 return nullptr;
331 Hash = Key.getHash();
332 } else {
333 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 333, __extension__ __PRETTY_FUNCTION__
))
;
334 }
335
336 // Use a nullptr for empty headers.
337 assert(isCanonical(Header) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Header) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Header) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 337, __extension__ __PRETTY_FUNCTION__
))
;
338 Metadata *PreOps[] = {Header};
339 return storeImpl(new (DwarfOps.size() + 1, Storage) GenericDINode(
340 Context, Storage, Hash, Tag, PreOps, DwarfOps),
341 Storage, Context.pImpl->GenericDINodes);
342}
343
344void GenericDINode::recalculateHash() {
345 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
346}
347
348#define UNWRAP_ARGS_IMPL(...)... __VA_ARGS__
349#define UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS UNWRAP_ARGS_IMPL ARGS
350#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 { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 350, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
\
351 do { \
352 if (Storage == Uniqued) { \
353 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
354 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS))) \
355 return N; \
356 if (!ShouldCreate) \
357 return nullptr; \
358 } else { \
359 assert(ShouldCreate && \(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 360, __extension__ __PRETTY_FUNCTION__
))
360 "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 360, __extension__ __PRETTY_FUNCTION__
))
; \
361 } \
362 } while (false)
363#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)return storeImpl(new (std::size(OPS), Storage) CLASS(Context,
Storage, UNWRAP_ARGS_IMPL ARGS, OPS), Storage, Context.pImpl
->CLASSs)
\
364 return storeImpl(new (std::size(OPS), Storage) \
365 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
366 Storage, Context.pImpl->CLASS##s)
367#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)return storeImpl(new (0u, Storage) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS), Storage, Context.pImpl->CLASSs)
\
368 return storeImpl(new (0u, Storage) \
369 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS), \
370 Storage, Context.pImpl->CLASS##s)
371#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)return storeImpl(new (std::size(OPS), Storage) CLASS(Context,
Storage, OPS), Storage, Context.pImpl->CLASSs)
\
372 return storeImpl(new (std::size(OPS), Storage) CLASS(Context, Storage, OPS), \
373 Storage, Context.pImpl->CLASS##s)
374#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)return storeImpl(new (NUM_OPS, Storage) CLASS(Context, Storage
, UNWRAP_ARGS_IMPL ARGS, OPS), Storage, Context.pImpl->CLASSs
)
\
375 return storeImpl(new (NUM_OPS, Storage) \
376 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
377 Storage, Context.pImpl->CLASS##s)
378
379DISubrange::DISubrange(LLVMContext &C, StorageType Storage,
380 ArrayRef<Metadata *> Ops)
381 : DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops) {}
382DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
383 StorageType Storage, bool ShouldCreate) {
384 auto *CountNode = ConstantAsMetadata::get(
385 ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
386 auto *LB = ConstantAsMetadata::get(
387 ConstantInt::getSigned(Type::getInt64Ty(Context), Lo));
388 return getImpl(Context, CountNode, LB, nullptr, nullptr, Storage,
389 ShouldCreate);
390}
391
392DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
393 int64_t Lo, StorageType Storage,
394 bool ShouldCreate) {
395 auto *LB = ConstantAsMetadata::get(
396 ConstantInt::getSigned(Type::getInt64Ty(Context), Lo));
397 return getImpl(Context, CountNode, LB, nullptr, nullptr, Storage,
398 ShouldCreate);
399}
400
401DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
402 Metadata *LB, Metadata *UB, Metadata *Stride,
403 StorageType Storage, bool ShouldCreate) {
404 DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, LB, UB, Stride))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubranges, DISubrangeInfo::KeyTy(CountNode, LB, UB
, Stride))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 404, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
405 Metadata *Ops[] = {CountNode, LB, UB, Stride};
406 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DISubrange, Ops)return storeImpl(new (std::size(Ops), Storage) DISubrange(Context
, Storage, Ops), Storage, Context.pImpl->DISubranges)
;
407}
408
409DISubrange::BoundType DISubrange::getCount() const {
410 Metadata *CB = getRawCountNode();
411 if (!CB)
412 return BoundType();
413
414 assert((isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) ||(static_cast <bool> ((isa<ConstantAsMetadata>(CB)
|| isa<DIVariable>(CB) || isa<DIExpression>(CB))
&& "Count must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) || isa<DIExpression>(CB)) && \"Count must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 416, __extension__ __PRETTY_FUNCTION__
))
415 isa<DIExpression>(CB)) &&(static_cast <bool> ((isa<ConstantAsMetadata>(CB)
|| isa<DIVariable>(CB) || isa<DIExpression>(CB))
&& "Count must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) || isa<DIExpression>(CB)) && \"Count must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 416, __extension__ __PRETTY_FUNCTION__
))
416 "Count must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<ConstantAsMetadata>(CB)
|| isa<DIVariable>(CB) || isa<DIExpression>(CB))
&& "Count must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) || isa<DIExpression>(CB)) && \"Count must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 416, __extension__ __PRETTY_FUNCTION__
))
;
417
418 if (auto *MD = dyn_cast<ConstantAsMetadata>(CB))
419 return BoundType(cast<ConstantInt>(MD->getValue()));
420
421 if (auto *MD = dyn_cast<DIVariable>(CB))
422 return BoundType(MD);
423
424 if (auto *MD = dyn_cast<DIExpression>(CB))
425 return BoundType(MD);
426
427 return BoundType();
428}
429
430DISubrange::BoundType DISubrange::getLowerBound() const {
431 Metadata *LB = getRawLowerBound();
432 if (!LB)
433 return BoundType();
434
435 assert((isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) ||(static_cast <bool> ((isa<ConstantAsMetadata>(LB)
|| isa<DIVariable>(LB) || isa<DIExpression>(LB))
&& "LowerBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) || isa<DIExpression>(LB)) && \"LowerBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 437, __extension__ __PRETTY_FUNCTION__
))
436 isa<DIExpression>(LB)) &&(static_cast <bool> ((isa<ConstantAsMetadata>(LB)
|| isa<DIVariable>(LB) || isa<DIExpression>(LB))
&& "LowerBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) || isa<DIExpression>(LB)) && \"LowerBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 437, __extension__ __PRETTY_FUNCTION__
))
437 "LowerBound must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<ConstantAsMetadata>(LB)
|| isa<DIVariable>(LB) || isa<DIExpression>(LB))
&& "LowerBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) || isa<DIExpression>(LB)) && \"LowerBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 437, __extension__ __PRETTY_FUNCTION__
))
;
438
439 if (auto *MD = dyn_cast<ConstantAsMetadata>(LB))
440 return BoundType(cast<ConstantInt>(MD->getValue()));
441
442 if (auto *MD = dyn_cast<DIVariable>(LB))
443 return BoundType(MD);
444
445 if (auto *MD = dyn_cast<DIExpression>(LB))
446 return BoundType(MD);
447
448 return BoundType();
449}
450
451DISubrange::BoundType DISubrange::getUpperBound() const {
452 Metadata *UB = getRawUpperBound();
453 if (!UB)
454 return BoundType();
455
456 assert((isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) ||(static_cast <bool> ((isa<ConstantAsMetadata>(UB)
|| isa<DIVariable>(UB) || isa<DIExpression>(UB))
&& "UpperBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) || isa<DIExpression>(UB)) && \"UpperBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 458, __extension__ __PRETTY_FUNCTION__
))
457 isa<DIExpression>(UB)) &&(static_cast <bool> ((isa<ConstantAsMetadata>(UB)
|| isa<DIVariable>(UB) || isa<DIExpression>(UB))
&& "UpperBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) || isa<DIExpression>(UB)) && \"UpperBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 458, __extension__ __PRETTY_FUNCTION__
))
458 "UpperBound must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<ConstantAsMetadata>(UB)
|| isa<DIVariable>(UB) || isa<DIExpression>(UB))
&& "UpperBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) || isa<DIExpression>(UB)) && \"UpperBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 458, __extension__ __PRETTY_FUNCTION__
))
;
459
460 if (auto *MD = dyn_cast<ConstantAsMetadata>(UB))
461 return BoundType(cast<ConstantInt>(MD->getValue()));
462
463 if (auto *MD = dyn_cast<DIVariable>(UB))
464 return BoundType(MD);
465
466 if (auto *MD = dyn_cast<DIExpression>(UB))
467 return BoundType(MD);
468
469 return BoundType();
470}
471
472DISubrange::BoundType DISubrange::getStride() const {
473 Metadata *ST = getRawStride();
474 if (!ST)
475 return BoundType();
476
477 assert((isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) ||(static_cast <bool> ((isa<ConstantAsMetadata>(ST)
|| isa<DIVariable>(ST) || isa<DIExpression>(ST))
&& "Stride must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) || isa<DIExpression>(ST)) && \"Stride must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 479, __extension__ __PRETTY_FUNCTION__
))
478 isa<DIExpression>(ST)) &&(static_cast <bool> ((isa<ConstantAsMetadata>(ST)
|| isa<DIVariable>(ST) || isa<DIExpression>(ST))
&& "Stride must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) || isa<DIExpression>(ST)) && \"Stride must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 479, __extension__ __PRETTY_FUNCTION__
))
479 "Stride must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<ConstantAsMetadata>(ST)
|| isa<DIVariable>(ST) || isa<DIExpression>(ST))
&& "Stride must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) || isa<DIExpression>(ST)) && \"Stride must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 479, __extension__ __PRETTY_FUNCTION__
))
;
480
481 if (auto *MD = dyn_cast<ConstantAsMetadata>(ST))
482 return BoundType(cast<ConstantInt>(MD->getValue()));
483
484 if (auto *MD = dyn_cast<DIVariable>(ST))
485 return BoundType(MD);
486
487 if (auto *MD = dyn_cast<DIExpression>(ST))
488 return BoundType(MD);
489
490 return BoundType();
491}
492DIGenericSubrange::DIGenericSubrange(LLVMContext &C, StorageType Storage,
493 ArrayRef<Metadata *> Ops)
494 : DINode(C, DIGenericSubrangeKind, Storage, dwarf::DW_TAG_generic_subrange,
495 Ops) {}
496
497DIGenericSubrange *DIGenericSubrange::getImpl(LLVMContext &Context,
498 Metadata *CountNode, Metadata *LB,
499 Metadata *UB, Metadata *Stride,
500 StorageType Storage,
501 bool ShouldCreate) {
502 DEFINE_GETIMPL_LOOKUP(DIGenericSubrange, (CountNode, LB, UB, Stride))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGenericSubranges, DIGenericSubrangeInfo::KeyTy(CountNode
, LB, UB, Stride))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 502, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
503 Metadata *Ops[] = {CountNode, LB, UB, Stride};
504 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGenericSubrange, Ops)return storeImpl(new (std::size(Ops), Storage) DIGenericSubrange
(Context, Storage, Ops), Storage, Context.pImpl->DIGenericSubranges
)
;
505}
506
507DIGenericSubrange::BoundType DIGenericSubrange::getCount() const {
508 Metadata *CB = getRawCountNode();
509 if (!CB)
510 return BoundType();
511
512 assert((isa<DIVariable>(CB) || isa<DIExpression>(CB)) &&(static_cast <bool> ((isa<DIVariable>(CB) || isa<
DIExpression>(CB)) && "Count must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(CB) || isa<DIExpression>(CB)) && \"Count must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 513, __extension__ __PRETTY_FUNCTION__
))
513 "Count must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<DIVariable>(CB) || isa<
DIExpression>(CB)) && "Count must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(CB) || isa<DIExpression>(CB)) && \"Count must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 513, __extension__ __PRETTY_FUNCTION__
))
;
514
515 if (auto *MD = dyn_cast<DIVariable>(CB))
516 return BoundType(MD);
517
518 if (auto *MD = dyn_cast<DIExpression>(CB))
519 return BoundType(MD);
520
521 return BoundType();
522}
523
524DIGenericSubrange::BoundType DIGenericSubrange::getLowerBound() const {
525 Metadata *LB = getRawLowerBound();
526 if (!LB)
527 return BoundType();
528
529 assert((isa<DIVariable>(LB) || isa<DIExpression>(LB)) &&(static_cast <bool> ((isa<DIVariable>(LB) || isa<
DIExpression>(LB)) && "LowerBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(LB) || isa<DIExpression>(LB)) && \"LowerBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 530, __extension__ __PRETTY_FUNCTION__
))
530 "LowerBound must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<DIVariable>(LB) || isa<
DIExpression>(LB)) && "LowerBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(LB) || isa<DIExpression>(LB)) && \"LowerBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 530, __extension__ __PRETTY_FUNCTION__
))
;
531
532 if (auto *MD = dyn_cast<DIVariable>(LB))
533 return BoundType(MD);
534
535 if (auto *MD = dyn_cast<DIExpression>(LB))
536 return BoundType(MD);
537
538 return BoundType();
539}
540
541DIGenericSubrange::BoundType DIGenericSubrange::getUpperBound() const {
542 Metadata *UB = getRawUpperBound();
543 if (!UB)
544 return BoundType();
545
546 assert((isa<DIVariable>(UB) || isa<DIExpression>(UB)) &&(static_cast <bool> ((isa<DIVariable>(UB) || isa<
DIExpression>(UB)) && "UpperBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(UB) || isa<DIExpression>(UB)) && \"UpperBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 547, __extension__ __PRETTY_FUNCTION__
))
547 "UpperBound must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<DIVariable>(UB) || isa<
DIExpression>(UB)) && "UpperBound must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(UB) || isa<DIExpression>(UB)) && \"UpperBound must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 547, __extension__ __PRETTY_FUNCTION__
))
;
548
549 if (auto *MD = dyn_cast<DIVariable>(UB))
550 return BoundType(MD);
551
552 if (auto *MD = dyn_cast<DIExpression>(UB))
553 return BoundType(MD);
554
555 return BoundType();
556}
557
558DIGenericSubrange::BoundType DIGenericSubrange::getStride() const {
559 Metadata *ST = getRawStride();
560 if (!ST)
561 return BoundType();
562
563 assert((isa<DIVariable>(ST) || isa<DIExpression>(ST)) &&(static_cast <bool> ((isa<DIVariable>(ST) || isa<
DIExpression>(ST)) && "Stride must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(ST) || isa<DIExpression>(ST)) && \"Stride must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 564, __extension__ __PRETTY_FUNCTION__
))
564 "Stride must be signed constant or DIVariable or DIExpression")(static_cast <bool> ((isa<DIVariable>(ST) || isa<
DIExpression>(ST)) && "Stride must be signed constant or DIVariable or DIExpression"
) ? void (0) : __assert_fail ("(isa<DIVariable>(ST) || isa<DIExpression>(ST)) && \"Stride must be signed constant or DIVariable or DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 564, __extension__ __PRETTY_FUNCTION__
))
;
565
566 if (auto *MD = dyn_cast<DIVariable>(ST))
567 return BoundType(MD);
568
569 if (auto *MD = dyn_cast<DIExpression>(ST))
570 return BoundType(MD);
571
572 return BoundType();
573}
574
575DIEnumerator::DIEnumerator(LLVMContext &C, StorageType Storage,
576 const APInt &Value, bool IsUnsigned,
577 ArrayRef<Metadata *> Ops)
578 : DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
579 Value(Value) {
580 SubclassData32 = IsUnsigned;
581}
582DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, const APInt &Value,
583 bool IsUnsigned, MDString *Name,
584 StorageType Storage, bool ShouldCreate) {
585 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 585, __extension__ __PRETTY_FUNCTION__
))
;
586 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
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 586, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
587 Metadata *Ops[] = {Name};
588 DEFINE_GETIMPL_STORE(DIEnumerator, (Value, IsUnsigned), Ops)return storeImpl(new (std::size(Ops), Storage) DIEnumerator(Context
, Storage, Value, IsUnsigned, Ops), Storage, Context.pImpl->
DIEnumerators)
;
589}
590
591DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
592 MDString *Name, uint64_t SizeInBits,
593 uint32_t AlignInBits, unsigned Encoding,
594 DIFlags Flags, StorageType Storage,
595 bool ShouldCreate) {
596 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 596, __extension__ __PRETTY_FUNCTION__
))
;
597 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 { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 598, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
598 (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 { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 598, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
599 Metadata *Ops[] = {nullptr, nullptr, Name};
600 DEFINE_GETIMPL_STORE(DIBasicType,return storeImpl(new (std::size(Ops), Storage) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Flags, Ops
), Storage, Context.pImpl->DIBasicTypes)
601 (Tag, SizeInBits, AlignInBits, Encoding, Flags), Ops)return storeImpl(new (std::size(Ops), Storage) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Flags, Ops
), Storage, Context.pImpl->DIBasicTypes)
;
602}
603
604Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
605 switch (getEncoding()) {
606 case dwarf::DW_ATE_signed:
607 case dwarf::DW_ATE_signed_char:
608 return Signedness::Signed;
609 case dwarf::DW_ATE_unsigned:
610 case dwarf::DW_ATE_unsigned_char:
611 return Signedness::Unsigned;
612 default:
613 return std::nullopt;
614 }
615}
616
617DIStringType *DIStringType::getImpl(LLVMContext &Context, unsigned Tag,
618 MDString *Name, Metadata *StringLength,
619 Metadata *StringLengthExp,
620 Metadata *StringLocationExp,
621 uint64_t SizeInBits, uint32_t AlignInBits,
622 unsigned Encoding, StorageType Storage,
623 bool ShouldCreate) {
624 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 624, __extension__ __PRETTY_FUNCTION__
))
;
625 DEFINE_GETIMPL_LOOKUP(DIStringType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIStringTypes, DIStringTypeInfo::KeyTy(Tag, Name, StringLength
, StringLengthExp, StringLocationExp, SizeInBits, AlignInBits
, Encoding))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 627, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
626 (Tag, Name, StringLength, StringLengthExp,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIStringTypes, DIStringTypeInfo::KeyTy(Tag, Name, StringLength
, StringLengthExp, StringLocationExp, SizeInBits, AlignInBits
, Encoding))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 627, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
627 StringLocationExp, SizeInBits, AlignInBits, Encoding))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIStringTypes, DIStringTypeInfo::KeyTy(Tag, Name, StringLength
, StringLengthExp, StringLocationExp, SizeInBits, AlignInBits
, Encoding))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 627, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
628 Metadata *Ops[] = {nullptr, nullptr, Name,
629 StringLength, StringLengthExp, StringLocationExp};
630 DEFINE_GETIMPL_STORE(DIStringType, (Tag, SizeInBits, AlignInBits, Encoding),return storeImpl(new (std::size(Ops), Storage) DIStringType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIStringTypes)
631 Ops)return storeImpl(new (std::size(Ops), Storage) DIStringType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIStringTypes)
;
632}
633DIType *DIDerivedType::getClassType() const {
634 assert(getTag() == dwarf::DW_TAG_ptr_to_member_type)(static_cast <bool> (getTag() == dwarf::DW_TAG_ptr_to_member_type
) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_ptr_to_member_type"
, "llvm/lib/IR/DebugInfoMetadata.cpp", 634, __extension__ __PRETTY_FUNCTION__
))
;
635 return cast_or_null<DIType>(getExtraData());
636}
637uint32_t DIDerivedType::getVBPtrOffset() const {
638 assert(getTag() == dwarf::DW_TAG_inheritance)(static_cast <bool> (getTag() == dwarf::DW_TAG_inheritance
) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_inheritance"
, "llvm/lib/IR/DebugInfoMetadata.cpp", 638, __extension__ __PRETTY_FUNCTION__
))
;
639 if (auto *CM = cast_or_null<ConstantAsMetadata>(getExtraData()))
640 if (auto *CI = dyn_cast_or_null<ConstantInt>(CM->getValue()))
641 return static_cast<uint32_t>(CI->getZExtValue());
642 return 0;
643}
644Constant *DIDerivedType::getStorageOffsetInBits() const {
645 assert(getTag() == dwarf::DW_TAG_member && isBitField())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
isBitField()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && isBitField()"
, "llvm/lib/IR/DebugInfoMetadata.cpp", 645, __extension__ __PRETTY_FUNCTION__
))
;
646 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
647 return C->getValue();
648 return nullptr;
649}
650
651Constant *DIDerivedType::getConstant() const {
652 assert(getTag() == dwarf::DW_TAG_member && isStaticMember())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
isStaticMember()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && isStaticMember()"
, "llvm/lib/IR/DebugInfoMetadata.cpp", 652, __extension__ __PRETTY_FUNCTION__
))
;
653 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
654 return C->getValue();
655 return nullptr;
656}
657Constant *DIDerivedType::getDiscriminantValue() const {
658 assert(getTag() == dwarf::DW_TAG_member && !isStaticMember())(static_cast <bool> (getTag() == dwarf::DW_TAG_member &&
!isStaticMember()) ? void (0) : __assert_fail ("getTag() == dwarf::DW_TAG_member && !isStaticMember()"
, "llvm/lib/IR/DebugInfoMetadata.cpp", 658, __extension__ __PRETTY_FUNCTION__
))
;
659 if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
660 return C->getValue();
661 return nullptr;
662}
663
664DIDerivedType *DIDerivedType::getImpl(
665 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
666 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
667 uint32_t AlignInBits, uint64_t OffsetInBits,
668 Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
669 Metadata *Annotations, StorageType Storage, bool ShouldCreate) {
670 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 670, __extension__ __PRETTY_FUNCTION__
))
;
671 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, Annotations))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 674, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
672 (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, Annotations))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 674, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
673 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, Annotations))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 674, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
674 ExtraData, Annotations))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, Annotations))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 674, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
675 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData, Annotations};
676 DEFINE_GETIMPL_STORE(DIDerivedType,return storeImpl(new (std::size(Ops), Storage) DIDerivedType(
Context, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, Ops), Storage, Context.pImpl->
DIDerivedTypes)
677 (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,return storeImpl(new (std::size(Ops), Storage) DIDerivedType(
Context, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, Ops), Storage, Context.pImpl->
DIDerivedTypes)
678 DWARFAddressSpace, Flags),return storeImpl(new (std::size(Ops), Storage) DIDerivedType(
Context, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, Ops), Storage, Context.pImpl->
DIDerivedTypes)
679 Ops)return storeImpl(new (std::size(Ops), Storage) DIDerivedType(
Context, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, Ops), Storage, Context.pImpl->
DIDerivedTypes)
;
680}
681
682DICompositeType *DICompositeType::getImpl(
683 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
684 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
685 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
686 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
687 Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
688 Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
689 Metadata *Rank, Metadata *Annotations, StorageType Storage,
690 bool ShouldCreate) {
691 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 691, __extension__ __PRETTY_FUNCTION__
))
;
692
693 // Keep this in sync with buildODRType.
694 DEFINE_GETIMPL_LOOKUP(DICompositeType,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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
695 (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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
696 AlignInBits, OffsetInBits, Flags, Elements,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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
697 RuntimeLang, VTableHolder, TemplateParams, Identifier,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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
698 Discriminator, DataLocation, Associated, Allocated,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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
699 Rank, Annotations))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, DataLocation, Associated, Allocated
, Rank, Annotations))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 699, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
700 Metadata *Ops[] = {File, Scope, Name, BaseType,
701 Elements, VTableHolder, TemplateParams, Identifier,
702 Discriminator, DataLocation, Associated, Allocated,
703 Rank, Annotations};
704 DEFINE_GETIMPL_STORE(return storeImpl(new (std::size(Ops), Storage) DICompositeType
(Context, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits
, OffsetInBits, Flags, Ops), Storage, Context.pImpl->DICompositeTypes
)
705 DICompositeType,return storeImpl(new (std::size(Ops), Storage) DICompositeType
(Context, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits
, OffsetInBits, Flags, Ops), Storage, Context.pImpl->DICompositeTypes
)
706 (Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits, Flags),return storeImpl(new (std::size(Ops), Storage) DICompositeType
(Context, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits
, OffsetInBits, Flags, Ops), Storage, Context.pImpl->DICompositeTypes
)
707 Ops)return storeImpl(new (std::size(Ops), Storage) DICompositeType
(Context, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits
, OffsetInBits, Flags, Ops), Storage, Context.pImpl->DICompositeTypes
)
;
708}
709
710DICompositeType *DICompositeType::buildODRType(
711 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
712 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
713 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
714 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
715 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator,
716 Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
717 Metadata *Rank, Metadata *Annotations) {
718 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 718, __extension__ __PRETTY_FUNCTION__
))
;
719 if (!Context.isODRUniquingDebugTypes())
720 return nullptr;
721 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
722 if (!CT)
723 return CT = DICompositeType::getDistinct(
724 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
725 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
726 VTableHolder, TemplateParams, &Identifier, Discriminator,
727 DataLocation, Associated, Allocated, Rank, Annotations);
728
729 if (CT->getTag() != Tag)
730 return nullptr;
731
732 // Only mutate CT if it's a forward declaration and the new operands aren't.
733 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?")(static_cast <bool> (CT->getRawIdentifier() == &
Identifier && "Wrong ODR identifier?") ? void (0) : __assert_fail
("CT->getRawIdentifier() == &Identifier && \"Wrong ODR identifier?\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 733, __extension__ __PRETTY_FUNCTION__
))
;
734 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
735 return CT;
736
737 // Mutate CT in place. Keep this in sync with getImpl.
738 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
739 Flags);
740 Metadata *Ops[] = {File, Scope, Name, BaseType,
741 Elements, VTableHolder, TemplateParams, &Identifier,
742 Discriminator, DataLocation, Associated, Allocated,
743 Rank, Annotations};
744 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) ==
(int)CT->getNumOperands() && "Mismatched number of operands"
) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 745, __extension__ __PRETTY_FUNCTION__
))
745 "Mismatched number of operands")(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) ==
(int)CT->getNumOperands() && "Mismatched number of operands"
) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 745, __extension__ __PRETTY_FUNCTION__
))
;
746 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
747 if (Ops[I] != CT->getOperand(I))
748 CT->setOperand(I, Ops[I]);
749 return CT;
750}
751
752DICompositeType *DICompositeType::getODRType(
753 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
754 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
755 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
756 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
757 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator,
758 Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
759 Metadata *Rank, Metadata *Annotations) {
760 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 760, __extension__ __PRETTY_FUNCTION__
))
;
761 if (!Context.isODRUniquingDebugTypes())
762 return nullptr;
763 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
764 if (!CT) {
765 CT = DICompositeType::getDistinct(
766 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
767 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
768 TemplateParams, &Identifier, Discriminator, DataLocation, Associated,
769 Allocated, Rank, Annotations);
770 } else {
771 if (CT->getTag() != Tag)
772 return nullptr;
773 }
774 return CT;
775}
776
777DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
778 MDString &Identifier) {
779 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 779, __extension__ __PRETTY_FUNCTION__
))
;
780 if (!Context.isODRUniquingDebugTypes())
781 return nullptr;
782 return Context.pImpl->DITypeMap->lookup(&Identifier);
783}
784DISubroutineType::DISubroutineType(LLVMContext &C, StorageType Storage,
785 DIFlags Flags, uint8_t CC,
786 ArrayRef<Metadata *> Ops)
787 : DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type, 0,
788 0, 0, 0, Flags, Ops),
789 CC(CC) {}
790
791DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
792 uint8_t CC, Metadata *TypeArray,
793 StorageType Storage,
794 bool ShouldCreate) {
795 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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 795, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
796 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
797 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops)return storeImpl(new (std::size(Ops), Storage) DISubroutineType
(Context, Storage, Flags, CC, Ops), Storage, Context.pImpl->
DISubroutineTypes)
;
798}
799
800DIFile::DIFile(LLVMContext &C, StorageType Storage,
801 Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
802 ArrayRef<Metadata *> Ops)
803 : DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
804 Checksum(CS), Source(Src) {}
805
806// FIXME: Implement this string-enum correspondence with a .def file and macros,
807// so that the association is explicit rather than implied.
808static const char *ChecksumKindName[DIFile::CSK_Last] = {
809 "CSK_MD5",
810 "CSK_SHA1",
811 "CSK_SHA256",
812};
813
814StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
815 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind")(static_cast <bool> (CSKind <= DIFile::CSK_Last &&
"Invalid checksum kind") ? void (0) : __assert_fail ("CSKind <= DIFile::CSK_Last && \"Invalid checksum kind\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 815, __extension__ __PRETTY_FUNCTION__
))
;
816 // The first space was originally the CSK_None variant, which is now
817 // obsolete, but the space is still reserved in ChecksumKind, so we account
818 // for it here.
819 return ChecksumKindName[CSKind - 1];
820}
821
822Optional<DIFile::ChecksumKind> DIFile::getChecksumKind(StringRef CSKindStr) {
823 return StringSwitch<Optional<DIFile::ChecksumKind>>(CSKindStr)
824 .Case("CSK_MD5", DIFile::CSK_MD5)
825 .Case("CSK_SHA1", DIFile::CSK_SHA1)
826 .Case("CSK_SHA256", DIFile::CSK_SHA256)
827 .Default(std::nullopt);
828}
829
830DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
831 MDString *Directory,
832 Optional<DIFile::ChecksumInfo<MDString *>> CS,
833 Optional<MDString *> Source, StorageType Storage,
834 bool ShouldCreate) {
835 assert(isCanonical(Filename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Filename) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Filename) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 835, __extension__ __PRETTY_FUNCTION__
))
;
836 assert(isCanonical(Directory) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Directory) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Directory) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 836, __extension__ __PRETTY_FUNCTION__
))
;
837 assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString")(static_cast <bool> ((!CS || isCanonical(CS->Value))
&& "Expected canonical MDString") ? void (0) : __assert_fail
("(!CS || isCanonical(CS->Value)) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 837, __extension__ __PRETTY_FUNCTION__
))
;
838 assert((!Source || isCanonical(*Source)) && "Expected canonical MDString")(static_cast <bool> ((!Source || isCanonical(*Source)) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("(!Source || isCanonical(*Source)) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 838, __extension__ __PRETTY_FUNCTION__
))
;
839 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
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 839, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
840 Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr,
841 Source.value_or(nullptr)};
842 DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops)return storeImpl(new (std::size(Ops), Storage) DIFile(Context
, Storage, CS, Source, Ops), Storage, Context.pImpl->DIFiles
)
;
843}
844DICompileUnit::DICompileUnit(LLVMContext &C, StorageType Storage,
845 unsigned SourceLanguage, bool IsOptimized,
846 unsigned RuntimeVersion, unsigned EmissionKind,
847 uint64_t DWOId, bool SplitDebugInlining,
848 bool DebugInfoForProfiling, unsigned NameTableKind,
849 bool RangesBaseAddress, ArrayRef<Metadata *> Ops)
850 : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
851 SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
852 RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind), DWOId(DWOId),
853 SplitDebugInlining(SplitDebugInlining),
854 DebugInfoForProfiling(DebugInfoForProfiling),
855 NameTableKind(NameTableKind), RangesBaseAddress(RangesBaseAddress) {
856 assert(Storage != Uniqued)(static_cast <bool> (Storage != Uniqued) ? void (0) : __assert_fail
("Storage != Uniqued", "llvm/lib/IR/DebugInfoMetadata.cpp", 856
, __extension__ __PRETTY_FUNCTION__))
;
857}
858
859DICompileUnit *DICompileUnit::getImpl(
860 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
861 MDString *Producer, bool IsOptimized, MDString *Flags,
862 unsigned RuntimeVersion, MDString *SplitDebugFilename,
863 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
864 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
865 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
866 unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
867 MDString *SDK, StorageType Storage, bool ShouldCreate) {
868 assert(Storage != Uniqued && "Cannot unique DICompileUnit")(static_cast <bool> (Storage != Uniqued && "Cannot unique DICompileUnit"
) ? void (0) : __assert_fail ("Storage != Uniqued && \"Cannot unique DICompileUnit\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 868, __extension__ __PRETTY_FUNCTION__
))
;
869 assert(isCanonical(Producer) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Producer) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Producer) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 869, __extension__ __PRETTY_FUNCTION__
))
;
870 assert(isCanonical(Flags) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Flags) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Flags) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 870, __extension__ __PRETTY_FUNCTION__
))
;
871 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SplitDebugFilename) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SplitDebugFilename) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 871, __extension__ __PRETTY_FUNCTION__
))
;
872
873 Metadata *Ops[] = {File,
874 Producer,
875 Flags,
876 SplitDebugFilename,
877 EnumTypes,
878 RetainedTypes,
879 GlobalVariables,
880 ImportedEntities,
881 Macros,
882 SysRoot,
883 SDK};
884 return storeImpl(new (std::size(Ops), Storage) DICompileUnit(
885 Context, Storage, SourceLanguage, IsOptimized,
886 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
887 DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
888 Ops),
889 Storage);
890}
891
892Optional<DICompileUnit::DebugEmissionKind>
893DICompileUnit::getEmissionKind(StringRef Str) {
894 return StringSwitch<Optional<DebugEmissionKind>>(Str)
895 .Case("NoDebug", NoDebug)
896 .Case("FullDebug", FullDebug)
897 .Case("LineTablesOnly", LineTablesOnly)
898 .Case("DebugDirectivesOnly", DebugDirectivesOnly)
899 .Default(std::nullopt);
900}
901
902Optional<DICompileUnit::DebugNameTableKind>
903DICompileUnit::getNameTableKind(StringRef Str) {
904 return StringSwitch<Optional<DebugNameTableKind>>(Str)
905 .Case("Default", DebugNameTableKind::Default)
906 .Case("GNU", DebugNameTableKind::GNU)
907 .Case("None", DebugNameTableKind::None)
908 .Default(std::nullopt);
909}
910
911const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
912 switch (EK) {
913 case NoDebug:
914 return "NoDebug";
915 case FullDebug:
916 return "FullDebug";
917 case LineTablesOnly:
918 return "LineTablesOnly";
919 case DebugDirectivesOnly:
920 return "DebugDirectivesOnly";
921 }
922 return nullptr;
923}
924
925const char *DICompileUnit::nameTableKindString(DebugNameTableKind NTK) {
926 switch (NTK) {
927 case DebugNameTableKind::Default:
928 return nullptr;
929 case DebugNameTableKind::GNU:
930 return "GNU";
931 case DebugNameTableKind::None:
932 return "None";
933 }
934 return nullptr;
935}
936DISubprogram::DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
937 unsigned ScopeLine, unsigned VirtualIndex,
938 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
939 ArrayRef<Metadata *> Ops)
940 : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram, Ops),
941 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
942 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
943 static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
944}
945DISubprogram::DISPFlags
946DISubprogram::toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized,
947 unsigned Virtuality, bool IsMainSubprogram) {
948 // We're assuming virtuality is the low-order field.
949 static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
950 int(SPFlagPureVirtual) ==
951 int(dwarf::DW_VIRTUALITY_pure_virtual),
952 "Virtuality constant mismatch");
953 return static_cast<DISPFlags>(
954 (Virtuality & SPFlagVirtuality) |
955 (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) |
956 (IsDefinition ? SPFlagDefinition : SPFlagZero) |
957 (IsOptimized ? SPFlagOptimized : SPFlagZero) |
958 (IsMainSubprogram ? SPFlagMainSubprogram : SPFlagZero));
959}
960
961DISubprogram *DILocalScope::getSubprogram() const {
962 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
963 return Block->getScope()->getSubprogram();
964 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
965}
966
967DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
968 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
969 return File->getScope()->getNonLexicalBlockFileScope();
970 return const_cast<DILocalScope *>(this);
971}
972
973DISubprogram::DISPFlags DISubprogram::getFlag(StringRef Flag) {
974 return StringSwitch<DISPFlags>(Flag)
975#define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
976#include "llvm/IR/DebugInfoFlags.def"
977 .Default(SPFlagZero);
978}
979
980StringRef DISubprogram::getFlagString(DISPFlags Flag) {
981 switch (Flag) {
982 // Appease a warning.
983 case SPFlagVirtuality:
984 return "";
985#define HANDLE_DISP_FLAG(ID, NAME) \
986 case SPFlag##NAME: \
987 return "DISPFlag" #NAME;
988#include "llvm/IR/DebugInfoFlags.def"
989 }
990 return "";
991}
992
993DISubprogram::DISPFlags
994DISubprogram::splitFlags(DISPFlags Flags,
995 SmallVectorImpl<DISPFlags> &SplitFlags) {
996 // Multi-bit fields can require special handling. In our case, however, the
997 // only multi-bit field is virtuality, and all its values happen to be
998 // single-bit values, so the right behavior just falls out.
999#define HANDLE_DISP_FLAG(ID, NAME) \
1000 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
1001 SplitFlags.push_back(Bit); \
1002 Flags &= ~Bit; \
1003 }
1004#include "llvm/IR/DebugInfoFlags.def"
1005 return Flags;
1006}
1007
1008DISubprogram *DISubprogram::getImpl(
1009 LLVMContext &Context, Metadata *Scope, MDString *Name,
1010 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1011 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
1012 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1013 Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
1014 Metadata *ThrownTypes, Metadata *Annotations, MDString *TargetFuncName,
1015 StorageType Storage, bool ShouldCreate) {
1016 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1016, __extension__ __PRETTY_FUNCTION__
))
;
1017 assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1017, __extension__ __PRETTY_FUNCTION__
))
;
1018 assert(isCanonical(TargetFuncName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(TargetFuncName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(TargetFuncName) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1018, __extension__ __PRETTY_FUNCTION__
))
;
1019 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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1020 (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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1021 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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1022 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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1023 RetainedNodes, ThrownTypes, Annotations,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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1024 TargetFuncName))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, Annotations, TargetFuncName))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1024, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1025 SmallVector<Metadata *, 13> Ops = {
1026 File, Scope, Name, LinkageName,
1027 Type, Unit, Declaration, RetainedNodes,
1028 ContainingType, TemplateParams, ThrownTypes, Annotations,
1029 TargetFuncName};
1030 if (!TargetFuncName) {
1031 Ops.pop_back();
1032 if (!Annotations) {
1033 Ops.pop_back();
1034 if (!ThrownTypes) {
1035 Ops.pop_back();
1036 if (!TemplateParams) {
1037 Ops.pop_back();
1038 if (!ContainingType)
1039 Ops.pop_back();
1040 }
1041 }
1042 }
1043 }
1044 DEFINE_GETIMPL_STORE_N(return storeImpl(new (Ops.size(), Storage) DISubprogram(Context
, Storage, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags
, SPFlags, Ops), Storage, Context.pImpl->DISubprograms)
1045 DISubprogram,return storeImpl(new (Ops.size(), Storage) DISubprogram(Context
, Storage, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags
, SPFlags, Ops), Storage, Context.pImpl->DISubprograms)
1046 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags), Ops,return storeImpl(new (Ops.size(), Storage) DISubprogram(Context
, Storage, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags
, SPFlags, Ops), Storage, Context.pImpl->DISubprograms)
1047 Ops.size())return storeImpl(new (Ops.size(), Storage) DISubprogram(Context
, Storage, Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags
, SPFlags, Ops), Storage, Context.pImpl->DISubprograms)
;
1048}
1049
1050bool DISubprogram::describes(const Function *F) const {
1051 assert(F && "Invalid function")(static_cast <bool> (F && "Invalid function") ?
void (0) : __assert_fail ("F && \"Invalid function\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1051, __extension__ __PRETTY_FUNCTION__
))
;
1052 return F->getSubprogram() == this;
1053}
1054DILexicalBlockBase::DILexicalBlockBase(LLVMContext &C, unsigned ID,
1055 StorageType Storage,
1056 ArrayRef<Metadata *> Ops)
1057 : DILocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1058
1059DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
1060 Metadata *File, unsigned Line,
1061 unsigned Column, StorageType Storage,
1062 bool ShouldCreate) {
1063 // Fixup column.
1064 adjustColumn(Column);
1065
1066 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1066, __extension__ __PRETTY_FUNCTION__
))
;
1067 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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1067, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1068 Metadata *Ops[] = {File, Scope};
1069 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops)return storeImpl(new (std::size(Ops), Storage) DILexicalBlock
(Context, Storage, Line, Column, Ops), Storage, Context.pImpl
->DILexicalBlocks)
;
1070}
1071
1072DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
1073 Metadata *Scope, Metadata *File,
1074 unsigned Discriminator,
1075 StorageType Storage,
1076 bool ShouldCreate) {
1077 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1077, __extension__ __PRETTY_FUNCTION__
))
;
1078 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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1078, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1079 Metadata *Ops[] = {File, Scope};
1080 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops)return storeImpl(new (std::size(Ops), Storage) DILexicalBlockFile
(Context, Storage, Discriminator, Ops), Storage, Context.pImpl
->DILexicalBlockFiles)
;
1081}
1082
1083DINamespace::DINamespace(LLVMContext &Context, StorageType Storage,
1084 bool ExportSymbols, ArrayRef<Metadata *> Ops)
1085 : DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace, Ops),
1086 ExportSymbols(ExportSymbols) {}
1087DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
1088 MDString *Name, bool ExportSymbols,
1089 StorageType Storage, bool ShouldCreate) {
1090 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1090, __extension__ __PRETTY_FUNCTION__
))
;
1091 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 { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1091, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1092 // The nullptr is for DIScope's File operand. This should be refactored.
1093 Metadata *Ops[] = {nullptr, Scope, Name};
1094 DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops)return storeImpl(new (std::size(Ops), Storage) DINamespace(Context
, Storage, ExportSymbols, Ops), Storage, Context.pImpl->DINamespaces
)
;
1095}
1096
1097DICommonBlock::DICommonBlock(LLVMContext &Context, StorageType Storage,
1098 unsigned LineNo, ArrayRef<Metadata *> Ops)
1099 : DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block,
1100 Ops),
1101 LineNo(LineNo) {}
1102DICommonBlock *DICommonBlock::getImpl(LLVMContext &Context, Metadata *Scope,
1103 Metadata *Decl, MDString *Name,
1104 Metadata *File, unsigned LineNo,
1105 StorageType Storage, bool ShouldCreate) {
1106 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1106, __extension__ __PRETTY_FUNCTION__
))
;
1107 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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1107, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1108 // The nullptr is for DIScope's File operand. This should be refactored.
1109 Metadata *Ops[] = {Scope, Decl, Name, File};
1110 DEFINE_GETIMPL_STORE(DICommonBlock, (LineNo), Ops)return storeImpl(new (std::size(Ops), Storage) DICommonBlock(
Context, Storage, LineNo, Ops), Storage, Context.pImpl->DICommonBlocks
)
;
1111}
1112
1113DIModule::DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
1114 bool IsDecl, ArrayRef<Metadata *> Ops)
1115 : DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops),
1116 LineNo(LineNo), IsDecl(IsDecl) {}
1117DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *File,
1118 Metadata *Scope, MDString *Name,
1119 MDString *ConfigurationMacros,
1120 MDString *IncludePath, MDString *APINotesFile,
1121 unsigned LineNo, bool IsDecl, StorageType Storage,
1122 bool ShouldCreate) {
1123 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1123, __extension__ __PRETTY_FUNCTION__
))
;
1124 DEFINE_GETIMPL_LOOKUP(DIModule, (File, Scope, Name, ConfigurationMacros,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(File, Scope, Name, ConfigurationMacros
, IncludePath, APINotesFile, LineNo, IsDecl))) return N; if (
!ShouldCreate) return nullptr; } else { (static_cast <bool
> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1125, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1125 IncludePath, APINotesFile, LineNo, IsDecl))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(File, Scope, Name, ConfigurationMacros
, IncludePath, APINotesFile, LineNo, IsDecl))) return N; if (
!ShouldCreate) return nullptr; } else { (static_cast <bool
> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1125, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1126 Metadata *Ops[] = {File, Scope, Name, ConfigurationMacros,
1127 IncludePath, APINotesFile};
1128 DEFINE_GETIMPL_STORE(DIModule, (LineNo, IsDecl), Ops)return storeImpl(new (std::size(Ops), Storage) DIModule(Context
, Storage, LineNo, IsDecl, Ops), Storage, Context.pImpl->DIModules
)
;
1129}
1130DITemplateTypeParameter::DITemplateTypeParameter(LLVMContext &Context,
1131 StorageType Storage,
1132 bool IsDefault,
1133 ArrayRef<Metadata *> Ops)
1134 : DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
1135 dwarf::DW_TAG_template_type_parameter, IsDefault,
1136 Ops) {}
1137
1138DITemplateTypeParameter *
1139DITemplateTypeParameter::getImpl(LLVMContext &Context, MDString *Name,
1140 Metadata *Type, bool isDefault,
1141 StorageType Storage, bool ShouldCreate) {
1142 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1142, __extension__ __PRETTY_FUNCTION__
))
;
1143 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 { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1143, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1144 Metadata *Ops[] = {Name, Type};
1145 DEFINE_GETIMPL_STORE(DITemplateTypeParameter, (isDefault), Ops)return storeImpl(new (std::size(Ops), Storage) DITemplateTypeParameter
(Context, Storage, isDefault, Ops), Storage, Context.pImpl->
DITemplateTypeParameters)
;
1146}
1147
1148DITemplateValueParameter *DITemplateValueParameter::getImpl(
1149 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
1150 bool isDefault, Metadata *Value, StorageType Storage, bool ShouldCreate) {
1151 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1151, __extension__ __PRETTY_FUNCTION__
))
;
1152 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 { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1153, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1153 (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 { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1153, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1154 Metadata *Ops[] = {Name, Type, Value};
1155 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag, isDefault), Ops)return storeImpl(new (std::size(Ops), Storage) DITemplateValueParameter
(Context, Storage, Tag, isDefault, Ops), Storage, Context.pImpl
->DITemplateValueParameters)
;
1156}
1157
1158DIGlobalVariable *
1159DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1160 MDString *LinkageName, Metadata *File, unsigned Line,
1161 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1162 Metadata *StaticDataMemberDeclaration,
1163 Metadata *TemplateParams, uint32_t AlignInBits,
1164 Metadata *Annotations, StorageType Storage,
1165 bool ShouldCreate) {
1166 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1166, __extension__ __PRETTY_FUNCTION__
))
;
1167 assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1167, __extension__ __PRETTY_FUNCTION__
))
;
1168 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1171, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1169 DIGlobalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1171, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1170 (Scope, Name, LinkageName, File, Line, 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, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1171, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1171 StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1171, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1172 Metadata *Ops[] = {Scope,
1173 Name,
1174 File,
1175 Type,
1176 Name,
1177 LinkageName,
1178 StaticDataMemberDeclaration,
1179 TemplateParams,
1180 Annotations};
1181 DEFINE_GETIMPL_STORE(DIGlobalVariable,return storeImpl(new (std::size(Ops), Storage) DIGlobalVariable
(Context, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits
, Ops), Storage, Context.pImpl->DIGlobalVariables)
1182 (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops)return storeImpl(new (std::size(Ops), Storage) DIGlobalVariable
(Context, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits
, Ops), Storage, Context.pImpl->DIGlobalVariables)
;
1183}
1184
1185DILocalVariable *
1186DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1187 Metadata *File, unsigned Line, Metadata *Type,
1188 unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
1189 Metadata *Annotations, StorageType Storage,
1190 bool ShouldCreate) {
1191 // 64K ought to be enough for any frontend.
1192 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits")(static_cast <bool> (Arg <= (65535) && "Expected argument number to fit in 16-bits"
) ? void (0) : __assert_fail ("Arg <= UINT16_MAX && \"Expected argument number to fit in 16-bits\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1192, __extension__ __PRETTY_FUNCTION__
))
;
1193
1194 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1194, __extension__ __PRETTY_FUNCTION__
))
;
1195 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1195, __extension__ __PRETTY_FUNCTION__
))
;
1196 DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Scope, Name, File, Line, Type, Arg,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1197, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1197 Flags, AlignInBits, Annotations))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits, Annotations
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1197, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1198 Metadata *Ops[] = {Scope, Name, File, Type, Annotations};
1199 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops)return storeImpl(new (std::size(Ops), Storage) DILocalVariable
(Context, Storage, Line, Arg, Flags, AlignInBits, Ops), Storage
, Context.pImpl->DILocalVariables)
;
1200}
1201
1202DIVariable::DIVariable(LLVMContext &C, unsigned ID, StorageType Storage,
1203 signed Line, ArrayRef<Metadata *> Ops,
1204 uint32_t AlignInBits)
1205 : DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
1206 AlignInBits(AlignInBits) {}
1207Optional<uint64_t> DIVariable::getSizeInBits() const {
1208 // This is used by the Verifier so be mindful of broken types.
1209 const Metadata *RawType = getRawType();
1210 while (RawType) {
1211 // Try to get the size directly.
1212 if (auto *T = dyn_cast<DIType>(RawType))
1213 if (uint64_t Size = T->getSizeInBits())
1214 return Size;
1215
1216 if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
1217 // Look at the base type.
1218 RawType = DT->getRawBaseType();
1219 continue;
1220 }
1221
1222 // Missing type or size.
1223 break;
1224 }
1225
1226 // Fail gracefully.
1227 return std::nullopt;
1228}
1229
1230DILabel::DILabel(LLVMContext &C, StorageType Storage, unsigned Line,
1231 ArrayRef<Metadata *> Ops)
1232 : DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops), Line(Line) {}
1233DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1234 Metadata *File, unsigned Line, StorageType Storage,
1235 bool ShouldCreate) {
1236 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1236, __extension__ __PRETTY_FUNCTION__
))
;
1237 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1237, __extension__ __PRETTY_FUNCTION__
))
;
1238 DEFINE_GETIMPL_LOOKUP(DILabel, (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 { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1238, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1239 Metadata *Ops[] = {Scope, Name, File};
1240 DEFINE_GETIMPL_STORE(DILabel, (Line), Ops)return storeImpl(new (std::size(Ops), Storage) DILabel(Context
, Storage, Line, Ops), Storage, Context.pImpl->DILabels)
;
1241}
1242
1243DIExpression *DIExpression::getImpl(LLVMContext &Context,
1244 ArrayRef<uint64_t> Elements,
1245 StorageType Storage, bool ShouldCreate) {
1246 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 { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1246, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1247 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements))return storeImpl(new (0u, Storage) DIExpression(Context, Storage
, Elements), Storage, Context.pImpl->DIExpressions)
;
1248}
1249bool DIExpression::isEntryValue() const {
1250 return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_LLVM_entry_value;
1251}
1252bool DIExpression::startsWithDeref() const {
1253 return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref;
1254}
1255
1256DIAssignID *DIAssignID::getImpl(LLVMContext &Context, StorageType Storage,
1257 bool ShouldCreate) {
1258 // Uniqued DIAssignID are not supported as the instance address *is* the ID.
1259 assert(Storage != StorageType::Uniqued && "uniqued DIAssignID unsupported")(static_cast <bool> (Storage != StorageType::Uniqued &&
"uniqued DIAssignID unsupported") ? void (0) : __assert_fail
("Storage != StorageType::Uniqued && \"uniqued DIAssignID unsupported\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1259, __extension__ __PRETTY_FUNCTION__
))
;
1260 return storeImpl(new (0u, Storage) DIAssignID(Context, Storage), Storage);
1261}
1262
1263unsigned DIExpression::ExprOperand::getSize() const {
1264 uint64_t Op = getOp();
1265
1266 if (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31)
1267 return 2;
1268
1269 switch (Op) {
1270 case dwarf::DW_OP_LLVM_convert:
1271 case dwarf::DW_OP_LLVM_fragment:
1272 case dwarf::DW_OP_bregx:
1273 return 3;
1274 case dwarf::DW_OP_constu:
1275 case dwarf::DW_OP_consts:
1276 case dwarf::DW_OP_deref_size:
1277 case dwarf::DW_OP_plus_uconst:
1278 case dwarf::DW_OP_LLVM_tag_offset:
1279 case dwarf::DW_OP_LLVM_entry_value:
1280 case dwarf::DW_OP_LLVM_arg:
1281 case dwarf::DW_OP_regx:
1282 return 2;
1283 default:
1284 return 1;
1285 }
1286}
1287
1288bool DIExpression::isValid() const {
1289 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
1290 // Check that there's space for the operand.
1291 if (I->get() + I->getSize() > E->get())
1292 return false;
1293
1294 uint64_t Op = I->getOp();
1295 if ((Op >= dwarf::DW_OP_reg0 && Op <= dwarf::DW_OP_reg31) ||
1296 (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31))
1297 return true;
1298
1299 // Check that the operand is valid.
1300 switch (Op) {
1301 default:
1302 return false;
1303 case dwarf::DW_OP_LLVM_fragment:
1304 // A fragment operator must appear at the end.
1305 return I->get() + I->getSize() == E->get();
1306 case dwarf::DW_OP_stack_value: {
1307 // Must be the last one or followed by a DW_OP_LLVM_fragment.
1308 if (I->get() + I->getSize() == E->get())
1309 break;
1310 auto J = I;
1311 if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
1312 return false;
1313 break;
1314 }
1315 case dwarf::DW_OP_swap: {
1316 // Must be more than one implicit element on the stack.
1317
1318 // FIXME: A better way to implement this would be to add a local variable
1319 // that keeps track of the stack depth and introduce something like a
1320 // DW_LLVM_OP_implicit_location as a placeholder for the location this
1321 // DIExpression is attached to, or else pass the number of implicit stack
1322 // elements into isValid.
1323 if (getNumElements() == 1)
1324 return false;
1325 break;
1326 }
1327 case dwarf::DW_OP_LLVM_entry_value: {
1328 // An entry value operator must appear at the beginning and the number of
1329 // operations it cover can currently only be 1, because we support only
1330 // entry values of a simple register location. One reason for this is that
1331 // we currently can't calculate the size of the resulting DWARF block for
1332 // other expressions.
1333 return I->get() == expr_op_begin()->get() && I->getArg(0) == 1;
1334 }
1335 case dwarf::DW_OP_LLVM_implicit_pointer:
1336 case dwarf::DW_OP_LLVM_convert:
1337 case dwarf::DW_OP_LLVM_arg:
1338 case dwarf::DW_OP_LLVM_tag_offset:
1339 case dwarf::DW_OP_constu:
1340 case dwarf::DW_OP_plus_uconst:
1341 case dwarf::DW_OP_plus:
1342 case dwarf::DW_OP_minus:
1343 case dwarf::DW_OP_mul:
1344 case dwarf::DW_OP_div:
1345 case dwarf::DW_OP_mod:
1346 case dwarf::DW_OP_or:
1347 case dwarf::DW_OP_and:
1348 case dwarf::DW_OP_xor:
1349 case dwarf::DW_OP_shl:
1350 case dwarf::DW_OP_shr:
1351 case dwarf::DW_OP_shra:
1352 case dwarf::DW_OP_deref:
1353 case dwarf::DW_OP_deref_size:
1354 case dwarf::DW_OP_xderef:
1355 case dwarf::DW_OP_lit0:
1356 case dwarf::DW_OP_not:
1357 case dwarf::DW_OP_dup:
1358 case dwarf::DW_OP_regx:
1359 case dwarf::DW_OP_bregx:
1360 case dwarf::DW_OP_push_object_address:
1361 case dwarf::DW_OP_over:
1362 case dwarf::DW_OP_consts:
1363 break;
1364 }
1365 }
1366 return true;
1367}
1368
1369bool DIExpression::isImplicit() const {
1370 if (!isValid())
1371 return false;
1372
1373 if (getNumElements() == 0)
1374 return false;
1375
1376 for (const auto &It : expr_ops()) {
1377 switch (It.getOp()) {
1378 default:
1379 break;
1380 case dwarf::DW_OP_stack_value:
1381 case dwarf::DW_OP_LLVM_tag_offset:
1382 return true;
1383 }
1384 }
1385
1386 return false;
1387}
1388
1389bool DIExpression::isComplex() const {
1390 if (!isValid())
1391 return false;
1392
1393 if (getNumElements() == 0)
1394 return false;
1395
1396 // If there are any elements other than fragment or tag_offset, then some
1397 // kind of complex computation occurs.
1398 for (const auto &It : expr_ops()) {
1399 switch (It.getOp()) {
1400 case dwarf::DW_OP_LLVM_tag_offset:
1401 case dwarf::DW_OP_LLVM_fragment:
1402 continue;
1403 default:
1404 return true;
1405 }
1406 }
1407
1408 return false;
1409}
1410
1411Optional<DIExpression::FragmentInfo>
1412DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
1413 for (auto I = Start; I != End; ++I)
1414 if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
1415 DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
1416 return Info;
1417 }
1418 return std::nullopt;
1419}
1420
1421void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
1422 int64_t Offset) {
1423 if (Offset > 0) {
1424 Ops.push_back(dwarf::DW_OP_plus_uconst);
1425 Ops.push_back(Offset);
1426 } else if (Offset < 0) {
1427 Ops.push_back(dwarf::DW_OP_constu);
1428 // Avoid UB when encountering LLONG_MIN, because in 2's complement
1429 // abs(LLONG_MIN) is LLONG_MAX+1.
1430 uint64_t AbsMinusOne = -(Offset+1);
1431 Ops.push_back(AbsMinusOne + 1);
1432 Ops.push_back(dwarf::DW_OP_minus);
1433 }
1434}
1435
1436bool DIExpression::extractIfOffset(int64_t &Offset) const {
1437 if (getNumElements() == 0) {
1438 Offset = 0;
1439 return true;
1440 }
1441
1442 if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
1443 Offset = Elements[1];
1444 return true;
1445 }
1446
1447 if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
1448 if (Elements[2] == dwarf::DW_OP_plus) {
1449 Offset = Elements[1];
1450 return true;
1451 }
1452 if (Elements[2] == dwarf::DW_OP_minus) {
1453 Offset = -Elements[1];
1454 return true;
1455 }
1456 }
1457
1458 return false;
1459}
1460
1461bool DIExpression::hasAllLocationOps(unsigned N) const {
1462 SmallDenseSet<uint64_t, 4> SeenOps;
1463 for (auto ExprOp : expr_ops())
1464 if (ExprOp.getOp() == dwarf::DW_OP_LLVM_arg)
1465 SeenOps.insert(ExprOp.getArg(0));
1466 for (uint64_t Idx = 0; Idx < N; ++Idx)
1467 if (!is_contained(SeenOps, Idx))
1468 return false;
1469 return true;
1470}
1471
1472const DIExpression *DIExpression::extractAddressClass(const DIExpression *Expr,
1473 unsigned &AddrClass) {
1474 // FIXME: This seems fragile. Nothing that verifies that these elements
1475 // actually map to ops and not operands.
1476 const unsigned PatternSize = 4;
1477 if (Expr->Elements.size() >= PatternSize &&
1478 Expr->Elements[PatternSize - 4] == dwarf::DW_OP_constu &&
1479 Expr->Elements[PatternSize - 2] == dwarf::DW_OP_swap &&
1480 Expr->Elements[PatternSize - 1] == dwarf::DW_OP_xderef) {
1481 AddrClass = Expr->Elements[PatternSize - 3];
1482
1483 if (Expr->Elements.size() == PatternSize)
1484 return nullptr;
1485 return DIExpression::get(Expr->getContext(),
1486 makeArrayRef(&*Expr->Elements.begin(),
1487 Expr->Elements.size() - PatternSize));
1488 }
1489 return Expr;
1490}
1491
1492DIExpression *DIExpression::prepend(const DIExpression *Expr, uint8_t Flags,
1493 int64_t Offset) {
1494 SmallVector<uint64_t, 8> Ops;
1495 if (Flags & DIExpression::DerefBefore)
1496 Ops.push_back(dwarf::DW_OP_deref);
1497
1498 appendOffset(Ops, Offset);
1499 if (Flags & DIExpression::DerefAfter)
1500 Ops.push_back(dwarf::DW_OP_deref);
1501
1502 bool StackValue = Flags & DIExpression::StackValue;
1503 bool EntryValue = Flags & DIExpression::EntryValue;
1504
1505 return prependOpcodes(Expr, Ops, StackValue, EntryValue);
1506}
1507
1508DIExpression *DIExpression::appendOpsToArg(const DIExpression *Expr,
1509 ArrayRef<uint64_t> Ops,
1510 unsigned ArgNo, bool StackValue) {
1511 assert(Expr && "Can't add ops to this expression")(static_cast <bool> (Expr && "Can't add ops to this expression"
) ? void (0) : __assert_fail ("Expr && \"Can't add ops to this expression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1511, __extension__ __PRETTY_FUNCTION__
))
;
1512
1513 // Handle non-variadic intrinsics by prepending the opcodes.
1514 if (!any_of(Expr->expr_ops(),
1515 [](auto Op) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) {
1516 assert(ArgNo == 0 &&(static_cast <bool> (ArgNo == 0 && "Location Index must be 0 for a non-variadic expression."
) ? void (0) : __assert_fail ("ArgNo == 0 && \"Location Index must be 0 for a non-variadic expression.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1517, __extension__ __PRETTY_FUNCTION__
))
1517 "Location Index must be 0 for a non-variadic expression.")(static_cast <bool> (ArgNo == 0 && "Location Index must be 0 for a non-variadic expression."
) ? void (0) : __assert_fail ("ArgNo == 0 && \"Location Index must be 0 for a non-variadic expression.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1517, __extension__ __PRETTY_FUNCTION__
))
;
1518 SmallVector<uint64_t, 8> NewOps(Ops.begin(), Ops.end());
1519 return DIExpression::prependOpcodes(Expr, NewOps, StackValue);
1520 }
1521
1522 SmallVector<uint64_t, 8> NewOps;
1523 for (auto Op : Expr->expr_ops()) {
1524 Op.appendToVector(NewOps);
1525 if (Op.getOp() == dwarf::DW_OP_LLVM_arg && Op.getArg(0) == ArgNo)
1526 NewOps.insert(NewOps.end(), Ops.begin(), Ops.end());
1527 }
1528
1529 return DIExpression::get(Expr->getContext(), NewOps);
1530}
1531
1532DIExpression *DIExpression::replaceArg(const DIExpression *Expr,
1533 uint64_t OldArg, uint64_t NewArg) {
1534 assert(Expr && "Can't replace args in this expression")(static_cast <bool> (Expr && "Can't replace args in this expression"
) ? void (0) : __assert_fail ("Expr && \"Can't replace args in this expression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1534, __extension__ __PRETTY_FUNCTION__
))
;
1535
1536 SmallVector<uint64_t, 8> NewOps;
1537
1538 for (auto Op : Expr->expr_ops()) {
1539 if (Op.getOp() != dwarf::DW_OP_LLVM_arg || Op.getArg(0) < OldArg) {
1540 Op.appendToVector(NewOps);
1541 continue;
1542 }
1543 NewOps.push_back(dwarf::DW_OP_LLVM_arg);
1544 uint64_t Arg = Op.getArg(0) == OldArg ? NewArg : Op.getArg(0);
1545 // OldArg has been deleted from the Op list, so decrement all indices
1546 // greater than it.
1547 if (Arg > OldArg)
1548 --Arg;
1549 NewOps.push_back(Arg);
1550 }
1551 return DIExpression::get(Expr->getContext(), NewOps);
1552}
1553
1554DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
1555 SmallVectorImpl<uint64_t> &Ops,
1556 bool StackValue, bool EntryValue) {
1557 assert(Expr && "Can't prepend ops to this expression")(static_cast <bool> (Expr && "Can't prepend ops to this expression"
) ? void (0) : __assert_fail ("Expr && \"Can't prepend ops to this expression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1557, __extension__ __PRETTY_FUNCTION__
))
;
1558
1559 if (EntryValue) {
1560 Ops.push_back(dwarf::DW_OP_LLVM_entry_value);
1561 // Use a block size of 1 for the target register operand. The
1562 // DWARF backend currently cannot emit entry values with a block
1563 // size > 1.
1564 Ops.push_back(1);
1565 }
1566
1567 // If there are no ops to prepend, do not even add the DW_OP_stack_value.
1568 if (Ops.empty())
1569 StackValue = false;
1570 for (auto Op : Expr->expr_ops()) {
1571 // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
1572 if (StackValue) {
1573 if (Op.getOp() == dwarf::DW_OP_stack_value)
1574 StackValue = false;
1575 else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
1576 Ops.push_back(dwarf::DW_OP_stack_value);
1577 StackValue = false;
1578 }
1579 }
1580 Op.appendToVector(Ops);
1581 }
1582 if (StackValue)
1583 Ops.push_back(dwarf::DW_OP_stack_value);
1584 return DIExpression::get(Expr->getContext(), Ops);
1585}
1586
1587DIExpression *DIExpression::append(const DIExpression *Expr,
1588 ArrayRef<uint64_t> Ops) {
1589 assert(Expr && !Ops.empty() && "Can't append ops to this expression")(static_cast <bool> (Expr && !Ops.empty() &&
"Can't append ops to this expression") ? void (0) : __assert_fail
("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1589, __extension__ __PRETTY_FUNCTION__
))
;
1590
1591 // Copy Expr's current op list.
1592 SmallVector<uint64_t, 16> NewOps;
1593 for (auto Op : Expr->expr_ops()) {
1594 // Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
1595 if (Op.getOp() == dwarf::DW_OP_stack_value ||
1596 Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
1597 NewOps.append(Ops.begin(), Ops.end());
1598
1599 // Ensure that the new opcodes are only appended once.
1600 Ops = std::nullopt;
1601 }
1602 Op.appendToVector(NewOps);
1603 }
1604
1605 NewOps.append(Ops.begin(), Ops.end());
1606 auto *result = DIExpression::get(Expr->getContext(), NewOps);
1607 assert(result->isValid() && "concatenated expression is not valid")(static_cast <bool> (result->isValid() && "concatenated expression is not valid"
) ? void (0) : __assert_fail ("result->isValid() && \"concatenated expression is not valid\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1607, __extension__ __PRETTY_FUNCTION__
))
;
1608 return result;
1609}
1610
1611DIExpression *DIExpression::appendToStack(const DIExpression *Expr,
1612 ArrayRef<uint64_t> Ops) {
1613 assert(Expr && !Ops.empty() && "Can't append ops to this expression")(static_cast <bool> (Expr && !Ops.empty() &&
"Can't append ops to this expression") ? void (0) : __assert_fail
("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1613, __extension__ __PRETTY_FUNCTION__
))
;
1614 assert(none_of(Ops,(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
1615 [](uint64_t Op) {(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
1616 return Op == dwarf::DW_OP_stack_value ||(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
1617 Op == dwarf::DW_OP_LLVM_fragment;(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
1618 }) &&(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
1619 "Can't append this op")(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? 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\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1619, __extension__ __PRETTY_FUNCTION__
))
;
1620
1621 // Append a DW_OP_deref after Expr's current op list if it's non-empty and
1622 // has no DW_OP_stack_value.
1623 //
1624 // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
1625 Optional<FragmentInfo> FI = Expr->getFragmentInfo();
1626 unsigned DropUntilStackValue = FI ? 3 : 0;
1627 ArrayRef<uint64_t> ExprOpsBeforeFragment =
1628 Expr->getElements().drop_back(DropUntilStackValue);
1629 bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
1630 (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
1631 bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
1632
1633 // Append a DW_OP_deref after Expr's current op list if needed, then append
1634 // the new ops, and finally ensure that a single DW_OP_stack_value is present.
1635 SmallVector<uint64_t, 16> NewOps;
1636 if (NeedsDeref)
1637 NewOps.push_back(dwarf::DW_OP_deref);
1638 NewOps.append(Ops.begin(), Ops.end());
1639 if (NeedsStackValue)
1640 NewOps.push_back(dwarf::DW_OP_stack_value);
1641 return DIExpression::append(Expr, NewOps);
1642}
1643
1644Optional<DIExpression *> DIExpression::createFragmentExpression(
1645 const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
1646 SmallVector<uint64_t, 8> Ops;
1647 // Track whether it's safe to split the value at the top of the DWARF stack,
1648 // assuming that it'll be used as an implicit location value.
1649 bool CanSplitValue = true;
1650 // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
1651 if (Expr) {
1
Assuming 'Expr' is null
1652 for (auto Op : Expr->expr_ops()) {
1653 switch (Op.getOp()) {
1654 default:
1655 break;
1656 case dwarf::DW_OP_shr:
1657 case dwarf::DW_OP_shra:
1658 case dwarf::DW_OP_shl:
1659 case dwarf::DW_OP_plus:
1660 case dwarf::DW_OP_plus_uconst:
1661 case dwarf::DW_OP_minus:
1662 // We can't safely split arithmetic or shift operations into multiple
1663 // fragments because we can't express carry-over between fragments.
1664 //
1665 // FIXME: We *could* preserve the lowest fragment of a constant offset
1666 // operation if the offset fits into SizeInBits.
1667 CanSplitValue = false;
1668 break;
1669 case dwarf::DW_OP_deref:
1670 case dwarf::DW_OP_deref_size:
1671 case dwarf::DW_OP_deref_type:
1672 case dwarf::DW_OP_xderef:
1673 case dwarf::DW_OP_xderef_size:
1674 case dwarf::DW_OP_xderef_type:
1675 // Preceeding arithmetic operations have been applied to compute an
1676 // address. It's okay to split the value loaded from that address.
1677 CanSplitValue = true;
1678 break;
1679 case dwarf::DW_OP_stack_value:
1680 // Bail if this expression computes a value that cannot be split.
1681 if (!CanSplitValue)
1682 return std::nullopt;
1683 break;
1684 case dwarf::DW_OP_LLVM_fragment: {
1685 // Make the new offset point into the existing fragment.
1686 uint64_t FragmentOffsetInBits = Op.getArg(0);
1687 uint64_t FragmentSizeInBits = Op.getArg(1);
1688 (void)FragmentSizeInBits;
1689 assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&(static_cast <bool> ((OffsetInBits + SizeInBits <= FragmentSizeInBits
) && "new fragment outside of original fragment") ? void
(0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1690, __extension__ __PRETTY_FUNCTION__
))
1690 "new fragment outside of original fragment")(static_cast <bool> ((OffsetInBits + SizeInBits <= FragmentSizeInBits
) && "new fragment outside of original fragment") ? void
(0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1690, __extension__ __PRETTY_FUNCTION__
))
;
1691 OffsetInBits += FragmentOffsetInBits;
1692 continue;
1693 }
1694 }
1695 Op.appendToVector(Ops);
1696 }
1697 }
1698 assert((!Expr->isImplicit() || CanSplitValue) && "Expr can't be split")(static_cast <bool> ((!Expr->isImplicit() || CanSplitValue
) && "Expr can't be split") ? void (0) : __assert_fail
("(!Expr->isImplicit() || CanSplitValue) && \"Expr can't be split\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1698, __extension__ __PRETTY_FUNCTION__
))
;
2
Taking false branch
3
Called C++ object pointer is null
1699 assert(Expr && "Unknown DIExpression")(static_cast <bool> (Expr && "Unknown DIExpression"
) ? void (0) : __assert_fail ("Expr && \"Unknown DIExpression\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1699, __extension__ __PRETTY_FUNCTION__
))
;
1700 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
1701 Ops.push_back(OffsetInBits);
1702 Ops.push_back(SizeInBits);
1703 return DIExpression::get(Expr->getContext(), Ops);
1704}
1705
1706std::pair<DIExpression *, const ConstantInt *>
1707DIExpression::constantFold(const ConstantInt *CI) {
1708 // Copy the APInt so we can modify it.
1709 APInt NewInt = CI->getValue();
1710 SmallVector<uint64_t, 8> Ops;
1711
1712 // Fold operators only at the beginning of the expression.
1713 bool First = true;
1714 bool Changed = false;
1715 for (auto Op : expr_ops()) {
1716 switch (Op.getOp()) {
1717 default:
1718 // We fold only the leading part of the expression; if we get to a part
1719 // that we're going to copy unchanged, and haven't done any folding,
1720 // then the entire expression is unchanged and we can return early.
1721 if (!Changed)
1722 return {this, CI};
1723 First = false;
1724 break;
1725 case dwarf::DW_OP_LLVM_convert:
1726 if (!First)
1727 break;
1728 Changed = true;
1729 if (Op.getArg(1) == dwarf::DW_ATE_signed)
1730 NewInt = NewInt.sextOrTrunc(Op.getArg(0));
1731 else {
1732 assert(Op.getArg(1) == dwarf::DW_ATE_unsigned && "Unexpected operand")(static_cast <bool> (Op.getArg(1) == dwarf::DW_ATE_unsigned
&& "Unexpected operand") ? void (0) : __assert_fail (
"Op.getArg(1) == dwarf::DW_ATE_unsigned && \"Unexpected operand\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1732, __extension__ __PRETTY_FUNCTION__
))
;
1733 NewInt = NewInt.zextOrTrunc(Op.getArg(0));
1734 }
1735 continue;
1736 }
1737 Op.appendToVector(Ops);
1738 }
1739 if (!Changed)
1740 return {this, CI};
1741 return {DIExpression::get(getContext(), Ops),
1742 ConstantInt::get(getContext(), NewInt)};
1743}
1744
1745uint64_t DIExpression::getNumLocationOperands() const {
1746 uint64_t Result = 0;
1747 for (auto ExprOp : expr_ops())
1748 if (ExprOp.getOp() == dwarf::DW_OP_LLVM_arg)
1749 Result = std::max(Result, ExprOp.getArg(0) + 1);
1750 assert(hasAllLocationOps(Result) &&(static_cast <bool> (hasAllLocationOps(Result) &&
"Expression is missing one or more location operands.") ? void
(0) : __assert_fail ("hasAllLocationOps(Result) && \"Expression is missing one or more location operands.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1751, __extension__ __PRETTY_FUNCTION__
))
1751 "Expression is missing one or more location operands.")(static_cast <bool> (hasAllLocationOps(Result) &&
"Expression is missing one or more location operands.") ? void
(0) : __assert_fail ("hasAllLocationOps(Result) && \"Expression is missing one or more location operands.\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1751, __extension__ __PRETTY_FUNCTION__
))
;
1752 return Result;
1753}
1754
1755llvm::Optional<DIExpression::SignedOrUnsignedConstant>
1756DIExpression::isConstant() const {
1757
1758 // Recognize signed and unsigned constants.
1759 // An signed constants can be represented as DW_OP_consts C DW_OP_stack_value
1760 // (DW_OP_LLVM_fragment of Len).
1761 // An unsigned constant can be represented as
1762 // DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment of Len).
1763
1764 if ((getNumElements() != 2 && getNumElements() != 3 &&
1765 getNumElements() != 6) ||
1766 (getElement(0) != dwarf::DW_OP_consts &&
1767 getElement(0) != dwarf::DW_OP_constu))
1768 return std::nullopt;
1769
1770 if (getNumElements() == 2 && getElement(0) == dwarf::DW_OP_consts)
1771 return SignedOrUnsignedConstant::SignedConstant;
1772
1773 if ((getNumElements() == 3 && getElement(2) != dwarf::DW_OP_stack_value) ||
1774 (getNumElements() == 6 && (getElement(2) != dwarf::DW_OP_stack_value ||
1775 getElement(3) != dwarf::DW_OP_LLVM_fragment)))
1776 return std::nullopt;
1777 return getElement(0) == dwarf::DW_OP_constu
1778 ? SignedOrUnsignedConstant::UnsignedConstant
1779 : SignedOrUnsignedConstant::SignedConstant;
1780}
1781
1782DIExpression::ExtOps DIExpression::getExtOps(unsigned FromSize, unsigned ToSize,
1783 bool Signed) {
1784 dwarf::TypeKind TK = Signed ? dwarf::DW_ATE_signed : dwarf::DW_ATE_unsigned;
1785 DIExpression::ExtOps Ops{{dwarf::DW_OP_LLVM_convert, FromSize, TK,
1786 dwarf::DW_OP_LLVM_convert, ToSize, TK}};
1787 return Ops;
1788}
1789
1790DIExpression *DIExpression::appendExt(const DIExpression *Expr,
1791 unsigned FromSize, unsigned ToSize,
1792 bool Signed) {
1793 return appendToStack(Expr, getExtOps(FromSize, ToSize, Signed));
1794}
1795
1796DIGlobalVariableExpression *
1797DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
1798 Metadata *Expression, StorageType Storage,
1799 bool ShouldCreate) {
1800 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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1800, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1801 Metadata *Ops[] = {Variable, Expression};
1802 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops)return storeImpl(new (std::size(Ops), Storage) DIGlobalVariableExpression
(Context, Storage, Ops), Storage, Context.pImpl->DIGlobalVariableExpressions
)
;
1803}
1804DIObjCProperty::DIObjCProperty(LLVMContext &C, StorageType Storage,
1805 unsigned Line, unsigned Attributes,
1806 ArrayRef<Metadata *> Ops)
1807 : DINode(C, DIObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property, Ops),
1808 Line(Line), Attributes(Attributes) {}
1809
1810DIObjCProperty *DIObjCProperty::getImpl(
1811 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
1812 MDString *GetterName, MDString *SetterName, unsigned Attributes,
1813 Metadata *Type, StorageType Storage, bool ShouldCreate) {
1814 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1814, __extension__ __PRETTY_FUNCTION__
))
;
1815 assert(isCanonical(GetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(GetterName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(GetterName) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1815, __extension__ __PRETTY_FUNCTION__
))
;
1816 assert(isCanonical(SetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SetterName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SetterName) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1816, __extension__ __PRETTY_FUNCTION__
))
;
1817 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 { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1818, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1818 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 { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1818, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1819 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
1820 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops)return storeImpl(new (std::size(Ops), Storage) DIObjCProperty
(Context, Storage, Line, Attributes, Ops), Storage, Context.pImpl
->DIObjCPropertys)
;
1821}
1822
1823DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
1824 Metadata *Scope, Metadata *Entity,
1825 Metadata *File, unsigned Line,
1826 MDString *Name, Metadata *Elements,
1827 StorageType Storage,
1828 bool ShouldCreate) {
1829 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1829, __extension__ __PRETTY_FUNCTION__
))
;
1830 DEFINE_GETIMPL_LOOKUP(DIImportedEntity,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name, Elements))) return N; if (
!ShouldCreate) return nullptr; } else { (static_cast <bool
> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1831, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
1831 (Tag, Scope, Entity, File, Line, Name, Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name, Elements))) return N; if (
!ShouldCreate) return nullptr; } else { (static_cast <bool
> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1831, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1832 Metadata *Ops[] = {Scope, Entity, Name, File, Elements};
1833 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops)return storeImpl(new (std::size(Ops), Storage) DIImportedEntity
(Context, Storage, Tag, Line, Ops), Storage, Context.pImpl->
DIImportedEntitys)
;
1834}
1835
1836DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
1837 MDString *Name, MDString *Value, StorageType Storage,
1838 bool ShouldCreate) {
1839 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1839, __extension__ __PRETTY_FUNCTION__
))
;
1840 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 { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1840, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1841 Metadata *Ops[] = {Name, Value};
1842 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops)return storeImpl(new (std::size(Ops), Storage) DIMacro(Context
, Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacros
)
;
1843}
1844
1845DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
1846 unsigned Line, Metadata *File,
1847 Metadata *Elements, StorageType Storage,
1848 bool ShouldCreate) {
1849 DEFINE_GETIMPL_LOOKUP(DIMacroFile, (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 { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1849, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1850 Metadata *Ops[] = {File, Elements};
1851 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops)return storeImpl(new (std::size(Ops), Storage) DIMacroFile(Context
, Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacroFiles
)
;
1852}
1853
1854DIArgList *DIArgList::getImpl(LLVMContext &Context,
1855 ArrayRef<ValueAsMetadata *> Args,
1856 StorageType Storage, bool ShouldCreate) {
1857 DEFINE_GETIMPL_LOOKUP(DIArgList, (Args))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIArgLists, DIArgListInfo::KeyTy(Args))) return N;
if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1857, __extension__ __PRETTY_FUNCTION__
)); } } while (false)
;
1858 DEFINE_GETIMPL_STORE_NO_OPS(DIArgList, (Args))return storeImpl(new (0u, Storage) DIArgList(Context, Storage
, Args), Storage, Context.pImpl->DIArgLists)
;
1859}
1860
1861void DIArgList::handleChangedOperand(void *Ref, Metadata *New) {
1862 ValueAsMetadata **OldVMPtr = static_cast<ValueAsMetadata **>(Ref);
1863 assert((!New || isa<ValueAsMetadata>(New)) &&(static_cast <bool> ((!New || isa<ValueAsMetadata>
(New)) && "DIArgList must be passed a ValueAsMetadata"
) ? void (0) : __assert_fail ("(!New || isa<ValueAsMetadata>(New)) && \"DIArgList must be passed a ValueAsMetadata\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1864, __extension__ __PRETTY_FUNCTION__
))
1864 "DIArgList must be passed a ValueAsMetadata")(static_cast <bool> ((!New || isa<ValueAsMetadata>
(New)) && "DIArgList must be passed a ValueAsMetadata"
) ? void (0) : __assert_fail ("(!New || isa<ValueAsMetadata>(New)) && \"DIArgList must be passed a ValueAsMetadata\""
, "llvm/lib/IR/DebugInfoMetadata.cpp", 1864, __extension__ __PRETTY_FUNCTION__
))
;
1865 untrack();
1866 bool Uniq = isUniqued();
1867 if (Uniq) {
1868 // We need to update the uniqueness once the Args are updated since they
1869 // form the key to the DIArgLists store.
1870 eraseFromStore();
1871 }
1872 ValueAsMetadata *NewVM = cast_or_null<ValueAsMetadata>(New);
1873 for (ValueAsMetadata *&VM : Args) {
1874 if (&VM == OldVMPtr) {
1875 if (NewVM)
1876 VM = NewVM;
1877 else
1878 VM = ValueAsMetadata::get(UndefValue::get(VM->getValue()->getType()));
1879 }
1880 }
1881 if (Uniq) {
1882 if (uniquify() != this)
1883 storeDistinctInContext();
1884 }
1885 track();
1886}
1887void DIArgList::track() {
1888 for (ValueAsMetadata *&VAM : Args)
1889 if (VAM)
1890 MetadataTracking::track(&VAM, *VAM, *this);
1891}
1892void DIArgList::untrack() {
1893 for (ValueAsMetadata *&VAM : Args)
1894 if (VAM)
1895 MetadataTracking::untrack(&VAM, *VAM);
1896}
1897void DIArgList::dropAllReferences() {
1898 untrack();
1899 Args.clear();
1900 MDNode::dropAllReferences();
1901}