[llvm] b15d779 - [llvm-c] Add header deprecations
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 00:18:13 PST 2021
Author: Nikita Popov
Date: 2021-12-06T09:17:10+01:00
New Revision: b15d77928e2b44d1667391d4650e61f1ab76bded
URL: https://github.com/llvm/llvm-project/commit/b15d77928e2b44d1667391d4650e61f1ab76bded
DIFF: https://github.com/llvm/llvm-project/commit/b15d77928e2b44d1667391d4650e61f1ab76bded.diff
LOG: [llvm-c] Add header deprecations
This adds support for header deprecation using
LLVM_ATTRIBUTE_C_DEPRECATED (note that we can't use
LLVM_ATTRIBUTE_DEPRECATED, which is C++ specific). This will not
help people using the FFI interface, but may help people using the
C headers.
Differential Revision: https://reviews.llvm.org/D114936
Added:
llvm/include/llvm-c/Deprecated.h
Modified:
llvm/include/llvm-c/Core.h
Removed:
################################################################################
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 2efb4d088709e..7e50d42bd6c0b 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -15,6 +15,7 @@
#ifndef LLVM_C_CORE_H
#define LLVM_C_CORE_H
+#include "llvm-c/Deprecated.h"
#include "llvm-c/ErrorHandling.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
@@ -2378,9 +2379,10 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
* @{
*/
-/** Deprecated: Use LLVMAddAlias2 instead. */
-LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
- const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty,
+ LLVMValueRef Aliasee, const char *Name),
+ "Use LLVMAddAlias2 instead to support opaque pointers");
/**
* Add a GlobalAlias with the given value type, address space and aliasee.
@@ -3681,12 +3683,12 @@ LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
LLVMBasicBlockRef Else, unsigned NumCases);
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
unsigned NumDests);
-// LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
-// for opaque pointer types.
-LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
- LLVMValueRef *Args, unsigned NumArgs,
- LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
- const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
+ LLVMValueRef *Args, unsigned NumArgs,
+ LLVMBasicBlockRef Then,
+ LLVMBasicBlockRef Catch, const char *Name),
+ "Use LLVMBuildInvoke2 instead to support opaque pointers");
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
@@ -3880,23 +3882,27 @@ LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef Val, const char *Name);
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
-// LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
-// opaque pointer types.
-LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
- const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
+ const char *Name),
+ "Use LLVMBuildLoad2 instead to support opaque pointers");
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef PointerVal, const char *Name);
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
-// LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
-// favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
-LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
- LLVMValueRef *Indices, unsigned NumIndices,
- const char *Name);
-LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
- LLVMValueRef *Indices, unsigned NumIndices,
- const char *Name);
-LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
- unsigned Idx, const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
+ LLVMValueRef *Indices, unsigned NumIndices,
+ const char *Name),
+ "Use LLVMBuildGEP2 instead to support opaque pointers");
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
+ LLVMValueRef *Indices,
+ unsigned NumIndices, const char *Name),
+ "Use LLVMBuildInBoundsGEP2 instead to support opaque pointers");
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
+ unsigned Idx, const char *Name),
+ "Use LLVMBuildStructGEP2 instead to support opaque pointers");
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef Pointer, LLVMValueRef *Indices,
unsigned NumIndices, const char *Name);
@@ -3976,11 +3982,11 @@ LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
/* Miscellaneous instructions */
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
-// LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
-// opaque pointer types.
-LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
- LLVMValueRef *Args, unsigned NumArgs,
- const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
+ LLVMValueRef *Args, unsigned NumArgs,
+ const char *Name),
+ "Use LLVMBuildCall2 instead to support opaque pointers");
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
diff --git a/llvm/include/llvm-c/Deprecated.h b/llvm/include/llvm-c/Deprecated.h
new file mode 100644
index 0000000000000..1ed5d11550d20
--- /dev/null
+++ b/llvm/include/llvm-c/Deprecated.h
@@ -0,0 +1,38 @@
+/*===-- llvm-c/Deprecated.h - Deprecation macro -------------------*- C -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This header declares LLVM_ATTRIBUTE_C_DEPRECATED() macro, which can be *|
+|* used to deprecate functions in the C interface. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef LLVM_C_DEPRECATED_H
+#define LLVM_C_DEPRECATED_H
+
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+// This is a variant of LLVM_ATTRIBUTE_DEPRECATED() that is compatible with
+// C compilers.
+#if __has_feature(attribute_deprecated_with_message)
+# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
+ decl __attribute__((deprecated(message)))
+#elif defined(__GNUC__)
+# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
+ decl __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
+ __declspec(deprecated(message)) decl
+#else
+# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
+ decl
+#endif
+
+#endif /* LLVM_C_DEPRECATED_H */
More information about the llvm-commits
mailing list