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

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 30 14:44:59 PDT 2024


================
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult &PotentialTemplateName) {
                     Priority);
 }
 
+bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) {
+  assert(Tok.is(tok::coloncolon));
+  Sema::DisableTypoCorrectionRAII DTC(Actions);
+  ColonProtectionRAIIObject ColonProtection(*this);
+
+  SourceLocation StartLoc = Tok.getLocation();
+  if (TryAnnotateTypeOrScopeToken())
+    return true;
+  if (Tok.isSimpleTypeSpecifier(getLangOpts()))
+    return false;
+  CXXScopeSpec SS;
+  ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
+                                 /*ObjectHasErrors=*/false,
+                                 /*EnteringContext=*/false);
+  ExprResult Result = tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false);
----------------
zygoloid wrote:

Parsing the same expression twice could also be problematic in some cases -- for example, if it contains a lambda, we might assign it the wrong mangling number. Can we arrange things such that for a valid program, we only parse the expression once?

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


More information about the cfe-commits mailing list