[clang] [Clang] Do not assume a perfect match is a better match than a non-template non-perfect match (PR #149504)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 18 05:15:12 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/Sema/Overload.h clang/lib/Sema/SemaOverload.cpp clang/test/SemaCXX/overload-resolution-deferred-templates.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index cf9bd1b71..5dd5b4954 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11353,13 +11353,13 @@ OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S,
   bool TwoPhaseResolution =
       DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
 
-  if(TwoPhaseResolution) {
-      OverloadingResult Res = BestViableFunctionImpl(S, Loc, Best);
-      if (Best != end() && Best->isPerfectMatch(S.Context)) {
-          if(!(HasDeferredTemplateConstructors &&
-               isa_and_nonnull<CXXConversionDecl>(Best->Function)))
-          return Res;
-      }
+  if (TwoPhaseResolution) {
+    OverloadingResult Res = BestViableFunctionImpl(S, Loc, Best);
+    if (Best != end() && Best->isPerfectMatch(S.Context)) {
+      if (!(HasDeferredTemplateConstructors &&
+            isa_and_nonnull<CXXConversionDecl>(Best->Function)))
+        return Res;
+    }
   }
 
   InjectNonDeducedTemplateCandidates(S);

``````````

</details>


https://github.com/llvm/llvm-project/pull/149504


More information about the cfe-commits mailing list