llvm.org GIT mirror llvm / efddacd
Fix LLVMContext to match what MDKind names that the LL parser permits. Fixes PR21799! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223995 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 5 years ago
2 changed file(s) with 3 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
228228 // Metadata Kind Uniquing
229229 //===----------------------------------------------------------------------===//
230230
231 #ifndef NDEBUG
232 /// isValidName - Return true if Name is a valid custom metadata handler name.
233 static bool isValidName(StringRef MDName) {
234 if (MDName.empty())
235 return false;
236
237 if (!std::isalpha(static_cast(MDName[0])))
238 return false;
239
240 for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E;
241 ++I) {
242 if (!std::isalnum(static_cast(*I)) && *I != '_' &&
243 *I != '-' && *I != '.')
244 return false;
245 }
246 return true;
247 }
248 #endif
249
250231 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
251232 unsigned LLVMContext::getMDKindID(StringRef Name) const {
252 assert(isValidName(Name) && "Invalid MDNode name");
233 assert(!std::isdigit(Name.front()) &&
234 "Named metadata may not start with a digit");
253235
254236 // If this is new, assign it its ID.
255237 return pImpl->CustomMDKindNames.insert(std::make_pair(
44 call void @llvm.zonk(metadata !{i32 %x}, i64 0, metadata !1)
55 store i32 0, i32* null, !whatever !0, !whatever_else !{}, !more !{metadata !"hello"}
66 store i32 0, i32* null, !whatever !{metadata !"hello", metadata !1, metadata !{}, metadata !2}
7 ret void
7 ret void, !_1 !0
88 }
99
1010 declare void @llvm.zonk(metadata, i64, metadata) nounwind readnone