-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] implement common-sugar for adjusted member-pointers #133613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This implements a missing case for an adjusted member-pointer in getCommonSugaredType, when that was originally implemented here: #130537 This missing case could otherwise cause a crash, so this is a regression fix. This should fix the crash reported here: #132401 (comment) No release notes, since this regression and the underlying feature were never released.
@llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesThis implements a missing case for an adjusted member-pointer in getCommonSugaredType, when that was originally implemented here: #130537 This missing case could otherwise cause a crash, so this is a regression fix. This should fix the crash reported here: #132401 (comment) No release notes, since this regression and its underlying feature were never released. Full diff: https://github.com/llvm/llvm-project/pull/133613.diff 2 Files Affected:
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c9d1bea4c623a..2d9480ebcf00c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14135,7 +14135,6 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X,
CANONICAL_TYPE(IncompleteArray)
CANONICAL_TYPE(HLSLAttributedResource)
CANONICAL_TYPE(LValueReference)
- CANONICAL_TYPE(MemberPointer)
CANONICAL_TYPE(ObjCInterface)
CANONICAL_TYPE(ObjCObject)
CANONICAL_TYPE(ObjCObjectPointer)
@@ -14313,6 +14312,15 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X,
return QualType();
return Ctx.getUsingType(CD, Ctx.getQualifiedType(Underlying));
}
+ case Type::MemberPointer: {
+ const auto *PX = cast<MemberPointerType>(X),
+ *PY = cast<MemberPointerType>(Y);
+ CXXRecordDecl *Cls = PX->getMostRecentCXXRecordDecl();
+ assert(Cls == PY->getMostRecentCXXRecordDecl());
+ return Ctx.getMemberPointerType(
+ ::getCommonPointeeType(Ctx, PX, PY),
+ ::getCommonQualifier(Ctx, PX, PY, /*IsSame=*/false), Cls);
+ }
case Type::CountAttributed: {
const auto *DX = cast<CountAttributedType>(X),
*DY = cast<CountAttributedType>(Y);
diff --git a/clang/test/SemaCXX/sugar-common-types.cpp b/clang/test/SemaCXX/sugar-common-types.cpp
index a21032517b2ba..d58f6cdd900fc 100644
--- a/clang/test/SemaCXX/sugar-common-types.cpp
+++ b/clang/test/SemaCXX/sugar-common-types.cpp
@@ -186,3 +186,19 @@ namespace arrays {
// expected-error@-1 {{lvalue of type 'const volatile volatile B1[1]' (aka 'const volatile volatile int[1]')}}
} // namespace balanced_qualifiers
} // namespace arrays
+
+namespace member_pointers {
+ template <class T> struct W {
+ X1 a;
+ Y1 b;
+ };
+ struct W1 : W<X2> {};
+ struct W2 : W<Y2> {};
+
+ N t1 = 0 ? &W<X2>::a : &W<Y2>::b;
+ // expected-error@-1 {{rvalue of type 'B1 W<B2>::*'}}
+
+ // FIXME: adjusted MemberPointer does not preserve qualifier
+ N t3 = 0 ? &W1::a : &W2::b;
+ // expected-error@-1 {{rvalue of type 'B1 W<void>::*'}}
+} // namespace member_pointers
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/143/builds/6546 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/5936 Here is the relevant piece of the build log for the reference
|
This implements a missing case for an adjusted member-pointer in getCommonSugaredType, when that was originally implemented here: #130537
This missing case could otherwise cause a crash, so this is a regression fix.
This should fix the crash reported here: #132401 (comment)
No release notes, since this regression and its underlying feature were never released.