[clang] [clang] [C++20] Defaulted operator== doesn't lookup in using-directive properly #97087 (PR #99542)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 11:19:10 PDT 2024
https://github.com/ofAlpaca created https://github.com/llvm/llvm-project/pull/99542
Resolve #97087
Since it's my first-time sending pull request for LLVM, I'm not sure if I made it right.
Here are my steps before sending pull request.
1. Adding changes to the source code.
2. Build the released version of clang.
3. Run `git-clang-format` to make sure coding style.
4. run `ninja check-clang` to make sure no testcase was failed. (The result is here)
```
Testing Time: 5004.53s
Total Discovered Tests: 37918
Skipped : 4 (0.01%)
Unsupported : 101 (0.27%)
Passed : 37786 (99.65%)
Expectedly Failed: 27 (0.07%)
```
5. Making a branch of this change and send pull request.
>From 2a381b47002db3c7a119a893c1a70e0b1604151f Mon Sep 17 00:00:00 2001
From: schiang <frank70199 at gmail.com>
Date: Thu, 18 Jul 2024 09:53:35 +0800
Subject: [PATCH 1/2] Pass 'Scope *' for 'SetDeclDefaulted()' and related utlis
---
clang/include/clang/Sema/Sema.h | 4 ++--
clang/lib/Parse/ParseCXXInlineMethods.cpp | 2 +-
clang/lib/Parse/Parser.cpp | 2 +-
clang/lib/Sema/SemaDeclCXX.cpp | 8 ++++----
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 48dff1b76cc57..f887fc261a07e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5995,9 +5995,9 @@ class Sema final : public SemaBase {
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
StringLiteral *Message = nullptr);
- void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
+ void SetDeclDefaulted(Scope *S, Decl *dcl, SourceLocation DefaultLoc);
- void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
+ void SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
StringLiteral *DeletedMessage = nullptr);
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D);
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr);
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 9ccbbf9a7d5d0..75a835f512144 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -124,7 +124,7 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(
? diag::warn_cxx98_compat_defaulted_deleted_function
: diag::ext_defaulted_deleted_function)
<< 0 /* defaulted */;
- Actions.SetDeclDefaulted(FnD, KWLoc);
+ Actions.SetDeclDefaulted(nullptr, FnD, KWLoc);
if (auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
DeclAsFunction->setRangeEnd(KWEndLoc);
}
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 5ebe71e496a2e..f1d98bced80b2 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1479,7 +1479,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
D.getMutableDeclSpec().abort();
if (BodyKind != Sema::FnBodyKind::Other) {
- Actions.SetFunctionBodyKind(Res, KWLoc, BodyKind, DeletedMessage);
+ Actions.SetFunctionBodyKind(getCurScope(), Res, KWLoc, BodyKind, DeletedMessage);
Stmt *GeneratedBody = Res ? Res->getBody() : nullptr;
Actions.ActOnFinishFunctionBody(Res, GeneratedBody, false);
return Res;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f24912cde275a..e57057fac10c6 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17940,7 +17940,7 @@ void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc,
Fn->setDeletedAsWritten(true, Message);
}
-void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
+void Sema::SetDeclDefaulted(Scope *S, Decl *Dcl, SourceLocation DefaultLoc) {
if (!Dcl || Dcl->isInvalidDecl())
return;
@@ -18016,7 +18016,7 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
}
if (DefKind.isComparison()) {
- if (CheckExplicitlyDefaultedComparison(nullptr, FD, DefKind.asComparison()))
+ if (CheckExplicitlyDefaultedComparison(S, FD, DefKind.asComparison()))
FD->setInvalidDecl();
else
DefineDefaultedComparison(DefaultLoc, FD, DefKind.asComparison());
@@ -18050,14 +18050,14 @@ void Sema::DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock) {
}
}
-void Sema::SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
+void Sema::SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
StringLiteral *DeletedMessage) {
switch (BodyKind) {
case FnBodyKind::Delete:
SetDeclDeleted(D, Loc, DeletedMessage);
break;
case FnBodyKind::Default:
- SetDeclDefaulted(D, Loc);
+ SetDeclDefaulted(S, D, Loc);
break;
case FnBodyKind::Other:
llvm_unreachable(
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 01432301633ed..65a755cb69048 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4856,7 +4856,7 @@ bool TemplateDeclInstantiator::SubstDefaultedFunction(FunctionDecl *New,
: DFI);
}
- SemaRef.SetDeclDefaulted(New, Tmpl->getLocation());
+ SemaRef.SetDeclDefaulted(nullptr, New, Tmpl->getLocation());
return false;
}
@@ -5133,7 +5133,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
if (PatternDecl->isDefaulted()) {
RebuildTypeSourceInfoForDefaultSpecialMembers();
- SetDeclDefaulted(Function, PatternDecl->getLocation());
+ SetDeclDefaulted(nullptr, Function, PatternDecl->getLocation());
} else {
MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(
Function, Function->getLexicalDeclContext(), /*Final=*/false,
>From 5dbfe6988c489344c4afff359d23cd0306b32611 Mon Sep 17 00:00:00 2001
From: schiang <frank70199 at gmail.com>
Date: Fri, 19 Jul 2024 01:00:44 +0800
Subject: [PATCH 2/2] git clang-format changes
---
clang/include/clang/Sema/Sema.h | 3 ++-
clang/lib/Parse/Parser.cpp | 3 ++-
clang/lib/Sema/SemaDeclCXX.cpp | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index f887fc261a07e..622b107b80081 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5997,7 +5997,8 @@ class Sema final : public SemaBase {
StringLiteral *Message = nullptr);
void SetDeclDefaulted(Scope *S, Decl *dcl, SourceLocation DefaultLoc);
- void SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
+ void SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc,
+ FnBodyKind BodyKind,
StringLiteral *DeletedMessage = nullptr);
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D);
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr);
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index f1d98bced80b2..eaf67ed633016 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1479,7 +1479,8 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
D.getMutableDeclSpec().abort();
if (BodyKind != Sema::FnBodyKind::Other) {
- Actions.SetFunctionBodyKind(getCurScope(), Res, KWLoc, BodyKind, DeletedMessage);
+ Actions.SetFunctionBodyKind(getCurScope(), Res, KWLoc, BodyKind,
+ DeletedMessage);
Stmt *GeneratedBody = Res ? Res->getBody() : nullptr;
Actions.ActOnFinishFunctionBody(Res, GeneratedBody, false);
return Res;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index e57057fac10c6..0f0fe10b57517 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18050,7 +18050,8 @@ void Sema::DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock) {
}
}
-void Sema::SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
+void Sema::SetFunctionBodyKind(Scope *S, Decl *D, SourceLocation Loc,
+ FnBodyKind BodyKind,
StringLiteral *DeletedMessage) {
switch (BodyKind) {
case FnBodyKind::Delete:
More information about the cfe-commits
mailing list