Skip to content

Commit

Permalink
feat: improved declaration resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Jul 11, 2023
1 parent ce7844f commit e4947d8
Show file tree
Hide file tree
Showing 10 changed files with 1,585 additions and 1,411 deletions.
307 changes: 255 additions & 52 deletions lib/AST/ASTVisitor.cpp

Large diffs are not rendered by default.

49 changes: 45 additions & 4 deletions lib/AST/ASTVisitorHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
#define MRDOX_TOOL_AST_ASTVISITORHELPERS_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/Record.hpp>
#include <mrdox/Metadata/Namespace.hpp>
#include <mrdox/Metadata.hpp>
#include <mrdox/Support/TypeTraits.hpp>
#include <clang/AST/AST.h>
#include <clang/AST/Attr.h>
#include <clang/AST/Decl.h>
#include <clang/AST/DeclCXX.h>
#include <clang/AST/DeclFriend.h>
#include <clang/AST/DeclOpenMP.h>
#include <type_traits>

namespace clang {
Expand Down Expand Up @@ -237,6 +238,46 @@ convertToQualifierKind(

}

template<
typename Visitor,
typename... Args,
typename Dependent = void>
decltype(auto)
visit(
Decl* D,
Visitor&& visitor,
Args&&... args)
{
switch(D->getKind())
{
#define ABSTRACT_DECL(DECL)
#define DECL(DERIVED, BASE) \
case Decl::DERIVED: \
return std::forward<Visitor>(visitor)( \
static_cast<DERIVED##Decl*>(D), \
std::forward<Args>(args)...);

#include <clang/AST/DeclNodes.inc>

default:
MRDOX_UNREACHABLE();
}
}

template<typename DeclTy>
consteval
Decl::Kind
DeclToKind() = delete;

#define ABSTRACT_DECL(DECL)
#define DECL(DERIVED, BASE) \
template<> \
consteval \
Decl::Kind \
DeclToKind<DERIVED##Decl>() { return Decl::DERIVED; }

#include <clang/AST/DeclNodes.inc>

} // mrdox
} // clang

Expand Down
Loading

0 comments on commit e4947d8

Please sign in to comment.