Bug Summary

File:lib/IR/DebugInfoMetadata.cpp
Warning:line 791, column 28
Called C++ object pointer is null

Annotated Source Code

1//===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the debug info Metadata classes.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/IR/DebugInfoMetadata.h"
15#include "LLVMContextImpl.h"
16#include "MetadataImpl.h"
17#include "llvm/ADT/SmallPtrSet.h"
18#include "llvm/ADT/StringSwitch.h"
19#include "llvm/IR/DIBuilder.h"
20#include "llvm/IR/Function.h"
21#include "llvm/IR/Instructions.h"
22
23using namespace llvm;
24
25DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
26 unsigned Column, ArrayRef<Metadata *> MDs)
27 : MDNode(C, DILocationKind, Storage, MDs) {
28 assert((MDs.size() == 1 || MDs.size() == 2) &&(((MDs.size() == 1 || MDs.size() == 2) && "Expected a scope and optional inlined-at"
) ? static_cast<void> (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 29, __PRETTY_FUNCTION__))
29 "Expected a scope and optional inlined-at")(((MDs.size() == 1 || MDs.size() == 2) && "Expected a scope and optional inlined-at"
) ? static_cast<void> (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 29, __PRETTY_FUNCTION__))
;
30
31 // Set line and column.
32 assert(Column < (1u << 16) && "Expected 16-bit column")((Column < (1u << 16) && "Expected 16-bit column"
) ? static_cast<void> (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 32, __PRETTY_FUNCTION__))
;
33
34 SubclassData32 = Line;
35 SubclassData16 = Column;
36}
37
38static void adjustColumn(unsigned &Column) {
39 // Set to unknown on overflow. We only have 16 bits to play with here.
40 if (Column >= (1u << 16))
41 Column = 0;
42}
43
44DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
45 unsigned Column, Metadata *Scope,
46 Metadata *InlinedAt, StorageType Storage,
47 bool ShouldCreate) {
48 // Fixup column.
49 adjustColumn(Column);
50
51 if (Storage == Uniqued) {
52 if (auto *N =
53 getUniqued(Context.pImpl->DILocations,
54 DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
55 return N;
56 if (!ShouldCreate)
57 return nullptr;
58 } else {
59 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 59, __PRETTY_FUNCTION__))
;
60 }
61
62 SmallVector<Metadata *, 2> Ops;
63 Ops.push_back(Scope);
64 if (InlinedAt)
65 Ops.push_back(InlinedAt);
66 return storeImpl(new (Ops.size())
67 DILocation(Context, Storage, Line, Column, Ops),
68 Storage, Context.pImpl->DILocations);
69}
70
71const DILocation *
72DILocation::getMergedLocation(const DILocation *LocA, const DILocation *LocB,
73 const Instruction *ForInst) {
74 if (!LocA || !LocB)
75 return nullptr;
76
77 if (LocA == LocB || !LocA->canDiscriminate(*LocB))
78 return LocA;
79
80 if (!dyn_cast_or_null<CallInst>(ForInst))
81 return nullptr;
82
83 SmallPtrSet<DILocation *, 5> InlinedLocationsA;
84 for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
85 InlinedLocationsA.insert(L);
86 const DILocation *Result = LocB;
87 for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {
88 Result = L;
89 if (InlinedLocationsA.count(L))
90 break;
91 }
92 return DILocation::get(Result->getContext(), 0, 0, Result->getScope(),
93 Result->getInlinedAt());
94}
95
96DINode::DIFlags DINode::getFlag(StringRef Flag) {
97 return StringSwitch<DIFlags>(Flag)
98#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
99#include "llvm/IR/DebugInfoFlags.def"
100 .Default(DINode::FlagZero);
101}
102
103StringRef DINode::getFlagString(DIFlags Flag) {
104 switch (Flag) {
105#define HANDLE_DI_FLAG(ID, NAME) \
106 case Flag##NAME: \
107 return "DIFlag" #NAME;
108#include "llvm/IR/DebugInfoFlags.def"
109 }
110 return "";
111}
112
113DINode::DIFlags DINode::splitFlags(DIFlags Flags,
114 SmallVectorImpl<DIFlags> &SplitFlags) {
115 // Flags that are packed together need to be specially handled, so
116 // that, for example, we emit "DIFlagPublic" and not
117 // "DIFlagPrivate | DIFlagProtected".
118 if (DIFlags A = Flags & FlagAccessibility) {
119 if (A == FlagPrivate)
120 SplitFlags.push_back(FlagPrivate);
121 else if (A == FlagProtected)
122 SplitFlags.push_back(FlagProtected);
123 else
124 SplitFlags.push_back(FlagPublic);
125 Flags &= ~A;
126 }
127 if (DIFlags R = Flags & FlagPtrToMemberRep) {
128 if (R == FlagSingleInheritance)
129 SplitFlags.push_back(FlagSingleInheritance);
130 else if (R == FlagMultipleInheritance)
131 SplitFlags.push_back(FlagMultipleInheritance);
132 else
133 SplitFlags.push_back(FlagVirtualInheritance);
134 Flags &= ~R;
135 }
136 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
137 Flags &= ~FlagIndirectVirtualBase;
138 SplitFlags.push_back(FlagIndirectVirtualBase);
139 }
140
141#define HANDLE_DI_FLAG(ID, NAME) \
142 if (DIFlags Bit = Flags & Flag##NAME) { \
143 SplitFlags.push_back(Bit); \
144 Flags &= ~Bit; \
145 }
146#include "llvm/IR/DebugInfoFlags.def"
147 return Flags;
148}
149
150DIScopeRef DIScope::getScope() const {
151 if (auto *T = dyn_cast<DIType>(this))
152 return T->getScope();
153
154 if (auto *SP = dyn_cast<DISubprogram>(this))
155 return SP->getScope();
156
157 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
158 return LB->getScope();
159
160 if (auto *NS = dyn_cast<DINamespace>(this))
161 return NS->getScope();
162
163 if (auto *M = dyn_cast<DIModule>(this))
164 return M->getScope();
165
166 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&(((isa<DIFile>(this) || isa<DICompileUnit>(this))
&& "Unhandled type of scope.") ? static_cast<void
> (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 167, __PRETTY_FUNCTION__))
167 "Unhandled type of scope.")(((isa<DIFile>(this) || isa<DICompileUnit>(this))
&& "Unhandled type of scope.") ? static_cast<void
> (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 167, __PRETTY_FUNCTION__))
;
168 return nullptr;
169}
170
171StringRef DIScope::getName() const {
172 if (auto *T = dyn_cast<DIType>(this))
173 return T->getName();
174 if (auto *SP = dyn_cast<DISubprogram>(this))
175 return SP->getName();
176 if (auto *NS = dyn_cast<DINamespace>(this))
177 return NS->getName();
178 if (auto *M = dyn_cast<DIModule>(this))
179 return M->getName();
180 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 182, __PRETTY_FUNCTION__))
181 isa<DICompileUnit>(this)) &&(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 182, __PRETTY_FUNCTION__))
182 "Unhandled type of scope.")(((isa<DILexicalBlockBase>(this) || isa<DIFile>(this
) || isa<DICompileUnit>(this)) && "Unhandled type of scope."
) ? static_cast<void> (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 182, __PRETTY_FUNCTION__))
;
183 return "";
184}
185
186#ifndef NDEBUG
187static bool isCanonical(const MDString *S) {
188 return !S || !S->getString().empty();
189}
190#endif
191
192GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
193 MDString *Header,
194 ArrayRef<Metadata *> DwarfOps,
195 StorageType Storage, bool ShouldCreate) {
196 unsigned Hash = 0;
197 if (Storage == Uniqued) {
198 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
199 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
200 return N;
201 if (!ShouldCreate)
202 return nullptr;
203 Hash = Key.getHash();
204 } else {
205 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 205, __PRETTY_FUNCTION__))
;
206 }
207
208 // Use a nullptr for empty headers.
209 assert(isCanonical(Header) && "Expected canonical MDString")((isCanonical(Header) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Header) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 209, __PRETTY_FUNCTION__))
;
210 Metadata *PreOps[] = {Header};
211 return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
212 Context, Storage, Hash, Tag, PreOps, DwarfOps),
213 Storage, Context.pImpl->GenericDINodes);
214}
215
216void GenericDINode::recalculateHash() {
217 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
218}
219
220#define UNWRAP_ARGS_IMPL(...)... __VA_ARGS__
221#define UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS UNWRAP_ARGS_IMPL ARGS
222#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->CLASSs, CLASSInfo::KeyTy(UNWRAP_ARGS_IMPL ARGS))) return
N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 222, __PRETTY_FUNCTION__)); } } while (false)
\
223 do { \
224 if (Storage == Uniqued) { \
225 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
226 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS))) \
227 return N; \
228 if (!ShouldCreate) \
229 return nullptr; \
230 } else { \
231 assert(ShouldCreate && \((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 232, __PRETTY_FUNCTION__))
232 "Expected non-uniqued nodes to always be created")((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 232, __PRETTY_FUNCTION__))
; \
233 } \
234 } while (false)
235#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, UNWRAP_ARGS_IMPL ARGS, OPS), Storage, Context.pImpl->CLASSs
)
\
236 return storeImpl(new (array_lengthof(OPS)) \
237 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
238 Storage, Context.pImpl->CLASS##s)
239#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS), Storage, Context.pImpl->CLASSs)
\
240 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS), \
241 Storage, Context.pImpl->CLASS##s)
242#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, OPS), Storage, Context.pImpl->CLASSs)
\
243 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
244 Storage, Context.pImpl->CLASS##s)
245#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)return storeImpl(new (NUM_OPS) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS, OPS), Storage, Context.pImpl->CLASSs)
\
246 return storeImpl(new (NUM_OPS) \
247 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
248 Storage, Context.pImpl->CLASS##s)
249
250DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
251 StorageType Storage, bool ShouldCreate) {
252 DEFINE_GETIMPL_LOOKUP(DISubrange, (Count, Lo))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubranges, DISubrangeInfo::KeyTy(Count, Lo))) return
N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 252, __PRETTY_FUNCTION__)); } } while (false)
;
253 DEFINE_GETIMPL_STORE_NO_OPS(DISubrange, (Count, Lo))return storeImpl(new (0u) DISubrange(Context, Storage, Count,
Lo), Storage, Context.pImpl->DISubranges)
;
254}
255
256DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
257 MDString *Name, StorageType Storage,
258 bool ShouldCreate) {
259 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 259, __PRETTY_FUNCTION__))
;
260 DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIEnumerators, DIEnumeratorInfo::KeyTy(Value, Name
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 260, __PRETTY_FUNCTION__)); } } while (false)
;
261 Metadata *Ops[] = {Name};
262 DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops)return storeImpl(new (array_lengthof(Ops)) DIEnumerator(Context
, Storage, Value, Ops), Storage, Context.pImpl->DIEnumerators
)
;
263}
264
265DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
266 MDString *Name, uint64_t SizeInBits,
267 uint32_t AlignInBits, unsigned Encoding,
268 StorageType Storage, bool ShouldCreate) {
269 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 269, __PRETTY_FUNCTION__))
;
270 DEFINE_GETIMPL_LOOKUP(DIBasicType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 271, __PRETTY_FUNCTION__)); } } while (false)
271 (Tag, Name, SizeInBits, AlignInBits, Encoding))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 271, __PRETTY_FUNCTION__)); } } while (false)
;
272 Metadata *Ops[] = {nullptr, nullptr, Name};
273 DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIBasicTypes)
274 Ops)return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIBasicTypes)
;
275}
276
277DIDerivedType *DIDerivedType::getImpl(
278 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
279 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
280 uint32_t AlignInBits, uint64_t OffsetInBits,
281 Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
282 StorageType Storage, bool ShouldCreate) {
283 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 283, __PRETTY_FUNCTION__))
;
284 DEFINE_GETIMPL_LOOKUP(DIDerivedType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 287, __PRETTY_FUNCTION__)); } } while (false)
285 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 287, __PRETTY_FUNCTION__)); } } while (false)
286 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 287, __PRETTY_FUNCTION__)); } } while (false)
287 ExtraData))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 287, __PRETTY_FUNCTION__)); } } while (false)
;
288 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
289 DEFINE_GETIMPL_STORE(return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
290 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
291 DWARFAddressSpace, Flags), Ops)return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
;
292}
293
294DICompositeType *DICompositeType::getImpl(
295 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
296 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
297 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
298 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
299 Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
300 bool ShouldCreate) {
301 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 301, __PRETTY_FUNCTION__))
;
302
303 // Keep this in sync with buildODRType.
304 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier))) return N; if (!ShouldCreate) return nullptr; }
else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 307, __PRETTY_FUNCTION__)); } } while (false)
305 DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier))) return N; if (!ShouldCreate) return nullptr; }
else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 307, __PRETTY_FUNCTION__)); } } while (false)
306 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier))) return N; if (!ShouldCreate) return nullptr; }
else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 307, __PRETTY_FUNCTION__)); } } while (false)
307 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))) return N; if (!ShouldCreate) return nullptr; }
else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 307, __PRETTY_FUNCTION__)); } } while (false)
;
308 Metadata *Ops[] = {File, Scope, Name, BaseType,
309 Elements, VTableHolder, TemplateParams, Identifier};
310 DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
311 AlignInBits, OffsetInBits, Flags),return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
312 Ops)return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
;
313}
314
315DICompositeType *DICompositeType::buildODRType(
316 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
317 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
318 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
319 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
320 Metadata *VTableHolder, Metadata *TemplateParams) {
321 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 321, __PRETTY_FUNCTION__))
;
322 if (!Context.isODRUniquingDebugTypes())
323 return nullptr;
324 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
325 if (!CT)
326 return CT = DICompositeType::getDistinct(
327 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
328 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
329 VTableHolder, TemplateParams, &Identifier);
330
331 // Only mutate CT if it's a forward declaration and the new operands aren't.
332 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?")((CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?"
) ? static_cast<void> (0) : __assert_fail ("CT->getRawIdentifier() == &Identifier && \"Wrong ODR identifier?\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 332, __PRETTY_FUNCTION__))
;
333 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
334 return CT;
335
336 // Mutate CT in place. Keep this in sync with getImpl.
337 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
338 Flags);
339 Metadata *Ops[] = {File, Scope, Name, BaseType,
340 Elements, VTableHolder, TemplateParams, &Identifier};
341 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&(((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands
() && "Mismatched number of operands") ? static_cast<
void> (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 342, __PRETTY_FUNCTION__))
342 "Mismatched number of operands")(((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands
() && "Mismatched number of operands") ? static_cast<
void> (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 342, __PRETTY_FUNCTION__))
;
343 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
344 if (Ops[I] != CT->getOperand(I))
345 CT->setOperand(I, Ops[I]);
346 return CT;
347}
348
349DICompositeType *DICompositeType::getODRType(
350 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
351 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
352 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
353 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
354 Metadata *VTableHolder, Metadata *TemplateParams) {
355 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 355, __PRETTY_FUNCTION__))
;
356 if (!Context.isODRUniquingDebugTypes())
357 return nullptr;
358 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
359 if (!CT)
360 CT = DICompositeType::getDistinct(
361 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
362 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
363 TemplateParams, &Identifier);
364 return CT;
365}
366
367DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
368 MDString &Identifier) {
369 assert(!Identifier.getString().empty() && "Expected valid identifier")((!Identifier.getString().empty() && "Expected valid identifier"
) ? static_cast<void> (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 369, __PRETTY_FUNCTION__))
;
370 if (!Context.isODRUniquingDebugTypes())
371 return nullptr;
372 return Context.pImpl->DITypeMap->lookup(&Identifier);
373}
374
375DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
376 uint8_t CC, Metadata *TypeArray,
377 StorageType Storage,
378 bool ShouldCreate) {
379 DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubroutineTypes, DISubroutineTypeInfo::KeyTy(Flags
, CC, TypeArray))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 379, __PRETTY_FUNCTION__)); } } while (false)
;
380 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
381 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops)return storeImpl(new (array_lengthof(Ops)) DISubroutineType(Context
, Storage, Flags, CC, Ops), Storage, Context.pImpl->DISubroutineTypes
)
;
382}
383
384// FIXME: Implement this string-enum correspondence with a .def file and macros,
385// so that the association is explicit rather than implied.
386static const char *ChecksumKindName[DIFile::CSK_Last + 1] = {
387 "CSK_None",
388 "CSK_MD5",
389 "CSK_SHA1"
390};
391
392DIFile::ChecksumKind DIFile::getChecksumKind(StringRef CSKindStr) {
393 return StringSwitch<DIFile::ChecksumKind>(CSKindStr)
394 .Case("CSK_MD5", DIFile::CSK_MD5)
395 .Case("CSK_SHA1", DIFile::CSK_SHA1)
396 .Default(DIFile::CSK_None);
397}
398
399StringRef DIFile::getChecksumKindAsString() const {
400 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind")((CSKind <= DIFile::CSK_Last && "Invalid checksum kind"
) ? static_cast<void> (0) : __assert_fail ("CSKind <= DIFile::CSK_Last && \"Invalid checksum kind\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 400, __PRETTY_FUNCTION__))
;
401 return ChecksumKindName[CSKind];
402}
403
404DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
405 MDString *Directory, DIFile::ChecksumKind CSKind,
406 MDString *Checksum, StorageType Storage,
407 bool ShouldCreate) {
408 assert(isCanonical(Filename) && "Expected canonical MDString")((isCanonical(Filename) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Filename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 408, __PRETTY_FUNCTION__))
;
409 assert(isCanonical(Directory) && "Expected canonical MDString")((isCanonical(Directory) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Directory) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 409, __PRETTY_FUNCTION__))
;
410 assert(isCanonical(Checksum) && "Expected canonical MDString")((isCanonical(Checksum) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Checksum) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 410, __PRETTY_FUNCTION__))
;
411 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CSKind, Checksum))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIFiles, DIFileInfo::KeyTy(Filename, Directory, CSKind
, Checksum))) return N; if (!ShouldCreate) return nullptr; } else
{ ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 411, __PRETTY_FUNCTION__)); } } while (false)
;
412 Metadata *Ops[] = {Filename, Directory, Checksum};
413 DEFINE_GETIMPL_STORE(DIFile, (CSKind), Ops)return storeImpl(new (array_lengthof(Ops)) DIFile(Context, Storage
, CSKind, Ops), Storage, Context.pImpl->DIFiles)
;
414}
415
416DICompileUnit *DICompileUnit::getImpl(
417 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
418 MDString *Producer, bool IsOptimized, MDString *Flags,
419 unsigned RuntimeVersion, MDString *SplitDebugFilename,
420 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
421 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
422 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
423 bool GnuPubnames, StorageType Storage, bool ShouldCreate) {
424 assert(Storage != Uniqued && "Cannot unique DICompileUnit")((Storage != Uniqued && "Cannot unique DICompileUnit"
) ? static_cast<void> (0) : __assert_fail ("Storage != Uniqued && \"Cannot unique DICompileUnit\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 424, __PRETTY_FUNCTION__))
;
425 assert(isCanonical(Producer) && "Expected canonical MDString")((isCanonical(Producer) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Producer) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 425, __PRETTY_FUNCTION__))
;
426 assert(isCanonical(Flags) && "Expected canonical MDString")((isCanonical(Flags) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(Flags) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 426, __PRETTY_FUNCTION__))
;
427 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString")((isCanonical(SplitDebugFilename) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(SplitDebugFilename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 427, __PRETTY_FUNCTION__))
;
428
429 Metadata *Ops[] = {
430 File, Producer, Flags, SplitDebugFilename,
431 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
432 Macros};
433 return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
434 Context, Storage, SourceLanguage, IsOptimized,
435 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
436 DebugInfoForProfiling, GnuPubnames, Ops),
437 Storage);
438}
439
440Optional<DICompileUnit::DebugEmissionKind>
441DICompileUnit::getEmissionKind(StringRef Str) {
442 return StringSwitch<Optional<DebugEmissionKind>>(Str)
443 .Case("NoDebug", NoDebug)
444 .Case("FullDebug", FullDebug)
445 .Case("LineTablesOnly", LineTablesOnly)
446 .Default(None);
447}
448
449const char *DICompileUnit::EmissionKindString(DebugEmissionKind EK) {
450 switch (EK) {
451 case NoDebug: return "NoDebug";
452 case FullDebug: return "FullDebug";
453 case LineTablesOnly: return "LineTablesOnly";
454 }
455 return nullptr;
456}
457
458DISubprogram *DILocalScope::getSubprogram() const {
459 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
460 return Block->getScope()->getSubprogram();
461 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
462}
463
464DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
465 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
466 return File->getScope()->getNonLexicalBlockFileScope();
467 return const_cast<DILocalScope *>(this);
468}
469
470DISubprogram *DISubprogram::getImpl(
471 LLVMContext &Context, Metadata *Scope, MDString *Name,
472 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
473 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
474 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
475 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
476 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
477 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
478 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 478, __PRETTY_FUNCTION__))
;
479 assert(isCanonical(LinkageName) && "Expected canonical MDString")((isCanonical(LinkageName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 479, __PRETTY_FUNCTION__))
;
480 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 484, __PRETTY_FUNCTION__)); } } while (false)
481 DISubprogram, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 484, __PRETTY_FUNCTION__)); } } while (false)
482 IsDefinition, ScopeLine, ContainingType, Virtuality,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 484, __PRETTY_FUNCTION__)); } } while (false)
483 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 484, __PRETTY_FUNCTION__)); } } while (false)
484 TemplateParams, Declaration, Variables, ThrownTypes))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 484, __PRETTY_FUNCTION__)); } } while (false)
;
485 SmallVector<Metadata *, 11> Ops = {
486 File, Scope, Name, LinkageName, Type, Unit,
487 Declaration, Variables, ContainingType, TemplateParams, ThrownTypes};
488 if (!ThrownTypes) {
489 Ops.pop_back();
490 if (!TemplateParams) {
491 Ops.pop_back();
492 if (!ContainingType)
493 Ops.pop_back();
494 }
495 }
496 DEFINE_GETIMPL_STORE_N(DISubprogram,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
497 (Line, ScopeLine, Virtuality, VirtualIndex,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
498 ThisAdjustment, Flags, IsLocalToUnit, IsDefinition,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
499 IsOptimized),return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
500 Ops, Ops.size())return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
;
501}
502
503bool DISubprogram::describes(const Function *F) const {
504 assert(F && "Invalid function")((F && "Invalid function") ? static_cast<void> (
0) : __assert_fail ("F && \"Invalid function\"", "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 504, __PRETTY_FUNCTION__))
;
505 if (F->getSubprogram() == this)
506 return true;
507 StringRef Name = getLinkageName();
508 if (Name.empty())
509 Name = getName();
510 return F->getName() == Name;
511}
512
513DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
514 Metadata *File, unsigned Line,
515 unsigned Column, StorageType Storage,
516 bool ShouldCreate) {
517 // Fixup column.
518 adjustColumn(Column);
519
520 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 520, __PRETTY_FUNCTION__))
;
521 DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlocks, DILexicalBlockInfo::KeyTy(Scope, File
, Line, Column))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 521, __PRETTY_FUNCTION__)); } } while (false)
;
522 Metadata *Ops[] = {File, Scope};
523 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlock(Context
, Storage, Line, Column, Ops), Storage, Context.pImpl->DILexicalBlocks
)
;
524}
525
526DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
527 Metadata *Scope, Metadata *File,
528 unsigned Discriminator,
529 StorageType Storage,
530 bool ShouldCreate) {
531 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 531, __PRETTY_FUNCTION__))
;
532 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlockFiles, DILexicalBlockFileInfo::KeyTy
(Scope, File, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 532, __PRETTY_FUNCTION__)); } } while (false)
;
533 Metadata *Ops[] = {File, Scope};
534 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlockFile
(Context, Storage, Discriminator, Ops), Storage, Context.pImpl
->DILexicalBlockFiles)
;
535}
536
537DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
538 MDString *Name, bool ExportSymbols,
539 StorageType Storage, bool ShouldCreate) {
540 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 540, __PRETTY_FUNCTION__))
;
541 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DINamespaces, DINamespaceInfo::KeyTy(Scope, Name, ExportSymbols
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 541, __PRETTY_FUNCTION__)); } } while (false)
;
542 // The nullptr is for DIScope's File operand. This should be refactored.
543 Metadata *Ops[] = {nullptr, Scope, Name};
544 DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops)return storeImpl(new (array_lengthof(Ops)) DINamespace(Context
, Storage, ExportSymbols, Ops), Storage, Context.pImpl->DINamespaces
)
;
545}
546
547DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
548 MDString *Name, MDString *ConfigurationMacros,
549 MDString *IncludePath, MDString *ISysRoot,
550 StorageType Storage, bool ShouldCreate) {
551 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 551, __PRETTY_FUNCTION__))
;
552 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath, ISysRoot))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 553, __PRETTY_FUNCTION__)); } } while (false)
553 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath, ISysRoot))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 553, __PRETTY_FUNCTION__)); } } while (false)
;
554 Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
555 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops)return storeImpl(new (array_lengthof(Ops)) DIModule(Context, Storage
, Ops), Storage, Context.pImpl->DIModules)
;
556}
557
558DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
559 MDString *Name,
560 Metadata *Type,
561 StorageType Storage,
562 bool ShouldCreate) {
563 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 563, __PRETTY_FUNCTION__))
;
564 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateTypeParameters, DITemplateTypeParameterInfo
::KeyTy(Name, Type))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 564, __PRETTY_FUNCTION__)); } } while (false)
;
565 Metadata *Ops[] = {Name, Type};
566 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateTypeParameter
(Context, Storage, Ops), Storage, Context.pImpl->DITemplateTypeParameters
)
;
567}
568
569DITemplateValueParameter *DITemplateValueParameter::getImpl(
570 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
571 Metadata *Value, StorageType Storage, bool ShouldCreate) {
572 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 572, __PRETTY_FUNCTION__))
;
573 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateValueParameters, DITemplateValueParameterInfo
::KeyTy(Tag, Name, Type, Value))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 573, __PRETTY_FUNCTION__)); } } while (false)
;
574 Metadata *Ops[] = {Name, Type, Value};
575 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateValueParameter
(Context, Storage, Tag, Ops), Storage, Context.pImpl->DITemplateValueParameters
)
;
576}
577
578DIGlobalVariable *
579DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
580 MDString *LinkageName, Metadata *File, unsigned Line,
581 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
582 Metadata *StaticDataMemberDeclaration,
583 uint32_t AlignInBits, StorageType Storage,
584 bool ShouldCreate) {
585 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 585, __PRETTY_FUNCTION__))
;
586 assert(isCanonical(LinkageName) && "Expected canonical MDString")((isCanonical(LinkageName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 586, __PRETTY_FUNCTION__))
;
587 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 590, __PRETTY_FUNCTION__)); } } while (false)
588 (Scope, Name, LinkageName, File, Line, Type,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 590, __PRETTY_FUNCTION__)); } } while (false)
589 IsLocalToUnit, IsDefinition,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 590, __PRETTY_FUNCTION__)); } } while (false)
590 StaticDataMemberDeclaration, AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 590, __PRETTY_FUNCTION__)); } } while (false)
;
591 Metadata *Ops[] = {
592 Scope, Name, File, Type, Name, LinkageName, StaticDataMemberDeclaration};
593 DEFINE_GETIMPL_STORE(DIGlobalVariable,return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
594 (Line, IsLocalToUnit, IsDefinition, AlignInBits),return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
595 Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
;
596}
597
598DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
599 MDString *Name, Metadata *File,
600 unsigned Line, Metadata *Type,
601 unsigned Arg, DIFlags Flags,
602 uint32_t AlignInBits,
603 StorageType Storage,
604 bool ShouldCreate) {
605 // 64K ought to be enough for any frontend.
606 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits")((Arg <= (65535) && "Expected argument number to fit in 16-bits"
) ? static_cast<void> (0) : __assert_fail ("Arg <= UINT16_MAX && \"Expected argument number to fit in 16-bits\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 606, __PRETTY_FUNCTION__))
;
607
608 assert(Scope && "Expected scope")((Scope && "Expected scope") ? static_cast<void>
(0) : __assert_fail ("Scope && \"Expected scope\"", "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 608, __PRETTY_FUNCTION__))
;
609 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 609, __PRETTY_FUNCTION__))
;
610 DEFINE_GETIMPL_LOOKUP(DILocalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 612, __PRETTY_FUNCTION__)); } } while (false)
611 (Scope, Name, File, Line, Type, Arg, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 612, __PRETTY_FUNCTION__)); } } while (false)
612 AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 612, __PRETTY_FUNCTION__)); } } while (false)
;
613 Metadata *Ops[] = {Scope, Name, File, Type};
614 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops)return storeImpl(new (array_lengthof(Ops)) DILocalVariable(Context
, Storage, Line, Arg, Flags, AlignInBits, Ops), Storage, Context
.pImpl->DILocalVariables)
;
615}
616
617DIExpression *DIExpression::getImpl(LLVMContext &Context,
618 ArrayRef<uint64_t> Elements,
619 StorageType Storage, bool ShouldCreate) {
620 DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIExpressions, DIExpressionInfo::KeyTy(Elements)))
return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 620, __PRETTY_FUNCTION__)); } } while (false)
;
621 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements))return storeImpl(new (0u) DIExpression(Context, Storage, Elements
), Storage, Context.pImpl->DIExpressions)
;
622}
623
624unsigned DIExpression::ExprOperand::getSize() const {
625 switch (getOp()) {
626 case dwarf::DW_OP_LLVM_fragment:
627 return 3;
628 case dwarf::DW_OP_constu:
629 case dwarf::DW_OP_plus_uconst:
630 return 2;
631 default:
632 return 1;
633 }
634}
635
636bool DIExpression::isValid() const {
637 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
638 // Check that there's space for the operand.
639 if (I->get() + I->getSize() > E->get())
640 return false;
641
642 // Check that the operand is valid.
643 switch (I->getOp()) {
644 default:
645 return false;
646 case dwarf::DW_OP_LLVM_fragment:
647 // A fragment operator must appear at the end.
648 return I->get() + I->getSize() == E->get();
649 case dwarf::DW_OP_stack_value: {
650 // Must be the last one or followed by a DW_OP_LLVM_fragment.
651 if (I->get() + I->getSize() == E->get())
652 break;
653 auto J = I;
654 if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
655 return false;
656 break;
657 }
658 case dwarf::DW_OP_swap: {
659 // Must be more than one implicit element on the stack.
660
661 // FIXME: A better way to implement this would be to add a local variable
662 // that keeps track of the stack depth and introduce something like a
663 // DW_LLVM_OP_implicit_location as a placeholder for the location this
664 // DIExpression is attached to, or else pass the number of implicit stack
665 // elements into isValid.
666 if (getNumElements() == 1)
667 return false;
668 break;
669 }
670 case dwarf::DW_OP_constu:
671 case dwarf::DW_OP_plus_uconst:
672 case dwarf::DW_OP_plus:
673 case dwarf::DW_OP_minus:
674 case dwarf::DW_OP_mul:
675 case dwarf::DW_OP_deref:
676 case dwarf::DW_OP_xderef:
677 break;
678 }
679 }
680 return true;
681}
682
683Optional<DIExpression::FragmentInfo>
684DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
685 for (auto I = Start; I != End; ++I)
686 if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
687 DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
688 return Info;
689 }
690 return None;
691}
692
693void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
694 int64_t Offset) {
695 if (Offset > 0) {
696 Ops.push_back(dwarf::DW_OP_plus_uconst);
697 Ops.push_back(Offset);
698 } else if (Offset < 0) {
699 Ops.push_back(dwarf::DW_OP_constu);
700 Ops.push_back(-Offset);
701 Ops.push_back(dwarf::DW_OP_minus);
702 }
703}
704
705bool DIExpression::extractIfOffset(int64_t &Offset) const {
706 if (getNumElements() == 0) {
707 Offset = 0;
708 return true;
709 }
710
711 if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
712 Offset = Elements[1];
713 return true;
714 }
715
716 if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
717 if (Elements[2] == dwarf::DW_OP_plus) {
718 Offset = Elements[1];
719 return true;
720 }
721 if (Elements[2] == dwarf::DW_OP_minus) {
722 Offset = -Elements[1];
723 return true;
724 }
725 }
726
727 return false;
728}
729
730DIExpression *DIExpression::prepend(const DIExpression *Expr, bool Deref,
731 int64_t Offset, bool StackValue) {
732 SmallVector<uint64_t, 8> Ops;
733 appendOffset(Ops, Offset);
734 if (Deref)
735 Ops.push_back(dwarf::DW_OP_deref);
736 if (Expr)
737 for (auto Op : Expr->expr_ops()) {
738 // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
739 if (StackValue) {
740 if (Op.getOp() == dwarf::DW_OP_stack_value)
741 StackValue = false;
742 else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
743 Ops.push_back(dwarf::DW_OP_stack_value);
744 StackValue = false;
745 }
746 }
747 Ops.push_back(Op.getOp());
748 for (unsigned I = 0; I < Op.getNumArgs(); ++I)
749 Ops.push_back(Op.getArg(I));
750 }
751 if (StackValue)
752 Ops.push_back(dwarf::DW_OP_stack_value);
753 return DIExpression::get(Expr->getContext(), Ops);
754}
755
756Optional<DIExpression *> DIExpression::createFragmentExpression(
757 const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
758 SmallVector<uint64_t, 8> Ops;
759 // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
760 if (Expr) {
1
Assuming 'Expr' is null
2
Taking false branch
761 for (auto Op : Expr->expr_ops()) {
762 switch (Op.getOp()) {
763 default: break;
764 case dwarf::DW_OP_plus:
765 case dwarf::DW_OP_minus:
766 // We can't safely split arithmetic into multiple fragments because we
767 // can't express carry-over between fragments.
768 //
769 // FIXME: We *could* preserve the lowest fragment of a constant offset
770 // operation if the offset fits into SizeInBits.
771 return None;
772 case dwarf::DW_OP_LLVM_fragment: {
773 // Make the new offset point into the existing fragment.
774 uint64_t FragmentOffsetInBits = Op.getArg(0);
775 // Op.getArg(0) is FragmentOffsetInBits.
776 // Op.getArg(1) is FragmentSizeInBits.
777 assert((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) &&(((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1
)) && "new fragment outside of original fragment") ? static_cast
<void> (0) : __assert_fail ("(OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 778, __PRETTY_FUNCTION__))
778 "new fragment outside of original fragment")(((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1
)) && "new fragment outside of original fragment") ? static_cast
<void> (0) : __assert_fail ("(OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 778, __PRETTY_FUNCTION__))
;
779 OffsetInBits += FragmentOffsetInBits;
780 continue;
781 }
782 }
783 Ops.push_back(Op.getOp());
784 for (unsigned I = 0; I < Op.getNumArgs(); ++I)
785 Ops.push_back(Op.getArg(I));
786 }
787 }
788 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
789 Ops.push_back(OffsetInBits);
790 Ops.push_back(SizeInBits);
791 return DIExpression::get(Expr->getContext(), Ops);
3
Called C++ object pointer is null
792}
793
794bool DIExpression::isConstant() const {
795 // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
796 if (getNumElements() != 3 && getNumElements() != 6)
797 return false;
798 if (getElement(0) != dwarf::DW_OP_constu ||
799 getElement(2) != dwarf::DW_OP_stack_value)
800 return false;
801 if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment)
802 return false;
803 return true;
804}
805
806DIGlobalVariableExpression *
807DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
808 Metadata *Expression, StorageType Storage,
809 bool ShouldCreate) {
810 DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariableExpressions, DIGlobalVariableExpressionInfo
::KeyTy(Variable, Expression))) return N; if (!ShouldCreate) return
nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 810, __PRETTY_FUNCTION__)); } } while (false)
;
811 Metadata *Ops[] = {Variable, Expression};
812 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariableExpression
(Context, Storage, Ops), Storage, Context.pImpl->DIGlobalVariableExpressions
)
;
813}
814
815DIObjCProperty *DIObjCProperty::getImpl(
816 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
817 MDString *GetterName, MDString *SetterName, unsigned Attributes,
818 Metadata *Type, StorageType Storage, bool ShouldCreate) {
819 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 819, __PRETTY_FUNCTION__))
;
820 assert(isCanonical(GetterName) && "Expected canonical MDString")((isCanonical(GetterName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(GetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 820, __PRETTY_FUNCTION__))
;
821 assert(isCanonical(SetterName) && "Expected canonical MDString")((isCanonical(SetterName) && "Expected canonical MDString"
) ? static_cast<void> (0) : __assert_fail ("isCanonical(SetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 821, __PRETTY_FUNCTION__))
;
822 DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 823, __PRETTY_FUNCTION__)); } } while (false)
823 SetterName, Attributes, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { ((ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? static_cast
<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 823, __PRETTY_FUNCTION__)); } } while (false)
;
824 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
825 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops)return storeImpl(new (array_lengthof(Ops)) DIObjCProperty(Context
, Storage, Line, Attributes, Ops), Storage, Context.pImpl->
DIObjCPropertys)
;
826}
827
828DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
829 Metadata *Scope, Metadata *Entity,
830 Metadata *File, unsigned Line,
831 MDString *Name, StorageType Storage,
832 bool ShouldCreate) {
833 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 833, __PRETTY_FUNCTION__))
;
834 DEFINE_GETIMPL_LOOKUP(DIImportedEntity,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 835, __PRETTY_FUNCTION__)); } } while (false)
835 (Tag, Scope, Entity, File, Line, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 835, __PRETTY_FUNCTION__)); } } while (false)
;
836 Metadata *Ops[] = {Scope, Entity, Name, File};
837 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIImportedEntity(Context
, Storage, Tag, Line, Ops), Storage, Context.pImpl->DIImportedEntitys
)
;
838}
839
840DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
841 unsigned Line, MDString *Name, MDString *Value,
842 StorageType Storage, bool ShouldCreate) {
843 assert(isCanonical(Name) && "Expected canonical MDString")((isCanonical(Name) && "Expected canonical MDString")
? static_cast<void> (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 843, __PRETTY_FUNCTION__))
;
844 DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacros, DIMacroInfo::KeyTy(MIType, Line, Name, Value
))) return N; if (!ShouldCreate) return nullptr; } else { ((ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 844, __PRETTY_FUNCTION__)); } } while (false)
;
845 Metadata *Ops[] = { Name, Value };
846 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacro(Context, Storage
, MIType, Line, Ops), Storage, Context.pImpl->DIMacros)
;
847}
848
849DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
850 unsigned Line, Metadata *File,
851 Metadata *Elements, StorageType Storage,
852 bool ShouldCreate) {
853 DEFINE_GETIMPL_LOOKUP(DIMacroFile,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 854, __PRETTY_FUNCTION__)); } } while (false)
854 (MIType, Line, File, Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { ((ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? static_cast<void> (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-6.0~svn318211/lib/IR/DebugInfoMetadata.cpp"
, 854, __PRETTY_FUNCTION__)); } } while (false)
;
855 Metadata *Ops[] = { File, Elements };
856 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacroFile(Context
, Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacroFiles
)
;
857}
858