diff options
Diffstat (limited to 'llvm/tools/llvm-c-test/echo.cpp')
-rw-r--r-- | llvm/tools/llvm-c-test/echo.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp index 885f9c0d899..05d80363162 100644 --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -927,18 +927,15 @@ int llvm_echo(void) { LLVMEnablePrettyStackTrace(); LLVMModuleRef Src = llvm_load_module(false, true); - size_t Len; - const char *ModuleName = LLVMGetModuleIdentifier(Src, &Len); + size_t SourceFileLen; + const char *SourceFileName = LLVMGetSourceFileName(Src, &SourceFileLen); + size_t ModuleIdentLen; + const char *ModuleName = LLVMGetModuleIdentifier(Src, &ModuleIdentLen); LLVMContextRef Ctx = LLVMContextCreate(); 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)); + LLVMSetSourceFileName(M, SourceFileName, SourceFileLen); + LLVMSetModuleIdentifier(M, ModuleName, ModuleIdentLen); LLVMSetTarget(M, LLVMGetTarget(Src)); LLVMSetModuleDataLayout(M, LLVMGetModuleDataLayout(Src)); |