Skip to content

Commit b5dc7b8

Browse files
authored
[LLVM] Change LLVMIntrinsicCopyOverloadedName API return type (#114334)
Change the return type of `LLVMIntrinsicCopyOverloadedName` and `LLVMIntrinsicCopyOverloadedName2` to `char *` instead of `const char *` since the returned memory is owned by the caller and we expect that the returned pointer is passed to free to deallocate it (without casting it back to non-const pointer).
1 parent 7da9da0 commit b5dc7b8

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

llvm/include/llvm-c/Core.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,10 +2834,8 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
28342834
const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
28352835

28362836
/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2837-
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2838-
LLVMTypeRef *ParamTypes,
2839-
size_t ParamCount,
2840-
size_t *NameLength);
2837+
char *LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes,
2838+
size_t ParamCount, size_t *NameLength);
28412839

28422840
/**
28432841
* Copies the name of an overloaded intrinsic identified by a given list of
@@ -2850,10 +2848,9 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
28502848
*
28512849
* @see llvm::Intrinsic::getName()
28522850
*/
2853-
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2854-
LLVMTypeRef *ParamTypes,
2855-
size_t ParamCount,
2856-
size_t *NameLength);
2851+
char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2852+
LLVMTypeRef *ParamTypes,
2853+
size_t ParamCount, size_t *NameLength);
28572854

28582855
/**
28592856
* Obtain if the intrinsic identified by the given ID is overloaded.

llvm/lib/IR/Core.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,21 +2485,18 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
24852485
return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
24862486
}
24872487

2488-
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2489-
LLVMTypeRef *ParamTypes,
2490-
size_t ParamCount,
2491-
size_t *NameLength) {
2488+
char *LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes,
2489+
size_t ParamCount, size_t *NameLength) {
24922490
auto IID = llvm_map_to_intrinsic_id(ID);
24932491
ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
24942492
auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
24952493
*NameLength = Str.length();
24962494
return strdup(Str.c_str());
24972495
}
24982496

2499-
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2500-
LLVMTypeRef *ParamTypes,
2501-
size_t ParamCount,
2502-
size_t *NameLength) {
2497+
char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2498+
LLVMTypeRef *ParamTypes,
2499+
size_t ParamCount, size_t *NameLength) {
25032500
auto IID = llvm_map_to_intrinsic_id(ID);
25042501
ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
25052502
auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));

0 commit comments

Comments
 (0)