Bug Summary

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