summaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 7e8634aeec4e..91b8fdc8a3c3 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2579,30 +2579,34 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) {
/// double ampersands. This applies for all nested scopes as well.
///
/// Returns whether there is a `=` token between the parentheses.
-bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
+bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType,
+ bool InMacroCall) {
assert(FormatTok->is(tok::l_paren) && "'(' expected.");
auto *LParen = FormatTok;
+ auto *Prev = FormatTok->Previous;
bool SeenComma = false;
bool SeenEqual = false;
bool MightBeFoldExpr = false;
nextToken();
const bool MightBeStmtExpr = FormatTok->is(tok::l_brace);
+ if (!InMacroCall && Prev && Prev->is(TT_FunctionLikeMacro))
+ InMacroCall = true;
do {
switch (FormatTok->Tok.getKind()) {
case tok::l_paren:
- if (parseParens(AmpAmpTokenType))
+ if (parseParens(AmpAmpTokenType, InMacroCall))
SeenEqual = true;
if (Style.isJava() && FormatTok->is(tok::l_brace))
parseChildBlock();
break;
case tok::r_paren: {
- auto *Prev = LParen->Previous;
auto *RParen = FormatTok;
nextToken();
if (Prev) {
auto OptionalParens = [&] {
- if (MightBeStmtExpr || MightBeFoldExpr || Line->InMacroBody ||
- SeenComma || Style.RemoveParentheses == FormatStyle::RPS_Leave ||
+ if (MightBeStmtExpr || MightBeFoldExpr || SeenComma || InMacroCall ||
+ Line->InMacroBody ||
+ Style.RemoveParentheses == FormatStyle::RPS_Leave ||
RParen->getPreviousNonComment() == LParen) {
return false;
}