[libcxx-commits] [clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 30 08:11:40 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 842a332f11f53c698fa0560505e533ecdca28876 e3829cd5d915958101e094a6354869a755198083 --extensions ,cpp,h,c -- clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3-example3.cpp clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3.cpp clang/test/CXX/temp/temp.names/p3-23.cpp clang/include/clang/AST/ExprCXX.h clang/include/clang/AST/Stmt.h clang/include/clang/AST/UnresolvedSet.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/DeclSpec.h clang/include/clang/Sema/Lookup.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/ExprCXX.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Parse/ParseTemplate.cpp clang/lib/Parse/ParseTentative.cpp clang/lib/Parse/Parser.cpp clang/lib/Sema/SemaCXXScopeSpec.cpp clang/lib/Sema/SemaCoroutine.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprMember.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmtAsm.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp clang/test/CXX/class.derived/class.member.lookup/p8.cpp clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp clang/test/CXX/drs/cwg1xx.cpp clang/test/CXX/temp/temp.res/p3.cpp clang/test/FixIt/fixit.cpp clang/test/Misc/warning-flags.c clang/test/Parser/cxx2a-concepts-requires-expr.cpp clang/test/SemaCXX/cxx0x-noexcept-expression.cpp clang/test/SemaCXX/nested-name-spec.cpp clang/test/SemaCXX/pseudo-destructors.cpp clang/test/SemaCXX/static-assert-cxx17.cpp clang/test/SemaTemplate/dependent-base-classes.cpp clang/test/SemaTemplate/dependent-template-recover.cpp clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp clang/test/SemaTemplate/template-id-expr.cpp clang/test/SemaTemplate/typename-specifier-3.cpp libcxx/include/regex
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index f5a6520610..57c16913e4 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -560,7 +560,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
 
       if (MemberOfUnknownSpecialization && !Disambiguation &&
           (ObjectType || SS.isSet()) &&
-          (IsTypename || isTemplateArgumentList(1, TNK_Non_template) == TPResult::True)) {
+          (IsTypename ||
+           isTemplateArgumentList(1, TNK_Non_template) == TPResult::True)) {
         // If we had errors before, ObjectType can be dependent even without any
         // templates. Do not report missing template keyword in that case.
         if (!ObjectHadErrors) {
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index dbf9e36d83..f0f94d20c2 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Parse/Parser.h"
 #include "clang/Parse/ParseDiagnostic.h"
+#include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/ParsedTemplate.h"
 using namespace clang;
@@ -1016,8 +1016,7 @@ Parser::TPResult Parser::TryParseNonConversionOperatorId() {
   return TPResult::False;
 }
 Parser::TPResult Parser::TryParseOperatorId() {
-  if (TPResult TPR = TryParseNonConversionOperatorId();
-      TPR != TPResult::False)
+  if (TPResult TPR = TryParseNonConversionOperatorId(); TPR != TPResult::False)
     return TPR;
 
   // Maybe this is a conversion-function-id.
@@ -2310,7 +2309,8 @@ Parser::TPResult Parser::TryParseBracketDeclarator() {
 /// of a template-id or simple-template-id, rather than a less-than comparison.
 /// This will often fail and produce an ambiguity, but should never be wrong
 /// if it returns True or False.
-Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateNameKind TNK) {
+Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
+                                                TemplateNameKind TNK) {
   if (!TokensToSkip) {
     if (Tok.isNot(tok::less))
       return TPResult::False;
@@ -2336,50 +2336,50 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
     unsigned TemplateDepth = 0;
     while (true) {
       switch (Tok.getKind()) {
-        case tok::eof:
-        case tok::annot_module_begin:
-        case tok::annot_module_end:
-        case tok::annot_module_include:
-        case tok::annot_repl_input_end:
-        case tok::semi:
-          return TPResult::False;
-
-        case tok::comma:
-        case tok::greater:
-        case tok::greatergreater:
-        case tok::greatergreatergreater:
-          return TPResult::True;
+      case tok::eof:
+      case tok::annot_module_begin:
+      case tok::annot_module_end:
+      case tok::annot_module_include:
+      case tok::annot_repl_input_end:
+      case tok::semi:
+        return TPResult::False;
 
-        case tok::l_paren:
-          ConsumeParen();
-          if (!SkipUntil(tok::r_paren, StopAtSemi))
-            return TPResult::Error;
-          break;
-        case tok::l_brace:
-          ConsumeBrace();
-          if (!SkipUntil(tok::r_brace, StopAtSemi))
-            return TPResult::Error;
-          break;
-        case tok::l_square:
-          ConsumeBracket();
-          if (!SkipUntil(tok::r_square, StopAtSemi))
-            return TPResult::Error;
-          break;
-        case tok::question:
+      case tok::comma:
+      case tok::greater:
+      case tok::greatergreater:
+      case tok::greatergreatergreater:
+        return TPResult::True;
+
+      case tok::l_paren:
+        ConsumeParen();
+        if (!SkipUntil(tok::r_paren, StopAtSemi))
+          return TPResult::Error;
+        break;
+      case tok::l_brace:
+        ConsumeBrace();
+        if (!SkipUntil(tok::r_brace, StopAtSemi))
+          return TPResult::Error;
+        break;
+      case tok::l_square:
+        ConsumeBracket();
+        if (!SkipUntil(tok::r_square, StopAtSemi))
+          return TPResult::Error;
+        break;
+      case tok::question:
         ConsumeToken();
         if (!SkipUntil(tok::colon, StopAtSemi))
-            return TPResult::Error;
+          return TPResult::Error;
         break;
 
-        #if 0
+#if 0
         case tok::kw_template:
           ConsumeToken();
           NextIsTemplateId = true;
           continue;
-        #endif
-        case tok::identifier:
-          ConsumeToken();
-          #if 0
+#endif
+      case tok::identifier:
+        ConsumeToken();
+#if 0
           if (Tok.is(tok::less)) {
             if (!NextIsTemplateId)
               return TPResult::Ambiguous;
@@ -2388,23 +2388,23 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
               return TPResult::Error;
             break;
           }
-          #else
+#else
+        if (Tok.is(tok::less))
+          return TPResult::Ambiguous;
+        break;
+#endif
+
+      case tok::kw_operator:
+        if (TPResult TPR = TryParseNonConversionOperatorId();
+            TPR == TPResult::Error) {
+          return TPResult::Error;
+        } else if (TPR == TPResult::True) {
           if (Tok.is(tok::less))
             return TPResult::Ambiguous;
-          break;
-          #endif
-
-        case tok::kw_operator:
-          if (TPResult TPR = TryParseNonConversionOperatorId();
-              TPR == TPResult::Error) {
-            return TPResult::Error;
-          } else if (TPR == TPResult::True) {
-            if (Tok.is(tok::less))
-              return TPResult::Ambiguous;
-          }
-          break;
+        }
+        break;
 
-          #if 0
+#if 0
           if (Tok.is(tok::less)) {
             if (!NextIsTemplateId)
               return TPResult::Ambiguous;
@@ -2413,40 +2413,42 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
               return TPResult::Error;
           }
           break;
-          #endif
+#endif
 
-        case tok::kw_const_cast:
-        case tok::kw_dynamic_cast:
-        case tok::kw_reinterpret_cast:
-        case tok::kw_static_cast: {
-          ConsumeToken();
-          if (!TryConsumeToken(tok::less))
-            return TPResult::Error;
-          bool MayHaveTrailingReturnType = Tok.is(tok::kw_auto);
-
-          while (true) {
-            TPResult TPR = isCXXDeclarationSpecifier(ImplicitTypenameContext::Yes);
-            if (TPR == TPResult::False)
-              break;
-            if (TPR == TPResult::Error ||
-                TryConsumeDeclarationSpecifier() == TPResult::Error)
-              return TPResult::Error;
-          }
-
-          if (TryParseDeclarator(
-              /*mayBeAbstract=*/true,
-              /*mayHaveIdentifier=*/false,
-              /*mayHaveDirectInit=*/false,
-              /*mayHaveTrailingReturnType=*/MayHaveTrailingReturnType) == TPResult::Error)
-            return TPResult::Error;
+      case tok::kw_const_cast:
+      case tok::kw_dynamic_cast:
+      case tok::kw_reinterpret_cast:
+      case tok::kw_static_cast: {
+        ConsumeToken();
+        if (!TryConsumeToken(tok::less))
+          return TPResult::Error;
+        bool MayHaveTrailingReturnType = Tok.is(tok::kw_auto);
 
-          if (!TryConsumeToken(tok::greater))
+        while (true) {
+          TPResult TPR =
+              isCXXDeclarationSpecifier(ImplicitTypenameContext::Yes);
+          if (TPR == TPResult::False)
+            break;
+          if (TPR == TPResult::Error ||
+              TryConsumeDeclarationSpecifier() == TPResult::Error)
             return TPResult::Error;
-          break;
         }
-        default:
-          ConsumeAnyToken();
-          break;
+
+        if (TryParseDeclarator(
+                /*mayBeAbstract=*/true,
+                /*mayHaveIdentifier=*/false,
+                /*mayHaveDirectInit=*/false,
+                /*mayHaveTrailingReturnType=*/MayHaveTrailingReturnType) ==
+            TPResult::Error)
+          return TPResult::Error;
+
+        if (!TryConsumeToken(tok::greater))
+          return TPResult::Error;
+        break;
+      }
+      default:
+        ConsumeAnyToken();
+        break;
       }
       NextIsTemplateId = false;
     }
@@ -2462,9 +2464,10 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
       return TPResult::Error;
 
     bool InvalidAsTemplateArgumentList = false;
-    TPResult TPR = isCXXDeclarationSpecifier(ImplicitTypenameContext::No,
-                                             /*BracedCastResult=*/TPResult::Ambiguous,
-                                             &InvalidAsTemplateArgumentList);
+    TPResult TPR =
+        isCXXDeclarationSpecifier(ImplicitTypenameContext::No,
+                                  /*BracedCastResult=*/TPResult::Ambiguous,
+                                  &InvalidAsTemplateArgumentList);
     if (InvalidAsTemplateArgumentList)
       return TPResult::False;
 
@@ -2501,7 +2504,7 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
     }
   }
 
-  #if 0
+#if 0
   // We can't do much to tell an expression apart from a template-argument,
   // but one good distinguishing factor is that a "decl-specifier" not
   // followed by '(' or '{' can't appear in an expression.
@@ -2512,7 +2515,7 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip, TemplateN
     return TPResult::True;
   if (InvalidAsTemplateArgumentList)
     return TPResult::False;
-  #endif
+#endif
 
   // FIXME: In many contexts, X<thing1, Type> can only be a
   // template-argument-list. But that's not true in general:

``````````

</details>


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


More information about the libcxx-commits mailing list