aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/Module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/Module.cpp')
-rw-r--r--lib/IR/Module.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp
index 3f505aa..3d3dc73 100644
--- a/lib/IR/Module.cpp
+++ b/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.