r223345 - clang-format: More restrictively classify import declarations.
Daniel Jasper
djasper at google.com
Thu Dec 4 00:57:27 PST 2014
Author: djasper
Date: Thu Dec 4 02:57:27 2014
New Revision: 223345
URL: http://llvm.org/viewvc/llvm-project?rev=223345&view=rev
Log:
clang-format: More restrictively classify import declarations.
Before:
import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=223345&r1=223344&r2=223345&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Dec 4 02:57:27 2014
@@ -615,7 +615,8 @@ public:
if ((Style.Language == FormatStyle::LK_Java &&
CurrentToken->is(Keywords.kw_package)) ||
(Info && Info->getPPKeywordID() == tok::pp_import &&
- CurrentToken->Next)) {
+ CurrentToken->Next &&
+ CurrentToken->Next->isOneOf(tok::string_literal, tok::identifier))) {
next();
parseIncludeDirective();
return LT_ImportStatement;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=223345&r1=223344&r2=223345&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Dec 4 02:57:27 2014
@@ -5611,6 +5611,10 @@ TEST_F(FormatTest, HandlesIncludeDirecti
Style.AlwaysBreakBeforeMultilineStrings = true;
Style.ColumnLimit = 0;
verifyFormat("#import \"abc.h\"", Style);
+
+ // But 'import' might also be a regular C++ namespace.
+ verifyFormat("import::SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list