Skip to content

Commit

Permalink
feat: recognize in_ref and forward_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Oct 9, 2024
1 parent ac5b07d commit eef8905
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions clang/lib/Format/FormatToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit eef8905

Please sign in to comment.