diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9b215dcd473..9f692437cad 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ea5f67ca49d..6481a3122f6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5611,6 +5611,10 @@ TEST_F(FormatTest, HandlesIncludeDirectives) { 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);"); } //===----------------------------------------------------------------------===// |

