compnerd created this revision. compnerd added a reviewer: djasper. compnerd added a subscriber: cfe-commits. Herald added a subscriber: klimek.
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. http://reviews.llvm.org/D14188 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2192,6 +2192,13 @@ "} // 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" Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1367,7 +1367,8 @@ const FormatToken &InitialToken = *FormatTok; nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->Tok.is(tok::identifier) || + FormatTok->Tok.is(tok::coloncolon)) nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (ShouldBreakBeforeBrace(Style, InitialToken))
Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2192,6 +2192,13 @@ "} // 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" Index: lib/Format/UnwrappedLineParser.cpp =================================================================== --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1367,7 +1367,8 @@ const FormatToken &InitialToken = *FormatTok; nextToken(); - if (FormatTok->Tok.is(tok::identifier)) + while (FormatTok->Tok.is(tok::identifier) || + FormatTok->Tok.is(tok::coloncolon)) nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (ShouldBreakBeforeBrace(Style, InitialToken))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits