summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-c-test
diff options
context:
space:
mode:
authorRobert Widmann <devteam.codafi@gmail.com>2018-01-30 21:34:29 +0000
committerRobert Widmann <devteam.codafi@gmail.com>2018-01-30 21:34:29 +0000
commit490a5808cd4eaa4dc86ed5ff69cda27e7f2c8c56 (patch)
treed78299fdd2b551f277090c230245cb95fc64fa13 /llvm/tools/llvm-c-test
parent59baf73a4dff3e19b5e0ecdd5b0801691b0db54f (diff)
downloadbcm5719-llvm-490a5808cd4eaa4dc86ed5ff69cda27e7f2c8c56.tar.gz
bcm5719-llvm-490a5808cd4eaa4dc86ed5ff69cda27e7f2c8c56.zip
[LLVM-C] Add Accessors For A Module's Source File Name
Summary: Also unblocks some cleanup in the echo-test. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: harlanhaskins, llvm-commits Differential Revision: https://reviews.llvm.org/D42618 llvm-svn: 323819
Diffstat (limited to 'llvm/tools/llvm-c-test')
-rw-r--r--llvm/tools/llvm-c-test/echo.cpp15
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));
OpenPOWER on IntegriCloud