[clang] [Clang][Sema] Diagnose friend function specialization definitions (PR #72863)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 27 05:03:12 PST 2023


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 57a11b7f75742ba74b563b8af75bc106a1e9d29e 2dc6567a7054feb755351b8d403b228f3d4b91ea -- clang/lib/AST/Decl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CXX/class.access/class.friend/p6.cpp clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp clang/test/SemaCXX/friend.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9dbfd92de7..b6748f8404 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17870,8 +17870,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D,
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
                         ForExternalRedeclaration);
 
-  bool isTemplateId =
-      D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId;
+  bool isTemplateId = D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId;
 
   // There are five cases here.
   //   - There's no scope specifier and we're in a local class. Only look
@@ -18072,8 +18071,8 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D,
         // FIXME: We should only do this if the scope specifier names the
         // innermost enclosing namespace; otherwise the fixit changes the
         // meaning of the code.
-        SemaDiagnosticBuilder DB
-          = Diag(SS.getRange().getBegin(), diag::err_qualified_friend_def);
+        SemaDiagnosticBuilder DB =
+            Diag(SS.getRange().getBegin(), diag::err_qualified_friend_def);
 
         DB << SS.getScopeRep();
         if (DC->isFileContext())
@@ -18085,9 +18084,10 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D,
       }
       // Per [basic.pre]p4, a template-id is not a name. Therefore, if we have
       // a template-id, the function name is not unqualified because these is no
-      // name. While the wording requires some reading in-between the lines, GCC,
-      // MSVC, and EDG all consider a friend function specialization definitions
-      // to be de facto explicit specialization and diagnose them as such.
+      // name. While the wording requires some reading in-between the lines,
+      // GCC, MSVC, and EDG all consider a friend function specialization
+      // definitions to be de facto explicit specialization and diagnose them as
+      // such.
       else if (isTemplateId) {
         Diag(NameInfo.getBeginLoc(), diag::err_friend_specialization_def);
       }

``````````

</details>


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


More information about the cfe-commits mailing list