aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-03-06 21:08:25 -0800
committerGitHub <noreply@github.com>2025-03-06 21:08:25 -0800
commit3664b4e2d5800eca5c8253a3915b87fa12ea7ebc (patch)
treeae2d5fd4b69ef40e3b96c5c88ff96dc4bb8ae17d /clang/lib/Format/UnwrappedLineParser.cpp
parent95767a9903208e545badd920a1a16e5476ae09f9 (diff)
downloadllvm-3664b4e2d5800eca5c8253a3915b87fa12ea7ebc.zip
llvm-3664b4e2d5800eca5c8253a3915b87fa12ea7ebc.tar.gz
llvm-3664b4e2d5800eca5c8253a3915b87fa12ea7ebc.tar.bz2
[clang-format] Remove special handling of C++ access specifiers in C (#129983)
This effectively reverts d1aed486efc6d35a81ca4acbabb4203c4b91cda9 because of #129426.
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp64
1 files changed, 2 insertions, 62 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index efb22bc..6854e22 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -3386,75 +3386,15 @@ void UnwrappedLineParser::parseSwitch(bool IsExpr) {
NestedTooDeep.pop_back();
}
-// Operators that can follow a C variable.
-static bool isCOperatorFollowingVar(tok::TokenKind Kind) {
- switch (Kind) {
- case tok::ampamp:
- case tok::ampequal:
- case tok::arrow:
- case tok::caret:
- case tok::caretequal:
- case tok::comma:
- case tok::ellipsis:
- case tok::equal:
- case tok::equalequal:
- case tok::exclaim:
- case tok::exclaimequal:
- case tok::greater:
- case tok::greaterequal:
- case tok::greatergreater:
- case tok::greatergreaterequal:
- case tok::l_paren:
- case tok::l_square:
- case tok::less:
- case tok::lessequal:
- case tok::lessless:
- case tok::lesslessequal:
- case tok::minus:
- case tok::minusequal:
- case tok::minusminus:
- case tok::percent:
- case tok::percentequal:
- case tok::period:
- case tok::pipe:
- case tok::pipeequal:
- case tok::pipepipe:
- case tok::plus:
- case tok::plusequal:
- case tok::plusplus:
- case tok::question:
- case tok::r_brace:
- case tok::r_paren:
- case tok::r_square:
- case tok::semi:
- case tok::slash:
- case tok::slashequal:
- case tok::star:
- case tok::starequal:
- return true;
- default:
- return false;
- }
-}
-
void UnwrappedLineParser::parseAccessSpecifier() {
- FormatToken *AccessSpecifierCandidate = FormatTok;
nextToken();
// Understand Qt's slots.
if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
nextToken();
// Otherwise, we don't know what it is, and we'd better keep the next token.
- if (FormatTok->is(tok::colon)) {
+ if (FormatTok->is(tok::colon))
nextToken();
- addUnwrappedLine();
- } else if (FormatTok->isNot(tok::coloncolon) &&
- !isCOperatorFollowingVar(FormatTok->Tok.getKind())) {
- // Not a variable name nor namespace name.
- addUnwrappedLine();
- } else if (AccessSpecifierCandidate) {
- // Consider the access specifier to be a C identifier.
- AccessSpecifierCandidate->Tok.setKind(tok::identifier);
- }
+ addUnwrappedLine();
}
/// \brief Parses a requires, decides if it is a clause or an expression.