//
GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
- GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), Type::Int32Ty,
+ GlobalVariable *Ret = new GlobalVariable(getGlobalContext(),
+ Type::getInt32Ty(getGlobalContext()),
false, GlobalValue::ExternalLinkage);
// This should not be garbage monitored.
LeakDetector::removeGarbageObject(Ret);
return Ret;
}
GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() {
- GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty,
+ GlobalAlias *Ret = new GlobalAlias(Type::getInt32Ty(getGlobalContext()),
GlobalValue::ExternalLinkage);
// This should not be garbage monitored.
LeakDetector::removeGarbageObject(Ret);
return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
}
-/// getNamedMetadata - Return the first named MDNode in the module with the
-/// specified name. This method returns null if a MDNode with the specified
-/// name is not found.
+/// getNamedMetadata - Return the first NamedMDNode in the module with the
+/// specified name. This method returns null if a NamedMDNode with the
+//// specified name is not found.
NamedMDNode *Module::getNamedMetadata(const StringRef &Name) const {
return dyn_cast_or_null<NamedMDNode>(getValueSymbolTable().lookup(Name));
}
+/// getOrInsertNamedMetadata - Return the first named MDNode in the module
+/// with the specified name. This method returns a new NamedMDNode if a
+/// NamedMDNode with the specified name is not found.
+NamedMDNode *Module::getOrInsertNamedMetadata(const StringRef &Name) {
+ NamedMDNode *NMD =
+ dyn_cast_or_null<NamedMDNode>(getValueSymbolTable().lookup(Name));
+ if (!NMD)
+ NMD = NamedMDNode::Create(getContext(), Name, NULL, 0, this);
+ return NMD;
+}
+
//===----------------------------------------------------------------------===//
// Methods for easy access to the types in the module.
//