blob: 893f9f295488e0c41f9b75cae4ebd8e9e1c2fc96 [file] [log] [blame]
Devang Patel57c5a202010-11-04 15:01:38 +00001//===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
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 DIBuilder.
11//
12//===----------------------------------------------------------------------===//
13
Chandler Carruth12664a02014-03-06 00:22:06 +000014#include "llvm/IR/DIBuilder.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000015#include "llvm/ADT/STLExtras.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000016#include "llvm/IR/Constants.h"
Chandler Carruth9a4c9e52014-03-06 00:46:21 +000017#include "llvm/IR/DebugInfo.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000018#include "llvm/IR/IntrinsicInst.h"
19#include "llvm/IR/Module.h"
Eric Christopher34164192012-04-03 00:43:49 +000020#include "llvm/Support/Debug.h"
Devang Patel57c5a202010-11-04 15:01:38 +000021#include "llvm/Support/Dwarf.h"
22
23using namespace llvm;
24using namespace llvm::dwarf;
25
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +000026namespace {
27class HeaderBuilder {
Duncan P. N. Exon Smithaa687a32015-01-20 05:02:42 +000028 /// \brief Whether there are any fields yet.
29 ///
30 /// Note that this is not equivalent to \c Chars.empty(), since \a concat()
31 /// may have been called already with an empty string.
32 bool IsEmpty;
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +000033 SmallVector<char, 256> Chars;
34
35public:
Duncan P. N. Exon Smithaa687a32015-01-20 05:02:42 +000036 HeaderBuilder() : IsEmpty(true) {}
37 HeaderBuilder(const HeaderBuilder &X) : IsEmpty(X.IsEmpty), Chars(X.Chars) {}
38 HeaderBuilder(HeaderBuilder &&X)
39 : IsEmpty(X.IsEmpty), Chars(std::move(X.Chars)) {}
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +000040
41 template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
Duncan P. N. Exon Smithaa687a32015-01-20 05:02:42 +000042 if (IsEmpty)
43 IsEmpty = false;
44 else
45 Chars.push_back(0);
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +000046 Twine(X).toVector(Chars);
47 return *this;
48 }
49
50 MDString *get(LLVMContext &Context) const {
51 return MDString::get(Context, StringRef(Chars.begin(), Chars.size()));
52 }
53
54 static HeaderBuilder get(unsigned Tag) {
Duncan P. N. Exon Smithaa687a32015-01-20 05:02:42 +000055 return HeaderBuilder().concat("0x" + Twine::utohexstr(Tag));
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +000056 }
57};
Devang Patel57c5a202010-11-04 15:01:38 +000058}
Devang Patel63f83cd2010-12-07 23:58:00 +000059
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000060DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes)
Craig Topperc6207612014-04-09 06:08:46 +000061 : M(m), VMContext(M.getContext()), TempEnumTypes(nullptr),
62 TempRetainTypes(nullptr), TempSubprograms(nullptr), TempGVs(nullptr),
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000063 DeclareFn(nullptr), ValueFn(nullptr),
64 AllowUnresolvedNodes(AllowUnresolvedNodes) {}
65
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000066void DIBuilder::trackIfUnresolved(MDNode *N) {
Duncan P. N. Exon Smith9b1c6d32015-01-19 19:09:14 +000067 if (!N)
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000068 return;
Duncan P. N. Exon Smith9b1c6d32015-01-19 19:09:14 +000069 if (N->isResolved())
70 return;
71
72 assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
73 UnresolvedNodes.emplace_back(N);
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000074}
Devang Patel57c5a202010-11-04 15:01:38 +000075
Devang Patel2b8acaf2011-08-15 23:00:00 +000076void DIBuilder::finalize() {
Devang Pateleb1bb4e2011-08-16 22:09:43 +000077 DIArray Enums = getOrCreateArray(AllEnumTypes);
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +000078 TempEnumTypes->replaceAllUsesWith(Enums.get());
Devang Pateleb1bb4e2011-08-16 22:09:43 +000079
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000080 SmallVector<Metadata *, 16> RetainValues;
Manman Ren0b410402013-08-29 23:17:54 +000081 // Declarations and definitions of the same type may be retained. Some
82 // clients RAUW these pairs, leaving duplicates in the retained types
83 // list. Use a set to remove the duplicates while we transform the
84 // TrackingVHs back into Values.
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +000085 SmallPtrSet<Metadata *, 16> RetainSet;
Manman Ren0b410402013-08-29 23:17:54 +000086 for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
David Blaikie70573dc2014-11-19 07:49:26 +000087 if (RetainSet.insert(AllRetainTypes[I]).second)
Manman Ren0b410402013-08-29 23:17:54 +000088 RetainValues.push_back(AllRetainTypes[I]);
89 DIArray RetainTypes = getOrCreateArray(RetainValues);
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +000090 TempRetainTypes->replaceAllUsesWith(RetainTypes.get());
Devang Pateleb1bb4e2011-08-16 22:09:43 +000091
92 DIArray SPs = getOrCreateArray(AllSubprograms);
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +000093 TempSubprograms->replaceAllUsesWith(SPs.get());
Duncan P. N. Exon Smith000fa2c2015-04-07 04:14:33 +000094 for (unsigned i = 0, e = SPs.size(); i != e; ++i) {
95 DISubprogram SP = cast<MDSubprogram>(SPs[i]);
Duncan P. N. Exon Smith537b4a82015-04-14 03:40:37 +000096 if (MDTuple *Temp = SP->getVariables().get()) {
Benjamin Kramer6cd780f2015-02-17 15:29:18 +000097 const auto &PV = PreservedVariables.lookup(SP);
98 SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
Eric Christopher27deb262012-04-23 19:00:11 +000099 DIArray AV = getOrCreateArray(Variables);
Duncan P. N. Exon Smith457bfc72015-04-10 18:01:58 +0000100 TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
Eric Christopher27deb262012-04-23 19:00:11 +0000101 }
Devang Patel59e27c52011-08-19 23:28:12 +0000102 }
Devang Pateleb1bb4e2011-08-16 22:09:43 +0000103
104 DIArray GVs = getOrCreateArray(AllGVs);
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +0000105 TempGVs->replaceAllUsesWith(GVs.get());
David Blaikief55abea2013-04-22 06:12:31 +0000106
Benjamin Kramer6cd780f2015-02-17 15:29:18 +0000107 SmallVector<Metadata *, 16> RetainValuesI(AllImportedModules.begin(),
108 AllImportedModules.end());
Eric Christopher2c3a6dc2014-02-28 21:27:57 +0000109 DIArray IMs = getOrCreateArray(RetainValuesI);
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +0000110 TempImportedModules->replaceAllUsesWith(IMs.get());
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000111
112 // Now that all temp nodes have been replaced or deleted, resolve remaining
113 // cycles.
114 for (const auto &N : UnresolvedNodes)
Duncan P. N. Exon Smith2bc00f42015-01-19 23:13:14 +0000115 if (N && !N->isResolved())
116 N->resolveCycles();
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000117 UnresolvedNodes.clear();
118
119 // Can't handle unresolved nodes anymore.
120 AllowUnresolvedNodes = false;
Devang Pateleb1bb4e2011-08-16 22:09:43 +0000121}
122
Duncan P. N. Exon Smith379e3752014-10-01 21:32:15 +0000123/// If N is compile unit return NULL otherwise return N.
Duncan P. N. Exon Smith3cd2cab2015-03-27 00:34:10 +0000124static MDScope *getNonCompileUnitScope(MDNode *N) {
125 if (!N || isa<MDCompileUnit>(N))
Craig Topperc6207612014-04-09 06:08:46 +0000126 return nullptr;
Duncan P. N. Exon Smith3cd2cab2015-03-27 00:34:10 +0000127 return cast<MDScope>(N);
Devang Patel2b8acaf2011-08-15 23:00:00 +0000128}
129
Eric Christopher03b3e112013-07-19 00:51:47 +0000130DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
131 StringRef Directory,
132 StringRef Producer, bool isOptimized,
133 StringRef Flags, unsigned RunTimeVer,
Eric Christopher75d49db2014-02-27 01:24:56 +0000134 StringRef SplitName,
Diego Novillo56653fd2014-06-24 17:02:03 +0000135 DebugEmissionKind Kind,
136 bool EmitDebugInfo) {
Eric Christopher75d49db2014-02-27 01:24:56 +0000137
Bruce Mitchener7e575ed2015-02-07 06:35:30 +0000138 assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
Chandler Carruth4c0ee742012-01-10 18:18:52 +0000139 (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
140 "Invalid Language tag");
141 assert(!Filename.empty() &&
142 "Unable to create compile unit without filename");
Devang Pateleb1bb4e2011-08-16 22:09:43 +0000143
Duncan P. N. Exon Smithb93569d2015-02-12 21:52:11 +0000144 // TODO: Once we make MDCompileUnit distinct, stop using temporaries here
145 // (just start with operands assigned to nullptr).
Duncan P. N. Exon Smith457bfc72015-04-10 18:01:58 +0000146 TempEnumTypes = MDTuple::getTemporary(VMContext, None);
147 TempRetainTypes = MDTuple::getTemporary(VMContext, None);
148 TempSubprograms = MDTuple::getTemporary(VMContext, None);
149 TempGVs = MDTuple::getTemporary(VMContext, None);
150 TempImportedModules = MDTuple::getTemporary(VMContext, None);
David Blaikief55abea2013-04-22 06:12:31 +0000151
Duncan P. N. Exon Smithb93569d2015-02-12 21:52:11 +0000152 // TODO: Switch to getDistinct(). We never want to merge compile units based
153 // on contents.
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000154 MDCompileUnit *CUNode = MDCompileUnit::get(
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000155 VMContext, Lang, MDFile::get(VMContext, Filename, Directory), Producer,
Duncan P. N. Exon Smith457bfc72015-04-10 18:01:58 +0000156 isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(),
157 TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(),
158 TempImportedModules.get());
Devang Patel09fa69e2011-05-03 16:18:28 +0000159
160 // Create a named metadata so that it is easier to find cu in a module.
Diego Novillo56653fd2014-06-24 17:02:03 +0000161 // Note that we only generate this when the caller wants to actually
162 // emit debug information. When we are only interested in tracking
163 // source line locations throughout the backend, we prevent codegen from
164 // emitting debug info in the final output by not generating llvm.dbg.cu.
165 if (EmitDebugInfo) {
166 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
167 NMD->addOperand(CUNode);
168 }
Eric Christopher03b3e112013-07-19 00:51:47 +0000169
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000170 trackIfUnresolved(CUNode);
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000171 return CUNode;
Devang Patel57c5a202010-11-04 15:01:38 +0000172}
173
David Blaikiee63d5d12013-05-20 22:50:35 +0000174static DIImportedEntity
David Blaikie2a40c142014-04-06 06:29:01 +0000175createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope Context,
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000176 Metadata *NS, unsigned Line, StringRef Name,
177 SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
Duncan P. N. Exon Smithd5e6a152015-04-07 04:07:31 +0000178 DIImportedEntity M =
179 MDImportedEntity::get(C, Tag, Context, DebugNodeRef(NS), Line, Name);
Duncan P. N. Exon Smithde8e4272015-04-14 01:46:44 +0000180 AllImportedModules.emplace_back(M);
David Blaikie1fd43652013-05-07 21:35:53 +0000181 return M;
182}
183
David Blaikiee63d5d12013-05-20 22:50:35 +0000184DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
David Blaikie2a40c142014-04-06 06:29:01 +0000185 DINameSpace NS,
186 unsigned Line) {
187 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
188 Context, NS, Line, StringRef(), AllImportedModules);
David Blaikiee63d5d12013-05-20 22:50:35 +0000189}
190
191DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
192 DIImportedEntity NS,
David Blaikie2a40c142014-04-06 06:29:01 +0000193 unsigned Line) {
194 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
195 Context, NS, Line, StringRef(), AllImportedModules);
David Blaikiee63d5d12013-05-20 22:50:35 +0000196}
197
David Blaikie1fd43652013-05-07 21:35:53 +0000198DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
Frederic Riss4aa51ae2014-11-06 17:46:55 +0000199 DIDescriptor Decl,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000200 unsigned Line,
201 StringRef Name) {
Frederic Riss4aa51ae2014-11-06 17:46:55 +0000202 // Make sure to use the unique identifier based metadata reference for
203 // types that have one.
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000204 return ::createImportedModule(
205 VMContext, dwarf::DW_TAG_imported_declaration, Context,
206 DebugNodeRef::get(cast_or_null<DebugNode>(Decl.get())), Line, Name,
207 AllImportedModules);
David Blaikie2a40c142014-04-06 06:29:01 +0000208}
209
210DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
211 DIImportedEntity Imp,
212 unsigned Line, StringRef Name) {
213 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
214 Context, Imp, Line, Name, AllImportedModules);
David Blaikief55abea2013-04-22 06:12:31 +0000215}
216
Devang Patel9b412732011-02-22 18:56:12 +0000217DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000218 return MDFile::get(VMContext, Filename, Directory);
Devang Patel57c5a202010-11-04 15:01:38 +0000219}
220
David Blaikieb7619002013-06-24 17:34:33 +0000221DIEnumerator DIBuilder::createEnumerator(StringRef Name, int64_t Val) {
Devang Patel1ad1abe2011-09-12 18:26:08 +0000222 assert(!Name.empty() && "Unable to create enumerator without name");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000223 return MDEnumerator::get(VMContext, Val, Name);
Devang Patel57c5a202010-11-04 15:01:38 +0000224}
225
Peter Collingbournea4a47cb2013-06-27 22:50:59 +0000226DIBasicType DIBuilder::createUnspecifiedType(StringRef Name) {
Devang Patel04d6d472011-09-14 23:13:28 +0000227 assert(!Name.empty() && "Unable to create type without name");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000228 return MDBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
Devang Patel04d6d472011-09-14 23:13:28 +0000229}
230
Peter Collingbournea4a47cb2013-06-27 22:50:59 +0000231DIBasicType DIBuilder::createNullPtrType() {
232 return createUnspecifiedType("decltype(nullptr)");
233}
234
David Blaikie209d63a2013-02-12 00:40:41 +0000235DIBasicType
236DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
237 uint64_t AlignInBits, unsigned Encoding) {
Devang Patel1ad1abe2011-09-12 18:26:08 +0000238 assert(!Name.empty() && "Unable to create type without name");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000239 return MDBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
240 AlignInBits, Encoding);
Devang Patel57c5a202010-11-04 15:01:38 +0000241}
242
David Blaikief11de2f2013-02-18 06:41:57 +0000243DIDerivedType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000244 return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000245 MDTypeRef::get(FromTy), 0, 0, 0, 0);
Devang Patel57c5a202010-11-04 15:01:38 +0000246}
247
David Blaikief11de2f2013-02-18 06:41:57 +0000248DIDerivedType
249DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
250 uint64_t AlignInBits, StringRef Name) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000251 // FIXME: Why is there a name here?
252 return MDDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000253 nullptr, 0, nullptr, MDTypeRef::get(PointeeTy),
254 SizeInBits, AlignInBits, 0, 0);
Devang Patel57c5a202010-11-04 15:01:38 +0000255}
256
Adrian Prantl48af2ef2014-12-23 19:11:47 +0000257DIDerivedType
258DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base,
259 uint64_t SizeInBits, uint64_t AlignInBits) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000260 return MDDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000261 nullptr, 0, nullptr, MDTypeRef::get(PointeeTy),
262 SizeInBits, AlignInBits, 0, 0, MDTypeRef::get(Base));
David Blaikie5d3249b2013-01-07 05:51:15 +0000263}
264
David Blaikief11de2f2013-02-18 06:41:57 +0000265DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000266 assert(RTy && "Unable to create reference type");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000267 return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000268 MDTypeRef::get(RTy), 0, 0, 0, 0);
Devang Patel57c5a202010-11-04 15:01:38 +0000269}
270
David Blaikief11de2f2013-02-18 06:41:57 +0000271DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
272 unsigned LineNo, DIDescriptor Context) {
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000273 return MDDerivedType::get(
274 VMContext, dwarf::DW_TAG_typedef, Name, File, LineNo,
275 MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
276 MDTypeRef::get(Ty), 0, 0, 0, 0);
Devang Patel57c5a202010-11-04 15:01:38 +0000277}
278
Manman Ren3c6acec2013-06-07 18:35:53 +0000279DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
Benjamin Kramered8b7bf2010-11-04 18:45:27 +0000280 // typedefs are encoded in DIDerivedType format.
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000281 assert(Ty && "Invalid type!");
282 assert(FriendTy && "Invalid friend type!");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000283 return MDDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000284 MDTypeRef::get(Ty), MDTypeRef::get(FriendTy), 0, 0,
285 0, 0);
Devang Patel57c5a202010-11-04 15:01:38 +0000286}
287
Eric Christopher98f9c232013-10-15 23:31:31 +0000288DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
289 uint64_t BaseOffset,
290 unsigned Flags) {
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000291 assert(Ty && "Unable to create inheritance");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000292 return MDDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000293 0, MDTypeRef::get(Ty), MDTypeRef::get(BaseTy), 0, 0,
294 BaseOffset, Flags);
Devang Patel57c5a202010-11-04 15:01:38 +0000295}
296
Eric Christopher98f9c232013-10-15 23:31:31 +0000297DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
298 DIFile File, unsigned LineNumber,
299 uint64_t SizeInBits,
300 uint64_t AlignInBits,
301 uint64_t OffsetInBits, unsigned Flags,
302 DIType Ty) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000303 return MDDerivedType::get(
304 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000305 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
306 MDTypeRef::get(Ty), SizeInBits, AlignInBits, OffsetInBits, Flags);
Devang Patel57c5a202010-11-04 15:01:38 +0000307}
308
Duncan P. N. Exon Smith3cd2cab2015-03-27 00:34:10 +0000309static ConstantAsMetadata *getConstantOrNull(Constant *C) {
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000310 if (C)
311 return ConstantAsMetadata::get(C);
312 return nullptr;
313}
314
Duncan P. N. Exon Smithdbf64acd2014-11-15 00:23:49 +0000315DIDerivedType DIBuilder::createStaticMemberType(DIDescriptor Scope,
316 StringRef Name, DIFile File,
317 unsigned LineNumber, DIType Ty,
318 unsigned Flags,
319 llvm::Constant *Val) {
Eric Christopher4d23a4a2013-01-16 01:22:23 +0000320 // TAG_member is encoded in DIDerivedType format.
321 Flags |= DIDescriptor::FlagStaticMember;
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000322 return MDDerivedType::get(
323 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000324 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
325 MDTypeRef::get(Ty), 0, 0, 0, Flags, getConstantOrNull(Val));
Eric Christopher4d23a4a2013-01-16 01:22:23 +0000326}
327
Eric Christopher98f9c232013-10-15 23:31:31 +0000328DIDerivedType DIBuilder::createObjCIVar(StringRef Name, DIFile File,
329 unsigned LineNumber,
330 uint64_t SizeInBits,
331 uint64_t AlignInBits,
332 uint64_t OffsetInBits, unsigned Flags,
333 DIType Ty, MDNode *PropertyNode) {
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000334 return MDDerivedType::get(
335 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
336 MDScopeRef::get(getNonCompileUnitScope(File)), MDTypeRef::get(Ty),
337 SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode);
Devang Patel44882172012-02-06 17:49:43 +0000338}
339
Eric Christopher98f9c232013-10-15 23:31:31 +0000340DIObjCProperty
341DIBuilder::createObjCProperty(StringRef Name, DIFile File, unsigned LineNumber,
342 StringRef GetterName, StringRef SetterName,
343 unsigned PropertyAttributes, DIType Ty) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000344 return MDObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
345 SetterName, PropertyAttributes, Ty);
Devang Patelcc481592012-02-04 00:59:25 +0000346}
347
Eric Christopher3cc90fe2011-08-26 21:02:40 +0000348DITemplateTypeParameter
Devang Patel9b412732011-02-22 18:56:12 +0000349DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000350 DIType Ty) {
Duncan P. N. Exon Smithb273d062015-04-16 01:37:00 +0000351 assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit");
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000352 return MDTemplateTypeParameter::get(VMContext, Name, MDTypeRef::get(Ty));
Devang Patel3a9e65e2011-02-02 21:38:25 +0000353}
354
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000355static DITemplateValueParameter
356createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag,
357 DIDescriptor Context, StringRef Name,
358 DIType Ty, Metadata *MD) {
Duncan P. N. Exon Smithb273d062015-04-16 01:37:00 +0000359 assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit");
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000360 return MDTemplateValueParameter::get(VMContext, Tag, Name, MDTypeRef::get(Ty),
361 MD);
Devang Patelbe933b42011-02-02 22:35:53 +0000362}
363
David Blaikie2b380232013-06-22 18:59:11 +0000364DITemplateValueParameter
365DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000366 DIType Ty, Constant *Val) {
Duncan P. N. Exon Smith774951f2014-11-15 00:05:04 +0000367 return createTemplateValueParameterHelper(
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000368 VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000369 getConstantOrNull(Val));
David Blaikie2b380232013-06-22 18:59:11 +0000370}
371
372DITemplateValueParameter
373DIBuilder::createTemplateTemplateParameter(DIDescriptor Context, StringRef Name,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000374 DIType Ty, StringRef Val) {
Duncan P. N. Exon Smith774951f2014-11-15 00:05:04 +0000375 return createTemplateValueParameterHelper(
376 VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000377 MDString::get(VMContext, Val));
David Blaikie2b380232013-06-22 18:59:11 +0000378}
379
380DITemplateValueParameter
381DIBuilder::createTemplateParameterPack(DIDescriptor Context, StringRef Name,
Duncan P. N. Exon Smithb4aa16f2015-02-13 03:35:29 +0000382 DIType Ty, DIArray Val) {
Duncan P. N. Exon Smith774951f2014-11-15 00:05:04 +0000383 return createTemplateValueParameterHelper(
384 VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +0000385 Val.get());
David Blaikie2b380232013-06-22 18:59:11 +0000386}
387
David Blaikiea7310a32013-03-26 23:46:39 +0000388DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
389 DIFile File, unsigned LineNumber,
390 uint64_t SizeInBits,
391 uint64_t AlignInBits,
392 uint64_t OffsetInBits,
393 unsigned Flags, DIType DerivedFrom,
394 DIArray Elements,
Manman Ren27552062013-09-06 23:54:23 +0000395 DIType VTableHolder,
Manman Ren547467b2013-08-27 23:06:40 +0000396 MDNode *TemplateParams,
397 StringRef UniqueIdentifier) {
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000398 assert((!Context || isa<MDScope>(Context)) &&
David Blaikie085abe32013-03-11 23:21:19 +0000399 "createClassType should be called with a valid Context");
400 // TAG_class_type is encoded in DICompositeType format.
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000401 DICompositeType R = MDCompositeType::get(
402 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000403 MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
404 MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags,
405 Elements, 0, MDTypeRef::get(VTableHolder),
406 cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
Manman Ren0b410402013-08-29 23:17:54 +0000407 if (!UniqueIdentifier.empty())
408 retainType(R);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000409 trackIfUnresolved(R);
David Blaikie085abe32013-03-11 23:21:19 +0000410 return R;
Eric Christopher17426692012-07-06 02:35:57 +0000411}
412
David Blaikiebbe0e1a2013-02-25 01:07:18 +0000413DICompositeType DIBuilder::createStructType(DIDescriptor Context,
414 StringRef Name, DIFile File,
415 unsigned LineNumber,
416 uint64_t SizeInBits,
417 uint64_t AlignInBits,
418 unsigned Flags, DIType DerivedFrom,
419 DIArray Elements,
420 unsigned RunTimeLang,
Manman Ren27552062013-09-06 23:54:23 +0000421 DIType VTableHolder,
Manman Ren547467b2013-08-27 23:06:40 +0000422 StringRef UniqueIdentifier) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000423 DICompositeType R = MDCompositeType::get(
424 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000425 MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
426 MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements,
427 RunTimeLang, MDTypeRef::get(VTableHolder), nullptr, UniqueIdentifier);
Manman Ren0b410402013-08-29 23:17:54 +0000428 if (!UniqueIdentifier.empty())
429 retainType(R);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000430 trackIfUnresolved(R);
David Blaikie085abe32013-03-11 23:21:19 +0000431 return R;
Devang Patel746660f2010-12-07 23:25:47 +0000432}
433
Eric Christopher17dd8f02013-04-02 22:55:52 +0000434DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
435 DIFile File, unsigned LineNumber,
436 uint64_t SizeInBits,
437 uint64_t AlignInBits, unsigned Flags,
438 DIArray Elements,
Manman Ren547467b2013-08-27 23:06:40 +0000439 unsigned RunTimeLang,
440 StringRef UniqueIdentifier) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000441 DICompositeType R = MDCompositeType::get(
442 VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000443 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
444 SizeInBits, AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr,
445 nullptr, UniqueIdentifier);
Manman Ren0b410402013-08-29 23:17:54 +0000446 if (!UniqueIdentifier.empty())
447 retainType(R);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000448 trackIfUnresolved(R);
Manman Ren0b410402013-08-29 23:17:54 +0000449 return R;
Devang Patel89ea4f22010-12-08 01:50:15 +0000450}
451
Manman Renf8a19672014-07-28 22:24:06 +0000452DISubroutineType DIBuilder::createSubroutineType(DIFile File,
453 DITypeArray ParameterTypes,
454 unsigned Flags) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000455 return MDSubroutineType::get(VMContext, Flags, ParameterTypes);
Devang Patel89ea4f22010-12-08 01:50:15 +0000456}
457
David Blaikief11de2f2013-02-18 06:41:57 +0000458DICompositeType DIBuilder::createEnumerationType(
459 DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
460 uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
Manman Ren547467b2013-08-27 23:06:40 +0000461 DIType UnderlyingType, StringRef UniqueIdentifier) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000462 DICompositeType CTy = MDCompositeType::get(
463 VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000464 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
465 MDTypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements,
466 0, nullptr, nullptr, UniqueIdentifier);
David Blaikie4f6bf27a2013-11-18 23:33:32 +0000467 AllEnumTypes.push_back(CTy);
Manman Ren0b410402013-08-29 23:17:54 +0000468 if (!UniqueIdentifier.empty())
David Blaikie4f6bf27a2013-11-18 23:33:32 +0000469 retainType(CTy);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000470 trackIfUnresolved(CTy);
David Blaikie4f6bf27a2013-11-18 23:33:32 +0000471 return CTy;
Devang Patel89ea4f22010-12-08 01:50:15 +0000472}
473
David Blaikief11de2f2013-02-18 06:41:57 +0000474DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
475 DIType Ty, DIArray Subscripts) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000476 auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000477 nullptr, 0, nullptr, MDTypeRef::get(Ty), Size,
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000478 AlignInBits, 0, 0, Subscripts, 0, nullptr);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000479 trackIfUnresolved(R);
480 return R;
Devang Patel89ea4f22010-12-08 01:50:15 +0000481}
482
Manman Ren60711602013-06-07 03:13:46 +0000483DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
484 DIType Ty, DIArray Subscripts) {
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000485 auto *R =
486 MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
487 nullptr, MDTypeRef::get(Ty), Size, AlignInBits, 0,
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000488 DebugNode::FlagVector, Subscripts, 0, nullptr);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000489 trackIfUnresolved(R);
490 return R;
Devang Patel89ea4f22010-12-08 01:50:15 +0000491}
Devang Patel746660f2010-12-07 23:25:47 +0000492
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +0000493static DIType createTypeWithFlags(LLVMContext &Context, DIType Ty,
494 unsigned FlagsToSet) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000495 TempMDType NewTy = cast<MDType>(static_cast<MDNode *>(Ty))->clone();
496 NewTy->setFlags(NewTy->getFlags() | FlagsToSet);
497 return MDNode::replaceWithUniqued(std::move(NewTy));
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +0000498}
499
Devang Patel9b412732011-02-22 18:56:12 +0000500DIType DIBuilder::createArtificialType(DIType Ty) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000501 // FIXME: Restrict this to the nodes where it's valid.
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000502 if (Ty->isArtificial())
Devang Patel57c5a202010-11-04 15:01:38 +0000503 return Ty;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000504 return createTypeWithFlags(VMContext, Ty, DebugNode::FlagArtificial);
Devang Patel57c5a202010-11-04 15:01:38 +0000505}
Devang Patel746660f2010-12-07 23:25:47 +0000506
Eric Christophere3417762012-09-12 23:36:19 +0000507DIType DIBuilder::createObjectPointerType(DIType Ty) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000508 // FIXME: Restrict this to the nodes where it's valid.
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000509 if (Ty->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000510 return Ty;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000511 unsigned Flags = DebugNode::FlagObjectPointer | DebugNode::FlagArtificial;
Duncan P. N. Exon Smith176b6912014-10-03 20:01:09 +0000512 return createTypeWithFlags(VMContext, Ty, Flags);
Eric Christophere3417762012-09-12 23:36:19 +0000513}
514
Duncan P. N. Exon Smithd9ccfb92015-03-27 23:00:49 +0000515void DIBuilder::retainType(DIType T) {
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000516 assert(T && "Expected non-null type");
Duncan P. N. Exon Smithd9ccfb92015-03-27 23:00:49 +0000517 AllRetainTypes.emplace_back(T);
518}
Devang Patel89ea4f22010-12-08 01:50:15 +0000519
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000520DIBasicType DIBuilder::createUnspecifiedParameter() { return nullptr; }
Devang Patel89ea4f22010-12-08 01:50:15 +0000521
Eric Christopher98f9c232013-10-15 23:31:31 +0000522DICompositeType
523DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIDescriptor Scope,
524 DIFile F, unsigned Line, unsigned RuntimeLang,
525 uint64_t SizeInBits, uint64_t AlignInBits,
526 StringRef UniqueIdentifier) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000527 // FIXME: Define in terms of createReplaceableForwardDecl() by calling
528 // replaceWithUniqued().
529 DICompositeType RetTy = MDCompositeType::get(
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000530 VMContext, Tag, Name, F, Line,
531 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
532 SizeInBits, AlignInBits, 0, DIDescriptor::FlagFwdDecl, nullptr,
533 RuntimeLang, nullptr, nullptr, UniqueIdentifier);
David Blaikied3f094a2014-05-06 03:41:57 +0000534 if (!UniqueIdentifier.empty())
535 retainType(RetTy);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000536 trackIfUnresolved(RetTy);
David Blaikied3f094a2014-05-06 03:41:57 +0000537 return RetTy;
538}
539
Adrian Prantl534a81a2015-02-11 17:45:05 +0000540DICompositeType DIBuilder::createReplaceableCompositeType(
David Blaikied3f094a2014-05-06 03:41:57 +0000541 unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F, unsigned Line,
542 unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits,
Adrian Prantl534a81a2015-02-11 17:45:05 +0000543 unsigned Flags, StringRef UniqueIdentifier) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000544 DICompositeType RetTy =
545 MDCompositeType::getTemporary(
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000546 VMContext, Tag, Name, F, Line,
547 MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
548 SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
549 nullptr, UniqueIdentifier)
550 .release();
Manman Ren0b410402013-08-29 23:17:54 +0000551 if (!UniqueIdentifier.empty())
552 retainType(RetTy);
Adrian Prantlea7f1c22015-02-17 19:17:39 +0000553 trackIfUnresolved(RetTy);
Manman Rend0e67aa2013-07-02 18:37:35 +0000554 return RetTy;
Eric Christopherae56eec2012-02-08 00:22:26 +0000555}
556
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000557DIArray DIBuilder::getOrCreateArray(ArrayRef<Metadata *> Elements) {
Jay Foaddbf81d82011-04-24 10:11:03 +0000558 return DIArray(MDNode::get(VMContext, Elements));
Devang Patel746660f2010-12-07 23:25:47 +0000559}
560
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000561DITypeArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) {
562 SmallVector<llvm::Metadata *, 16> Elts;
Manman Ren1a125c92014-07-28 19:33:20 +0000563 for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
564 if (Elements[i] && isa<MDNode>(Elements[i]))
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000565 Elts.push_back(MDTypeRef::get(cast<MDType>(Elements[i])));
Manman Ren1a125c92014-07-28 19:33:20 +0000566 else
567 Elts.push_back(Elements[i]);
568 }
569 return DITypeArray(MDNode::get(VMContext, Elts));
570}
571
Bill Wendlingd7767122012-12-04 21:34:03 +0000572DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000573 return MDSubrange::get(VMContext, Count, Lo);
Devang Patel89ea4f22010-12-08 01:50:15 +0000574}
575
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000576static void checkGlobalVariableScope(DIDescriptor Context) {
Duncan P. N. Exon Smith430220f2015-04-06 23:34:41 +0000577#ifndef NDEBUG
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000578 if (auto *CT =
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000579 dyn_cast_or_null<MDCompositeType>(getNonCompileUnitScope(Context)))
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000580 assert(CT->getIdentifier().empty() &&
Manman Renbfd2b8292014-11-21 19:47:48 +0000581 "Context of a global variable should not be a type with identifier");
Duncan P. N. Exon Smith430220f2015-04-06 23:34:41 +0000582#endif
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000583}
584
Duncan P. N. Exon Smithdbf64acd2014-11-15 00:23:49 +0000585DIGlobalVariable DIBuilder::createGlobalVariable(
586 DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000587 unsigned LineNumber, DIType Ty, bool isLocalToUnit, Constant *Val,
Duncan P. N. Exon Smithdbf64acd2014-11-15 00:23:49 +0000588 MDNode *Decl) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000589 checkGlobalVariableScope(Context);
590
Duncan P. N. Exon Smithb273d062015-04-16 01:37:00 +0000591 auto *N = MDGlobalVariable::get(VMContext, cast_or_null<MDScope>(Context),
592 Name, LinkageName, F, LineNumber,
593 MDTypeRef::get(Ty), isLocalToUnit, true, Val,
594 cast_or_null<MDDerivedType>(Decl));
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000595 AllGVs.push_back(N);
596 return N;
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000597}
598
Duncan P. N. Exon Smithdbf64acd2014-11-15 00:23:49 +0000599DIGlobalVariable DIBuilder::createTempGlobalVariableFwdDecl(
600 DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000601 unsigned LineNumber, DIType Ty, bool isLocalToUnit, Constant *Val,
Duncan P. N. Exon Smithdbf64acd2014-11-15 00:23:49 +0000602 MDNode *Decl) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000603 checkGlobalVariableScope(Context);
604
Duncan P. N. Exon Smith3d2afaa2015-03-27 17:29:58 +0000605 return MDGlobalVariable::getTemporary(
Duncan P. N. Exon Smithb273d062015-04-16 01:37:00 +0000606 VMContext, cast_or_null<MDScope>(Context), Name, LinkageName, F,
607 LineNumber, MDTypeRef::get(Ty), isLocalToUnit, false, Val,
608 cast_or_null<MDDerivedType>(Decl))
609 .release();
Devang Patel746660f2010-12-07 23:25:47 +0000610}
611
Devang Patel9b412732011-02-22 18:56:12 +0000612DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
Devang Patel63f83cd2010-12-07 23:58:00 +0000613 StringRef Name, DIFile File,
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000614 unsigned LineNo, DIType Ty,
Devang Patel40eee1e2011-03-01 22:58:13 +0000615 bool AlwaysPreserve, unsigned Flags,
616 unsigned ArgNo) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000617 // FIXME: Why getNonCompileUnitScope()?
618 // FIXME: Why is "!Context" okay here?
619 // FIXME: WHy doesn't this check for a subprogram or lexical block (AFAICT
620 // the only valid scopes)?
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000621 DIScope Context = getNonCompileUnitScope(Scope);
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000622
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000623 auto *Node = MDLocalVariable::get(
Duncan P. N. Exon Smithb273d062015-04-16 01:37:00 +0000624 VMContext, Tag, cast_or_null<MDLocalScope>(Context), Name, File, LineNo,
625 MDTypeRef::get(Ty), ArgNo, Flags);
Devang Patel63f83cd2010-12-07 23:58:00 +0000626 if (AlwaysPreserve) {
627 // The optimizer may remove local variable. If there is an interest
628 // to preserve variable info in such situation then stash it in a
629 // named mdnode.
630 DISubprogram Fn(getDISubprogram(Scope));
Duncan P. N. Exon Smith3bfffde2014-10-15 16:11:41 +0000631 assert(Fn && "Missing subprogram for local variable");
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000632 PreservedVariables[Fn].emplace_back(Node);
Devang Patel63f83cd2010-12-07 23:58:00 +0000633 }
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000634 return Node;
Devang Patel63f83cd2010-12-07 23:58:00 +0000635}
636
Duncan P. N. Exon Smithbd75ad42015-02-09 22:13:27 +0000637DIExpression DIBuilder::createExpression(ArrayRef<uint64_t> Addr) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000638 return MDExpression::get(VMContext, Addr);
Devang Patel746660f2010-12-07 23:25:47 +0000639}
640
Duncan P. N. Exon Smithbd75ad42015-02-09 22:13:27 +0000641DIExpression DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
642 // TODO: Remove the callers of this signed version and delete.
643 SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
644 return createExpression(Addr);
645}
646
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000647DIExpression DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
648 unsigned SizeInBytes) {
649 uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
650 return MDExpression::get(VMContext, Addr);
Duncan P. N. Exon Smith9affbba2014-10-01 21:32:12 +0000651}
652
Eric Christopher98f9c232013-10-15 23:31:31 +0000653DISubprogram DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
654 StringRef LinkageName, DIFile File,
655 unsigned LineNo, DICompositeType Ty,
Manman Renc50fa112013-10-10 18:40:01 +0000656 bool isLocalToUnit, bool isDefinition,
Eric Christopher98f9c232013-10-15 23:31:31 +0000657 unsigned ScopeLine, unsigned Flags,
658 bool isOptimized, Function *Fn,
659 MDNode *TParams, MDNode *Decl) {
Manman Renc50fa112013-10-10 18:40:01 +0000660 // dragonegg does not generate identifier for types, so using an empty map
661 // to resolve the context should be fine.
662 DITypeIdentifierMap EmptyMap;
663 return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
664 LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
665 Flags, isOptimized, Fn, TParams, Decl);
666}
667
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000668DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
669 StringRef LinkageName, DIFile File,
670 unsigned LineNo, DICompositeType Ty,
671 bool isLocalToUnit, bool isDefinition,
672 unsigned ScopeLine, unsigned Flags,
673 bool isOptimized, Function *Fn,
674 MDNode *TParams, MDNode *Decl) {
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000675 assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000676 "function types should be subroutines");
677 auto *Node = MDSubprogram::get(
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000678 VMContext, MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000679 Name, LinkageName, File, LineNo, cast_or_null<MDSubroutineType>(Ty),
Duncan P. N. Exon Smith35ef22c2015-04-15 23:19:27 +0000680 isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized,
681 Fn, cast_or_null<MDTuple>(TParams), cast_or_null<MDSubprogram>(Decl),
Duncan P. N. Exon Smith869db502015-03-30 16:19:15 +0000682 MDTuple::getTemporary(VMContext, None).release());
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000683
684 if (isDefinition)
685 AllSubprograms.push_back(Node);
686 trackIfUnresolved(Node);
687 return Node;
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000688}
689
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000690DISubprogram
691DIBuilder::createTempFunctionFwdDecl(DIDescriptor Context, StringRef Name,
692 StringRef LinkageName, DIFile File,
693 unsigned LineNo, DICompositeType Ty,
694 bool isLocalToUnit, bool isDefinition,
695 unsigned ScopeLine, unsigned Flags,
696 bool isOptimized, Function *Fn,
697 MDNode *TParams, MDNode *Decl) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000698 return MDSubprogram::getTemporary(
Duncan P. N. Exon Smith3ec5fa62015-04-06 19:03:45 +0000699 VMContext,
700 MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))), Name,
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000701 LinkageName, File, LineNo, cast_or_null<MDSubroutineType>(Ty),
702 isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags,
703 isOptimized, Fn, cast_or_null<MDTuple>(TParams),
704 cast_or_null<MDSubprogram>(Decl), nullptr)
Duncan P. N. Exon Smith35ef22c2015-04-15 23:19:27 +0000705 .release();
Frederic Riss5e6bc9e2014-09-17 09:28:34 +0000706}
707
Eric Christopher98f9c232013-10-15 23:31:31 +0000708DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
709 StringRef LinkageName, DIFile F,
David Blaikie5174c842013-05-22 23:22:18 +0000710 unsigned LineNo, DICompositeType Ty,
Eric Christopher98f9c232013-10-15 23:31:31 +0000711 bool isLocalToUnit, bool isDefinition,
Devang Patelb68c6232010-12-08 20:42:44 +0000712 unsigned VK, unsigned VIndex,
Eric Christopher98f9c232013-10-15 23:31:31 +0000713 DIType VTableHolder, unsigned Flags,
714 bool isOptimized, Function *Fn,
Devang Patel9f738842011-04-05 22:52:06 +0000715 MDNode *TParam) {
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000716 assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
David Blaikie5174c842013-05-22 23:22:18 +0000717 "function types should be subroutines");
Eric Christopher5cb56322013-10-15 23:31:36 +0000718 assert(getNonCompileUnitScope(Context) &&
719 "Methods should have both a Context and a context that isn't "
720 "the compile unit.");
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000721 // FIXME: Do we want to use different scope/lines?
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000722 auto *SP = MDSubprogram::get(
Duncan P. N. Exon Smith35ef22c2015-04-15 23:19:27 +0000723 VMContext, MDScopeRef::get(cast<MDScope>(Context)), Name, LinkageName, F,
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000724 LineNo, cast_or_null<MDSubroutineType>(Ty), isLocalToUnit, isDefinition,
725 LineNo, MDTypeRef::get(VTableHolder), VK, VIndex, Flags, isOptimized, Fn,
726 cast_or_null<MDTuple>(TParam), nullptr, nullptr);
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000727
David Blaikie595eb442013-02-18 07:10:22 +0000728 if (isDefinition)
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000729 AllSubprograms.push_back(SP);
730 trackIfUnresolved(SP);
731 return SP;
Devang Patelb68c6232010-12-08 20:42:44 +0000732}
733
Devang Patel9b412732011-02-22 18:56:12 +0000734DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
Devang Patel746660f2010-12-07 23:25:47 +0000735 DIFile File, unsigned LineNo) {
Duncan P. N. Exon Smitha5099dc2015-04-06 19:49:39 +0000736 return MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
737 LineNo);
Devang Patel746660f2010-12-07 23:25:47 +0000738}
739
Eric Christopher6647b832011-10-11 22:59:11 +0000740DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
David Blaikie2f3f76f2014-08-21 22:45:21 +0000741 DIFile File,
742 unsigned Discriminator) {
Duncan P. N. Exon Smith35ef22c2015-04-15 23:19:27 +0000743 return MDLexicalBlockFile::get(VMContext, Scope, File, Discriminator);
Eric Christopher6647b832011-10-11 22:59:11 +0000744}
745
Devang Patel9b412732011-02-22 18:56:12 +0000746DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
David Blaikie2f3f76f2014-08-21 22:45:21 +0000747 unsigned Line, unsigned Col) {
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000748 // Make these distinct, to avoid merging two lexical blocks on the same
749 // file/line/column.
Duncan P. N. Exon Smitha5099dc2015-04-06 19:49:39 +0000750 return MDLexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
Duncan P. N. Exon Smith35ef22c2015-04-15 23:19:27 +0000751 File, Line, Col);
Devang Patel89ea4f22010-12-08 01:50:15 +0000752}
753
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000754static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
755 assert(V && "no value passed to dbg intrinsic");
756 return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
757}
758
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000759static Instruction *withDebugLoc(Instruction *I, const MDLocation *DL) {
760 I->setDebugLoc(const_cast<MDLocation *>(DL));
761 return I;
762}
763
Devang Patel9b412732011-02-22 18:56:12 +0000764Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000765 DIExpression Expr, const MDLocation *DL,
Devang Patel746660f2010-12-07 23:25:47 +0000766 Instruction *InsertBefore) {
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000767 assert(VarInfo && "empty or invalid DIVariable passed to dbg.declare");
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000768 assert(DL && "Expected debug loc");
769 assert(DL->getScope()->getSubprogram() ==
770 VarInfo->getScope()->getSubprogram() &&
771 "Expected matching subprograms");
Devang Patel746660f2010-12-07 23:25:47 +0000772 if (!DeclareFn)
773 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
774
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000775 trackIfUnresolved(VarInfo);
776 trackIfUnresolved(Expr);
777 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
778 MetadataAsValue::get(VMContext, VarInfo),
779 MetadataAsValue::get(VMContext, Expr)};
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000780 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
Devang Patel746660f2010-12-07 23:25:47 +0000781}
782
Devang Patel9b412732011-02-22 18:56:12 +0000783Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000784 DIExpression Expr, const MDLocation *DL,
Devang Patel746660f2010-12-07 23:25:47 +0000785 BasicBlock *InsertAtEnd) {
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000786 assert(VarInfo && "empty or invalid DIVariable passed to dbg.declare");
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000787 assert(DL && "Expected debug loc");
788 assert(DL->getScope()->getSubprogram() ==
789 VarInfo->getScope()->getSubprogram() &&
790 "Expected matching subprograms");
Devang Patel746660f2010-12-07 23:25:47 +0000791 if (!DeclareFn)
792 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
793
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000794 trackIfUnresolved(VarInfo);
795 trackIfUnresolved(Expr);
796 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
797 MetadataAsValue::get(VMContext, VarInfo),
798 MetadataAsValue::get(VMContext, Expr)};
Devang Patel746660f2010-12-07 23:25:47 +0000799
800 // If this block already has a terminator then insert this intrinsic
801 // before the terminator.
802 if (TerminatorInst *T = InsertAtEnd->getTerminator())
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000803 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL);
804 return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
Devang Patel746660f2010-12-07 23:25:47 +0000805}
806
Devang Patel9b412732011-02-22 18:56:12 +0000807Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
Devang Patel746660f2010-12-07 23:25:47 +0000808 DIVariable VarInfo,
Adrian Prantl87b7eb92014-10-01 18:55:02 +0000809 DIExpression Expr,
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000810 const MDLocation *DL,
Devang Patel746660f2010-12-07 23:25:47 +0000811 Instruction *InsertBefore) {
812 assert(V && "no value passed to dbg.value");
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000813 assert(VarInfo && "empty or invalid DIVariable passed to dbg.value");
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000814 assert(DL && "Expected debug loc");
815 assert(DL->getScope()->getSubprogram() ==
816 VarInfo->getScope()->getSubprogram() &&
817 "Expected matching subprograms");
Devang Patel746660f2010-12-07 23:25:47 +0000818 if (!ValueFn)
819 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
820
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000821 trackIfUnresolved(VarInfo);
822 trackIfUnresolved(Expr);
823 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
824 ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
825 MetadataAsValue::get(VMContext, VarInfo),
826 MetadataAsValue::get(VMContext, Expr)};
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000827 return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
Devang Patel746660f2010-12-07 23:25:47 +0000828}
829
Devang Patel9b412732011-02-22 18:56:12 +0000830Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
Devang Patel746660f2010-12-07 23:25:47 +0000831 DIVariable VarInfo,
Adrian Prantl87b7eb92014-10-01 18:55:02 +0000832 DIExpression Expr,
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000833 const MDLocation *DL,
Devang Patel746660f2010-12-07 23:25:47 +0000834 BasicBlock *InsertAtEnd) {
835 assert(V && "no value passed to dbg.value");
Duncan P. N. Exon Smith9d1cf4c2015-04-06 23:18:49 +0000836 assert(VarInfo && "empty or invalid DIVariable passed to dbg.value");
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000837 assert(DL && "Expected debug loc");
838 assert(DL->getScope()->getSubprogram() ==
839 VarInfo->getScope()->getSubprogram() &&
840 "Expected matching subprograms");
Devang Patel746660f2010-12-07 23:25:47 +0000841 if (!ValueFn)
842 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
843
Duncan P. N. Exon Smith5bf8fef2014-12-09 18:38:53 +0000844 trackIfUnresolved(VarInfo);
845 trackIfUnresolved(Expr);
846 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
847 ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
848 MetadataAsValue::get(VMContext, VarInfo),
849 MetadataAsValue::get(VMContext, Expr)};
Duncan P. N. Exon Smithcd1aecf2015-04-15 21:18:07 +0000850
851 return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
Devang Patel746660f2010-12-07 23:25:47 +0000852}
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000853
854void DIBuilder::replaceVTableHolder(DICompositeType &T, DICompositeType VTableHolder) {
Duncan P. N. Exon Smith8d33fdc2015-04-07 04:12:02 +0000855 {
856 TypedTrackingMDRef<MDCompositeTypeBase> N(T);
857 N->replaceVTableHolder(MDTypeRef::get(VTableHolder));
858 T = N.get();
859 }
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000860
861 // If this didn't create a self-reference, just return.
862 if (T != VTableHolder)
863 return;
864
Adrian Prantl18a25b02015-02-11 17:45:10 +0000865 // Look for unresolved operands. T will drop RAUW support, orphaning any
866 // cycles underneath it.
867 if (T->isResolved())
868 for (const MDOperand &O : T->operands())
869 if (auto *N = dyn_cast_or_null<MDNode>(O))
870 trackIfUnresolved(N);
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000871}
872
873void DIBuilder::replaceArrays(DICompositeType &T, DIArray Elements,
874 DIArray TParams) {
Duncan P. N. Exon Smith8d33fdc2015-04-07 04:12:02 +0000875 {
876 TypedTrackingMDRef<MDCompositeTypeBase> N(T);
877 if (Elements)
Duncan P. N. Exon Smith000fa2c2015-04-07 04:14:33 +0000878 N->replaceElements(Elements);
Duncan P. N. Exon Smith8d33fdc2015-04-07 04:12:02 +0000879 if (TParams)
Duncan P. N. Exon Smithcb9b43b2015-04-07 17:30:52 +0000880 N->replaceTemplateParams(MDTemplateParameterArray(TParams));
Duncan P. N. Exon Smith8d33fdc2015-04-07 04:12:02 +0000881 T = N.get();
882 }
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000883
884 // If T isn't resolved, there's no problem.
885 if (!T->isResolved())
886 return;
887
888 // If "T" is resolved, it may be due to a self-reference cycle. Track the
889 // arrays explicitly if they're unresolved, or else the cycles will be
890 // orphaned.
891 if (Elements)
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +0000892 trackIfUnresolved(Elements.get());
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000893 if (TParams)
Duncan P. N. Exon Smith11344732015-04-07 16:50:39 +0000894 trackIfUnresolved(TParams.get());
Duncan P. N. Exon Smith97f07c22014-12-18 00:46:16 +0000895}