summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-30 23:59:04 +0000
committerDevang Patel <dpatel@apple.com>2009-07-30 23:59:04 +0000
commit98250795e801944b5d42b4a714b87335910bfa19 (patch)
tree6299571682468285d621dc5a8380f801c906a312 /llvm/lib/VMCore/Module.cpp
parentd8db5e6a97edfda8d845c0a7e50590b50d9c7876 (diff)
downloadbcm5719-llvm-98250795e801944b5d42b4a714b87335910bfa19.tar.gz
bcm5719-llvm-98250795e801944b5d42b4a714b87335910bfa19.zip
Add getOrInsertNamedMetadata().
llvm-svn: 77646
Diffstat (limited to 'llvm/lib/VMCore/Module.cpp')
-rw-r--r--llvm/lib/VMCore/Module.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index 9e1622e93d0..e06e79a0268 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -289,13 +289,24 @@ GlobalAlias *Module::getNamedAlias(const StringRef &Name) const {
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(Name, NULL, 0, this);
+ return NMD;
+}
+
//===----------------------------------------------------------------------===//
// Methods for easy access to the types in the module.
//
OpenPOWER on IntegriCloud