blob: 19f02cd38d60565222312124d1bed5c7fcf2440c [file] [log] [blame]
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +00001//===- 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"
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000017#include "llvm/ADT/StringSwitch.h"
Duncan P. N. Exon Smithdf523492015-02-18 20:32:57 +000018#include "llvm/IR/Function.h"
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000019
20using namespace llvm;
21
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000022DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000023 unsigned Column, ArrayRef<Metadata *> MDs)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000024 : MDNode(C, DILocationKind, Storage, MDs) {
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000025 assert((MDs.size() == 1 || MDs.size() == 2) &&
26 "Expected a scope and optional inlined-at");
27
28 // Set line and column.
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000029 assert(Column < (1u << 16) && "Expected 16-bit column");
30
31 SubclassData32 = Line;
32 SubclassData16 = Column;
33}
34
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000035static void adjustColumn(unsigned &Column) {
36 // Set to unknown on overflow. We only have 16 bits to play with here.
37 if (Column >= (1u << 16))
38 Column = 0;
39}
40
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000041DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000042 unsigned Column, Metadata *Scope,
43 Metadata *InlinedAt, StorageType Storage,
44 bool ShouldCreate) {
Duncan P. N. Exon Smithaf677eb2015-02-06 22:50:13 +000045 // Fixup column.
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000046 adjustColumn(Column);
47
48 if (Storage == Uniqued) {
49 if (auto *N =
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000050 getUniqued(Context.pImpl->DILocations,
51 DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000052 return N;
53 if (!ShouldCreate)
54 return nullptr;
55 } else {
56 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
57 }
58
59 SmallVector<Metadata *, 2> Ops;
60 Ops.push_back(Scope);
61 if (InlinedAt)
62 Ops.push_back(InlinedAt);
63 return storeImpl(new (Ops.size())
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000064 DILocation(Context, Storage, Line, Column, Ops),
65 Storage, Context.pImpl->DILocations);
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +000066}
67
Leny Kholodov5fcc4182016-09-06 10:46:28 +000068DINode::DIFlags DINode::getFlag(StringRef Flag) {
69 return StringSwitch<DIFlags>(Flag)
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000070#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
71#include "llvm/IR/DebugInfoFlags.def"
Leny Kholodov5fcc4182016-09-06 10:46:28 +000072 .Default(DINode::FlagZero);
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000073}
74
Mehdi Aminif42ec792016-10-01 05:57:50 +000075StringRef DINode::getFlagString(DIFlags Flag) {
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000076 switch (Flag) {
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000077#define HANDLE_DI_FLAG(ID, NAME) \
78 case Flag##NAME: \
79 return "DIFlag" #NAME;
80#include "llvm/IR/DebugInfoFlags.def"
81 }
Leny Kholodov5fcc4182016-09-06 10:46:28 +000082 return "";
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000083}
84
Leny Kholodov5fcc4182016-09-06 10:46:28 +000085DINode::DIFlags DINode::splitFlags(DIFlags Flags,
Leny Kholodov40c62352016-09-06 17:03:02 +000086 SmallVectorImpl<DIFlags> &SplitFlags) {
Reid Kleckner604105b2016-06-17 21:31:33 +000087 // Accessibility and member pointer flags need to be specially handled, since
88 // they're packed together.
Leny Kholodov5fcc4182016-09-06 10:46:28 +000089 if (DIFlags A = Flags & FlagAccessibility) {
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000090 if (A == FlagPrivate)
91 SplitFlags.push_back(FlagPrivate);
92 else if (A == FlagProtected)
93 SplitFlags.push_back(FlagProtected);
94 else
95 SplitFlags.push_back(FlagPublic);
96 Flags &= ~A;
97 }
Leny Kholodov5fcc4182016-09-06 10:46:28 +000098 if (DIFlags R = Flags & FlagPtrToMemberRep) {
Reid Kleckner604105b2016-06-17 21:31:33 +000099 if (R == FlagSingleInheritance)
100 SplitFlags.push_back(FlagSingleInheritance);
101 else if (R == FlagMultipleInheritance)
102 SplitFlags.push_back(FlagMultipleInheritance);
103 else
104 SplitFlags.push_back(FlagVirtualInheritance);
105 Flags &= ~R;
106 }
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000107
108#define HANDLE_DI_FLAG(ID, NAME) \
Leny Kholodov5fcc4182016-09-06 10:46:28 +0000109 if (DIFlags Bit = Flags & Flag##NAME) { \
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000110 SplitFlags.push_back(Bit); \
111 Flags &= ~Bit; \
112 }
113#include "llvm/IR/DebugInfoFlags.def"
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000114 return Flags;
115}
116
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000117DIScopeRef DIScope::getScope() const {
118 if (auto *T = dyn_cast<DIType>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000119 return T->getScope();
120
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000121 if (auto *SP = dyn_cast<DISubprogram>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000122 return SP->getScope();
123
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000124 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000125 return LB->getScope();
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000126
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000127 if (auto *NS = dyn_cast<DINamespace>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000128 return NS->getScope();
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000129
Adrian Prantlab1243f2015-06-29 23:03:47 +0000130 if (auto *M = dyn_cast<DIModule>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000131 return M->getScope();
Adrian Prantlab1243f2015-06-29 23:03:47 +0000132
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000133 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000134 "Unhandled type of scope.");
135 return nullptr;
136}
137
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000138StringRef DIScope::getName() const {
139 if (auto *T = dyn_cast<DIType>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000140 return T->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000141 if (auto *SP = dyn_cast<DISubprogram>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000142 return SP->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000143 if (auto *NS = dyn_cast<DINamespace>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000144 return NS->getName();
Adrian Prantlab1243f2015-06-29 23:03:47 +0000145 if (auto *M = dyn_cast<DIModule>(this))
146 return M->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000147 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
148 isa<DICompileUnit>(this)) &&
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000149 "Unhandled type of scope.");
150 return "";
151}
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000152
Duncan P. N. Exon Smithc7e08132015-02-02 20:20:56 +0000153#ifndef NDEBUG
Duncan P. N. Exon Smith9146fc82015-02-02 20:01:03 +0000154static bool isCanonical(const MDString *S) {
155 return !S || !S->getString().empty();
Duncan P. N. Exon Smith442ec022015-02-02 19:54:05 +0000156}
Duncan P. N. Exon Smithc7e08132015-02-02 20:20:56 +0000157#endif
Duncan P. N. Exon Smith442ec022015-02-02 19:54:05 +0000158
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000159GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
160 MDString *Header,
161 ArrayRef<Metadata *> DwarfOps,
162 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000163 unsigned Hash = 0;
164 if (Storage == Uniqued) {
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000165 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000166 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000167 return N;
168 if (!ShouldCreate)
169 return nullptr;
170 Hash = Key.getHash();
171 } else {
172 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
173 }
174
175 // Use a nullptr for empty headers.
Duncan P. N. Exon Smith9146fc82015-02-02 20:01:03 +0000176 assert(isCanonical(Header) && "Expected canonical MDString");
177 Metadata *PreOps[] = {Header};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000178 return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000179 Context, Storage, Hash, Tag, PreOps, DwarfOps),
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000180 Storage, Context.pImpl->GenericDINodes);
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000181}
182
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000183void GenericDINode::recalculateHash() {
184 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000185}
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000186
187#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
188#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
189#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
190 do { \
191 if (Storage == Uniqued) { \
192 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
193 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
194 return N; \
195 if (!ShouldCreate) \
196 return nullptr; \
197 } else { \
198 assert(ShouldCreate && \
199 "Expected non-uniqued nodes to always be created"); \
200 } \
201 } while (false)
202#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
David Blaikie6662d6a2016-04-13 17:42:56 +0000203 return storeImpl(new (array_lengthof(OPS)) \
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000204 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
205 Storage, Context.pImpl->CLASS##s)
206#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
207 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
208 Storage, Context.pImpl->CLASS##s)
Duncan P. N. Exon Smithbd33d372015-02-10 01:59:57 +0000209#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
David Blaikie6662d6a2016-04-13 17:42:56 +0000210 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
Duncan P. N. Exon Smithbd33d372015-02-10 01:59:57 +0000211 Storage, Context.pImpl->CLASS##s)
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000212
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000213DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000214 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000215 DEFINE_GETIMPL_LOOKUP(DISubrange, (Count, Lo));
216 DEFINE_GETIMPL_STORE_NO_OPS(DISubrange, (Count, Lo));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000217}
218
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000219DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000220 MDString *Name, StorageType Storage,
221 bool ShouldCreate) {
222 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000223 DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, Name));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000224 Metadata *Ops[] = {Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000225 DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000226}
227
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000228DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000229 MDString *Name, uint64_t SizeInBits,
Victor Leschuk197aa312016-10-18 14:31:22 +0000230 uint32_t AlignInBits, unsigned Encoding,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000231 StorageType Storage, bool ShouldCreate) {
232 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000233 DEFINE_GETIMPL_LOOKUP(DIBasicType,
234 (Tag, Name, SizeInBits, AlignInBits, Encoding));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000235 Metadata *Ops[] = {nullptr, nullptr, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000236 DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000237 Ops);
238}
239
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000240DIDerivedType *DIDerivedType::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000241 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000242 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
Victor Leschuk197aa312016-10-18 14:31:22 +0000243 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000244 Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
245 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000246 DEFINE_GETIMPL_LOOKUP(DIDerivedType,
247 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
248 AlignInBits, OffsetInBits, Flags, ExtraData));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000249 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
250 DEFINE_GETIMPL_STORE(
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000251 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000252 Ops);
253}
254
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000255DICompositeType *DICompositeType::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000256 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000257 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
Victor Leschuk197aa312016-10-18 14:31:22 +0000258 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000259 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
260 Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
261 bool ShouldCreate) {
262 assert(isCanonical(Name) && "Expected canonical MDString");
Duncan P. N. Exon Smith5ab2be02016-04-17 03:58:21 +0000263
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000264 // Keep this in sync with buildODRType.
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000265 DEFINE_GETIMPL_LOOKUP(
266 DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
267 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
268 VTableHolder, TemplateParams, Identifier));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000269 Metadata *Ops[] = {File, Scope, Name, BaseType,
270 Elements, VTableHolder, TemplateParams, Identifier};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000271 DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000272 AlignInBits, OffsetInBits, Flags),
273 Ops);
274}
275
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000276DICompositeType *DICompositeType::buildODRType(
277 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
278 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
Victor Leschuk197aa312016-10-18 14:31:22 +0000279 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
Leny Kholodov5fcc4182016-09-06 10:46:28 +0000280 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000281 Metadata *VTableHolder, Metadata *TemplateParams) {
282 assert(!Identifier.getString().empty() && "Expected valid identifier");
283 if (!Context.isODRUniquingDebugTypes())
284 return nullptr;
285 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
286 if (!CT)
287 return CT = DICompositeType::getDistinct(
288 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
289 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
290 VTableHolder, TemplateParams, &Identifier);
291
292 // Only mutate CT if it's a forward declaration and the new operands aren't.
293 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?");
294 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
295 return CT;
296
297 // Mutate CT in place. Keep this in sync with getImpl.
298 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
299 Flags);
300 Metadata *Ops[] = {File, Scope, Name, BaseType,
301 Elements, VTableHolder, TemplateParams, &Identifier};
Simon Pilgrim1ec7dc72016-05-02 16:45:02 +0000302 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000303 "Mismatched number of operands");
304 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
305 if (Ops[I] != CT->getOperand(I))
306 CT->setOperand(I, Ops[I]);
307 return CT;
308}
309
Duncan P. N. Exon Smith0b0271e2016-04-19 14:55:09 +0000310DICompositeType *DICompositeType::getODRType(
311 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
312 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
Victor Leschuk197aa312016-10-18 14:31:22 +0000313 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
Leny Kholodov5fcc4182016-09-06 10:46:28 +0000314 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Duncan P. N. Exon Smith0b0271e2016-04-19 14:55:09 +0000315 Metadata *VTableHolder, Metadata *TemplateParams) {
316 assert(!Identifier.getString().empty() && "Expected valid identifier");
317 if (!Context.isODRUniquingDebugTypes())
318 return nullptr;
319 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
320 if (!CT)
321 CT = DICompositeType::getDistinct(
322 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
323 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
324 TemplateParams, &Identifier);
325 return CT;
326}
327
328DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
329 MDString &Identifier) {
330 assert(!Identifier.getString().empty() && "Expected valid identifier");
331 if (!Context.isODRUniquingDebugTypes())
332 return nullptr;
333 return Context.pImpl->DITypeMap->lookup(&Identifier);
334}
335
Leny Kholodov40c62352016-09-06 17:03:02 +0000336DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
337 uint8_t CC, Metadata *TypeArray,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000338 StorageType Storage,
339 bool ShouldCreate) {
Reid Klecknerde3d8b52016-06-08 20:34:29 +0000340 DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray));
Duncan P. N. Exon Smithb9e045a2015-07-24 20:56:36 +0000341 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
Reid Klecknerde3d8b52016-06-08 20:34:29 +0000342 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000343}
344
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000345DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000346 MDString *Directory, StorageType Storage,
347 bool ShouldCreate) {
348 assert(isCanonical(Filename) && "Expected canonical MDString");
349 assert(isCanonical(Directory) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000350 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory));
Duncan P. N. Exon Smitha5c57cc2015-02-20 20:35:17 +0000351 Metadata *Ops[] = {Filename, Directory};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000352 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIFile, Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000353}
354
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000355DICompileUnit *DICompileUnit::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000356 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
357 MDString *Producer, bool IsOptimized, MDString *Flags,
358 unsigned RuntimeVersion, MDString *SplitDebugFilename,
359 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Adrian Prantl75819ae2016-04-15 15:57:41 +0000360 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
David Blaikiea01f2952016-08-24 18:29:49 +0000361 uint64_t DWOId, bool SplitDebugInlining, StorageType Storage,
362 bool ShouldCreate) {
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000363 assert(Storage != Uniqued && "Cannot unique DICompileUnit");
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000364 assert(isCanonical(Producer) && "Expected canonical MDString");
365 assert(isCanonical(Flags) && "Expected canonical MDString");
366 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000367
Adrian Prantl75819ae2016-04-15 15:57:41 +0000368 Metadata *Ops[] = {
369 File, Producer, Flags, SplitDebugFilename,
370 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
371 Macros};
David Blaikiea01f2952016-08-24 18:29:49 +0000372 return storeImpl(new (array_lengthof(Ops))
373 DICompileUnit(Context, Storage, SourceLanguage,
374 IsOptimized, RuntimeVersion, EmissionKind,
375 DWOId, SplitDebugInlining, Ops),
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000376 Storage);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000377}
378
Adrian Prantlb939a252016-03-31 23:56:58 +0000379Optional<DICompileUnit::DebugEmissionKind>
380DICompileUnit::getEmissionKind(StringRef Str) {
381 return StringSwitch<Optional<DebugEmissionKind>>(Str)
382 .Case("NoDebug", NoDebug)
383 .Case("FullDebug", FullDebug)
384 .Case("LineTablesOnly", LineTablesOnly)
385 .Default(None);
386}
387
388const char *DICompileUnit::EmissionKindString(DebugEmissionKind EK) {
389 switch (EK) {
390 case NoDebug: return "NoDebug";
391 case FullDebug: return "FullDebug";
392 case LineTablesOnly: return "LineTablesOnly";
393 }
394 return nullptr;
395}
396
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000397DISubprogram *DILocalScope::getSubprogram() const {
398 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
Duncan P. N. Exon Smithfd07a2a2015-03-30 21:32:28 +0000399 return Block->getScope()->getSubprogram();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000400 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
Duncan P. N. Exon Smithfd07a2a2015-03-30 21:32:28 +0000401}
402
Amjad Abouda5ba9912016-04-21 16:58:49 +0000403DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
404 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
405 return File->getScope()->getNonLexicalBlockFileScope();
406 return const_cast<DILocalScope *>(this);
407}
408
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000409DISubprogram *DISubprogram::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000410 LLVMContext &Context, Metadata *Scope, MDString *Name,
411 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
412 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
413 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
Leny Kholodov5fcc4182016-09-06 10:46:28 +0000414 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000415 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
416 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000417 assert(isCanonical(Name) && "Expected canonical MDString");
418 assert(isCanonical(LinkageName) && "Expected canonical MDString");
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000419 DEFINE_GETIMPL_LOOKUP(
420 DISubprogram,
421 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
422 ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
423 Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables));
Adrian Prantl75819ae2016-04-15 15:57:41 +0000424 Metadata *Ops[] = {File, Scope, Name, Name,
425 LinkageName, Type, ContainingType, Unit,
426 TemplateParams, Declaration, Variables};
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000427 DEFINE_GETIMPL_STORE(DISubprogram, (Line, ScopeLine, Virtuality, VirtualIndex,
428 ThisAdjustment, Flags, IsLocalToUnit,
429 IsDefinition, IsOptimized),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000430 Ops);
431}
432
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000433bool DISubprogram::describes(const Function *F) const {
Duncan P. N. Exon Smith3c2d7042015-04-13 19:07:27 +0000434 assert(F && "Invalid function");
Peter Collingbourned4bff302015-11-05 22:03:56 +0000435 if (F->getSubprogram() == this)
Duncan P. N. Exon Smith3c2d7042015-04-13 19:07:27 +0000436 return true;
437 StringRef Name = getLinkageName();
438 if (Name.empty())
439 Name = getName();
440 return F->getName() == Name;
441}
442
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000443DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000444 Metadata *File, unsigned Line,
445 unsigned Column, StorageType Storage,
446 bool ShouldCreate) {
Duncan P. N. Exon Smithb09eb9f2015-08-28 22:58:50 +0000447 // Fixup column.
448 adjustColumn(Column);
449
Duncan P. N. Exon Smith0e202b92015-03-30 16:37:48 +0000450 assert(Scope && "Expected scope");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000451 DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000452 Metadata *Ops[] = {File, Scope};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000453 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000454}
455
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000456DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000457 Metadata *Scope, Metadata *File,
458 unsigned Discriminator,
459 StorageType Storage,
460 bool ShouldCreate) {
Duncan P. N. Exon Smith0e202b92015-03-30 16:37:48 +0000461 assert(Scope && "Expected scope");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000462 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000463 Metadata *Ops[] = {File, Scope};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000464 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000465}
466
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000467DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000468 Metadata *File, MDString *Name, unsigned Line,
469 StorageType Storage, bool ShouldCreate) {
470 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000471 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, Name, Line));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000472 Metadata *Ops[] = {File, Scope, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000473 DEFINE_GETIMPL_STORE(DINamespace, (Line), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000474}
475
Adrian Prantlab1243f2015-06-29 23:03:47 +0000476DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
477 MDString *Name, MDString *ConfigurationMacros,
478 MDString *IncludePath, MDString *ISysRoot,
479 StorageType Storage, bool ShouldCreate) {
480 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000481 DEFINE_GETIMPL_LOOKUP(
482 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
Adrian Prantlab1243f2015-06-29 23:03:47 +0000483 Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
484 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops);
485}
486
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000487DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000488 MDString *Name,
489 Metadata *Type,
490 StorageType Storage,
491 bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000492 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000493 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type));
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000494 Metadata *Ops[] = {Name, Type};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000495 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000496}
497
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000498DITemplateValueParameter *DITemplateValueParameter::getImpl(
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000499 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
500 Metadata *Value, StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000501 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000502 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value));
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000503 Metadata *Ops[] = {Name, Type, Value};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000504 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000505}
506
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000507DIGlobalVariable *
508DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000509 MDString *LinkageName, Metadata *File, unsigned Line,
510 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
511 Metadata *Variable,
512 Metadata *StaticDataMemberDeclaration,
Victor Leschuk2ede1262016-10-20 00:13:12 +0000513 uint64_t AlignInBits,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000514 StorageType Storage, bool ShouldCreate) {
515 assert(isCanonical(Name) && "Expected canonical MDString");
516 assert(isCanonical(LinkageName) && "Expected canonical MDString");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000517 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000518 (Scope, Name, LinkageName, File, Line, Type,
519 IsLocalToUnit, IsDefinition, Variable,
Victor Leschuk2ede1262016-10-20 00:13:12 +0000520 StaticDataMemberDeclaration, AlignInBits));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000521 Metadata *Ops[] = {Scope, Name, File, Type,
522 Name, LinkageName, Variable, StaticDataMemberDeclaration};
Victor Leschuk2ede1262016-10-20 00:13:12 +0000523 DEFINE_GETIMPL_STORE(DIGlobalVariable,
524 (Line, IsLocalToUnit, IsDefinition, AlignInBits),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000525 Ops);
526}
527
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000528DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
529 MDString *Name, Metadata *File,
530 unsigned Line, Metadata *Type,
Leny Kholodov5fcc4182016-09-06 10:46:28 +0000531 unsigned Arg, DIFlags Flags,
Victor Leschuk2ede1262016-10-20 00:13:12 +0000532 uint64_t AlignInBits,
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000533 StorageType Storage,
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000534 bool ShouldCreate) {
Duncan P. N. Exon Smith1ec75ae2015-04-28 01:07:33 +0000535 // 64K ought to be enough for any frontend.
536 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
Duncan P. N. Exon Smith72fe2d02015-02-13 01:39:44 +0000537
Duncan P. N. Exon Smithe2c61d92015-03-27 17:56:39 +0000538 assert(Scope && "Expected scope");
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000539 assert(isCanonical(Name) && "Expected canonical MDString");
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000540 DEFINE_GETIMPL_LOOKUP(DILocalVariable,
Victor Leschuk2ede1262016-10-20 00:13:12 +0000541 (Scope, Name, File, Line, Type, Arg, Flags,
542 AlignInBits));
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000543 Metadata *Ops[] = {Scope, Name, File, Type};
Victor Leschuk2ede1262016-10-20 00:13:12 +0000544 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000545}
546
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000547DIExpression *DIExpression::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000548 ArrayRef<uint64_t> Elements,
549 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000550 DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
551 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000552}
553
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000554unsigned DIExpression::ExprOperand::getSize() const {
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000555 switch (getOp()) {
556 case dwarf::DW_OP_bit_piece:
557 return 3;
Peter Collingbourned4135bb2016-09-13 01:12:59 +0000558 case dwarf::DW_OP_constu:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000559 case dwarf::DW_OP_plus:
Evgeniy Stepanovf6081112015-09-30 19:55:43 +0000560 case dwarf::DW_OP_minus:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000561 return 2;
562 default:
563 return 1;
564 }
565}
566
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000567bool DIExpression::isValid() const {
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000568 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
569 // Check that there's space for the operand.
570 if (I->get() + I->getSize() > E->get())
571 return false;
572
573 // Check that the operand is valid.
574 switch (I->getOp()) {
575 default:
576 return false;
577 case dwarf::DW_OP_bit_piece:
Peter Collingbourned4135bb2016-09-13 01:12:59 +0000578 case dwarf::DW_OP_stack_value:
579 // We only support bit piece and stack value expressions which appear at
580 // the end.
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000581 return I->get() + I->getSize() == E->get();
Peter Collingbourned4135bb2016-09-13 01:12:59 +0000582 case dwarf::DW_OP_constu:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000583 case dwarf::DW_OP_plus:
Evgeniy Stepanovf6081112015-09-30 19:55:43 +0000584 case dwarf::DW_OP_minus:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000585 case dwarf::DW_OP_deref:
586 break;
587 }
588 }
589 return true;
590}
591
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000592bool DIExpression::isBitPiece() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000593 assert(isValid() && "Expected valid expression");
594 if (unsigned N = getNumElements())
595 if (N >= 3)
596 return getElement(N - 3) == dwarf::DW_OP_bit_piece;
597 return false;
598}
599
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000600uint64_t DIExpression::getBitPieceOffset() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000601 assert(isBitPiece() && "Expected bit piece");
602 return getElement(getNumElements() - 2);
603}
604
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000605uint64_t DIExpression::getBitPieceSize() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000606 assert(isBitPiece() && "Expected bit piece");
607 return getElement(getNumElements() - 1);
608}
609
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000610DIObjCProperty *DIObjCProperty::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000611 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
612 MDString *GetterName, MDString *SetterName, unsigned Attributes,
613 Metadata *Type, StorageType Storage, bool ShouldCreate) {
614 assert(isCanonical(Name) && "Expected canonical MDString");
615 assert(isCanonical(GetterName) && "Expected canonical MDString");
616 assert(isCanonical(SetterName) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000617 DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,
618 SetterName, Attributes, Type));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000619 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000620 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000621}
622
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000623DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000624 Metadata *Scope, Metadata *Entity,
625 unsigned Line, MDString *Name,
626 StorageType Storage,
627 bool ShouldCreate) {
628 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000629 DEFINE_GETIMPL_LOOKUP(DIImportedEntity, (Tag, Scope, Entity, Line, Name));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000630 Metadata *Ops[] = {Scope, Entity, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000631 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000632}
Amjad Abouda9bcf162015-12-10 12:56:35 +0000633
634DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
635 unsigned Line, MDString *Name, MDString *Value,
636 StorageType Storage, bool ShouldCreate) {
637 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000638 DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value));
Amjad Abouda9bcf162015-12-10 12:56:35 +0000639 Metadata *Ops[] = { Name, Value };
640 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops);
641}
642
643DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
644 unsigned Line, Metadata *File,
645 Metadata *Elements, StorageType Storage,
646 bool ShouldCreate) {
647 DEFINE_GETIMPL_LOOKUP(DIMacroFile,
648 (MIType, Line, File, Elements));
649 Metadata *Ops[] = { File, Elements };
650 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
651}
652