Skip to content

Commit 09c5b88

Browse files
committed
[LLVM-C] Deprecate the LLVMValueRef-returning metadata creation functions
Summary: There is still some value in using these functions while the remaining LLVMValueRef-based accessors are still around, but LLVMMDNodeInContext in particular has some wonky semantics that make it worth replacing outright. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60524 llvm-svn: 359114
1 parent cee607e commit 09c5b88

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

llvm/include/llvm-c/Core.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,34 +2735,23 @@ void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
27352735
*/
27362736

27372737
/**
2738-
* Obtain a MDString value from a context.
2738+
* Create an MDString value from a given string value.
27392739
*
2740-
* The returned instance corresponds to the llvm::MDString class.
2740+
* The MDString value does not take ownership of the given string, it remains
2741+
* the responsibility of the caller to free it.
27412742
*
2742-
* The instance is specified by string data of a specified length. The
2743-
* string content is copied, so the backing memory can be freed after
2744-
* this function returns.
2743+
* @see llvm::MDString::get()
27452744
*/
2746-
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2747-
unsigned SLen);
2748-
2749-
/**
2750-
* Obtain a MDString value from the global context.
2751-
*/
2752-
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2745+
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
2746+
size_t SLen);
27532747

27542748
/**
2755-
* Obtain a MDNode value from a context.
2749+
* Create an MDNode value with the given array of operands.
27562750
*
2757-
* The returned value corresponds to the llvm::MDNode class.
2751+
* @see llvm::MDNode::get()
27582752
*/
2759-
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2760-
unsigned Count);
2761-
2762-
/**
2763-
* Obtain a MDNode value from the global context.
2764-
*/
2765-
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2753+
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
2754+
size_t Count);
27662755

27672756
/**
27682757
* Obtain a Metadata as a Value.
@@ -2804,6 +2793,17 @@ unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
28042793
*/
28052794
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
28062795

2796+
/** Deprecated: Use LLVMMDStringInContext2 instead. */
2797+
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
2798+
unsigned SLen);
2799+
/** Deprecated: Use LLVMMDStringInContext2 instead. */
2800+
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2801+
/** Deprecated: Use LLVMMDNodeInContext2 instead. */
2802+
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
2803+
unsigned Count);
2804+
/** Deprecated: Use LLVMMDNodeInContext2 instead. */
2805+
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
2806+
28072807
/**
28082808
* @}
28092809
*/

llvm/lib/IR/Core.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,16 @@ LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty) {
10361036

10371037
/*--.. Operations on metadata nodes ........................................--*/
10381038

1039+
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
1040+
size_t SLen) {
1041+
return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1042+
}
1043+
1044+
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
1045+
size_t Count) {
1046+
return wrap(MDNode::get(*unwrap(C), ArrayRef<Metadata*>(unwrap(MDs), Count)));
1047+
}
1048+
10391049
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
10401050
unsigned SLen) {
10411051
LLVMContext &Context = *unwrap(C);

0 commit comments

Comments
 (0)