aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-10-02 19:06:56 -0700
committerGitHub <noreply@github.com>2024-10-02 19:06:56 -0700
commit14e1fef73625daf9fad1a2c51b16f67b3152a675 (patch)
tree5deedea9f3ef8b1c25729087c591228aacadd8c4 /clang/lib/Format/UnwrappedLineParser.cpp
parentb91a25ef58160acd296e87cf89a92fafd26b64ef (diff)
downloadllvm-14e1fef73625daf9fad1a2c51b16f67b3152a675.zip
llvm-14e1fef73625daf9fad1a2c51b16f67b3152a675.tar.gz
llvm-14e1fef73625daf9fad1a2c51b16f67b3152a675.tar.bz2
[clang-format] Handle template closer followed by empty paretheses (#110408)
Fixes #109925.
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 40f7726..a38a867 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2556,7 +2556,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
parseChildBlock();
break;
case tok::r_paren: {
- const auto *Prev = LeftParen->Previous;
+ auto *Prev = LeftParen->Previous;
if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody &&
Style.RemoveParentheses > FormatStyle::RPS_Leave) {
const auto *Next = Tokens->peekNextToken();
@@ -2585,9 +2585,13 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
FormatTok->Optional = true;
}
}
- if (Prev && Prev->is(TT_TypenameMacro)) {
- LeftParen->setFinalizedType(TT_TypeDeclarationParen);
- FormatTok->setFinalizedType(TT_TypeDeclarationParen);
+ if (Prev) {
+ if (Prev->is(TT_TypenameMacro)) {
+ LeftParen->setFinalizedType(TT_TypeDeclarationParen);
+ FormatTok->setFinalizedType(TT_TypeDeclarationParen);
+ } else if (Prev->is(tok::greater) && FormatTok->Previous == LeftParen) {
+ Prev->setFinalizedType(TT_TemplateCloser);
+ }
}
nextToken();
return SeenEqual;