CustomAttributes.h (1218B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef CustomAttributes_h__ 6 #define CustomAttributes_h__ 7 8 #include "clang/AST/DeclBase.h" 9 #include "llvm/ADT/StringRef.h" 10 11 enum CustomAttributes { 12 #define ATTR(a) a, 13 #include "CustomAttributes.inc" 14 #include "external/CustomAttributes.inc" 15 #undef ATTR 16 }; 17 18 struct CustomAttributesSet { 19 #define ATTR(a) bool has_##a : 1; 20 #include "CustomAttributes.inc" 21 #include "external/CustomAttributes.inc" 22 #undef ATTR 23 }; 24 25 template <CustomAttributes A> bool hasCustomAttribute(const clang::Decl *D) { 26 return false; 27 } 28 29 extern CustomAttributesSet GetAttributes(const clang::Decl *D); 30 31 #define ATTR(name) \ 32 template <> inline bool hasCustomAttribute<name>(const clang::Decl *D) { \ 33 return GetAttributes(D).has_##name; \ 34 } 35 #include "CustomAttributes.inc" 36 #include "external/CustomAttributes.inc" 37 #undef ATTR 38 39 extern bool hasCustomAttribute(const clang::Decl *D, CustomAttributes A); 40 41 #endif /* CustomAttributes_h__ */