aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2013-07-16 23:21:16 +0000
committerManman Ren <mren@apple.com>2013-07-16 23:21:16 +0000
commit8bfde8917ed77b89fe916854b67352884ffb7b16 (patch)
tree0a90b0bd3e820d5582b7cb1aa73396a44556cb2a /llvm/lib/IR/Module.cpp
parent86bae2c54d34ffecfabdd2a452153f4f871999e1 (diff)
downloadllvm-8bfde8917ed77b89fe916854b67352884ffb7b16.zip
llvm-8bfde8917ed77b89fe916854b67352884ffb7b16.tar.gz
llvm-8bfde8917ed77b89fe916854b67352884ffb7b16.tar.bz2
Add getModuleFlag(StringRef Key) to query a module flag given Key.
No functionality change. llvm-svn: 186470
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 3f505aa..3d3dc73 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -325,6 +325,19 @@ getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const {
}
}
+/// Return the corresponding value if Key appears in module flags, otherwise
+/// return null.
+Value *Module::getModuleFlag(StringRef Key) const {
+ SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags;
+ getModuleFlagsMetadata(ModuleFlags);
+ for (unsigned I = 0, E = ModuleFlags.size(); I < E; ++I) {
+ const ModuleFlagEntry &MFE = ModuleFlags[I];
+ if (Key == MFE.Key->getString())
+ return MFE.Val;
+ }
+ return 0;
+}
+
/// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
/// represents module-level flags. This method returns null if there are no
/// module-level flags.