forked from OSchip/llvm-project
clang-format: Fix corner case in OpenMP pragma formatting.
Before: #pragma omp reduction( | : var) After: #pragma omp reduction(| : var) llvm-svn: 187892
This commit is contained in:
parent
54533f73a8
commit
9613c81fd2
|
@ -1236,7 +1236,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
|
|||
if (Tok.isOneOf(tok::arrowstar, tok::periodstar) ||
|
||||
Tok.Previous->isOneOf(tok::arrowstar, tok::periodstar))
|
||||
return false;
|
||||
if (Tok.Type == TT_BinaryOperator || Tok.Previous->Type == TT_BinaryOperator)
|
||||
if ((Tok.Type == TT_BinaryOperator && !Tok.Previous->is(tok::l_paren)) ||
|
||||
Tok.Previous->Type == TT_BinaryOperator)
|
||||
return true;
|
||||
if (Tok.Previous->Type == TT_TemplateCloser && Tok.is(tok::l_paren))
|
||||
return false;
|
||||
|
|
|
@ -5532,6 +5532,11 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
|
|||
BreakBeforeBrace);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, UnderstandsPragmas) {
|
||||
verifyFormat("#pragma omp reduction(| : var)");
|
||||
verifyFormat("#pragma omp reduction(+ : var)");
|
||||
}
|
||||
|
||||
bool allStylesEqual(ArrayRef<FormatStyle> Styles) {
|
||||
for (size_t i = 1; i < Styles.size(); ++i)
|
||||
if (!(Styles[0] == Styles[i]))
|
||||
|
|
Loading…
Reference in New Issue