blob: 1ed1b366367ecd8818a023ab0db61ee12e7e6eb7 [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
Mehdi Amini356d6b62016-09-06 03:14:06 +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"
Mehdi Amini356d6b62016-09-06 03:14:06 +000072 .Default(DINode::FlagZero);
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000073}
74
Mehdi Amini356d6b62016-09-06 03:14:06 +000075const char *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 }
82}
83
Mehdi Amini356d6b62016-09-06 03:14:06 +000084DINode::DIFlags DINode::splitFlags(DIFlags Flags,
85 SmallVectorImpl<DIFlags> &SplitFlags) {
Reid Kleckner604105b2016-06-17 21:31:33 +000086 // Accessibility and member pointer flags need to be specially handled, since
87 // they're packed together.
Mehdi Amini356d6b62016-09-06 03:14:06 +000088 if (DIFlags A = Flags & FlagAccessibility) {
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +000089 if (A == FlagPrivate)
90 SplitFlags.push_back(FlagPrivate);
91 else if (A == FlagProtected)
92 SplitFlags.push_back(FlagProtected);
93 else
94 SplitFlags.push_back(FlagPublic);
95 Flags &= ~A;
96 }
Mehdi Amini356d6b62016-09-06 03:14:06 +000097 if (DIFlags R = Flags & FlagPtrToMemberRep) {
Reid Kleckner604105b2016-06-17 21:31:33 +000098 if (R == FlagSingleInheritance)
99 SplitFlags.push_back(FlagSingleInheritance);
100 else if (R == FlagMultipleInheritance)
101 SplitFlags.push_back(FlagMultipleInheritance);
102 else
103 SplitFlags.push_back(FlagVirtualInheritance);
104 Flags &= ~R;
105 }
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000106
107#define HANDLE_DI_FLAG(ID, NAME) \
Mehdi Amini356d6b62016-09-06 03:14:06 +0000108 if (DIFlags Bit = Flags & Flag##NAME) { \
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000109 SplitFlags.push_back(Bit); \
110 Flags &= ~Bit; \
111 }
112#include "llvm/IR/DebugInfoFlags.def"
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000113 return Flags;
114}
115
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000116DIScopeRef DIScope::getScope() const {
117 if (auto *T = dyn_cast<DIType>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000118 return T->getScope();
119
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000120 if (auto *SP = dyn_cast<DISubprogram>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000121 return SP->getScope();
122
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000123 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000124 return LB->getScope();
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000125
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000126 if (auto *NS = dyn_cast<DINamespace>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000127 return NS->getScope();
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000128
Adrian Prantlab1243f2015-06-29 23:03:47 +0000129 if (auto *M = dyn_cast<DIModule>(this))
Duncan P. N. Exon Smitha59d3e52016-04-23 21:08:00 +0000130 return M->getScope();
Adrian Prantlab1243f2015-06-29 23:03:47 +0000131
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000132 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000133 "Unhandled type of scope.");
134 return nullptr;
135}
136
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000137StringRef DIScope::getName() const {
138 if (auto *T = dyn_cast<DIType>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000139 return T->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000140 if (auto *SP = dyn_cast<DISubprogram>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000141 return SP->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000142 if (auto *NS = dyn_cast<DINamespace>(this))
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000143 return NS->getName();
Adrian Prantlab1243f2015-06-29 23:03:47 +0000144 if (auto *M = dyn_cast<DIModule>(this))
145 return M->getName();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000146 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
147 isa<DICompileUnit>(this)) &&
Duncan P. N. Exon Smithf0d81a52015-04-11 17:37:23 +0000148 "Unhandled type of scope.");
149 return "";
150}
Duncan P. N. Exon Smith5261e4b2015-04-07 01:21:40 +0000151
Duncan P. N. Exon Smithc7e08132015-02-02 20:20:56 +0000152#ifndef NDEBUG
Duncan P. N. Exon Smith9146fc82015-02-02 20:01:03 +0000153static bool isCanonical(const MDString *S) {
154 return !S || !S->getString().empty();
Duncan P. N. Exon Smith442ec022015-02-02 19:54:05 +0000155}
Duncan P. N. Exon Smithc7e08132015-02-02 20:20:56 +0000156#endif
Duncan P. N. Exon Smith442ec022015-02-02 19:54:05 +0000157
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000158GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
159 MDString *Header,
160 ArrayRef<Metadata *> DwarfOps,
161 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000162 unsigned Hash = 0;
163 if (Storage == Uniqued) {
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000164 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000165 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000166 return N;
167 if (!ShouldCreate)
168 return nullptr;
169 Hash = Key.getHash();
170 } else {
171 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
172 }
173
174 // Use a nullptr for empty headers.
Duncan P. N. Exon Smith9146fc82015-02-02 20:01:03 +0000175 assert(isCanonical(Header) && "Expected canonical MDString");
176 Metadata *PreOps[] = {Header};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000177 return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000178 Context, Storage, Hash, Tag, PreOps, DwarfOps),
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000179 Storage, Context.pImpl->GenericDINodes);
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000180}
181
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000182void GenericDINode::recalculateHash() {
183 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
Duncan P. N. Exon Smithd9901ff2015-02-02 18:53:21 +0000184}
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000185
186#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
187#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
188#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
189 do { \
190 if (Storage == Uniqued) { \
191 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
192 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
193 return N; \
194 if (!ShouldCreate) \
195 return nullptr; \
196 } else { \
197 assert(ShouldCreate && \
198 "Expected non-uniqued nodes to always be created"); \
199 } \
200 } while (false)
201#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
David Blaikie6662d6a2016-04-13 17:42:56 +0000202 return storeImpl(new (array_lengthof(OPS)) \
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000203 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
204 Storage, Context.pImpl->CLASS##s)
205#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
206 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
207 Storage, Context.pImpl->CLASS##s)
Duncan P. N. Exon Smithbd33d372015-02-10 01:59:57 +0000208#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
David Blaikie6662d6a2016-04-13 17:42:56 +0000209 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
Duncan P. N. Exon Smithbd33d372015-02-10 01:59:57 +0000210 Storage, Context.pImpl->CLASS##s)
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000211
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000212DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000213 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000214 DEFINE_GETIMPL_LOOKUP(DISubrange, (Count, Lo));
215 DEFINE_GETIMPL_STORE_NO_OPS(DISubrange, (Count, Lo));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000216}
217
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000218DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000219 MDString *Name, StorageType Storage,
220 bool ShouldCreate) {
221 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000222 DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, Name));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000223 Metadata *Ops[] = {Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000224 DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000225}
226
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000227DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000228 MDString *Name, uint64_t SizeInBits,
229 uint64_t AlignInBits, unsigned Encoding,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000230 StorageType Storage, bool ShouldCreate) {
231 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000232 DEFINE_GETIMPL_LOOKUP(DIBasicType,
233 (Tag, Name, SizeInBits, AlignInBits, Encoding));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000234 Metadata *Ops[] = {nullptr, nullptr, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000235 DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000236 Ops);
237}
238
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000239DIDerivedType *DIDerivedType::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000240 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000241 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000242 uint64_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000243 Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
244 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000245 DEFINE_GETIMPL_LOOKUP(DIDerivedType,
246 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
247 AlignInBits, OffsetInBits, Flags, ExtraData));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000248 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
249 DEFINE_GETIMPL_STORE(
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000250 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000251 Ops);
252}
253
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000254DICompositeType *DICompositeType::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000255 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
Duncan P. N. Exon Smithd34db172015-02-19 23:56:07 +0000256 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000257 uint64_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000258 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
259 Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
260 bool ShouldCreate) {
261 assert(isCanonical(Name) && "Expected canonical MDString");
Duncan P. N. Exon Smith5ab2be02016-04-17 03:58:21 +0000262
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000263 // Keep this in sync with buildODRType.
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000264 DEFINE_GETIMPL_LOOKUP(
265 DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
266 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
267 VTableHolder, TemplateParams, Identifier));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000268 Metadata *Ops[] = {File, Scope, Name, BaseType,
269 Elements, VTableHolder, TemplateParams, Identifier};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000270 DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000271 AlignInBits, OffsetInBits, Flags),
272 Ops);
273}
274
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000275DICompositeType *DICompositeType::buildODRType(
276 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
277 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
278 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000279 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000280 Metadata *VTableHolder, Metadata *TemplateParams) {
281 assert(!Identifier.getString().empty() && "Expected valid identifier");
282 if (!Context.isODRUniquingDebugTypes())
283 return nullptr;
284 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
285 if (!CT)
286 return CT = DICompositeType::getDistinct(
287 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
288 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
289 VTableHolder, TemplateParams, &Identifier);
290
291 // Only mutate CT if it's a forward declaration and the new operands aren't.
292 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?");
293 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
294 return CT;
295
296 // Mutate CT in place. Keep this in sync with getImpl.
297 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
298 Flags);
299 Metadata *Ops[] = {File, Scope, Name, BaseType,
300 Elements, VTableHolder, TemplateParams, &Identifier};
Simon Pilgrim1ec7dc72016-05-02 16:45:02 +0000301 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
Duncan P. N. Exon Smith97386022016-04-19 18:00:19 +0000302 "Mismatched number of operands");
303 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
304 if (Ops[I] != CT->getOperand(I))
305 CT->setOperand(I, Ops[I]);
306 return CT;
307}
308
Duncan P. N. Exon Smith0b0271e2016-04-19 14:55:09 +0000309DICompositeType *DICompositeType::getODRType(
310 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
311 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
312 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000313 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Duncan P. N. Exon Smith0b0271e2016-04-19 14:55:09 +0000314 Metadata *VTableHolder, Metadata *TemplateParams) {
315 assert(!Identifier.getString().empty() && "Expected valid identifier");
316 if (!Context.isODRUniquingDebugTypes())
317 return nullptr;
318 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
319 if (!CT)
320 CT = DICompositeType::getDistinct(
321 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
322 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
323 TemplateParams, &Identifier);
324 return CT;
325}
326
327DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
328 MDString &Identifier) {
329 assert(!Identifier.getString().empty() && "Expected valid identifier");
330 if (!Context.isODRUniquingDebugTypes())
331 return nullptr;
332 return Context.pImpl->DITypeMap->lookup(&Identifier);
333}
334
Mehdi Amini356d6b62016-09-06 03:14:06 +0000335DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
336 uint8_t CC, Metadata *TypeArray,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000337 StorageType Storage,
338 bool ShouldCreate) {
Reid Klecknerde3d8b52016-06-08 20:34:29 +0000339 DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray));
Duncan P. N. Exon Smithb9e045a2015-07-24 20:56:36 +0000340 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
Reid Klecknerde3d8b52016-06-08 20:34:29 +0000341 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000342}
343
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000344DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000345 MDString *Directory, StorageType Storage,
346 bool ShouldCreate) {
347 assert(isCanonical(Filename) && "Expected canonical MDString");
348 assert(isCanonical(Directory) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000349 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory));
Duncan P. N. Exon Smitha5c57cc2015-02-20 20:35:17 +0000350 Metadata *Ops[] = {Filename, Directory};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000351 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIFile, Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000352}
353
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000354DICompileUnit *DICompileUnit::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000355 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
356 MDString *Producer, bool IsOptimized, MDString *Flags,
357 unsigned RuntimeVersion, MDString *SplitDebugFilename,
358 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Adrian Prantl75819ae2016-04-15 15:57:41 +0000359 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
David Blaikiea01f2952016-08-24 18:29:49 +0000360 uint64_t DWOId, bool SplitDebugInlining, StorageType Storage,
361 bool ShouldCreate) {
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000362 assert(Storage != Uniqued && "Cannot unique DICompileUnit");
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000363 assert(isCanonical(Producer) && "Expected canonical MDString");
364 assert(isCanonical(Flags) && "Expected canonical MDString");
365 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000366
Adrian Prantl75819ae2016-04-15 15:57:41 +0000367 Metadata *Ops[] = {
368 File, Producer, Flags, SplitDebugFilename,
369 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
370 Macros};
David Blaikiea01f2952016-08-24 18:29:49 +0000371 return storeImpl(new (array_lengthof(Ops))
372 DICompileUnit(Context, Storage, SourceLanguage,
373 IsOptimized, RuntimeVersion, EmissionKind,
374 DWOId, SplitDebugInlining, Ops),
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +0000375 Storage);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000376}
377
Adrian Prantlb939a252016-03-31 23:56:58 +0000378Optional<DICompileUnit::DebugEmissionKind>
379DICompileUnit::getEmissionKind(StringRef Str) {
380 return StringSwitch<Optional<DebugEmissionKind>>(Str)
381 .Case("NoDebug", NoDebug)
382 .Case("FullDebug", FullDebug)
383 .Case("LineTablesOnly", LineTablesOnly)
384 .Default(None);
385}
386
387const char *DICompileUnit::EmissionKindString(DebugEmissionKind EK) {
388 switch (EK) {
389 case NoDebug: return "NoDebug";
390 case FullDebug: return "FullDebug";
391 case LineTablesOnly: return "LineTablesOnly";
392 }
393 return nullptr;
394}
395
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000396DISubprogram *DILocalScope::getSubprogram() const {
397 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
Duncan P. N. Exon Smithfd07a2a2015-03-30 21:32:28 +0000398 return Block->getScope()->getSubprogram();
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000399 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
Duncan P. N. Exon Smithfd07a2a2015-03-30 21:32:28 +0000400}
401
Amjad Abouda5ba9912016-04-21 16:58:49 +0000402DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
403 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
404 return File->getScope()->getNonLexicalBlockFileScope();
405 return const_cast<DILocalScope *>(this);
406}
407
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000408DISubprogram *DISubprogram::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000409 LLVMContext &Context, Metadata *Scope, MDString *Name,
410 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
411 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
412 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000413 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000414 Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
415 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000416 assert(isCanonical(Name) && "Expected canonical MDString");
417 assert(isCanonical(LinkageName) && "Expected canonical MDString");
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000418 DEFINE_GETIMPL_LOOKUP(
419 DISubprogram,
420 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
421 ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
422 Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables));
Adrian Prantl75819ae2016-04-15 15:57:41 +0000423 Metadata *Ops[] = {File, Scope, Name, Name,
424 LinkageName, Type, ContainingType, Unit,
425 TemplateParams, Declaration, Variables};
Reid Klecknerb5af11d2016-07-01 02:41:21 +0000426 DEFINE_GETIMPL_STORE(DISubprogram, (Line, ScopeLine, Virtuality, VirtualIndex,
427 ThisAdjustment, Flags, IsLocalToUnit,
428 IsDefinition, IsOptimized),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000429 Ops);
430}
431
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000432bool DISubprogram::describes(const Function *F) const {
Duncan P. N. Exon Smith3c2d7042015-04-13 19:07:27 +0000433 assert(F && "Invalid function");
Peter Collingbourned4bff302015-11-05 22:03:56 +0000434 if (F->getSubprogram() == this)
Duncan P. N. Exon Smith3c2d7042015-04-13 19:07:27 +0000435 return true;
436 StringRef Name = getLinkageName();
437 if (Name.empty())
438 Name = getName();
439 return F->getName() == Name;
440}
441
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000442DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000443 Metadata *File, unsigned Line,
444 unsigned Column, StorageType Storage,
445 bool ShouldCreate) {
Duncan P. N. Exon Smithb09eb9f2015-08-28 22:58:50 +0000446 // Fixup column.
447 adjustColumn(Column);
448
Duncan P. N. Exon Smith0e202b92015-03-30 16:37:48 +0000449 assert(Scope && "Expected scope");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000450 DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000451 Metadata *Ops[] = {File, Scope};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000452 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000453}
454
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000455DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000456 Metadata *Scope, Metadata *File,
457 unsigned Discriminator,
458 StorageType Storage,
459 bool ShouldCreate) {
Duncan P. N. Exon Smith0e202b92015-03-30 16:37:48 +0000460 assert(Scope && "Expected scope");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000461 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000462 Metadata *Ops[] = {File, Scope};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000463 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000464}
465
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000466DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000467 Metadata *File, MDString *Name, unsigned Line,
468 StorageType Storage, bool ShouldCreate) {
469 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000470 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, Name, Line));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000471 Metadata *Ops[] = {File, Scope, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000472 DEFINE_GETIMPL_STORE(DINamespace, (Line), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000473}
474
Adrian Prantlab1243f2015-06-29 23:03:47 +0000475DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
476 MDString *Name, MDString *ConfigurationMacros,
477 MDString *IncludePath, MDString *ISysRoot,
478 StorageType Storage, bool ShouldCreate) {
479 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000480 DEFINE_GETIMPL_LOOKUP(
481 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
Adrian Prantlab1243f2015-06-29 23:03:47 +0000482 Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
483 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops);
484}
485
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000486DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000487 MDString *Name,
488 Metadata *Type,
489 StorageType Storage,
490 bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000491 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000492 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type));
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000493 Metadata *Ops[] = {Name, Type};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000494 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000495}
496
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000497DITemplateValueParameter *DITemplateValueParameter::getImpl(
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000498 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
499 Metadata *Value, StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000500 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000501 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value));
Duncan P. N. Exon Smith3d62bba2015-02-19 00:37:21 +0000502 Metadata *Ops[] = {Name, Type, Value};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000503 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000504}
505
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000506DIGlobalVariable *
507DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000508 MDString *LinkageName, Metadata *File, unsigned Line,
509 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
510 Metadata *Variable,
511 Metadata *StaticDataMemberDeclaration,
512 StorageType Storage, bool ShouldCreate) {
513 assert(isCanonical(Name) && "Expected canonical MDString");
514 assert(isCanonical(LinkageName) && "Expected canonical MDString");
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000515 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000516 (Scope, Name, LinkageName, File, Line, Type,
517 IsLocalToUnit, IsDefinition, Variable,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000518 StaticDataMemberDeclaration));
519 Metadata *Ops[] = {Scope, Name, File, Type,
520 Name, LinkageName, Variable, StaticDataMemberDeclaration};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000521 DEFINE_GETIMPL_STORE(DIGlobalVariable, (Line, IsLocalToUnit, IsDefinition),
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000522 Ops);
523}
524
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000525DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
526 MDString *Name, Metadata *File,
527 unsigned Line, Metadata *Type,
Mehdi Amini356d6b62016-09-06 03:14:06 +0000528 unsigned Arg, DIFlags Flags,
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000529 StorageType Storage,
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000530 bool ShouldCreate) {
Duncan P. N. Exon Smith1ec75ae2015-04-28 01:07:33 +0000531 // 64K ought to be enough for any frontend.
532 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
Duncan P. N. Exon Smith72fe2d02015-02-13 01:39:44 +0000533
Duncan P. N. Exon Smithe2c61d92015-03-27 17:56:39 +0000534 assert(Scope && "Expected scope");
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000535 assert(isCanonical(Name) && "Expected canonical MDString");
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000536 DEFINE_GETIMPL_LOOKUP(DILocalVariable,
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000537 (Scope, Name, File, Line, Type, Arg, Flags));
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000538 Metadata *Ops[] = {Scope, Name, File, Type};
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000539 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000540}
541
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000542DIExpression *DIExpression::getImpl(LLVMContext &Context,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000543 ArrayRef<uint64_t> Elements,
544 StorageType Storage, bool ShouldCreate) {
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000545 DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
546 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000547}
548
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000549unsigned DIExpression::ExprOperand::getSize() const {
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000550 switch (getOp()) {
551 case dwarf::DW_OP_bit_piece:
552 return 3;
553 case dwarf::DW_OP_plus:
Evgeniy Stepanovf6081112015-09-30 19:55:43 +0000554 case dwarf::DW_OP_minus:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000555 return 2;
556 default:
557 return 1;
558 }
559}
560
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000561bool DIExpression::isValid() const {
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000562 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
563 // Check that there's space for the operand.
564 if (I->get() + I->getSize() > E->get())
565 return false;
566
567 // Check that the operand is valid.
568 switch (I->getOp()) {
569 default:
570 return false;
571 case dwarf::DW_OP_bit_piece:
572 // Piece expressions must be at the end.
573 return I->get() + I->getSize() == E->get();
574 case dwarf::DW_OP_plus:
Evgeniy Stepanovf6081112015-09-30 19:55:43 +0000575 case dwarf::DW_OP_minus:
Duncan P. N. Exon Smith193a4fd2015-02-13 01:07:46 +0000576 case dwarf::DW_OP_deref:
577 break;
578 }
579 }
580 return true;
581}
582
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000583bool DIExpression::isBitPiece() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000584 assert(isValid() && "Expected valid expression");
585 if (unsigned N = getNumElements())
586 if (N >= 3)
587 return getElement(N - 3) == dwarf::DW_OP_bit_piece;
588 return false;
589}
590
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000591uint64_t DIExpression::getBitPieceOffset() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000592 assert(isBitPiece() && "Expected bit piece");
593 return getElement(getNumElements() - 2);
594}
595
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000596uint64_t DIExpression::getBitPieceSize() const {
Duncan P. N. Exon Smith86cc3322015-04-07 03:49:59 +0000597 assert(isBitPiece() && "Expected bit piece");
598 return getElement(getNumElements() - 1);
599}
600
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000601DIObjCProperty *DIObjCProperty::getImpl(
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000602 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
603 MDString *GetterName, MDString *SetterName, unsigned Attributes,
604 Metadata *Type, StorageType Storage, bool ShouldCreate) {
605 assert(isCanonical(Name) && "Expected canonical MDString");
606 assert(isCanonical(GetterName) && "Expected canonical MDString");
607 assert(isCanonical(SetterName) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000608 DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,
609 SetterName, Attributes, Type));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000610 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000611 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000612}
613
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000614DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000615 Metadata *Scope, Metadata *Entity,
616 unsigned Line, MDString *Name,
617 StorageType Storage,
618 bool ShouldCreate) {
619 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000620 DEFINE_GETIMPL_LOOKUP(DIImportedEntity, (Tag, Scope, Entity, Line, Name));
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000621 Metadata *Ops[] = {Scope, Entity, Name};
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000622 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
Duncan P. N. Exon Smith01fc1762015-02-10 00:52:32 +0000623}
Amjad Abouda9bcf162015-12-10 12:56:35 +0000624
625DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
626 unsigned Line, MDString *Name, MDString *Value,
627 StorageType Storage, bool ShouldCreate) {
628 assert(isCanonical(Name) && "Expected canonical MDString");
Mehdi Amini5d99c4e2016-03-19 01:02:34 +0000629 DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value));
Amjad Abouda9bcf162015-12-10 12:56:35 +0000630 Metadata *Ops[] = { Name, Value };
631 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops);
632}
633
634DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
635 unsigned Line, Metadata *File,
636 Metadata *Elements, StorageType Storage,
637 bool ShouldCreate) {
638 DEFINE_GETIMPL_LOOKUP(DIMacroFile,
639 (MIType, Line, File, Elements));
640 Metadata *Ops[] = { File, Elements };
641 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
642}
643