forked from OSchip/llvm-project
				
			Fix clang-format's expression parser for leading }s.
The leading "}" in the construct "} else if (..) {" was confusing the
expression parser. Thus, no fake parentheses were generated and the
indentation was broken in some cases.
llvm-svn: 183393
			
			
This commit is contained in:
		
							parent
							
								
									c87e009059
								
							
						
					
					
						commit
						6dcecb6b33
					
				| 
						 | 
				
			
			@ -773,7 +773,11 @@ private:
 | 
			
		|||
/// operator precedence.
 | 
			
		||||
class ExpressionParser {
 | 
			
		||||
public:
 | 
			
		||||
  ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {}
 | 
			
		||||
  ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {
 | 
			
		||||
    // Skip leading "}", e.g. in "} else if (...) {".
 | 
			
		||||
    if (Current->is(tok::r_brace))
 | 
			
		||||
      next();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// \brief Parse expressions with the given operatore precedence.
 | 
			
		||||
  void parse(int Precedence = 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2073,6 +2073,10 @@ TEST_F(FormatTest, ExpressionIndentation) {
 | 
			
		|||
               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n"
 | 
			
		||||
               "            aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n"
 | 
			
		||||
               "        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}");
 | 
			
		||||
  verifyFormat("if () {\n"
 | 
			
		||||
               "} else if (aaaaa && bbbbb > // break\n"
 | 
			
		||||
               "                        ccccc) {\n"
 | 
			
		||||
               "}");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_F(FormatTest, ConstructorInitializers) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue