forked from OSchip/llvm-project
				
			Dont break between (( in __attribute__((.
Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
    (aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
     aaaaaaaaaaaaaaaaaaaaaaaaa));
After:
void aaaaaaaaaaaaaaaaaa()
    __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
                   aaaaaaaaaaaaaaaaaaaaaaaaa));
llvm-svn: 176260
			
			
This commit is contained in:
		
							parent
							
								
									c3c5c0971d
								
							
						
					
					
						commit
						9a23be7451
					
				| 
						 | 
					@ -1092,6 +1092,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
 | 
					  if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
					  if (Left.is(tok::l_paren) && Right.is(tok::l_paren) && Left.Parent &&
 | 
				
			||||||
 | 
					      Left.Parent->is(tok::kw___attribute))
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (Right.Type == TT_LineComment)
 | 
					  if (Right.Type == TT_LineComment)
 | 
				
			||||||
    // We rely on MustBreakBefore being set correctly here as we should not
 | 
					    // We rely on MustBreakBefore being set correctly here as we should not
 | 
				
			||||||
| 
						 | 
					@ -1120,7 +1123,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
 | 
				
			||||||
         Right.is(tok::colon) || Left.is(tok::coloncolon) ||
 | 
					         Right.is(tok::colon) || Left.is(tok::coloncolon) ||
 | 
				
			||||||
         Left.is(tok::semi) || Left.is(tok::l_brace) ||
 | 
					         Left.is(tok::semi) || Left.is(tok::l_brace) ||
 | 
				
			||||||
         (Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&
 | 
					         (Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&
 | 
				
			||||||
          Right.is(tok::identifier)) ||
 | 
					          (Right.is(tok::identifier) || Right.is(tok::kw___attribute))) ||
 | 
				
			||||||
         (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
 | 
					         (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
 | 
				
			||||||
         (Left.is(tok::l_square) && !Right.is(tok::r_square));
 | 
					         (Left.is(tok::l_square) && !Right.is(tok::r_square));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1334,6 +1334,10 @@ TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {
 | 
				
			||||||
               "    GUARDED_BY(aaaaaaaaaaaaa);");
 | 
					               "    GUARDED_BY(aaaaaaaaaaaaa);");
 | 
				
			||||||
  verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
 | 
					  verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
 | 
				
			||||||
               "    GUARDED_BY(aaaaaaaaaaaaa) {}");
 | 
					               "    GUARDED_BY(aaaaaaaaaaaaa) {}");
 | 
				
			||||||
 | 
					  verifyFormat(
 | 
				
			||||||
 | 
					      "void aaaaaaaaaaaaaaaaaa()\n"
 | 
				
			||||||
 | 
					      "    __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"
 | 
				
			||||||
 | 
					      "                   aaaaaaaaaaaaaaaaaaaaaaaaa));");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
 | 
					TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue