forked from OSchip/llvm-project
Format: support inline namespaces
Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. llvm-svn: 251690
This commit is contained in:
parent
49359bf3d7
commit
328085f325
|
@ -1367,7 +1367,7 @@ void UnwrappedLineParser::parseNamespace() {
|
|||
|
||||
const FormatToken &InitialToken = *FormatTok;
|
||||
nextToken();
|
||||
if (FormatTok->Tok.is(tok::identifier))
|
||||
while (FormatTok->isOneOf(tok::identifier, tok::coloncolon))
|
||||
nextToken();
|
||||
if (FormatTok->Tok.is(tok::l_brace)) {
|
||||
if (ShouldBreakBeforeBrace(Style, InitialToken))
|
||||
|
|
|
@ -2192,6 +2192,13 @@ TEST_F(FormatTest, FormatsNamespaces) {
|
|||
"} // my_namespace\n"
|
||||
"#endif // HEADER_GUARD"));
|
||||
|
||||
EXPECT_EQ("namespace A::B {\n"
|
||||
"class C {};\n"
|
||||
"}",
|
||||
format("namespace A::B {\n"
|
||||
"class C {};\n"
|
||||
"}"));
|
||||
|
||||
FormatStyle Style = getLLVMStyle();
|
||||
Style.NamespaceIndentation = FormatStyle::NI_All;
|
||||
EXPECT_EQ("namespace out {\n"
|
||||
|
|
Loading…
Reference in New Issue