[PATCH] D94877: Add API to retrieve a clade kind from ASTNodeKind
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 17 10:08:00 PST 2021
steveire created this revision.
steveire added a reviewer: aaron.ballman.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94877
Files:
clang/include/clang/AST/ASTTypeTraits.h
clang/lib/AST/ASTTypeTraits.cpp
Index: clang/lib/AST/ASTTypeTraits.cpp
===================================================================
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -63,6 +63,17 @@
return Derived == Base;
}
+ASTNodeKind ASTNodeKind::getCladeKind() const {
+ auto LastId = KindId;
+ while (LastId) {
+ auto ParentId = AllKindInfo[LastId].ParentId;
+ if (ParentId == NKI_None)
+ return LastId;
+ LastId = ParentId;
+ }
+ return NKI_None;
+}
+
StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,
Index: clang/include/clang/AST/ASTTypeTraits.h
===================================================================
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -100,6 +100,8 @@
static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1,
ASTNodeKind Kind2);
+ ASTNodeKind getCladeKind() const;
+
/// Hooks for using ASTNodeKind as a key in a DenseMap.
struct DenseMapInfo {
// ASTNodeKind() is a good empty key because it is represented as a 0.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94877.317226.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210117/b429d938/attachment.bin>
More information about the cfe-commits
mailing list