Skip to content

Commit e913f65

Browse files
committed
[clang] fix RecursiveASTVisitor traversal from type to decl
For that visitor, it is not expected that a type can traverse into a declaration. This makes the MemberPointer visitor conform to that rule. This turns the base class visitor into a CXXRecordType visitor, and only performs that visit in case it points to something different than the qualifier does. Fixes a regression reported here: #132401 (comment) As this fixes a regression which has not been released, there are no release notes.
1 parent fbaf3b8 commit e913f65

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,9 @@ DEF_TRAVERSE_TYPE(RValueReferenceType,
10051005

10061006
DEF_TRAVERSE_TYPE(MemberPointerType, {
10071007
TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1008-
TRY_TO(TraverseDecl(T->getMostRecentCXXRecordDecl()));
1008+
if (T->isSugared())
1009+
TRY_TO(TraverseType(
1010+
QualType(T->getMostRecentCXXRecordDecl()->getTypeForDecl(), 0)));
10091011
TRY_TO(TraverseType(T->getPointeeType()));
10101012
})
10111013

clang/test/SemaCXX/member-pointer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,14 @@ namespace GH132494 {
344344
};
345345
template struct A<E>; // expected-note {{requested here}}
346346
} // namespace GH132494
347+
348+
namespace GH132401 {
349+
template <typename Func> struct CallableHelper {
350+
static auto Resolve() -> Func;
351+
};
352+
struct QIODevice {
353+
void d_func() { (void)d_ptr; }
354+
int d_ptr;
355+
};
356+
template struct CallableHelper<void (QIODevice::*)()>;
357+
} // namespace GH132401

0 commit comments

Comments
 (0)