@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
38
38
39
39
namespace {
40
40
41
+ SmallVector<llvm::StringRef, 100 > castIdentifiers{" __type_identity_t" ,
42
+ " remove_reference_t" };
43
+
41
44
// / Returns \c true if the line starts with a token that can start a statement
42
45
// / with an initializer.
43
46
static bool startsWithInitStatement (const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
2474
2477
Current.getNextNonComment ()->isOneOf (tok::comma, tok::r_brace)) {
2475
2478
Current.setType (TT_StringInConcatenation);
2476
2479
}
2480
+ } else if (Current.is (tok::kw_using)) {
2481
+ if (Current.Next ->Next ->Next ->isTypeName (LangOpts))
2482
+ castIdentifiers.push_back (Current.Next ->TokenText );
2477
2483
} else if (Current.is (tok::l_paren)) {
2478
2484
if (lParenStartsCppCast (Current))
2479
2485
Current.setType (TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
2831
2837
IsQualifiedPointerOrReference (BeforeRParen, LangOpts);
2832
2838
bool ParensCouldEndDecl =
2833
2839
AfterRParen->isOneOf (tok::equal, tok::semi, tok::l_brace, tok::greater);
2834
- if (ParensAreType && !ParensCouldEndDecl)
2840
+ if (ParensAreType && !ParensCouldEndDecl) {
2841
+ if (BeforeRParen->is (TT_TemplateCloser)) {
2842
+ auto *Prev = BeforeRParen->MatchingParen ->getPreviousNonComment ();
2843
+ if (Prev) {
2844
+ for (auto &name : castIdentifiers)
2845
+ if (Prev->TokenText == name)
2846
+ return true ;
2847
+ return false ;
2848
+ }
2849
+ }
2835
2850
return true ;
2851
+ }
2836
2852
2837
2853
// At this point, we heuristically assume that there are no casts at the
2838
2854
// start of the line. We assume that we have found most cases where there
0 commit comments