forked from andreasfertig/cppinsights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClangCompat.h
62 lines (50 loc) · 1.93 KB
/
ClangCompat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/******************************************************************************
*
* C++ Insights, copyright (C) by Andreas Fertig
* Distributed under an MIT license. See LICENSE for details
*
****************************************************************************/
#ifndef INSIGHTS_CLANG_COMPAT_H
#define INSIGHTS_CLANG_COMPAT_H
//-----------------------------------------------------------------------------
#include <clang/Basic/Version.h>
#include "version.h"
//-----------------------------------------------------------------------------
#define IS_CLANG_NEWER_THAN(major) CLANG_VERSION_MAJOR > (major)
//-----------------------------------------------------------------------------
namespace clang::insights {
template<unsigned int MAJOR>
struct IsClangNewerThan
{
static_assert(INSIGHTS_MIN_LLVM_MAJOR_VERSION < MAJOR, "Remove this function, all clang versions support it now");
constexpr static inline bool value{CLANG_VERSION_MAJOR > MAJOR};
};
//-----------------------------------------------------------------------------
// inline constexpr bool IsClangNewerThan8 = IsClangNewerThan<8>::value;
//-----------------------------------------------------------------------------
template<typename T>
auto inline GetBeginLoc(const T& decl)
{
return decl.getBeginLoc();
}
//-----------------------------------------------------------------------------
template<typename T>
auto inline GetBeginLoc(const T* decl)
{
return decl->getBeginLoc();
}
//-----------------------------------------------------------------------------
template<typename T>
auto inline GetEndLoc(const T& decl)
{
return decl.getEndLoc();
}
//-----------------------------------------------------------------------------
template<typename T>
auto inline GetEndLoc(const T* decl)
{
return decl->getEndLoc();
}
//-----------------------------------------------------------------------------
} // namespace clang::insights
#endif /* INSIGHTS_CLANG_COMPAT_H */