https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/84459
We don't modify the MLTAL parameter in `SetupConstraintScope`, and it is better if we don't copy the 120-byte object each time we call the function. >From 6d51233690d0030e3191198c1a7a330be723b1af Mon Sep 17 00:00:00 2001 From: Younan Zhang <zyn7...@gmail.com> Date: Fri, 8 Mar 2024 18:40:27 +0800 Subject: [PATCH] [Sema] Avoid unnecessary copy on MultiLevelTemplateArgumentList. NFC We don't modify the MLTAL parameter in SetupConstraintScope, and it is better if we don't copy the 120-byte object each time we call the function. --- clang/include/clang/Sema/Sema.h | 10 ++++++---- clang/lib/Sema/SemaConcept.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 592c7871a4a55d..2cac7e6ca08fad 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -11607,12 +11607,14 @@ class Sema final { LocalInstantiationScope &Scope, const MultiLevelTemplateArgumentList &TemplateArgs); - /// used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in + /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in /// the case of lambdas) set up the LocalInstantiationScope of the current /// function. - bool SetupConstraintScope( - FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs, - MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope); + bool + SetupConstraintScope(FunctionDecl *FD, + std::optional<ArrayRef<TemplateArgument>> TemplateArgs, + const MultiLevelTemplateArgumentList &MLTAL, + LocalInstantiationScope &Scope); /// Used during constraint checking, sets up the constraint template argument /// lists, and calls SetupConstraintScope to set up the diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 2878e4d31ee8fe..a8e387e35fb4c9 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -586,7 +586,8 @@ bool Sema::addInstantiatedCapturesToScope( bool Sema::SetupConstraintScope( FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs, - MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope) { + const MultiLevelTemplateArgumentList &MLTAL, + LocalInstantiationScope &Scope) { if (FD->isTemplateInstantiation() && FD->getPrimaryTemplate()) { FunctionTemplateDecl *PrimaryTemplate = FD->getPrimaryTemplate(); InstantiatingTemplate Inst( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits