diff options
| author | Amaury Sechet <deadalnix@gmail.com> | 2016-04-13 22:51:40 +0000 |
|---|---|---|
| committer | Amaury Sechet <deadalnix@gmail.com> | 2016-04-13 22:51:40 +0000 |
| commit | 3ef4e4a98c9c8ea57ee803897895458087856dbb (patch) | |
| tree | dd91168cfea63dd1700900c6507ab20316031960 /llvm/lib | |
| parent | 01db54113c5dfb4f6c0d85e83c8ff3e0e2e5a0a8 (diff) | |
| download | bcm5719-llvm-3ef4e4a98c9c8ea57ee803897895458087856dbb.tar.gz bcm5719-llvm-3ef4e4a98c9c8ea57ee803897895458087856dbb.zip | |
Add LLVMGetAttrKindIDInContext 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.
Reviewers: Wallbraker, whitequark, joker.eph, echristo
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D18749
llvm-svn: 266257
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Core.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 1b4ad203969..147700dea0a 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,16 @@ unsigned LLVMGetMDKindID(const char *Name, unsigned SLen) { return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen); } +#define GET_ATTR_KIND_FROM_NAME +#include "AttributesCompatFunc.inc" + +unsigned LLVMGetAttrKindIDInContext(LLVMContextRef C, const char *Name, + size_t SLen) { + auto K = getAttrKindFromName(StringRef(Name, SLen)); + assert(K != Attribute::None && "Invalid attribute"); + return AttributeImpl::getAttrMask(K); +} + char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) { std::string MsgStorage; raw_string_ostream Stream(MsgStorage); |

