[clang] [Clang][Sema] Fix a bug on template partial specialization with issue on deduction of nontype tempalte parameter (PR #90376)

via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 28 02:12:21 PDT 2024


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 37eb9c9632fb5e82827d1a0559f2279e9a9f1969 641f3e695c4bf7cd67e9aff0e0d345b59ad88685 -- clang/test/SemaCXX/PR68885.cpp clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5425d862a0..6e5f7bd61a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8507,17 +8507,17 @@ ExprResult Sema::BuildExpressionFromDeclTemplateArgument(
   } else {
     assert(ParamType->isReferenceType() &&
            "unexpected type for decl template argument");
-      if (NonTypeTemplateParmDecl *NTTP =
-              dyn_cast_if_present<NonTypeTemplateParmDecl>(TemplateParam)) {
-        QualType TemplateParamType = NTTP->getType();
-        const AutoType *AT = TemplateParamType->getAs<AutoType>();
-        if (AT && AT->isDecltypeAuto()) {
+    if (NonTypeTemplateParmDecl *NTTP =
+            dyn_cast_if_present<NonTypeTemplateParmDecl>(TemplateParam)) {
+      QualType TemplateParamType = NTTP->getType();
+      const AutoType *AT = TemplateParamType->getAs<AutoType>();
+      if (AT && AT->isDecltypeAuto()) {
         RefExpr = new (getASTContext()) SubstNonTypeTemplateParmExpr(
             ParamType->getPointeeType(), RefExpr.get()->getValueKind(),
             RefExpr.get()->getExprLoc(), RefExpr.get(), VD, 0, std::nullopt,
             true);
-        }
       }
+    }
   }
 
   // At this point we should have the right value category.

``````````

</details>


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


More information about the cfe-commits mailing list