[llvm] c2c2592 - const char* for LLVMTargetMachineEmitToFile's argument
Amaury Séchet via llvm-commits
llvm-commits at lists.llvm.org
Sat May 7 07:41:00 PDT 2022
Author: Amaury Séchet
Date: 2022-05-07T14:40:55Z
New Revision: c2c259224bb30b089206dd69dc44aefddffec2f4
URL: https://github.com/llvm/llvm-project/commit/c2c259224bb30b089206dd69dc44aefddffec2f4
DIFF: https://github.com/llvm/llvm-project/commit/c2c259224bb30b089206dd69dc44aefddffec2f4.diff
LOG: const char* for LLVMTargetMachineEmitToFile's argument
The `LLVMTargetMachineEmitToFile` takes a `char* Filename` right now, but it doesn't modify it.
This is annoying to use in the case where you want to pass a const string, because you either have to remove the const, or copy it somewhere else and pass that. Either way, it's not very nice.
I added a const and clang formatted it. This shouldn't break any ABI in my opinion.
I'm sorry but I didn't know whom to put as reviewer for this, so I chose someone with a lot of commits from the .cpp file.
Reviewed By: deadalnix
Differential Revision: https://reviews.llvm.org/D124453
Added:
Modified:
llvm/include/llvm-c/TargetMachine.h
llvm/lib/Target/TargetMachineC.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm-c/TargetMachine.h b/llvm/include/llvm-c/TargetMachine.h
index 23c8c63ff0b46..bfbe1421a3560 100644
--- a/llvm/include/llvm-c/TargetMachine.h
+++ b/llvm/include/llvm-c/TargetMachine.h
@@ -136,7 +136,9 @@ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
wraps several c++ only classes (among them a file stream). Returns any
error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */
LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
- char *Filename, LLVMCodeGenFileType codegen, char **ErrorMessage);
+ const char *Filename,
+ LLVMCodeGenFileType codegen,
+ char **ErrorMessage);
/** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M,
diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index 1275f93f64e4c..b8cefbe5b6b7f 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/lib/Target/TargetMachineC.cpp
@@ -213,7 +213,9 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
}
LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
- char* Filename, LLVMCodeGenFileType codegen, char** ErrorMessage) {
+ const char *Filename,
+ LLVMCodeGenFileType codegen,
+ char **ErrorMessage) {
std::error_code EC;
raw_fd_ostream dest(Filename, EC, sys::fs::OF_None);
if (EC) {
More information about the llvm-commits
mailing list