diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-07-11 23:10:18 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-07-11 23:10:18 +0000 |
commit | 45e997da60432acabe2118fa68c56a44504645e9 (patch) | |
tree | 07a4ec304475867a7a930e9c78b118aa430db69a /tools/lto | |
parent | 9e937064ea231bceb6ca13df6dd09e6cbeaeb6aa (diff) |
Add a libLTO API to query a memory buffer and check if it contains ObjC categories
The linker supports a feature to force load an object from a static
archive if it defines an Objective-C category.
This API supports this feature by looking at every section in the
module to find if a category is defined in the module.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275125 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 9 | ||||
-rw-r--r-- | tools/lto/lto.exports | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index e69f360b074..0c36c99c07f 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -14,6 +14,7 @@ #include "llvm-c/lto.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" @@ -180,6 +181,14 @@ bool lto_module_is_object_file_for_target(const char* path, return LTOModule::isBitcodeForTarget(Buffer->get(), target_triplet_prefix); } +bool lto_module_has_objc_category(const void *mem, size_t length) { + std::unique_ptr<MemoryBuffer> Buffer(LTOModule::makeBuffer(mem, length)); + if (!Buffer) + return false; + LLVMContext Ctx; + return llvm::isBitcodeContainingObjCCategory(*Buffer, Ctx); +} + bool lto_module_is_object_file_in_memory(const void* mem, size_t length) { return LTOModule::isBitcodeFile(mem, length); } diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports index 83a59437e81..74091c2641b 100644 --- a/tools/lto/lto.exports +++ b/tools/lto/lto.exports @@ -18,6 +18,7 @@ lto_module_is_object_file lto_module_is_object_file_for_target lto_module_is_object_file_in_memory lto_module_is_object_file_in_memory_for_target +lto_module_has_objc_category lto_module_dispose lto_api_version lto_codegen_set_diagnostic_handler |