File: | lib/IR/DebugInfoMetadata.cpp |
Warning: | line 792, column 28 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | ||||
23 | using namespace llvm; | |||
24 | ||||
25 | DILocation::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) &&(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2 ) && "Expected a scope and optional inlined-at") ? void (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 29, __extension__ __PRETTY_FUNCTION__)) | |||
29 | "Expected a scope and optional inlined-at")(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2 ) && "Expected a scope and optional inlined-at") ? void (0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 29, __extension__ __PRETTY_FUNCTION__)); | |||
30 | ||||
31 | // Set line and column. | |||
32 | assert(Column < (1u << 16) && "Expected 16-bit column")(static_cast <bool> (Column < (1u << 16) && "Expected 16-bit column") ? void (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 32, __extension__ __PRETTY_FUNCTION__)); | |||
33 | ||||
34 | SubclassData32 = Line; | |||
35 | SubclassData16 = Column; | |||
36 | } | |||
37 | ||||
38 | static 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 | ||||
44 | DILocation *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")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 59, __extension__ __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 | ||||
71 | const DILocation * | |||
72 | DILocation::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 | ||||
96 | DINode::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 | ||||
103 | StringRef 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 | ||||
113 | DINode::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 | ||||
150 | DIScopeRef 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)) &&(static_cast <bool> ((isa<DIFile>(this) || isa< DICompileUnit>(this)) && "Unhandled type of scope." ) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 167, __extension__ __PRETTY_FUNCTION__)) | |||
167 | "Unhandled type of scope.")(static_cast <bool> ((isa<DIFile>(this) || isa< DICompileUnit>(this)) && "Unhandled type of scope." ) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 167, __extension__ __PRETTY_FUNCTION__)); | |||
168 | return nullptr; | |||
169 | } | |||
170 | ||||
171 | StringRef 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) ||(static_cast <bool> ((isa<DILexicalBlockBase>(this ) || isa<DIFile>(this) || isa<DICompileUnit>(this )) && "Unhandled type of scope.") ? void (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 182, __extension__ __PRETTY_FUNCTION__)) | |||
181 | isa<DICompileUnit>(this)) &&(static_cast <bool> ((isa<DILexicalBlockBase>(this ) || isa<DIFile>(this) || isa<DICompileUnit>(this )) && "Unhandled type of scope.") ? void (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 182, __extension__ __PRETTY_FUNCTION__)) | |||
182 | "Unhandled type of scope.")(static_cast <bool> ((isa<DILexicalBlockBase>(this ) || isa<DIFile>(this) || isa<DICompileUnit>(this )) && "Unhandled type of scope.") ? void (0) : __assert_fail ("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 182, __extension__ __PRETTY_FUNCTION__)); | |||
183 | return ""; | |||
184 | } | |||
185 | ||||
186 | #ifndef NDEBUG | |||
187 | static bool isCanonical(const MDString *S) { | |||
188 | return !S || !S->getString().empty(); | |||
189 | } | |||
190 | #endif | |||
191 | ||||
192 | GenericDINode *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")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 205, __extension__ __PRETTY_FUNCTION__)); | |||
206 | } | |||
207 | ||||
208 | // Use a nullptr for empty headers. | |||
209 | assert(isCanonical(Header) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Header) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Header) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 209, __extension__ __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 | ||||
216 | void 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 { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 222, __extension__ __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 && \(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 232, __extension__ __PRETTY_FUNCTION__)) | |||
232 | "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 232, __extension__ __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 | ||||
250 | DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo, | |||
251 | StorageType Storage, bool ShouldCreate) { | |||
252 | auto *CountNode = ConstantAsMetadata::get( | |||
253 | ConstantInt::getSigned(Type::getInt64Ty(Context), Count)); | |||
254 | return getImpl(Context, CountNode, Lo, Storage, ShouldCreate); | |||
255 | } | |||
256 | ||||
257 | DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode, | |||
258 | int64_t Lo, StorageType Storage, | |||
259 | bool ShouldCreate) { | |||
260 | DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, Lo))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DISubranges, DISubrangeInfo::KeyTy(CountNode, Lo)) ) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 260, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
261 | Metadata *Ops[] = { CountNode }; | |||
262 | DEFINE_GETIMPL_STORE(DISubrange, (CountNode, Lo), Ops)return storeImpl(new (array_lengthof(Ops)) DISubrange(Context , Storage, CountNode, Lo, Ops), Storage, Context.pImpl->DISubranges ); | |||
263 | } | |||
264 | ||||
265 | DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value, | |||
266 | MDString *Name, StorageType Storage, | |||
267 | bool ShouldCreate) { | |||
268 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 268, __extension__ __PRETTY_FUNCTION__)); | |||
269 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 269, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
270 | Metadata *Ops[] = {Name}; | |||
271 | DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops)return storeImpl(new (array_lengthof(Ops)) DIEnumerator(Context , Storage, Value, Ops), Storage, Context.pImpl->DIEnumerators ); | |||
272 | } | |||
273 | ||||
274 | DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag, | |||
275 | MDString *Name, uint64_t SizeInBits, | |||
276 | uint32_t AlignInBits, unsigned Encoding, | |||
277 | StorageType Storage, bool ShouldCreate) { | |||
278 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 278, __extension__ __PRETTY_FUNCTION__)); | |||
279 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 280, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
280 | (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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 280, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
281 | Metadata *Ops[] = {nullptr, nullptr, Name}; | |||
282 | 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) | |||
283 | Ops)return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context , Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage , Context.pImpl->DIBasicTypes); | |||
284 | } | |||
285 | ||||
286 | DIDerivedType *DIDerivedType::getImpl( | |||
287 | LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, | |||
288 | unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, | |||
289 | uint32_t AlignInBits, uint64_t OffsetInBits, | |||
290 | Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData, | |||
291 | StorageType Storage, bool ShouldCreate) { | |||
292 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 292, __extension__ __PRETTY_FUNCTION__)); | |||
293 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 296, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
294 | (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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 296, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
295 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 296, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
296 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 296, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
297 | Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData}; | |||
298 | DEFINE_GETIMPL_STORE(return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context , Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace , Flags, Ops), Storage, Context.pImpl->DIDerivedTypes) | |||
299 | 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) | |||
300 | DWARFAddressSpace, Flags), Ops)return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context , Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace , Flags, Ops), Storage, Context.pImpl->DIDerivedTypes); | |||
301 | } | |||
302 | ||||
303 | DICompositeType *DICompositeType::getImpl( | |||
304 | LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, | |||
305 | unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, | |||
306 | uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags, | |||
307 | Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, | |||
308 | Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator, | |||
309 | StorageType Storage, bool ShouldCreate) { | |||
310 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 310, __extension__ __PRETTY_FUNCTION__)); | |||
311 | ||||
312 | // Keep this in sync with buildODRType. | |||
313 | DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name , File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits , Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier, Discriminator))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 316, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
314 | DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name , File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits , Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier, Discriminator))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 316, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
315 | AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name , File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits , Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier, Discriminator))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 316, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
316 | VTableHolder, TemplateParams, Identifier, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name , File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits , Flags, Elements, RuntimeLang, VTableHolder, TemplateParams, Identifier, Discriminator))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 316, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
317 | Metadata *Ops[] = {File, Scope, Name, BaseType, | |||
318 | Elements, VTableHolder, TemplateParams, Identifier, | |||
319 | Discriminator}; | |||
320 | 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) | |||
321 | AlignInBits, OffsetInBits, Flags),return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context , Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits , Flags, Ops), Storage, Context.pImpl->DICompositeTypes) | |||
322 | Ops)return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context , Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits , Flags, Ops), Storage, Context.pImpl->DICompositeTypes); | |||
323 | } | |||
324 | ||||
325 | DICompositeType *DICompositeType::buildODRType( | |||
326 | LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, | |||
327 | Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, | |||
328 | uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, | |||
329 | DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, | |||
330 | Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) { | |||
331 | assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() && "Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 331, __extension__ __PRETTY_FUNCTION__)); | |||
332 | if (!Context.isODRUniquingDebugTypes()) | |||
333 | return nullptr; | |||
334 | auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier]; | |||
335 | if (!CT) | |||
336 | return CT = DICompositeType::getDistinct( | |||
337 | Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, | |||
338 | AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, | |||
339 | VTableHolder, TemplateParams, &Identifier, Discriminator); | |||
340 | ||||
341 | // Only mutate CT if it's a forward declaration and the new operands aren't. | |||
342 | assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?")(static_cast <bool> (CT->getRawIdentifier() == & Identifier && "Wrong ODR identifier?") ? void (0) : __assert_fail ("CT->getRawIdentifier() == &Identifier && \"Wrong ODR identifier?\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 342, __extension__ __PRETTY_FUNCTION__)); | |||
343 | if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl)) | |||
344 | return CT; | |||
345 | ||||
346 | // Mutate CT in place. Keep this in sync with getImpl. | |||
347 | CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits, | |||
348 | Flags); | |||
349 | Metadata *Ops[] = {File, Scope, Name, BaseType, | |||
350 | Elements, VTableHolder, TemplateParams, &Identifier, | |||
351 | Discriminator}; | |||
352 | assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && "Mismatched number of operands" ) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 353, __extension__ __PRETTY_FUNCTION__)) | |||
353 | "Mismatched number of operands")(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && "Mismatched number of operands" ) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 353, __extension__ __PRETTY_FUNCTION__)); | |||
354 | for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I) | |||
355 | if (Ops[I] != CT->getOperand(I)) | |||
356 | CT->setOperand(I, Ops[I]); | |||
357 | return CT; | |||
358 | } | |||
359 | ||||
360 | DICompositeType *DICompositeType::getODRType( | |||
361 | LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, | |||
362 | Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, | |||
363 | uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, | |||
364 | DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, | |||
365 | Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) { | |||
366 | assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() && "Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 366, __extension__ __PRETTY_FUNCTION__)); | |||
367 | if (!Context.isODRUniquingDebugTypes()) | |||
368 | return nullptr; | |||
369 | auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier]; | |||
370 | if (!CT) | |||
371 | CT = DICompositeType::getDistinct( | |||
372 | Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits, | |||
373 | AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, | |||
374 | TemplateParams, &Identifier, Discriminator); | |||
375 | return CT; | |||
376 | } | |||
377 | ||||
378 | DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context, | |||
379 | MDString &Identifier) { | |||
380 | assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() && "Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 380, __extension__ __PRETTY_FUNCTION__)); | |||
381 | if (!Context.isODRUniquingDebugTypes()) | |||
382 | return nullptr; | |||
383 | return Context.pImpl->DITypeMap->lookup(&Identifier); | |||
384 | } | |||
385 | ||||
386 | DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags, | |||
387 | uint8_t CC, Metadata *TypeArray, | |||
388 | StorageType Storage, | |||
389 | bool ShouldCreate) { | |||
390 | DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DISubroutineTypes, DISubroutineTypeInfo::KeyTy(Flags , CC, TypeArray))) return N; if (!ShouldCreate) return nullptr ; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 390, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
391 | Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray}; | |||
392 | DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops)return storeImpl(new (array_lengthof(Ops)) DISubroutineType(Context , Storage, Flags, CC, Ops), Storage, Context.pImpl->DISubroutineTypes ); | |||
393 | } | |||
394 | ||||
395 | // FIXME: Implement this string-enum correspondence with a .def file and macros, | |||
396 | // so that the association is explicit rather than implied. | |||
397 | static const char *ChecksumKindName[DIFile::CSK_Last + 1] = { | |||
398 | "CSK_None", | |||
399 | "CSK_MD5", | |||
400 | "CSK_SHA1" | |||
401 | }; | |||
402 | ||||
403 | DIFile::ChecksumKind DIFile::getChecksumKind(StringRef CSKindStr) { | |||
404 | return StringSwitch<DIFile::ChecksumKind>(CSKindStr) | |||
405 | .Case("CSK_MD5", DIFile::CSK_MD5) | |||
406 | .Case("CSK_SHA1", DIFile::CSK_SHA1) | |||
407 | .Default(DIFile::CSK_None); | |||
408 | } | |||
409 | ||||
410 | StringRef DIFile::getChecksumKindAsString() const { | |||
411 | assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind")(static_cast <bool> (CSKind <= DIFile::CSK_Last && "Invalid checksum kind") ? void (0) : __assert_fail ("CSKind <= DIFile::CSK_Last && \"Invalid checksum kind\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 411, __extension__ __PRETTY_FUNCTION__)); | |||
412 | return ChecksumKindName[CSKind]; | |||
413 | } | |||
414 | ||||
415 | DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename, | |||
416 | MDString *Directory, DIFile::ChecksumKind CSKind, | |||
417 | MDString *Checksum, StorageType Storage, | |||
418 | bool ShouldCreate) { | |||
419 | assert(isCanonical(Filename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Filename) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Filename) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 419, __extension__ __PRETTY_FUNCTION__)); | |||
420 | assert(isCanonical(Directory) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Directory) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Directory) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 420, __extension__ __PRETTY_FUNCTION__)); | |||
421 | assert(isCanonical(Checksum) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Checksum) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Checksum) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 421, __extension__ __PRETTY_FUNCTION__)); | |||
422 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 422, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
423 | Metadata *Ops[] = {Filename, Directory, Checksum}; | |||
424 | DEFINE_GETIMPL_STORE(DIFile, (CSKind), Ops)return storeImpl(new (array_lengthof(Ops)) DIFile(Context, Storage , CSKind, Ops), Storage, Context.pImpl->DIFiles); | |||
425 | } | |||
426 | ||||
427 | DICompileUnit *DICompileUnit::getImpl( | |||
428 | LLVMContext &Context, unsigned SourceLanguage, Metadata *File, | |||
429 | MDString *Producer, bool IsOptimized, MDString *Flags, | |||
430 | unsigned RuntimeVersion, MDString *SplitDebugFilename, | |||
431 | unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes, | |||
432 | Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros, | |||
433 | uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling, | |||
434 | bool GnuPubnames, StorageType Storage, bool ShouldCreate) { | |||
435 | assert(Storage != Uniqued && "Cannot unique DICompileUnit")(static_cast <bool> (Storage != Uniqued && "Cannot unique DICompileUnit" ) ? void (0) : __assert_fail ("Storage != Uniqued && \"Cannot unique DICompileUnit\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 435, __extension__ __PRETTY_FUNCTION__)); | |||
436 | assert(isCanonical(Producer) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Producer) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Producer) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 436, __extension__ __PRETTY_FUNCTION__)); | |||
437 | assert(isCanonical(Flags) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Flags) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Flags) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 437, __extension__ __PRETTY_FUNCTION__)); | |||
438 | assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SplitDebugFilename) && "Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SplitDebugFilename) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 438, __extension__ __PRETTY_FUNCTION__)); | |||
439 | ||||
440 | Metadata *Ops[] = { | |||
441 | File, Producer, Flags, SplitDebugFilename, | |||
442 | EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities, | |||
443 | Macros}; | |||
444 | return storeImpl(new (array_lengthof(Ops)) DICompileUnit( | |||
445 | Context, Storage, SourceLanguage, IsOptimized, | |||
446 | RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining, | |||
447 | DebugInfoForProfiling, GnuPubnames, Ops), | |||
448 | Storage); | |||
449 | } | |||
450 | ||||
451 | Optional<DICompileUnit::DebugEmissionKind> | |||
452 | DICompileUnit::getEmissionKind(StringRef Str) { | |||
453 | return StringSwitch<Optional<DebugEmissionKind>>(Str) | |||
454 | .Case("NoDebug", NoDebug) | |||
455 | .Case("FullDebug", FullDebug) | |||
456 | .Case("LineTablesOnly", LineTablesOnly) | |||
457 | .Default(None); | |||
458 | } | |||
459 | ||||
460 | const char *DICompileUnit::EmissionKindString(DebugEmissionKind EK) { | |||
461 | switch (EK) { | |||
462 | case NoDebug: return "NoDebug"; | |||
463 | case FullDebug: return "FullDebug"; | |||
464 | case LineTablesOnly: return "LineTablesOnly"; | |||
465 | } | |||
466 | return nullptr; | |||
467 | } | |||
468 | ||||
469 | DISubprogram *DILocalScope::getSubprogram() const { | |||
470 | if (auto *Block = dyn_cast<DILexicalBlockBase>(this)) | |||
471 | return Block->getScope()->getSubprogram(); | |||
472 | return const_cast<DISubprogram *>(cast<DISubprogram>(this)); | |||
473 | } | |||
474 | ||||
475 | DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const { | |||
476 | if (auto *File = dyn_cast<DILexicalBlockFile>(this)) | |||
477 | return File->getScope()->getNonLexicalBlockFileScope(); | |||
478 | return const_cast<DILocalScope *>(this); | |||
479 | } | |||
480 | ||||
481 | DISubprogram *DISubprogram::getImpl( | |||
482 | LLVMContext &Context, Metadata *Scope, MDString *Name, | |||
483 | MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, | |||
484 | bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, | |||
485 | Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex, | |||
486 | int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit, | |||
487 | Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables, | |||
488 | Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) { | |||
489 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 489, __extension__ __PRETTY_FUNCTION__)); | |||
490 | assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) && "Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 490, __extension__ __PRETTY_FUNCTION__)); | |||
491 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 495, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
492 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 495, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
493 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 495, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
494 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 495, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
495 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 495, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
496 | SmallVector<Metadata *, 11> Ops = { | |||
497 | File, Scope, Name, LinkageName, Type, Unit, | |||
498 | Declaration, Variables, ContainingType, TemplateParams, ThrownTypes}; | |||
499 | if (!ThrownTypes) { | |||
500 | Ops.pop_back(); | |||
501 | if (!TemplateParams) { | |||
502 | Ops.pop_back(); | |||
503 | if (!ContainingType) | |||
504 | Ops.pop_back(); | |||
505 | } | |||
506 | } | |||
507 | 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) | |||
508 | (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) | |||
509 | 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) | |||
510 | IsOptimized),return storeImpl(new (Ops.size()) DISubprogram(Context, Storage , Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags , IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context .pImpl->DISubprograms) | |||
511 | 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); | |||
512 | } | |||
513 | ||||
514 | bool DISubprogram::describes(const Function *F) const { | |||
515 | assert(F && "Invalid function")(static_cast <bool> (F && "Invalid function") ? void (0) : __assert_fail ("F && \"Invalid function\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 515, __extension__ __PRETTY_FUNCTION__)); | |||
516 | if (F->getSubprogram() == this) | |||
517 | return true; | |||
518 | StringRef Name = getLinkageName(); | |||
519 | if (Name.empty()) | |||
520 | Name = getName(); | |||
521 | return F->getName() == Name; | |||
522 | } | |||
523 | ||||
524 | DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope, | |||
525 | Metadata *File, unsigned Line, | |||
526 | unsigned Column, StorageType Storage, | |||
527 | bool ShouldCreate) { | |||
528 | // Fixup column. | |||
529 | adjustColumn(Column); | |||
530 | ||||
531 | assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope") ? void (0) : __assert_fail ("Scope && \"Expected scope\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 531, __extension__ __PRETTY_FUNCTION__)); | |||
532 | DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DILexicalBlocks, DILexicalBlockInfo::KeyTy(Scope, File , Line, Column))) return N; if (!ShouldCreate) return nullptr ; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 532, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
533 | Metadata *Ops[] = {File, Scope}; | |||
534 | DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlock(Context , Storage, Line, Column, Ops), Storage, Context.pImpl->DILexicalBlocks ); | |||
535 | } | |||
536 | ||||
537 | DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context, | |||
538 | Metadata *Scope, Metadata *File, | |||
539 | unsigned Discriminator, | |||
540 | StorageType Storage, | |||
541 | bool ShouldCreate) { | |||
542 | assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope") ? void (0) : __assert_fail ("Scope && \"Expected scope\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 542, __extension__ __PRETTY_FUNCTION__)); | |||
543 | DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DILexicalBlockFiles, DILexicalBlockFileInfo::KeyTy (Scope, File, Discriminator))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 543, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
544 | Metadata *Ops[] = {File, Scope}; | |||
545 | DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlockFile (Context, Storage, Discriminator, Ops), Storage, Context.pImpl ->DILexicalBlockFiles); | |||
546 | } | |||
547 | ||||
548 | DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope, | |||
549 | MDString *Name, bool ExportSymbols, | |||
550 | StorageType Storage, bool ShouldCreate) { | |||
551 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 551, __extension__ __PRETTY_FUNCTION__)); | |||
552 | DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DINamespaces, DINamespaceInfo::KeyTy(Scope, Name, ExportSymbols ))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 552, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
553 | // The nullptr is for DIScope's File operand. This should be refactored. | |||
554 | Metadata *Ops[] = {nullptr, Scope, Name}; | |||
555 | DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops)return storeImpl(new (array_lengthof(Ops)) DINamespace(Context , Storage, ExportSymbols, Ops), Storage, Context.pImpl->DINamespaces ); | |||
556 | } | |||
557 | ||||
558 | DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope, | |||
559 | MDString *Name, MDString *ConfigurationMacros, | |||
560 | MDString *IncludePath, MDString *ISysRoot, | |||
561 | StorageType Storage, bool ShouldCreate) { | |||
562 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 562, __extension__ __PRETTY_FUNCTION__)); | |||
563 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 564, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
564 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 564, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
565 | Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot}; | |||
566 | DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops)return storeImpl(new (array_lengthof(Ops)) DIModule(Context, Storage , Ops), Storage, Context.pImpl->DIModules); | |||
567 | } | |||
568 | ||||
569 | DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context, | |||
570 | MDString *Name, | |||
571 | Metadata *Type, | |||
572 | StorageType Storage, | |||
573 | bool ShouldCreate) { | |||
574 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 574, __extension__ __PRETTY_FUNCTION__)); | |||
575 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 575, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
576 | Metadata *Ops[] = {Name, Type}; | |||
577 | DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateTypeParameter (Context, Storage, Ops), Storage, Context.pImpl->DITemplateTypeParameters ); | |||
578 | } | |||
579 | ||||
580 | DITemplateValueParameter *DITemplateValueParameter::getImpl( | |||
581 | LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type, | |||
582 | Metadata *Value, StorageType Storage, bool ShouldCreate) { | |||
583 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 583, __extension__ __PRETTY_FUNCTION__)); | |||
584 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 584, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
585 | Metadata *Ops[] = {Name, Type, Value}; | |||
586 | DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateValueParameter (Context, Storage, Tag, Ops), Storage, Context.pImpl->DITemplateValueParameters ); | |||
587 | } | |||
588 | ||||
589 | DIGlobalVariable * | |||
590 | DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, | |||
591 | MDString *LinkageName, Metadata *File, unsigned Line, | |||
592 | Metadata *Type, bool IsLocalToUnit, bool IsDefinition, | |||
593 | Metadata *StaticDataMemberDeclaration, | |||
594 | uint32_t AlignInBits, StorageType Storage, | |||
595 | bool ShouldCreate) { | |||
596 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 596, __extension__ __PRETTY_FUNCTION__)); | |||
597 | assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) && "Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 597, __extension__ __PRETTY_FUNCTION__)); | |||
598 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 601, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
599 | (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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 601, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
600 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 601, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
601 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 601, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
602 | Metadata *Ops[] = { | |||
603 | Scope, Name, File, Type, Name, LinkageName, StaticDataMemberDeclaration}; | |||
604 | DEFINE_GETIMPL_STORE(DIGlobalVariable,return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context , Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops ), Storage, Context.pImpl->DIGlobalVariables) | |||
605 | (Line, IsLocalToUnit, IsDefinition, AlignInBits),return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context , Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops ), Storage, Context.pImpl->DIGlobalVariables) | |||
606 | Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context , Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops ), Storage, Context.pImpl->DIGlobalVariables); | |||
607 | } | |||
608 | ||||
609 | DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, | |||
610 | MDString *Name, Metadata *File, | |||
611 | unsigned Line, Metadata *Type, | |||
612 | unsigned Arg, DIFlags Flags, | |||
613 | uint32_t AlignInBits, | |||
614 | StorageType Storage, | |||
615 | bool ShouldCreate) { | |||
616 | // 64K ought to be enough for any frontend. | |||
617 | assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits")(static_cast <bool> (Arg <= (65535) && "Expected argument number to fit in 16-bits" ) ? void (0) : __assert_fail ("Arg <= UINT16_MAX && \"Expected argument number to fit in 16-bits\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 617, __extension__ __PRETTY_FUNCTION__)); | |||
618 | ||||
619 | assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope") ? void (0) : __assert_fail ("Scope && \"Expected scope\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 619, __extension__ __PRETTY_FUNCTION__)); | |||
620 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 620, __extension__ __PRETTY_FUNCTION__)); | |||
621 | 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 { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 623, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
622 | (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 { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 623, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
623 | 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 { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 623, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
624 | Metadata *Ops[] = {Scope, Name, File, Type}; | |||
625 | 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); | |||
626 | } | |||
627 | ||||
628 | Optional<uint64_t> DIVariable::getSizeInBits() const { | |||
629 | // This is used by the Verifier so be mindful of broken types. | |||
630 | const Metadata *RawType = getRawType(); | |||
631 | while (RawType) { | |||
632 | // Try to get the size directly. | |||
633 | if (auto *T = dyn_cast<DIType>(RawType)) | |||
634 | if (uint64_t Size = T->getSizeInBits()) | |||
635 | return Size; | |||
636 | ||||
637 | if (auto *DT = dyn_cast<DIDerivedType>(RawType)) { | |||
638 | // Look at the base type. | |||
639 | RawType = DT->getRawBaseType(); | |||
640 | continue; | |||
641 | } | |||
642 | ||||
643 | // Missing type or size. | |||
644 | break; | |||
645 | } | |||
646 | ||||
647 | // Fail gracefully. | |||
648 | return None; | |||
649 | } | |||
650 | ||||
651 | DIExpression *DIExpression::getImpl(LLVMContext &Context, | |||
652 | ArrayRef<uint64_t> Elements, | |||
653 | StorageType Storage, bool ShouldCreate) { | |||
654 | DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIExpressions, DIExpressionInfo::KeyTy(Elements))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 654, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
655 | DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements))return storeImpl(new (0u) DIExpression(Context, Storage, Elements ), Storage, Context.pImpl->DIExpressions); | |||
656 | } | |||
657 | ||||
658 | unsigned DIExpression::ExprOperand::getSize() const { | |||
659 | switch (getOp()) { | |||
660 | case dwarf::DW_OP_LLVM_fragment: | |||
661 | return 3; | |||
662 | case dwarf::DW_OP_constu: | |||
663 | case dwarf::DW_OP_plus_uconst: | |||
664 | return 2; | |||
665 | default: | |||
666 | return 1; | |||
667 | } | |||
668 | } | |||
669 | ||||
670 | bool DIExpression::isValid() const { | |||
671 | for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) { | |||
672 | // Check that there's space for the operand. | |||
673 | if (I->get() + I->getSize() > E->get()) | |||
674 | return false; | |||
675 | ||||
676 | // Check that the operand is valid. | |||
677 | switch (I->getOp()) { | |||
678 | default: | |||
679 | return false; | |||
680 | case dwarf::DW_OP_LLVM_fragment: | |||
681 | // A fragment operator must appear at the end. | |||
682 | return I->get() + I->getSize() == E->get(); | |||
683 | case dwarf::DW_OP_stack_value: { | |||
684 | // Must be the last one or followed by a DW_OP_LLVM_fragment. | |||
685 | if (I->get() + I->getSize() == E->get()) | |||
686 | break; | |||
687 | auto J = I; | |||
688 | if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment) | |||
689 | return false; | |||
690 | break; | |||
691 | } | |||
692 | case dwarf::DW_OP_swap: { | |||
693 | // Must be more than one implicit element on the stack. | |||
694 | ||||
695 | // FIXME: A better way to implement this would be to add a local variable | |||
696 | // that keeps track of the stack depth and introduce something like a | |||
697 | // DW_LLVM_OP_implicit_location as a placeholder for the location this | |||
698 | // DIExpression is attached to, or else pass the number of implicit stack | |||
699 | // elements into isValid. | |||
700 | if (getNumElements() == 1) | |||
701 | return false; | |||
702 | break; | |||
703 | } | |||
704 | case dwarf::DW_OP_constu: | |||
705 | case dwarf::DW_OP_plus_uconst: | |||
706 | case dwarf::DW_OP_plus: | |||
707 | case dwarf::DW_OP_minus: | |||
708 | case dwarf::DW_OP_mul: | |||
709 | case dwarf::DW_OP_deref: | |||
710 | case dwarf::DW_OP_xderef: | |||
711 | break; | |||
712 | } | |||
713 | } | |||
714 | return true; | |||
715 | } | |||
716 | ||||
717 | Optional<DIExpression::FragmentInfo> | |||
718 | DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) { | |||
719 | for (auto I = Start; I != End; ++I) | |||
720 | if (I->getOp() == dwarf::DW_OP_LLVM_fragment) { | |||
721 | DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)}; | |||
722 | return Info; | |||
723 | } | |||
724 | return None; | |||
725 | } | |||
726 | ||||
727 | void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops, | |||
728 | int64_t Offset) { | |||
729 | if (Offset > 0) { | |||
730 | Ops.push_back(dwarf::DW_OP_plus_uconst); | |||
731 | Ops.push_back(Offset); | |||
732 | } else if (Offset < 0) { | |||
733 | Ops.push_back(dwarf::DW_OP_constu); | |||
734 | Ops.push_back(-Offset); | |||
735 | Ops.push_back(dwarf::DW_OP_minus); | |||
736 | } | |||
737 | } | |||
738 | ||||
739 | bool DIExpression::extractIfOffset(int64_t &Offset) const { | |||
740 | if (getNumElements() == 0) { | |||
741 | Offset = 0; | |||
742 | return true; | |||
743 | } | |||
744 | ||||
745 | if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) { | |||
746 | Offset = Elements[1]; | |||
747 | return true; | |||
748 | } | |||
749 | ||||
750 | if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) { | |||
751 | if (Elements[2] == dwarf::DW_OP_plus) { | |||
752 | Offset = Elements[1]; | |||
753 | return true; | |||
754 | } | |||
755 | if (Elements[2] == dwarf::DW_OP_minus) { | |||
756 | Offset = -Elements[1]; | |||
757 | return true; | |||
758 | } | |||
759 | } | |||
760 | ||||
761 | return false; | |||
762 | } | |||
763 | ||||
764 | DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore, | |||
765 | int64_t Offset, bool DerefAfter, | |||
766 | bool StackValue) { | |||
767 | SmallVector<uint64_t, 8> Ops; | |||
768 | if (DerefBefore) | |||
| ||||
769 | Ops.push_back(dwarf::DW_OP_deref); | |||
770 | ||||
771 | appendOffset(Ops, Offset); | |||
772 | if (DerefAfter) | |||
773 | Ops.push_back(dwarf::DW_OP_deref); | |||
774 | ||||
775 | if (Expr) | |||
776 | for (auto Op : Expr->expr_ops()) { | |||
777 | // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment. | |||
778 | if (StackValue) { | |||
779 | if (Op.getOp() == dwarf::DW_OP_stack_value) | |||
780 | StackValue = false; | |||
781 | else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) { | |||
782 | Ops.push_back(dwarf::DW_OP_stack_value); | |||
783 | StackValue = false; | |||
784 | } | |||
785 | } | |||
786 | Ops.push_back(Op.getOp()); | |||
787 | for (unsigned I = 0; I < Op.getNumArgs(); ++I) | |||
788 | Ops.push_back(Op.getArg(I)); | |||
789 | } | |||
790 | if (StackValue) | |||
791 | Ops.push_back(dwarf::DW_OP_stack_value); | |||
792 | return DIExpression::get(Expr->getContext(), Ops); | |||
| ||||
793 | } | |||
794 | ||||
795 | Optional<DIExpression *> DIExpression::createFragmentExpression( | |||
796 | const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) { | |||
797 | SmallVector<uint64_t, 8> Ops; | |||
798 | // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment. | |||
799 | if (Expr) { | |||
800 | for (auto Op : Expr->expr_ops()) { | |||
801 | switch (Op.getOp()) { | |||
802 | default: break; | |||
803 | case dwarf::DW_OP_plus: | |||
804 | case dwarf::DW_OP_minus: | |||
805 | // We can't safely split arithmetic into multiple fragments because we | |||
806 | // can't express carry-over between fragments. | |||
807 | // | |||
808 | // FIXME: We *could* preserve the lowest fragment of a constant offset | |||
809 | // operation if the offset fits into SizeInBits. | |||
810 | return None; | |||
811 | case dwarf::DW_OP_LLVM_fragment: { | |||
812 | // Make the new offset point into the existing fragment. | |||
813 | uint64_t FragmentOffsetInBits = Op.getArg(0); | |||
814 | // Op.getArg(0) is FragmentOffsetInBits. | |||
815 | // Op.getArg(1) is FragmentSizeInBits. | |||
816 | assert((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) &&(static_cast <bool> ((OffsetInBits + SizeInBits <= Op .getArg(0) + Op.getArg(1)) && "new fragment outside of original fragment" ) ? void (0) : __assert_fail ("(OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) && \"new fragment outside of original fragment\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 817, __extension__ __PRETTY_FUNCTION__)) | |||
817 | "new fragment outside of original fragment")(static_cast <bool> ((OffsetInBits + SizeInBits <= Op .getArg(0) + Op.getArg(1)) && "new fragment outside of original fragment" ) ? void (0) : __assert_fail ("(OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) && \"new fragment outside of original fragment\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 817, __extension__ __PRETTY_FUNCTION__)); | |||
818 | OffsetInBits += FragmentOffsetInBits; | |||
819 | continue; | |||
820 | } | |||
821 | } | |||
822 | Ops.push_back(Op.getOp()); | |||
823 | for (unsigned I = 0; I < Op.getNumArgs(); ++I) | |||
824 | Ops.push_back(Op.getArg(I)); | |||
825 | } | |||
826 | } | |||
827 | Ops.push_back(dwarf::DW_OP_LLVM_fragment); | |||
828 | Ops.push_back(OffsetInBits); | |||
829 | Ops.push_back(SizeInBits); | |||
830 | return DIExpression::get(Expr->getContext(), Ops); | |||
831 | } | |||
832 | ||||
833 | bool DIExpression::isConstant() const { | |||
834 | // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?. | |||
835 | if (getNumElements() != 3 && getNumElements() != 6) | |||
836 | return false; | |||
837 | if (getElement(0) != dwarf::DW_OP_constu || | |||
838 | getElement(2) != dwarf::DW_OP_stack_value) | |||
839 | return false; | |||
840 | if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment) | |||
841 | return false; | |||
842 | return true; | |||
843 | } | |||
844 | ||||
845 | DIGlobalVariableExpression * | |||
846 | DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable, | |||
847 | Metadata *Expression, StorageType Storage, | |||
848 | bool ShouldCreate) { | |||
849 | DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIGlobalVariableExpressions, DIGlobalVariableExpressionInfo ::KeyTy(Variable, Expression))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 849, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
850 | Metadata *Ops[] = {Variable, Expression}; | |||
851 | DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariableExpression (Context, Storage, Ops), Storage, Context.pImpl->DIGlobalVariableExpressions ); | |||
852 | } | |||
853 | ||||
854 | DIObjCProperty *DIObjCProperty::getImpl( | |||
855 | LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line, | |||
856 | MDString *GetterName, MDString *SetterName, unsigned Attributes, | |||
857 | Metadata *Type, StorageType Storage, bool ShouldCreate) { | |||
858 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 858, __extension__ __PRETTY_FUNCTION__)); | |||
859 | assert(isCanonical(GetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(GetterName) && "Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(GetterName) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 859, __extension__ __PRETTY_FUNCTION__)); | |||
860 | assert(isCanonical(SetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SetterName) && "Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SetterName) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 860, __extension__ __PRETTY_FUNCTION__)); | |||
861 | DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File , Line, GetterName, SetterName, Attributes, Type))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 862, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
862 | SetterName, Attributes, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File , Line, GetterName, SetterName, Attributes, Type))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast < bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 862, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
863 | Metadata *Ops[] = {Name, File, GetterName, SetterName, Type}; | |||
864 | DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops)return storeImpl(new (array_lengthof(Ops)) DIObjCProperty(Context , Storage, Line, Attributes, Ops), Storage, Context.pImpl-> DIObjCPropertys); | |||
865 | } | |||
866 | ||||
867 | DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag, | |||
868 | Metadata *Scope, Metadata *Entity, | |||
869 | Metadata *File, unsigned Line, | |||
870 | MDString *Name, StorageType Storage, | |||
871 | bool ShouldCreate) { | |||
872 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 872, __extension__ __PRETTY_FUNCTION__)); | |||
873 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 874, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
874 | (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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 874, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
875 | Metadata *Ops[] = {Scope, Entity, Name, File}; | |||
876 | DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIImportedEntity(Context , Storage, Tag, Line, Ops), Storage, Context.pImpl->DIImportedEntitys ); | |||
877 | } | |||
878 | ||||
879 | DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, | |||
880 | unsigned Line, MDString *Name, MDString *Value, | |||
881 | StorageType Storage, bool ShouldCreate) { | |||
882 | assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString" ) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 882, __extension__ __PRETTY_FUNCTION__)); | |||
883 | DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIMacros, DIMacroInfo::KeyTy(MIType, Line, Name, Value ))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created" ) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 883, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
884 | Metadata *Ops[] = { Name, Value }; | |||
885 | DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacro(Context, Storage , MIType, Line, Ops), Storage, Context.pImpl->DIMacros); | |||
886 | } | |||
887 | ||||
888 | DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType, | |||
889 | unsigned Line, Metadata *File, | |||
890 | Metadata *Elements, StorageType Storage, | |||
891 | bool ShouldCreate) { | |||
892 | 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 { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 893, __extension__ __PRETTY_FUNCTION__)); } } while (false) | |||
893 | (MIType, Line, File, Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context .pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line, File, Elements))) return N; if (!ShouldCreate) return nullptr ; } else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created") ? void (0 ) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\"" , "/build/llvm-toolchain-snapshot-7~svn324650/lib/IR/DebugInfoMetadata.cpp" , 893, __extension__ __PRETTY_FUNCTION__)); } } while (false); | |||
894 | Metadata *Ops[] = { File, Elements }; | |||
895 | DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacroFile(Context , Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacroFiles ); | |||
896 | } | |||
897 |