From: Manuel Klimek Date: Mon, 21 Jan 2013 14:32:05 +0000 (+0000) Subject: Fixes indent in linkage specification blocks. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d19dc2ddf3f8630cfdbefec490c0000c14bee6bd;p=clang Fixes indent in linkage specification blocks. We now indent: extern "C" { int a; } without additional indent inside the extern "C" block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173045 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 7f9e97eab0..f1d08a6bdf 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -311,6 +311,18 @@ void UnwrappedLineParser::parseStructuralElement() { case tok::kw_return: parseReturn(); return; + case tok::kw_extern: + nextToken(); + if (FormatTok.Tok.is(tok::string_literal)) { + nextToken(); + if (FormatTok.Tok.is(tok::l_brace)) { + parseBlock(0); + addUnwrappedLine(); + return; + } + } + // In all other cases, parse the declaration. + break; default: break; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index f8c454b7bc..f67cd8c222 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -526,6 +526,10 @@ TEST_F(FormatTest, FormatsNamespaces) { "void f() { f(); }"); } +TEST_F(FormatTest, FormatsExternC) { + verifyFormat("extern \"C\" {\nint a;"); +} + TEST_F(FormatTest, FormatTryCatch) { // FIXME: Handle try-catch explicitly in the UnwrappedLineParser, then we'll // also not create single-line-blocks.