diff options
author | Amaury Sechet <deadalnix@gmail.com> | 2016-04-20 01:02:12 +0000 |
---|---|---|
committer | Amaury Sechet <deadalnix@gmail.com> | 2016-04-20 01:02:12 +0000 |
commit | 60b31453ac9cc8f8c1f484d6e16ae987b7059c0c (patch) | |
tree | 323b5de9d18e6738935dd2eda61b487f5ff7e781 /llvm/lib/IR | |
parent | 8a57b23e8686299ce7f2695ce804eb1e54c0fbce (diff) | |
download | bcm5719-llvm-60b31453ac9cc8f8c1f484d6e16ae987b7059c0c.tar.gz bcm5719-llvm-60b31453ac9cc8f8c1f484d6e16ae987b7059c0c.zip |
Add LLVMGetAttrKindID in the C API in order to facilitate migration away from LLVMAttribute
Summary:
LLVMAttribute has outlived its utility and is becoming a problem for C API users that what to use all the LLVM attributes. In order to help moving away from LLVMAttribute in a smooth manner, this diff introduce LLVMGetAttrKindIDInContext, which can be used instead of the enum values.
See D18749 for reference.
Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D19081
llvm-svn: 266842
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 43a25838369..4a66c26d623 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "llvm-c/Core.h" +#include "llvm/ADT/StringSwitch.h" +#include "AttributeImpl.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/CallSite.h" @@ -119,6 +121,18 @@ unsigned LLVMGetMDKindID(const char *Name, unsigned SLen) { return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen); } +#define GET_ATTR_KIND_FROM_NAME +#include "AttributesCompatFunc.inc" + +unsigned LLVMGetAttrKindID(const char *Name, size_t SLen) { + auto K = getAttrKindFromName(StringRef(Name, SLen)); + if (K == Attribute::None) { + return 0; + } + + return AttributeImpl::getAttrMask(K); +} + char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) { std::string MsgStorage; raw_string_ostream Stream(MsgStorage); |