From eef89054c7e76c6a92a2d2ac99c563e679bfd9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Tue, 8 Oct 2024 23:52:39 -0400 Subject: [PATCH] feat: recognize `in_ref` and `forward_ref` --- clang/lib/Format/FormatToken.h | 4 ++++ clang/lib/Format/UnwrappedLineParser.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index f2c3e4caa14b0e..912ebbcc140fd1 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -1109,9 +1109,11 @@ struct AdditionalKeywords { // Cpp2 keywords kw_next = &IdentTable.get("next"); kw_inspect = &IdentTable.get("inspect"); + kw_in_ref = &IdentTable.get("in_ref"); kw_copy = &IdentTable.get("copy"); kw_move = &IdentTable.get("move"); kw_forward = &IdentTable.get("forward"); + kw_forward_ref = &IdentTable.get("forward_ref"); kw_pre = &IdentTable.get("pre"); kw_post = &IdentTable.get("post"); @@ -1430,9 +1432,11 @@ struct AdditionalKeywords { // Cpp2 keywords. IdentifierInfo *kw_inspect; IdentifierInfo *kw_next; + IdentifierInfo *kw_in_ref; IdentifierInfo *kw_copy; IdentifierInfo *kw_move; IdentifierInfo *kw_forward; + IdentifierInfo *kw_forward_ref; IdentifierInfo *kw_pre; IdentifierInfo *kw_post; diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 281d0d3cdbf5ba..02eca5250bc99d 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2806,9 +2806,10 @@ void UnwrappedLineParser::parseCpp2PostfixExpression() { bool UnwrappedLineParser::atCpp2ParameterDirection( const CurrentToken Tok) const { const FormatToken *const Next = Tokens->peekNextToken(/*SkipComment=*/true); - return llvm::is_contained({Keywords.kw_in, Keywords.kw_copy, - Keywords.kw_inout, Keywords.kw_out, - Keywords.kw_move, Keywords.kw_forward}, + return llvm::is_contained({Keywords.kw_in, Keywords.kw_in_ref, + Keywords.kw_copy, Keywords.kw_inout, + Keywords.kw_out, Keywords.kw_move, + Keywords.kw_forward, Keywords.kw_forward_ref}, Tok->Tok.getIdentifierInfo()) && (startsCpp2Identifier(Next) || Next->is(tok::colon)); }