Formatter: parse and format inline namespaces like regular namespaces
This changes formatting from: inline namespace X { class A { }; } to: inline namespace X { class A { }; } llvm-svn: 171266
This commit is contained in:
parent
2a5f569d88
commit
58d64e2bb1
|
@ -100,10 +100,19 @@ void UnwrappedLineParser::parseComments() {
|
|||
void UnwrappedLineParser::parseStatement() {
|
||||
parseComments();
|
||||
|
||||
int TokenNumber = 0;
|
||||
switch (FormatTok.Tok.getKind()) {
|
||||
case tok::kw_namespace:
|
||||
parseNamespace();
|
||||
return;
|
||||
case tok::kw_inline:
|
||||
nextToken();
|
||||
TokenNumber++;
|
||||
if (FormatTok.Tok.is(tok::kw_namespace)) {
|
||||
parseNamespace();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case tok::kw_public:
|
||||
case tok::kw_protected:
|
||||
case tok::kw_private:
|
||||
|
@ -132,7 +141,6 @@ void UnwrappedLineParser::parseStatement() {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
int TokenNumber = 0;
|
||||
do {
|
||||
++TokenNumber;
|
||||
switch (FormatTok.Tok.getKind()) {
|
||||
|
|
|
@ -349,6 +349,13 @@ TEST_F(FormatTest, FormatsNamespaces) {
|
|||
" f();\n"
|
||||
"}\n"
|
||||
"}");
|
||||
verifyFormat("inline namespace X {\n"
|
||||
"class A {\n"
|
||||
"};\n"
|
||||
"void f() {\n"
|
||||
" f();\n"
|
||||
"}\n"
|
||||
"}");
|
||||
verifyFormat("using namespace some_namespace;\n"
|
||||
"class A {\n"
|
||||
"};\n"
|
||||
|
|
Loading…
Reference in New Issue