Skip to content

Commit

Permalink
[FOLD] format
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Oct 22, 2024
1 parent 963479d commit 1c80dcd
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 89 deletions.
3 changes: 2 additions & 1 deletion clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
179 changes: 91 additions & 88 deletions clang/lib/Parse/ParseTentative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2314,7 +2313,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;
Expand All @@ -2340,50 +2340,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;
Expand All @@ -2392,23 +2392,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;
Expand All @@ -2417,40 +2417,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;
}
Expand All @@ -2466,9 +2468,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;

Expand Down Expand Up @@ -2505,7 +2508,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.
Expand All @@ -2516,7 +2519,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:
Expand Down

0 comments on commit 1c80dcd

Please sign in to comment.