forked from OSchip/llvm-project
clang-format: Fix segfault in 'incomplete' macros.
The code leading to a segfault was: #pragma omp threadprivate(y)), // long comment leading to a line break This fixes llvm.org/PR16513. llvm-svn: 189460
This commit is contained in:
parent
a49393f54d
commit
96df37a6a1
|
@ -536,9 +536,10 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
|
|||
|
||||
// If we encounter a closing ), ], } or >, we can remove a level from our
|
||||
// stacks.
|
||||
if (Current.isOneOf(tok::r_paren, tok::r_square) ||
|
||||
(Current.is(tok::r_brace) && State.NextToken != Line.First) ||
|
||||
State.NextToken->Type == TT_TemplateCloser) {
|
||||
if (State.Stack.size() > 1 &&
|
||||
(Current.isOneOf(tok::r_paren, tok::r_square) ||
|
||||
(Current.is(tok::r_brace) && State.NextToken != Line.First) ||
|
||||
State.NextToken->Type == TT_TemplateCloser)) {
|
||||
State.Stack.pop_back();
|
||||
--State.ParenLevel;
|
||||
}
|
||||
|
|
|
@ -1942,6 +1942,9 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) {
|
|||
verifyFormat("#define A template <typename T>");
|
||||
verifyFormat("#define STR(x) #x\n"
|
||||
"f(STR(this_is_a_string_literal{));");
|
||||
verifyFormat("#pragma omp threadprivate( \\\n"
|
||||
" y)), // expected-warning",
|
||||
getLLVMStyleWithColumns(28));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
|
||||
|
|
Loading…
Reference in New Issue