diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-18 03:57:26 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-18 03:57:26 +0000 |
commit | 0b270d1d748ae6faeb9e410088b374847bafc7a8 (patch) | |
tree | c4feefa921394da0a0b2e2d8f248ea3132d72c87 /tools/llvm-c-test/module.c | |
parent | 2027fcbfdaea79a5486db80a4da7407f50f7f4ec (diff) |
Add a test for LLVMGetBitcodeModule.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255985 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-c-test/module.c')
-rw-r--r-- | tools/llvm-c-test/module.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/llvm-c-test/module.c b/tools/llvm-c-test/module.c index 2661fc81d88..0f27337eb7c 100644 --- a/tools/llvm-c-test/module.c +++ b/tools/llvm-c-test/module.c @@ -19,7 +19,7 @@ #include <stdlib.h> #include <string.h> -static LLVMModuleRef load_module(void) { +static LLVMModuleRef load_module(bool Lazy) { LLVMMemoryBufferRef MB; LLVMModuleRef M; char *msg = NULL; @@ -29,18 +29,26 @@ static LLVMModuleRef load_module(void) { exit(1); } - if (LLVMParseBitcode(MB, &M, &msg)) { + LLVMBool Ret; + if (Lazy) + Ret = LLVMGetBitcodeModule(MB, &M, &msg); + else + Ret = LLVMParseBitcode(MB, &M, &msg); + + if (Ret) { fprintf(stderr, "Error parsing bitcode: %s\n", msg); LLVMDisposeMemoryBuffer(MB); exit(1); } - LLVMDisposeMemoryBuffer(MB); + if (!Lazy) + LLVMDisposeMemoryBuffer(MB); + return M; } -int module_dump(void) { - LLVMModuleRef M = load_module(); +int module_dump(bool Lazy) { + LLVMModuleRef M = load_module(Lazy); char *irstr = LLVMPrintModuleToString(M); puts(irstr); @@ -52,7 +60,7 @@ int module_dump(void) { } int module_list_functions(void) { - LLVMModuleRef M = load_module(); + LLVMModuleRef M = load_module(false); LLVMValueRef f; f = LLVMGetFirstFunction(M); @@ -93,7 +101,7 @@ int module_list_functions(void) { } int module_list_globals(void) { - LLVMModuleRef M = load_module(); + LLVMModuleRef M = load_module(false); LLVMValueRef g; g = LLVMGetFirstGlobal(M); |