This prevents contracting:
auto lambda = []() {
int a = 2
#if A
+ 2
#endif
;
};
into:
auto lambda = []() { int a = 2
#if A + 2
#endif ; };
Which is obviously BAD.
This fixes llvm.org/PR22496.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228522
91177308-0d34-0410-b5e6-
96231b3b80d8
(FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) {
// If there is an unfinished unwrapped line, we flush the preprocessor
// directives only after that unwrapped line was finished later.
- bool SwitchToPreprocessorLines =
- !Line->Tokens.empty() && CurrentLines == &Lines;
+ bool SwitchToPreprocessorLines = !Line->Tokens.empty();
ScopedLineState BlockState(*this, SwitchToPreprocessorLines);
// Comments stored before the preprocessor directive need to be output
// before the preprocessor directive, at the same level as the
" doo_dah();\n"
" })) {\n"
"}");
+ verifyFormat("auto lambda = []() {\n"
+ " int a = 2\n"
+ "#if A\n"
+ " + 2\n"
+ "#endif\n"
+ " ;\n"
+ "};");
}
TEST_F(FormatTest, FormatsBlocks) {