Skip to content

[Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr #124533

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

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions clang/include/clang/AST/ExprCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -4326,8 +4326,6 @@ class SizeOfPackExpr final
/// Retrieve the parameter pack.
NamedDecl *getPack() const { return Pack; }

void setPack(NamedDecl *NewPack) { Pack = NewPack; }

/// Retrieve the length of the parameter pack.
///
/// This routine may only be invoked when the expression is not
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/StmtProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,13 +2266,13 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {

void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
VisitExpr(S);
VisitDecl(S->getPack());
if (S->isPartiallySubstituted()) {
auto Args = S->getPartialArguments();
ID.AddInteger(Args.size());
for (const auto &TA : Args)
VisitTemplateArgument(TA);
} else {
VisitDecl(S->getPack());
ID.AddInteger(0);
}
}
Expand Down
17 changes: 0 additions & 17 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,23 +1747,6 @@ namespace {
return inherited::TransformLambdaBody(E, Body);
}

ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) {
ExprResult Transformed = inherited::TransformSizeOfPackExpr(E);
if (!Transformed.isUsable())
return Transformed;
auto *TransformedExpr = cast<SizeOfPackExpr>(Transformed.get());
if (SemaRef.CodeSynthesisContexts.back().Kind ==
Sema::CodeSynthesisContext::ConstraintNormalization &&
TransformedExpr->getPack() == E->getPack()) {
Decl *NewPack =
TransformDecl(E->getPackLoc(), TransformedExpr->getPack());
if (!NewPack)
return ExprError();
TransformedExpr->setPack(cast<NamedDecl>(NewPack));
}
return TransformedExpr;
}

ExprResult TransformRequiresExpr(RequiresExpr *E) {
LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
ExprResult TransReq = inherited::TransformRequiresExpr(E);
Expand Down
28 changes: 28 additions & 0 deletions clang/test/SemaTemplate/concepts-out-of-line-def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,34 @@ template <typename... Ts> struct d {
template struct c<int>;
template struct d<int, int>;

namespace Regression_123441 {

struct buf {
constexpr buf(auto&&... initList) requires (sizeof...(initList) <= 8);
};

constexpr buf::buf(auto&&... initList) requires (sizeof...(initList) <= 8) {}

template <class>
struct buffer {
constexpr buffer(auto&&... initList) requires (sizeof...(initList) <= 8);
};

template <class T>
constexpr buffer<T>::buffer(auto&&... initList) requires (sizeof...(initList) <= 8) {}

template <class...>
struct foo { // expected-note {{foo defined here}}
constexpr foo(auto&&... initList)
requires (sizeof...(initList) <= 8);
};

template <class... T>
constexpr foo<T...>::foo(auto&&... initList) // expected-error {{does not match any declaration}}
requires (sizeof...(T) <= 8) {}

}

} // namespace GH115098

namespace GH114685 {
Expand Down
Loading