Bug Summary

File:lib/IR/DebugInfoMetadata.cpp
Warning:line 932, column 28
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name DebugInfoMetadata.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn338205/build-llvm/lib/IR -I /build/llvm-toolchain-snapshot-7~svn338205/lib/IR -I /build/llvm-toolchain-snapshot-7~svn338205/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn338205/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/lib/gcc/x86_64-linux-gnu/8/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn338205/build-llvm/lib/IR -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-07-29-043837-17923-1 -x c++ /build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp -faddrsig
1//===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the debug info Metadata classes.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/IR/DebugInfoMetadata.h"
15#include "LLVMContextImpl.h"
16#include "MetadataImpl.h"
17#include "llvm/ADT/SmallPtrSet.h"
18#include "llvm/ADT/StringSwitch.h"
19#include "llvm/IR/DIBuilder.h"
20#include "llvm/IR/Function.h"
21#include "llvm/IR/Instructions.h"
22
23using namespace llvm;
24
25DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
26 unsigned Column, ArrayRef<Metadata *> MDs)
27 : MDNode(C, DILocationKind, Storage, MDs) {
28 assert((MDs.size() == 1 || MDs.size() == 2) &&(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2
) && "Expected a scope and optional inlined-at") ? void
(0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 29, __extension__ __PRETTY_FUNCTION__))
29 "Expected a scope and optional inlined-at")(static_cast <bool> ((MDs.size() == 1 || MDs.size() == 2
) && "Expected a scope and optional inlined-at") ? void
(0) : __assert_fail ("(MDs.size() == 1 || MDs.size() == 2) && \"Expected a scope and optional inlined-at\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 29, __extension__ __PRETTY_FUNCTION__))
;
30
31 // Set line and column.
32 assert(Column < (1u << 16) && "Expected 16-bit column")(static_cast <bool> (Column < (1u << 16) &&
"Expected 16-bit column") ? void (0) : __assert_fail ("Column < (1u << 16) && \"Expected 16-bit column\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 32, __extension__ __PRETTY_FUNCTION__))
;
33
34 SubclassData32 = Line;
35 SubclassData16 = Column;
36}
37
38static void adjustColumn(unsigned &Column) {
39 // Set to unknown on overflow. We only have 16 bits to play with here.
40 if (Column >= (1u << 16))
41 Column = 0;
42}
43
44DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
45 unsigned Column, Metadata *Scope,
46 Metadata *InlinedAt, StorageType Storage,
47 bool ShouldCreate) {
48 // Fixup column.
49 adjustColumn(Column);
50
51 if (Storage == Uniqued) {
52 if (auto *N =
53 getUniqued(Context.pImpl->DILocations,
54 DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
55 return N;
56 if (!ShouldCreate)
57 return nullptr;
58 } else {
59 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 59, __extension__ __PRETTY_FUNCTION__))
;
60 }
61
62 SmallVector<Metadata *, 2> Ops;
63 Ops.push_back(Scope);
64 if (InlinedAt)
65 Ops.push_back(InlinedAt);
66 return storeImpl(new (Ops.size())
67 DILocation(Context, Storage, Line, Column, Ops),
68 Storage, Context.pImpl->DILocations);
69}
70
71const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
72 const DILocation *LocB,
73 bool GenerateLocation) {
74 if (!LocA || !LocB)
75 return nullptr;
76
77 if (LocA == LocB || !LocA->canDiscriminate(*LocB))
78 return LocA;
79
80 if (!GenerateLocation)
81 return nullptr;
82
83 SmallPtrSet<DILocation *, 5> InlinedLocationsA;
84 for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
85 InlinedLocationsA.insert(L);
86 const DILocation *Result = LocB;
87 for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {
88 Result = L;
89 if (InlinedLocationsA.count(L))
90 break;
91 }
92 return DILocation::get(Result->getContext(), 0, 0, Result->getScope(),
93 Result->getInlinedAt());
94}
95
96DINode::DIFlags DINode::getFlag(StringRef Flag) {
97 return StringSwitch<DIFlags>(Flag)
98#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
99#include "llvm/IR/DebugInfoFlags.def"
100 .Default(DINode::FlagZero);
101}
102
103StringRef DINode::getFlagString(DIFlags Flag) {
104 switch (Flag) {
105#define HANDLE_DI_FLAG(ID, NAME) \
106 case Flag##NAME: \
107 return "DIFlag" #NAME;
108#include "llvm/IR/DebugInfoFlags.def"
109 }
110 return "";
111}
112
113DINode::DIFlags DINode::splitFlags(DIFlags Flags,
114 SmallVectorImpl<DIFlags> &SplitFlags) {
115 // Flags that are packed together need to be specially handled, so
116 // that, for example, we emit "DIFlagPublic" and not
117 // "DIFlagPrivate | DIFlagProtected".
118 if (DIFlags A = Flags & FlagAccessibility) {
119 if (A == FlagPrivate)
120 SplitFlags.push_back(FlagPrivate);
121 else if (A == FlagProtected)
122 SplitFlags.push_back(FlagProtected);
123 else
124 SplitFlags.push_back(FlagPublic);
125 Flags &= ~A;
126 }
127 if (DIFlags R = Flags & FlagPtrToMemberRep) {
128 if (R == FlagSingleInheritance)
129 SplitFlags.push_back(FlagSingleInheritance);
130 else if (R == FlagMultipleInheritance)
131 SplitFlags.push_back(FlagMultipleInheritance);
132 else
133 SplitFlags.push_back(FlagVirtualInheritance);
134 Flags &= ~R;
135 }
136 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
137 Flags &= ~FlagIndirectVirtualBase;
138 SplitFlags.push_back(FlagIndirectVirtualBase);
139 }
140
141#define HANDLE_DI_FLAG(ID, NAME) \
142 if (DIFlags Bit = Flags & Flag##NAME) { \
143 SplitFlags.push_back(Bit); \
144 Flags &= ~Bit; \
145 }
146#include "llvm/IR/DebugInfoFlags.def"
147 return Flags;
148}
149
150DIScopeRef DIScope::getScope() const {
151 if (auto *T = dyn_cast<DIType>(this))
152 return T->getScope();
153
154 if (auto *SP = dyn_cast<DISubprogram>(this))
155 return SP->getScope();
156
157 if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
158 return LB->getScope();
159
160 if (auto *NS = dyn_cast<DINamespace>(this))
161 return NS->getScope();
162
163 if (auto *M = dyn_cast<DIModule>(this))
164 return M->getScope();
165
166 assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&(static_cast <bool> ((isa<DIFile>(this) || isa<
DICompileUnit>(this)) && "Unhandled type of scope."
) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 167, __extension__ __PRETTY_FUNCTION__))
167 "Unhandled type of scope.")(static_cast <bool> ((isa<DIFile>(this) || isa<
DICompileUnit>(this)) && "Unhandled type of scope."
) ? void (0) : __assert_fail ("(isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 167, __extension__ __PRETTY_FUNCTION__))
;
168 return nullptr;
169}
170
171StringRef DIScope::getName() const {
172 if (auto *T = dyn_cast<DIType>(this))
173 return T->getName();
174 if (auto *SP = dyn_cast<DISubprogram>(this))
175 return SP->getName();
176 if (auto *NS = dyn_cast<DINamespace>(this))
177 return NS->getName();
178 if (auto *M = dyn_cast<DIModule>(this))
179 return M->getName();
180 assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 182, __extension__ __PRETTY_FUNCTION__))
181 isa<DICompileUnit>(this)) &&(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 182, __extension__ __PRETTY_FUNCTION__))
182 "Unhandled type of scope.")(static_cast <bool> ((isa<DILexicalBlockBase>(this
) || isa<DIFile>(this) || isa<DICompileUnit>(this
)) && "Unhandled type of scope.") ? void (0) : __assert_fail
("(isa<DILexicalBlockBase>(this) || isa<DIFile>(this) || isa<DICompileUnit>(this)) && \"Unhandled type of scope.\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 182, __extension__ __PRETTY_FUNCTION__))
;
183 return "";
184}
185
186#ifndef NDEBUG
187static bool isCanonical(const MDString *S) {
188 return !S || !S->getString().empty();
189}
190#endif
191
192GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
193 MDString *Header,
194 ArrayRef<Metadata *> DwarfOps,
195 StorageType Storage, bool ShouldCreate) {
196 unsigned Hash = 0;
197 if (Storage == Uniqued) {
198 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
199 if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
200 return N;
201 if (!ShouldCreate)
202 return nullptr;
203 Hash = Key.getHash();
204 } else {
205 assert(ShouldCreate && "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 205, __extension__ __PRETTY_FUNCTION__))
;
206 }
207
208 // Use a nullptr for empty headers.
209 assert(isCanonical(Header) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Header) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Header) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 Metadata *PreOps[] = {Header};
211 return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
212 Context, Storage, Hash, Tag, PreOps, DwarfOps),
213 Storage, Context.pImpl->GenericDINodes);
214}
215
216void GenericDINode::recalculateHash() {
217 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
218}
219
220#define UNWRAP_ARGS_IMPL(...)... __VA_ARGS__
221#define UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS UNWRAP_ARGS_IMPL ARGS
222#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->CLASSs, CLASSInfo::KeyTy(UNWRAP_ARGS_IMPL ARGS))) return
N; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 222, __extension__ __PRETTY_FUNCTION__)); } } while (false)
\
223 do { \
224 if (Storage == Uniqued) { \
225 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
226 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS))) \
227 return N; \
228 if (!ShouldCreate) \
229 return nullptr; \
230 } else { \
231 assert(ShouldCreate && \(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 232, __extension__ __PRETTY_FUNCTION__))
232 "Expected non-uniqued nodes to always be created")(static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 232, __extension__ __PRETTY_FUNCTION__))
; \
233 } \
234 } while (false)
235#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, UNWRAP_ARGS_IMPL ARGS, OPS), Storage, Context.pImpl->CLASSs
)
\
236 return storeImpl(new (array_lengthof(OPS)) \
237 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
238 Storage, Context.pImpl->CLASS##s)
239#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS), Storage, Context.pImpl->CLASSs)
\
240 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS), \
241 Storage, Context.pImpl->CLASS##s)
242#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage
, OPS), Storage, Context.pImpl->CLASSs)
\
243 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
244 Storage, Context.pImpl->CLASS##s)
245#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)return storeImpl(new (NUM_OPS) CLASS(Context, Storage, UNWRAP_ARGS_IMPL
ARGS, OPS), Storage, Context.pImpl->CLASSs)
\
246 return storeImpl(new (NUM_OPS) \
247 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)UNWRAP_ARGS_IMPL ARGS, OPS), \
248 Storage, Context.pImpl->CLASS##s)
249
250DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
251 StorageType Storage, bool ShouldCreate) {
252 auto *CountNode = ConstantAsMetadata::get(
253 ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
254 return getImpl(Context, CountNode, Lo, Storage, ShouldCreate);
255}
256
257DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
258 int64_t Lo, StorageType Storage,
259 bool ShouldCreate) {
260 DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, Lo))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubranges, DISubrangeInfo::KeyTy(CountNode, Lo))
) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 260, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
261 Metadata *Ops[] = { CountNode };
262 DEFINE_GETIMPL_STORE(DISubrange, (CountNode, Lo), Ops)return storeImpl(new (array_lengthof(Ops)) DISubrange(Context
, Storage, CountNode, Lo, Ops), Storage, Context.pImpl->DISubranges
)
;
263}
264
265DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, int64_t Value,
266 bool IsUnsigned, MDString *Name,
267 StorageType Storage, bool ShouldCreate) {
268 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 268, __extension__ __PRETTY_FUNCTION__))
;
269 DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, IsUnsigned, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIEnumerators, DIEnumeratorInfo::KeyTy(Value, IsUnsigned
, Name))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 269, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
270 Metadata *Ops[] = {Name};
271 DEFINE_GETIMPL_STORE(DIEnumerator, (Value, IsUnsigned), Ops)return storeImpl(new (array_lengthof(Ops)) DIEnumerator(Context
, Storage, Value, IsUnsigned, Ops), Storage, Context.pImpl->
DIEnumerators)
;
272}
273
274DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
275 MDString *Name, uint64_t SizeInBits,
276 uint32_t AlignInBits, unsigned Encoding,
277 StorageType Storage, bool ShouldCreate) {
278 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 278, __extension__ __PRETTY_FUNCTION__))
;
279 DEFINE_GETIMPL_LOOKUP(DIBasicType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 280, __extension__ __PRETTY_FUNCTION__)); } } while (false)
280 (Tag, Name, SizeInBits, AlignInBits, Encoding))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIBasicTypes, DIBasicTypeInfo::KeyTy(Tag, Name, SizeInBits
, AlignInBits, Encoding))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 280, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
281 Metadata *Ops[] = {nullptr, nullptr, Name};
282 DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIBasicTypes)
283 Ops)return storeImpl(new (array_lengthof(Ops)) DIBasicType(Context
, Storage, Tag, SizeInBits, AlignInBits, Encoding, Ops), Storage
, Context.pImpl->DIBasicTypes)
;
284}
285
286Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
287 switch (getEncoding()) {
288 case dwarf::DW_ATE_signed:
289 case dwarf::DW_ATE_signed_char:
290 return Signedness::Signed;
291 case dwarf::DW_ATE_unsigned:
292 case dwarf::DW_ATE_unsigned_char:
293 return Signedness::Unsigned;
294 default:
295 return None;
296 }
297}
298
299DIDerivedType *DIDerivedType::getImpl(
300 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
301 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
302 uint32_t AlignInBits, uint64_t OffsetInBits,
303 Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Metadata *ExtraData,
304 StorageType Storage, bool ShouldCreate) {
305 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 305, __extension__ __PRETTY_FUNCTION__))
;
306 DEFINE_GETIMPL_LOOKUP(DIDerivedType,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 309, __extension__ __PRETTY_FUNCTION__)); } } while (false)
307 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 309, __extension__ __PRETTY_FUNCTION__)); } } while (false)
308 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 309, __extension__ __PRETTY_FUNCTION__)); } } while (false)
309 ExtraData))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIDerivedTypes, DIDerivedTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, DWARFAddressSpace, Flags, ExtraData))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 309, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
310 Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
311 DEFINE_GETIMPL_STORE(return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
312 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
313 DWARFAddressSpace, Flags), Ops)return storeImpl(new (array_lengthof(Ops)) DIDerivedType(Context
, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, DWARFAddressSpace
, Flags, Ops), Storage, Context.pImpl->DIDerivedTypes)
;
314}
315
316DICompositeType *DICompositeType::getImpl(
317 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
318 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
319 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
320 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
321 Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
322 StorageType Storage, bool ShouldCreate) {
323 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 323, __extension__ __PRETTY_FUNCTION__))
;
324
325 // Keep this in sync with buildODRType.
326 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 329, __extension__ __PRETTY_FUNCTION__)); } } while (false)
327 DICompositeType, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 329, __extension__ __PRETTY_FUNCTION__)); } } while (false)
328 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 329, __extension__ __PRETTY_FUNCTION__)); } } while (false)
329 VTableHolder, TemplateParams, Identifier, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DICompositeTypes, DICompositeTypeInfo::KeyTy(Tag, Name
, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits
, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 329, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
330 Metadata *Ops[] = {File, Scope, Name, BaseType,
331 Elements, VTableHolder, TemplateParams, Identifier,
332 Discriminator};
333 DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
334 AlignInBits, OffsetInBits, Flags),return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
335 Ops)return storeImpl(new (array_lengthof(Ops)) DICompositeType(Context
, Storage, Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits
, Flags, Ops), Storage, Context.pImpl->DICompositeTypes)
;
336}
337
338DICompositeType *DICompositeType::buildODRType(
339 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
340 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
341 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
342 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
343 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
344 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 344, __extension__ __PRETTY_FUNCTION__))
;
345 if (!Context.isODRUniquingDebugTypes())
346 return nullptr;
347 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
348 if (!CT)
349 return CT = DICompositeType::getDistinct(
350 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
351 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
352 VTableHolder, TemplateParams, &Identifier, Discriminator);
353
354 // Only mutate CT if it's a forward declaration and the new operands aren't.
355 assert(CT->getRawIdentifier() == &Identifier && "Wrong ODR identifier?")(static_cast <bool> (CT->getRawIdentifier() == &
Identifier && "Wrong ODR identifier?") ? void (0) : __assert_fail
("CT->getRawIdentifier() == &Identifier && \"Wrong ODR identifier?\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 355, __extension__ __PRETTY_FUNCTION__))
;
356 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
357 return CT;
358
359 // Mutate CT in place. Keep this in sync with getImpl.
360 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
361 Flags);
362 Metadata *Ops[] = {File, Scope, Name, BaseType,
363 Elements, VTableHolder, TemplateParams, &Identifier,
364 Discriminator};
365 assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) ==
(int)CT->getNumOperands() && "Mismatched number of operands"
) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 366, __extension__ __PRETTY_FUNCTION__))
366 "Mismatched number of operands")(static_cast <bool> ((std::end(Ops) - std::begin(Ops)) ==
(int)CT->getNumOperands() && "Mismatched number of operands"
) ? void (0) : __assert_fail ("(std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() && \"Mismatched number of operands\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 366, __extension__ __PRETTY_FUNCTION__))
;
367 for (unsigned I = 0, E = CT->getNumOperands(); I != E; ++I)
368 if (Ops[I] != CT->getOperand(I))
369 CT->setOperand(I, Ops[I]);
370 return CT;
371}
372
373DICompositeType *DICompositeType::getODRType(
374 LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
375 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
376 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
377 DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
378 Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator) {
379 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 379, __extension__ __PRETTY_FUNCTION__))
;
380 if (!Context.isODRUniquingDebugTypes())
381 return nullptr;
382 auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
383 if (!CT)
384 CT = DICompositeType::getDistinct(
385 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
386 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
387 TemplateParams, &Identifier, Discriminator);
388 return CT;
389}
390
391DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
392 MDString &Identifier) {
393 assert(!Identifier.getString().empty() && "Expected valid identifier")(static_cast <bool> (!Identifier.getString().empty() &&
"Expected valid identifier") ? void (0) : __assert_fail ("!Identifier.getString().empty() && \"Expected valid identifier\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 393, __extension__ __PRETTY_FUNCTION__))
;
394 if (!Context.isODRUniquingDebugTypes())
395 return nullptr;
396 return Context.pImpl->DITypeMap->lookup(&Identifier);
397}
398
399DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
400 uint8_t CC, Metadata *TypeArray,
401 StorageType Storage,
402 bool ShouldCreate) {
403 DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC, TypeArray))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubroutineTypes, DISubroutineTypeInfo::KeyTy(Flags
, CC, TypeArray))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 403, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
404 Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
405 DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops)return storeImpl(new (array_lengthof(Ops)) DISubroutineType(Context
, Storage, Flags, CC, Ops), Storage, Context.pImpl->DISubroutineTypes
)
;
406}
407
408// FIXME: Implement this string-enum correspondence with a .def file and macros,
409// so that the association is explicit rather than implied.
410static const char *ChecksumKindName[DIFile::CSK_Last] = {
411 "CSK_MD5",
412 "CSK_SHA1"
413};
414
415StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
416 assert(CSKind <= DIFile::CSK_Last && "Invalid checksum kind")(static_cast <bool> (CSKind <= DIFile::CSK_Last &&
"Invalid checksum kind") ? void (0) : __assert_fail ("CSKind <= DIFile::CSK_Last && \"Invalid checksum kind\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 416, __extension__ __PRETTY_FUNCTION__))
;
417 // The first space was originally the CSK_None variant, which is now
418 // obsolete, but the space is still reserved in ChecksumKind, so we account
419 // for it here.
420 return ChecksumKindName[CSKind - 1];
421}
422
423Optional<DIFile::ChecksumKind> DIFile::getChecksumKind(StringRef CSKindStr) {
424 return StringSwitch<Optional<DIFile::ChecksumKind>>(CSKindStr)
425 .Case("CSK_MD5", DIFile::CSK_MD5)
426 .Case("CSK_SHA1", DIFile::CSK_SHA1)
427 .Default(None);
428}
429
430DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
431 MDString *Directory,
432 Optional<DIFile::ChecksumInfo<MDString *>> CS,
433 Optional<MDString *> Source, StorageType Storage,
434 bool ShouldCreate) {
435 assert(isCanonical(Filename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Filename) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Filename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 435, __extension__ __PRETTY_FUNCTION__))
;
436 assert(isCanonical(Directory) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Directory) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Directory) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 436, __extension__ __PRETTY_FUNCTION__))
;
437 assert((!CS || isCanonical(CS->Value)) && "Expected canonical MDString")(static_cast <bool> ((!CS || isCanonical(CS->Value))
&& "Expected canonical MDString") ? void (0) : __assert_fail
("(!CS || isCanonical(CS->Value)) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 437, __extension__ __PRETTY_FUNCTION__))
;
438 assert((!Source || isCanonical(*Source)) && "Expected canonical MDString")(static_cast <bool> ((!Source || isCanonical(*Source)) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("(!Source || isCanonical(*Source)) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 438, __extension__ __PRETTY_FUNCTION__))
;
439 DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS, Source))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIFiles, DIFileInfo::KeyTy(Filename, Directory, CS
, Source))) return N; if (!ShouldCreate) return nullptr; } else
{ (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 439, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
440 Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr,
441 Source.getValueOr(nullptr)};
442 DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops)return storeImpl(new (array_lengthof(Ops)) DIFile(Context, Storage
, CS, Source, Ops), Storage, Context.pImpl->DIFiles)
;
443}
444
445DICompileUnit *DICompileUnit::getImpl(
446 LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
447 MDString *Producer, bool IsOptimized, MDString *Flags,
448 unsigned RuntimeVersion, MDString *SplitDebugFilename,
449 unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
450 Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
451 uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
452 bool GnuPubnames, StorageType Storage, bool ShouldCreate) {
453 assert(Storage != Uniqued && "Cannot unique DICompileUnit")(static_cast <bool> (Storage != Uniqued && "Cannot unique DICompileUnit"
) ? void (0) : __assert_fail ("Storage != Uniqued && \"Cannot unique DICompileUnit\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 453, __extension__ __PRETTY_FUNCTION__))
;
454 assert(isCanonical(Producer) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Producer) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Producer) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 454, __extension__ __PRETTY_FUNCTION__))
;
455 assert(isCanonical(Flags) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Flags) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Flags) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 455, __extension__ __PRETTY_FUNCTION__))
;
456 assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SplitDebugFilename) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SplitDebugFilename) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 456, __extension__ __PRETTY_FUNCTION__))
;
457
458 Metadata *Ops[] = {
459 File, Producer, Flags, SplitDebugFilename,
460 EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities,
461 Macros};
462 return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
463 Context, Storage, SourceLanguage, IsOptimized,
464 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
465 DebugInfoForProfiling, GnuPubnames, Ops),
466 Storage);
467}
468
469Optional<DICompileUnit::DebugEmissionKind>
470DICompileUnit::getEmissionKind(StringRef Str) {
471 return StringSwitch<Optional<DebugEmissionKind>>(Str)
472 .Case("NoDebug", NoDebug)
473 .Case("FullDebug", FullDebug)
474 .Case("LineTablesOnly", LineTablesOnly)
475 .Default(None);
476}
477
478const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
479 switch (EK) {
480 case NoDebug: return "NoDebug";
481 case FullDebug: return "FullDebug";
482 case LineTablesOnly: return "LineTablesOnly";
483 }
484 return nullptr;
485}
486
487DISubprogram *DILocalScope::getSubprogram() const {
488 if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
489 return Block->getScope()->getSubprogram();
490 return const_cast<DISubprogram *>(cast<DISubprogram>(this));
491}
492
493DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const {
494 if (auto *File = dyn_cast<DILexicalBlockFile>(this))
495 return File->getScope()->getNonLexicalBlockFileScope();
496 return const_cast<DILocalScope *>(this);
497}
498
499DISubprogram *DISubprogram::getImpl(
500 LLVMContext &Context, Metadata *Scope, MDString *Name,
501 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
502 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
503 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
504 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
505 Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
506 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
507 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 507, __extension__ __PRETTY_FUNCTION__))
;
508 assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 508, __extension__ __PRETTY_FUNCTION__))
;
509 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 513, __extension__ __PRETTY_FUNCTION__)); } } while (false)
510 DISubprogram, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 513, __extension__ __PRETTY_FUNCTION__)); } } while (false)
511 IsDefinition, ScopeLine, ContainingType, Virtuality,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 513, __extension__ __PRETTY_FUNCTION__)); } } while (false)
512 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 513, __extension__ __PRETTY_FUNCTION__)); } } while (false)
513 TemplateParams, Declaration, RetainedNodes, ThrownTypes))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DISubprograms, DISubprogramInfo::KeyTy(Scope, Name
, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment
, Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes
, ThrownTypes))) return N; if (!ShouldCreate) return nullptr;
} else { (static_cast <bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 513, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
514 SmallVector<Metadata *, 11> Ops = {
515 File, Scope, Name, LinkageName, Type, Unit,
516 Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes};
517 if (!ThrownTypes) {
518 Ops.pop_back();
519 if (!TemplateParams) {
520 Ops.pop_back();
521 if (!ContainingType)
522 Ops.pop_back();
523 }
524 }
525 DEFINE_GETIMPL_STORE_N(DISubprogram,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
526 (Line, ScopeLine, Virtuality, VirtualIndex,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
527 ThisAdjustment, Flags, IsLocalToUnit, IsDefinition,return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
528 IsOptimized),return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
529 Ops, Ops.size())return storeImpl(new (Ops.size()) DISubprogram(Context, Storage
, Line, ScopeLine, Virtuality, VirtualIndex, ThisAdjustment, Flags
, IsLocalToUnit, IsDefinition, IsOptimized, Ops), Storage, Context
.pImpl->DISubprograms)
;
530}
531
532bool DISubprogram::describes(const Function *F) const {
533 assert(F && "Invalid function")(static_cast <bool> (F && "Invalid function") ?
void (0) : __assert_fail ("F && \"Invalid function\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 533, __extension__ __PRETTY_FUNCTION__))
;
534 if (F->getSubprogram() == this)
535 return true;
536 StringRef Name = getLinkageName();
537 if (Name.empty())
538 Name = getName();
539 return F->getName() == Name;
540}
541
542DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
543 Metadata *File, unsigned Line,
544 unsigned Column, StorageType Storage,
545 bool ShouldCreate) {
546 // Fixup column.
547 adjustColumn(Column);
548
549 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 549, __extension__ __PRETTY_FUNCTION__))
;
550 DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlocks, DILexicalBlockInfo::KeyTy(Scope, File
, Line, Column))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 550, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
551 Metadata *Ops[] = {File, Scope};
552 DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlock(Context
, Storage, Line, Column, Ops), Storage, Context.pImpl->DILexicalBlocks
)
;
553}
554
555DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
556 Metadata *Scope, Metadata *File,
557 unsigned Discriminator,
558 StorageType Storage,
559 bool ShouldCreate) {
560 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 560, __extension__ __PRETTY_FUNCTION__))
;
561 DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILexicalBlockFiles, DILexicalBlockFileInfo::KeyTy
(Scope, File, Discriminator))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 561, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
562 Metadata *Ops[] = {File, Scope};
563 DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops)return storeImpl(new (array_lengthof(Ops)) DILexicalBlockFile
(Context, Storage, Discriminator, Ops), Storage, Context.pImpl
->DILexicalBlockFiles)
;
564}
565
566DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
567 MDString *Name, bool ExportSymbols,
568 StorageType Storage, bool ShouldCreate) {
569 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 569, __extension__ __PRETTY_FUNCTION__))
;
570 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DINamespaces, DINamespaceInfo::KeyTy(Scope, Name, ExportSymbols
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 570, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
571 // The nullptr is for DIScope's File operand. This should be refactored.
572 Metadata *Ops[] = {nullptr, Scope, Name};
573 DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops)return storeImpl(new (array_lengthof(Ops)) DINamespace(Context
, Storage, ExportSymbols, Ops), Storage, Context.pImpl->DINamespaces
)
;
574}
575
576DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
577 MDString *Name, MDString *ConfigurationMacros,
578 MDString *IncludePath, MDString *ISysRoot,
579 StorageType Storage, bool ShouldCreate) {
580 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 580, __extension__ __PRETTY_FUNCTION__))
;
581 DEFINE_GETIMPL_LOOKUP(do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath, ISysRoot))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 582, __extension__ __PRETTY_FUNCTION__)); } } while (false)
582 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIModules, DIModuleInfo::KeyTy(Scope, Name, ConfigurationMacros
, IncludePath, ISysRoot))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 582, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
583 Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
584 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops)return storeImpl(new (array_lengthof(Ops)) DIModule(Context, Storage
, Ops), Storage, Context.pImpl->DIModules)
;
585}
586
587DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVMContext &Context,
588 MDString *Name,
589 Metadata *Type,
590 StorageType Storage,
591 bool ShouldCreate) {
592 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 592, __extension__ __PRETTY_FUNCTION__))
;
593 DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateTypeParameters, DITemplateTypeParameterInfo
::KeyTy(Name, Type))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 593, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
594 Metadata *Ops[] = {Name, Type};
595 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateTypeParameter
(Context, Storage, Ops), Storage, Context.pImpl->DITemplateTypeParameters
)
;
596}
597
598DITemplateValueParameter *DITemplateValueParameter::getImpl(
599 LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
600 Metadata *Value, StorageType Storage, bool ShouldCreate) {
601 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 601, __extension__ __PRETTY_FUNCTION__))
;
602 DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter, (Tag, Name, Type, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DITemplateValueParameters, DITemplateValueParameterInfo
::KeyTy(Tag, Name, Type, Value))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 602, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
603 Metadata *Ops[] = {Name, Type, Value};
604 DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops)return storeImpl(new (array_lengthof(Ops)) DITemplateValueParameter
(Context, Storage, Tag, Ops), Storage, Context.pImpl->DITemplateValueParameters
)
;
605}
606
607DIGlobalVariable *
608DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
609 MDString *LinkageName, Metadata *File, unsigned Line,
610 Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
611 Metadata *StaticDataMemberDeclaration,
612 uint32_t AlignInBits, StorageType Storage,
613 bool ShouldCreate) {
614 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 614, __extension__ __PRETTY_FUNCTION__))
;
615 assert(isCanonical(LinkageName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(LinkageName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(LinkageName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 615, __extension__ __PRETTY_FUNCTION__))
;
616 DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { (static_cast <bool>
(ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 619, __extension__ __PRETTY_FUNCTION__)); } } while (false)
617 (Scope, Name, LinkageName, File, Line, Type,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { (static_cast <bool>
(ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 619, __extension__ __PRETTY_FUNCTION__)); } } while (false)
618 IsLocalToUnit, IsDefinition,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { (static_cast <bool>
(ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 619, __extension__ __PRETTY_FUNCTION__)); } } while (false)
619 StaticDataMemberDeclaration, AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariables, DIGlobalVariableInfo::KeyTy(Scope
, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition
, StaticDataMemberDeclaration, AlignInBits))) return N; if (!
ShouldCreate) return nullptr; } else { (static_cast <bool>
(ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 619, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
620 Metadata *Ops[] = {
621 Scope, Name, File, Type, Name, LinkageName, StaticDataMemberDeclaration};
622 DEFINE_GETIMPL_STORE(DIGlobalVariable,return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
623 (Line, IsLocalToUnit, IsDefinition, AlignInBits),return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
624 Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariable(Context
, Storage, Line, IsLocalToUnit, IsDefinition, AlignInBits, Ops
), Storage, Context.pImpl->DIGlobalVariables)
;
625}
626
627DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
628 MDString *Name, Metadata *File,
629 unsigned Line, Metadata *Type,
630 unsigned Arg, DIFlags Flags,
631 uint32_t AlignInBits,
632 StorageType Storage,
633 bool ShouldCreate) {
634 // 64K ought to be enough for any frontend.
635 assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits")(static_cast <bool> (Arg <= (65535) && "Expected argument number to fit in 16-bits"
) ? void (0) : __assert_fail ("Arg <= UINT16_MAX && \"Expected argument number to fit in 16-bits\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 635, __extension__ __PRETTY_FUNCTION__))
;
636
637 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 637, __extension__ __PRETTY_FUNCTION__))
;
638 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 638, __extension__ __PRETTY_FUNCTION__))
;
639 DEFINE_GETIMPL_LOOKUP(DILocalVariable,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 641, __extension__ __PRETTY_FUNCTION__)); } } while (false)
640 (Scope, Name, File, Line, Type, Arg, Flags,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 641, __extension__ __PRETTY_FUNCTION__)); } } while (false)
641 AlignInBits))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILocalVariables, DILocalVariableInfo::KeyTy(Scope
, Name, File, Line, Type, Arg, Flags, AlignInBits))) return N
; if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 641, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
642 Metadata *Ops[] = {Scope, Name, File, Type};
643 DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops)return storeImpl(new (array_lengthof(Ops)) DILocalVariable(Context
, Storage, Line, Arg, Flags, AlignInBits, Ops), Storage, Context
.pImpl->DILocalVariables)
;
644}
645
646Optional<uint64_t> DIVariable::getSizeInBits() const {
647 // This is used by the Verifier so be mindful of broken types.
648 const Metadata *RawType = getRawType();
649 while (RawType) {
650 // Try to get the size directly.
651 if (auto *T = dyn_cast<DIType>(RawType))
652 if (uint64_t Size = T->getSizeInBits())
653 return Size;
654
655 if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
656 // Look at the base type.
657 RawType = DT->getRawBaseType();
658 continue;
659 }
660
661 // Missing type or size.
662 break;
663 }
664
665 // Fail gracefully.
666 return None;
667}
668
669DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope,
670 MDString *Name, Metadata *File, unsigned Line,
671 StorageType Storage,
672 bool ShouldCreate) {
673 assert(Scope && "Expected scope")(static_cast <bool> (Scope && "Expected scope")
? void (0) : __assert_fail ("Scope && \"Expected scope\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 673, __extension__ __PRETTY_FUNCTION__))
;
674 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 674, __extension__ __PRETTY_FUNCTION__))
;
675 DEFINE_GETIMPL_LOOKUP(DILabel,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILabels, DILabelInfo::KeyTy(Scope, Name, File, Line
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 676, __extension__ __PRETTY_FUNCTION__)); } } while (false)
676 (Scope, Name, File, Line))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DILabels, DILabelInfo::KeyTy(Scope, Name, File, Line
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 676, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
677 Metadata *Ops[] = {Scope, Name, File};
678 DEFINE_GETIMPL_STORE(DILabel, (Line), Ops)return storeImpl(new (array_lengthof(Ops)) DILabel(Context, Storage
, Line, Ops), Storage, Context.pImpl->DILabels)
;
679}
680
681DIExpression *DIExpression::getImpl(LLVMContext &Context,
682 ArrayRef<uint64_t> Elements,
683 StorageType Storage, bool ShouldCreate) {
684 DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIExpressions, DIExpressionInfo::KeyTy(Elements)))
return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 684, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
685 DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements))return storeImpl(new (0u) DIExpression(Context, Storage, Elements
), Storage, Context.pImpl->DIExpressions)
;
686}
687
688unsigned DIExpression::ExprOperand::getSize() const {
689 switch (getOp()) {
690 case dwarf::DW_OP_LLVM_fragment:
691 return 3;
692 case dwarf::DW_OP_constu:
693 case dwarf::DW_OP_plus_uconst:
694 return 2;
695 default:
696 return 1;
697 }
698}
699
700bool DIExpression::isValid() const {
701 for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
702 // Check that there's space for the operand.
703 if (I->get() + I->getSize() > E->get())
704 return false;
705
706 // Check that the operand is valid.
707 switch (I->getOp()) {
708 default:
709 return false;
710 case dwarf::DW_OP_LLVM_fragment:
711 // A fragment operator must appear at the end.
712 return I->get() + I->getSize() == E->get();
713 case dwarf::DW_OP_stack_value: {
714 // Must be the last one or followed by a DW_OP_LLVM_fragment.
715 if (I->get() + I->getSize() == E->get())
716 break;
717 auto J = I;
718 if ((++J)->getOp() != dwarf::DW_OP_LLVM_fragment)
719 return false;
720 break;
721 }
722 case dwarf::DW_OP_swap: {
723 // Must be more than one implicit element on the stack.
724
725 // FIXME: A better way to implement this would be to add a local variable
726 // that keeps track of the stack depth and introduce something like a
727 // DW_LLVM_OP_implicit_location as a placeholder for the location this
728 // DIExpression is attached to, or else pass the number of implicit stack
729 // elements into isValid.
730 if (getNumElements() == 1)
731 return false;
732 break;
733 }
734 case dwarf::DW_OP_constu:
735 case dwarf::DW_OP_plus_uconst:
736 case dwarf::DW_OP_plus:
737 case dwarf::DW_OP_minus:
738 case dwarf::DW_OP_mul:
739 case dwarf::DW_OP_div:
740 case dwarf::DW_OP_mod:
741 case dwarf::DW_OP_or:
742 case dwarf::DW_OP_and:
743 case dwarf::DW_OP_xor:
744 case dwarf::DW_OP_shl:
745 case dwarf::DW_OP_shr:
746 case dwarf::DW_OP_shra:
747 case dwarf::DW_OP_deref:
748 case dwarf::DW_OP_xderef:
749 case dwarf::DW_OP_lit0:
750 case dwarf::DW_OP_not:
751 case dwarf::DW_OP_dup:
752 break;
753 }
754 }
755 return true;
756}
757
758Optional<DIExpression::FragmentInfo>
759DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) {
760 for (auto I = Start; I != End; ++I)
761 if (I->getOp() == dwarf::DW_OP_LLVM_fragment) {
762 DIExpression::FragmentInfo Info = {I->getArg(1), I->getArg(0)};
763 return Info;
764 }
765 return None;
766}
767
768void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
769 int64_t Offset) {
770 if (Offset > 0) {
771 Ops.push_back(dwarf::DW_OP_plus_uconst);
772 Ops.push_back(Offset);
773 } else if (Offset < 0) {
774 Ops.push_back(dwarf::DW_OP_constu);
775 Ops.push_back(-Offset);
776 Ops.push_back(dwarf::DW_OP_minus);
777 }
778}
779
780bool DIExpression::extractIfOffset(int64_t &Offset) const {
781 if (getNumElements() == 0) {
782 Offset = 0;
783 return true;
784 }
785
786 if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
787 Offset = Elements[1];
788 return true;
789 }
790
791 if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
792 if (Elements[2] == dwarf::DW_OP_plus) {
793 Offset = Elements[1];
794 return true;
795 }
796 if (Elements[2] == dwarf::DW_OP_minus) {
797 Offset = -Elements[1];
798 return true;
799 }
800 }
801
802 return false;
803}
804
805DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
806 int64_t Offset, bool DerefAfter,
807 bool StackValue) {
808 SmallVector<uint64_t, 8> Ops;
809 if (DerefBefore)
810 Ops.push_back(dwarf::DW_OP_deref);
811
812 appendOffset(Ops, Offset);
813 if (DerefAfter)
814 Ops.push_back(dwarf::DW_OP_deref);
815
816 return prependOpcodes(Expr, Ops, StackValue);
817}
818
819DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
820 SmallVectorImpl<uint64_t> &Ops,
821 bool StackValue) {
822 assert(Expr && "Can't prepend ops to this expression")(static_cast <bool> (Expr && "Can't prepend ops to this expression"
) ? void (0) : __assert_fail ("Expr && \"Can't prepend ops to this expression\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 822, __extension__ __PRETTY_FUNCTION__))
;
823
824 // If there are no ops to prepend, do not even add the DW_OP_stack_value.
825 if (Ops.empty())
826 StackValue = false;
827 for (auto Op : Expr->expr_ops()) {
828 // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
829 if (StackValue) {
830 if (Op.getOp() == dwarf::DW_OP_stack_value)
831 StackValue = false;
832 else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
833 Ops.push_back(dwarf::DW_OP_stack_value);
834 StackValue = false;
835 }
836 }
837 Op.appendToVector(Ops);
838 }
839 if (StackValue)
840 Ops.push_back(dwarf::DW_OP_stack_value);
841 return DIExpression::get(Expr->getContext(), Ops);
842}
843
844DIExpression *DIExpression::append(const DIExpression *Expr,
845 ArrayRef<uint64_t> Ops) {
846 assert(Expr && !Ops.empty() && "Can't append ops to this expression")(static_cast <bool> (Expr && !Ops.empty() &&
"Can't append ops to this expression") ? void (0) : __assert_fail
("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 846, __extension__ __PRETTY_FUNCTION__))
;
847
848 // Copy Expr's current op list.
849 SmallVector<uint64_t, 16> NewOps;
850 for (auto Op : Expr->expr_ops()) {
851 // Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
852 if (Op.getOp() == dwarf::DW_OP_stack_value ||
853 Op.getOp() == dwarf::DW_OP_LLVM_fragment) {
854 NewOps.append(Ops.begin(), Ops.end());
855
856 // Ensure that the new opcodes are only appended once.
857 Ops = None;
858 }
859 Op.appendToVector(NewOps);
860 }
861
862 NewOps.append(Ops.begin(), Ops.end());
863 return DIExpression::get(Expr->getContext(), NewOps);
864}
865
866DIExpression *DIExpression::appendToStack(const DIExpression *Expr,
867 ArrayRef<uint64_t> Ops) {
868 assert(Expr && !Ops.empty() && "Can't append ops to this expression")(static_cast <bool> (Expr && !Ops.empty() &&
"Can't append ops to this expression") ? void (0) : __assert_fail
("Expr && !Ops.empty() && \"Can't append ops to this expression\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 868, __extension__ __PRETTY_FUNCTION__))
;
869 assert(none_of(Ops,(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
870 [](uint64_t Op) {(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
871 return Op == dwarf::DW_OP_stack_value ||(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
872 Op == dwarf::DW_OP_LLVM_fragment;(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
873 }) &&(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
874 "Can't append this op")(static_cast <bool> (none_of(Ops, [](uint64_t Op) { return
Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment
; }) && "Can't append this op") ? void (0) : __assert_fail
("none_of(Ops, [](uint64_t Op) { return Op == dwarf::DW_OP_stack_value || Op == dwarf::DW_OP_LLVM_fragment; }) && \"Can't append this op\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 874, __extension__ __PRETTY_FUNCTION__))
;
875
876 // Append a DW_OP_deref after Expr's current op list if it's non-empty and
877 // has no DW_OP_stack_value.
878 //
879 // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
880 Optional<FragmentInfo> FI = Expr->getFragmentInfo();
881 unsigned DropUntilStackValue = FI.hasValue() ? 3 : 0;
882 ArrayRef<uint64_t> ExprOpsBeforeFragment =
883 Expr->getElements().drop_back(DropUntilStackValue);
884 bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
885 (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
886 bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
887
888 // Append a DW_OP_deref after Expr's current op list if needed, then append
889 // the new ops, and finally ensure that a single DW_OP_stack_value is present.
890 SmallVector<uint64_t, 16> NewOps;
891 if (NeedsDeref)
892 NewOps.push_back(dwarf::DW_OP_deref);
893 NewOps.append(Ops.begin(), Ops.end());
894 if (NeedsStackValue)
895 NewOps.push_back(dwarf::DW_OP_stack_value);
896 return DIExpression::append(Expr, NewOps);
897}
898
899Optional<DIExpression *> DIExpression::createFragmentExpression(
900 const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) {
901 SmallVector<uint64_t, 8> Ops;
902 // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
903 if (Expr) {
1
Assuming 'Expr' is null
2
Taking false branch
904 for (auto Op : Expr->expr_ops()) {
905 switch (Op.getOp()) {
906 default: break;
907 case dwarf::DW_OP_plus:
908 case dwarf::DW_OP_minus:
909 // We can't safely split arithmetic into multiple fragments because we
910 // can't express carry-over between fragments.
911 //
912 // FIXME: We *could* preserve the lowest fragment of a constant offset
913 // operation if the offset fits into SizeInBits.
914 return None;
915 case dwarf::DW_OP_LLVM_fragment: {
916 // Make the new offset point into the existing fragment.
917 uint64_t FragmentOffsetInBits = Op.getArg(0);
918 uint64_t FragmentSizeInBits = Op.getArg(1);
919 (void)FragmentSizeInBits;
920 assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&(static_cast <bool> ((OffsetInBits + SizeInBits <= FragmentSizeInBits
) && "new fragment outside of original fragment") ? void
(0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 921, __extension__ __PRETTY_FUNCTION__))
921 "new fragment outside of original fragment")(static_cast <bool> ((OffsetInBits + SizeInBits <= FragmentSizeInBits
) && "new fragment outside of original fragment") ? void
(0) : __assert_fail ("(OffsetInBits + SizeInBits <= FragmentSizeInBits) && \"new fragment outside of original fragment\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 921, __extension__ __PRETTY_FUNCTION__))
;
922 OffsetInBits += FragmentOffsetInBits;
923 continue;
924 }
925 }
926 Op.appendToVector(Ops);
927 }
928 }
929 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
930 Ops.push_back(OffsetInBits);
931 Ops.push_back(SizeInBits);
932 return DIExpression::get(Expr->getContext(), Ops);
3
Called C++ object pointer is null
933}
934
935bool DIExpression::isConstant() const {
936 // Recognize DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment Len Ofs)?.
937 if (getNumElements() != 3 && getNumElements() != 6)
938 return false;
939 if (getElement(0) != dwarf::DW_OP_constu ||
940 getElement(2) != dwarf::DW_OP_stack_value)
941 return false;
942 if (getNumElements() == 6 && getElement(3) != dwarf::DW_OP_LLVM_fragment)
943 return false;
944 return true;
945}
946
947DIGlobalVariableExpression *
948DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
949 Metadata *Expression, StorageType Storage,
950 bool ShouldCreate) {
951 DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable, Expression))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIGlobalVariableExpressions, DIGlobalVariableExpressionInfo
::KeyTy(Variable, Expression))) return N; if (!ShouldCreate) return
nullptr; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 951, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
952 Metadata *Ops[] = {Variable, Expression};
953 DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops)return storeImpl(new (array_lengthof(Ops)) DIGlobalVariableExpression
(Context, Storage, Ops), Storage, Context.pImpl->DIGlobalVariableExpressions
)
;
954}
955
956DIObjCProperty *DIObjCProperty::getImpl(
957 LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
958 MDString *GetterName, MDString *SetterName, unsigned Attributes,
959 Metadata *Type, StorageType Storage, bool ShouldCreate) {
960 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 960, __extension__ __PRETTY_FUNCTION__))
;
961 assert(isCanonical(GetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(GetterName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(GetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 961, __extension__ __PRETTY_FUNCTION__))
;
962 assert(isCanonical(SetterName) && "Expected canonical MDString")(static_cast <bool> (isCanonical(SetterName) &&
"Expected canonical MDString") ? void (0) : __assert_fail ("isCanonical(SetterName) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 962, __extension__ __PRETTY_FUNCTION__))
;
963 DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name, File, Line, GetterName,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 964, __extension__ __PRETTY_FUNCTION__)); } } while (false)
964 SetterName, Attributes, Type))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIObjCPropertys, DIObjCPropertyInfo::KeyTy(Name, File
, Line, GetterName, SetterName, Attributes, Type))) return N;
if (!ShouldCreate) return nullptr; } else { (static_cast <
bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 964, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
965 Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
966 DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops)return storeImpl(new (array_lengthof(Ops)) DIObjCProperty(Context
, Storage, Line, Attributes, Ops), Storage, Context.pImpl->
DIObjCPropertys)
;
967}
968
969DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
970 Metadata *Scope, Metadata *Entity,
971 Metadata *File, unsigned Line,
972 MDString *Name, StorageType Storage,
973 bool ShouldCreate) {
974 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 974, __extension__ __PRETTY_FUNCTION__))
;
975 DEFINE_GETIMPL_LOOKUP(DIImportedEntity,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 976, __extension__ __PRETTY_FUNCTION__)); } } while (false)
976 (Tag, Scope, Entity, File, Line, Name))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIImportedEntitys, DIImportedEntityInfo::KeyTy(Tag
, Scope, Entity, File, Line, Name))) return N; if (!ShouldCreate
) return nullptr; } else { (static_cast <bool> (ShouldCreate
&& "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 976, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
977 Metadata *Ops[] = {Scope, Entity, Name, File};
978 DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIImportedEntity(Context
, Storage, Tag, Line, Ops), Storage, Context.pImpl->DIImportedEntitys
)
;
979}
980
981DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType,
982 unsigned Line, MDString *Name, MDString *Value,
983 StorageType Storage, bool ShouldCreate) {
984 assert(isCanonical(Name) && "Expected canonical MDString")(static_cast <bool> (isCanonical(Name) && "Expected canonical MDString"
) ? void (0) : __assert_fail ("isCanonical(Name) && \"Expected canonical MDString\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 984, __extension__ __PRETTY_FUNCTION__))
;
985 DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacros, DIMacroInfo::KeyTy(MIType, Line, Name, Value
))) return N; if (!ShouldCreate) return nullptr; } else { (static_cast
<bool> (ShouldCreate && "Expected non-uniqued nodes to always be created"
) ? void (0) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 985, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
986 Metadata *Ops[] = { Name, Value };
987 DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacro(Context, Storage
, MIType, Line, Ops), Storage, Context.pImpl->DIMacros)
;
988}
989
990DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
991 unsigned Line, Metadata *File,
992 Metadata *Elements, StorageType Storage,
993 bool ShouldCreate) {
994 DEFINE_GETIMPL_LOOKUP(DIMacroFile,do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 995, __extension__ __PRETTY_FUNCTION__)); } } while (false)
995 (MIType, Line, File, Elements))do { if (Storage == Uniqued) { if (auto *N = getUniqued(Context
.pImpl->DIMacroFiles, DIMacroFileInfo::KeyTy(MIType, Line,
File, Elements))) return N; if (!ShouldCreate) return nullptr
; } else { (static_cast <bool> (ShouldCreate &&
"Expected non-uniqued nodes to always be created") ? void (0
) : __assert_fail ("ShouldCreate && \"Expected non-uniqued nodes to always be created\""
, "/build/llvm-toolchain-snapshot-7~svn338205/lib/IR/DebugInfoMetadata.cpp"
, 995, __extension__ __PRETTY_FUNCTION__)); } } while (false)
;
996 Metadata *Ops[] = { File, Elements };
997 DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops)return storeImpl(new (array_lengthof(Ops)) DIMacroFile(Context
, Storage, MIType, Line, Ops), Storage, Context.pImpl->DIMacroFiles
)
;
998}