Author: Younan Zhang
Date: 2025-10-04T14:13:57+08:00
New Revision: 7fbfbab3324b88d75d68b2bdb3aed696be80d8d5

URL: 
https://github.com/llvm/llvm-project/commit/7fbfbab3324b88d75d68b2bdb3aed696be80d8d5
DIFF: 
https://github.com/llvm/llvm-project/commit/7fbfbab3324b88d75d68b2bdb3aed696be80d8d5.diff

LOG: [Clang][NFC] Avoid duplication in BuildDeductionGuideForTypeAlias (#161948)

This addresses the post-commit review 
https://github.com/llvm/llvm-project/pull/161035#discussion_r2403312649 from 
Shafik

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 9a61888e318b3..8ba23aa334afd 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1189,14 +1189,13 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
     // parameter list of a synthesized CTAD guide. See also the FIXME in
     // test/SemaCXX/cxx20-ctad-type-alias.cpp:test25.
     Sema::CheckTemplateArgumentInfo CTAI;
+    for (auto TA : Output.arguments())
+      if (SemaRef.CheckTemplateArgument(
+              TP, TA, F, F->getLocation(), F->getLocation(),
+              /*ArgumentPackIndex=*/-1, CTAI,
+              Sema::CheckTemplateArgumentKind::CTAK_Specified))
+        return nullptr;
     if (Input.getArgument().getKind() == TemplateArgument::Pack) {
-      for (auto TA : Output.arguments()) {
-        if (SemaRef.CheckTemplateArgument(
-                TP, TA, F, F->getLocation(), F->getLocation(),
-                /*ArgumentPackIndex=*/-1, CTAI,
-                Sema::CheckTemplateArgumentKind::CTAK_Specified))
-          return nullptr;
-      }
       // We will substitute the non-deduced template arguments with these
       // transformed (unpacked at this point) arguments, where that 
substitution
       // requires a pack for the corresponding parameter packs.
@@ -1204,12 +1203,6 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
           TemplateArgument::CreatePackCopy(Context, CTAI.SugaredConverted);
     } else {
       assert(Output.arguments().size() == 1);
-      TemplateArgumentLoc Transformed = Output.arguments()[0];
-      if (SemaRef.CheckTemplateArgument(
-              TP, Transformed, F, F->getLocation(), F->getLocation(),
-              /*ArgumentPackIndex=*/-1, CTAI,
-              Sema::CheckTemplateArgumentKind::CTAK_Specified))
-        return nullptr;
       TemplateArgsForBuildingFPrime[Index] = CTAI.SugaredConverted[0];
     }
   }


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to