|
11 | 11 | #define MRDOX_TOOL_AST_ASTVISITORHELPERS_HPP
|
12 | 12 |
|
13 | 13 | #include <mrdox/Platform.hpp>
|
14 |
| -#include <mrdox/Metadata/Record.hpp> |
15 |
| -#include <mrdox/Metadata/Namespace.hpp> |
| 14 | +#include <mrdox/Metadata.hpp> |
| 15 | +#include <mrdox/Support/TypeTraits.hpp> |
| 16 | +#include <clang/AST/AST.h> |
16 | 17 | #include <clang/AST/Attr.h>
|
17 |
| -#include <clang/AST/Decl.h> |
18 |
| -#include <clang/AST/DeclCXX.h> |
| 18 | +#include <clang/AST/DeclFriend.h> |
| 19 | +#include <clang/AST/DeclOpenMP.h> |
19 | 20 | #include <type_traits>
|
20 | 21 |
|
21 | 22 | namespace clang {
|
@@ -237,6 +238,46 @@ convertToQualifierKind(
|
237 | 238 |
|
238 | 239 | }
|
239 | 240 |
|
| 241 | +template< |
| 242 | + typename Visitor, |
| 243 | + typename... Args, |
| 244 | + typename Dependent = void> |
| 245 | +decltype(auto) |
| 246 | +visit( |
| 247 | + Decl* D, |
| 248 | + Visitor&& visitor, |
| 249 | + Args&&... args) |
| 250 | +{ |
| 251 | + switch(D->getKind()) |
| 252 | + { |
| 253 | + #define ABSTRACT_DECL(DECL) |
| 254 | + #define DECL(DERIVED, BASE) \ |
| 255 | + case Decl::DERIVED: \ |
| 256 | + return std::forward<Visitor>(visitor)( \ |
| 257 | + static_cast<DERIVED##Decl*>(D), \ |
| 258 | + std::forward<Args>(args)...); |
| 259 | + |
| 260 | + #include <clang/AST/DeclNodes.inc> |
| 261 | + |
| 262 | + default: |
| 263 | + MRDOX_UNREACHABLE(); |
| 264 | + } |
| 265 | +} |
| 266 | + |
| 267 | +template<typename DeclTy> |
| 268 | +consteval |
| 269 | +Decl::Kind |
| 270 | +DeclToKind() = delete; |
| 271 | + |
| 272 | +#define ABSTRACT_DECL(DECL) |
| 273 | +#define DECL(DERIVED, BASE) \ |
| 274 | + template<> \ |
| 275 | + consteval \ |
| 276 | + Decl::Kind \ |
| 277 | + DeclToKind<DERIVED##Decl>() { return Decl::DERIVED; } |
| 278 | + |
| 279 | +#include <clang/AST/DeclNodes.inc> |
| 280 | + |
240 | 281 | } // mrdox
|
241 | 282 | } // clang
|
242 | 283 |
|
|
0 commit comments