Skip to content

Commit e4947d8

Browse files
committed
feat: improved declaration resolution
1 parent ce7844f commit e4947d8

10 files changed

+1585
-1411
lines changed

lib/AST/ASTVisitor.cpp

+255-52
Large diffs are not rendered by default.

lib/AST/ASTVisitorHelpers.hpp

+45-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
#define MRDOX_TOOL_AST_ASTVISITORHELPERS_HPP
1212

1313
#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>
1617
#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>
1920
#include <type_traits>
2021

2122
namespace clang {
@@ -237,6 +238,46 @@ convertToQualifierKind(
237238

238239
}
239240

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+
240281
} // mrdox
241282
} // clang
242283

0 commit comments

Comments
 (0)