From ae610d173dee8a17b5a4c7c0029d05e6105dfd62 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Mon, 21 Jan 2013 14:32:05 +0000 Subject: [PATCH] Fixes indent in linkage specification blocks. We now indent: extern "C" { int a; } without additional indent inside the extern "C" block. llvm-svn: 173045 --- clang/lib/Format/UnwrappedLineParser.cpp | 12 ++++++++++++ clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7f9e97e..f1d08a6 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f8c454b7..f67cd8c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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. -- 2.7.4