[PATCH] D18727: Add support for attribute in the C API

Jakob Bornecrantz via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 08:14:58 PDT 2016


Wallbraker added a comment.

In http://reviews.llvm.org/D18727#391285, @rnk wrote:

> First, you're breaking compatibility here with old programs using LLVMAttribute. We should ask Jeurgen about that. If we decide that LLVM's underlying attribute handling has changed so drastically that we're OK with a break, then we should delete the LLVMAttribute enum.


Well LLVMAttribute are flags and we have already run out of bits, as per the comment:

  /* FIXME: These attributes are currently not included in the C API as
     a temporary measure until the API/ABI impact to the C API is understood
     and the path forward agreed upon.
  LLVMSanitizeAddressAttribute = 1ULL << 32,
  LLVMStackProtectStrongAttribute = 1ULL<<35,
  */

So something needs to be done.

> Second, you're exposing the C++ enum values of LLVM's attributes. I have a feeling that people will start adding enum attributes in the middle to keep related attributes together. If we want to go this way, where we leverage tablegen instead of maintaining a self-contained mapping the C API layer, then the tablegen records should have manually maintained attribute numbers. We'd either use those as the direct C++ enum values or use them to generate a switch to translate from C to C++. This would be just like protobuf field ids.


A translating switch sounds better, especially if the enums on the C++ side change value.


http://reviews.llvm.org/D18727





More information about the llvm-commits mailing list