diff options
author | Peter Zotov <whitequark@whitequark.org> | 2016-04-05 13:56:59 +0000 |
---|---|---|
committer | Peter Zotov <whitequark@whitequark.org> | 2016-04-05 13:56:59 +0000 |
commit | 0a2fa0a13b83405ef3a524e5cc543937e3b1809b (patch) | |
tree | 39021838b6261853b1a806778d238524e8d63ac3 /llvm/tools/llvm-c-test | |
parent | 57c5f0b1c44754a6a07bd70be49e4c4beb878b67 (diff) | |
download | bcm5719-llvm-0a2fa0a13b83405ef3a524e5cc543937e3b1809b.tar.gz bcm5719-llvm-0a2fa0a13b83405ef3a524e5cc543937e3b1809b.zip |
[llvm-c] Expose LLVM{Get,Set}ModuleIdentifier
Patch by Nicole Mazzuca <npmazzuca@gmail.com>.
Differential Revision: http://reviews.llvm.org/D18736
llvm-svn: 265394
Diffstat (limited to 'llvm/tools/llvm-c-test')
-rw-r--r-- | llvm/tools/llvm-c-test/echo.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp index 5a2102a1579..1922b429eb2 100644 --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -865,9 +865,18 @@ int llvm_echo(void) { LLVMEnablePrettyStackTrace(); LLVMModuleRef Src = llvm_load_module(false, true); - + size_t Len; + const char *ModuleName = LLVMGetModuleIdentifier(Src, &Len); LLVMContextRef Ctx = LLVMContextCreate(); - LLVMModuleRef M = LLVMModuleCreateWithNameInContext("<stdin>", Ctx); + LLVMModuleRef M = LLVMModuleCreateWithNameInContext(ModuleName, Ctx); + + // This whole switcharound is done because the C API has no way to + // set the source_filename + LLVMSetModuleIdentifier(M, "", 0); + LLVMGetModuleIdentifier(M, &Len); + if (Len != 0) + report_fatal_error("LLVM{Set,Get}ModuleIdentifier failed"); + LLVMSetModuleIdentifier(M, ModuleName, strlen(ModuleName)); LLVMSetTarget(M, LLVMGetTarget(Src)); LLVMSetModuleDataLayout(M, LLVMGetModuleDataLayout(Src)); |