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 | e75aa6f674ce90570fba9e5a3600535cba12a016 (patch) | |
| tree | 8f2b3cbf8ccbda75c65ceaa416d8c99ca2061acc /llvm/tools/llvm-lto/llvm-lto.cpp | |
| parent | c9c5405b52dd8063c4a2253f1824bcaf519a39ca (diff) | |
| download | bcm5719-llvm-e75aa6f674ce90570fba9e5a3600535cba12a016.tar.gz bcm5719-llvm-e75aa6f674ce90570fba9e5a3600535cba12a016.zip | |
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.
llvm-svn: 275125
Diffstat (limited to 'llvm/tools/llvm-lto/llvm-lto.cpp')
| -rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index f3c6c62d496..84dce23aee2 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -156,6 +156,10 @@ static cl::opt<bool> RestoreGlobalsLinkage( "restore-linkage", cl::init(false), cl::desc("Restore original linkage of globals prior to CodeGen")); +static cl::opt<bool> CheckHasObjC( + "check-for-objc", cl::init(false), + cl::desc("Only check if the module has objective-C defined in it")); + namespace { struct ModuleInfo { std::vector<bool> CanBeHidden; @@ -714,6 +718,21 @@ int main(int argc, char **argv) { return 0; } + if (CheckHasObjC) { + for (auto &Filename : InputFilenames) { + ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr = + MemoryBuffer::getFile(Filename); + error(BufferOrErr, "error loading file '" + Filename + "'"); + auto Buffer = std::move(BufferOrErr.get()); + LLVMContext Ctx; + if (llvm::isBitcodeContainingObjCCategory(*Buffer, Ctx)) + outs() << "Bitcode " << Filename << " contains ObjC\n"; + else + outs() << "Bitcode " << Filename << " does not contain ObjC\n"; + } + return 0; + } + if (ThinLTOMode.getNumOccurrences()) { if (ThinLTOMode.getNumOccurrences() > 1) report_fatal_error("You can't specify more than one -thinlto-action"); |

