Source code

Revision control

Other Tools

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
#undef ATTR
15
};
16
17
struct CustomAttributesSet {
18
#define ATTR(a) bool has_ ## a: 1;
19
#include "CustomAttributes.inc"
20
#undef ATTR
21
};
22
23
template<CustomAttributes A>
24
bool hasCustomAttribute(const clang::Decl* D) {
25
return false;
26
}
27
28
extern CustomAttributesSet GetAttributes(const clang::Decl* D);
29
30
#define ATTR(name) \
31
template<> \
32
inline bool hasCustomAttribute<name>(const clang::Decl* D) { \
33
return GetAttributes(D).has_ ## name; \
34
}
35
#include "CustomAttributes.inc"
36
#undef ATTR
37
38
extern bool hasCustomAttribute(const clang::Decl* D, CustomAttributes A);
39
40
#endif /* CustomAttributes_h__ */