llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: ofAlpaca (ofAlpaca) <details> <summary>Changes</summary> 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. --- Full diff: https://github.com/llvm/llvm-project/pull/99542.diff 5 Files Affected: - (modified) clang/include/clang/Sema/Sema.h (+3-2) - (modified) clang/lib/Parse/ParseCXXInlineMethods.cpp (+1-1) - (modified) clang/lib/Parse/Parser.cpp (+2-1) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+5-4) - (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2-2) ``````````diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 48dff1b76cc57..622b107b80081 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -5995,9 +5995,10 @@ 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..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(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..0f0fe10b57517 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,15 @@ 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, `````````` </details> https://github.com/llvm/llvm-project/pull/99542 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits