diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 12 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJava.cpp | 13 |
2 files changed, 19 insertions, 6 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index b50a9a9a127..53876bab581 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -905,12 +905,6 @@ unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current, unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, LineState &State, bool DryRun) { - // FIXME: String literal breaking is currently disabled for Java and JS, as - // it requires strings to be merged using "+" which we don't support. - if (Style.Language == FormatStyle::LK_Java || - Style.Language == FormatStyle::LK_JavaScript) - return 0; - // Don't break multi-line tokens other than block comments. Instead, just // update the state. if (Current.isNot(TT_BlockComment) && Current.IsMultiline) @@ -929,6 +923,12 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, unsigned ColumnLimit = getColumnLimit(State); if (Current.isStringLiteral()) { + // FIXME: String literal breaking is currently disabled for Java and JS, as + // it requires strings to be merged using "+" which we don't support. + if (Style.Language == FormatStyle::LK_Java || + Style.Language == FormatStyle::LK_JavaScript) + return 0; + // Don't break string literals inside preprocessor directives (except for // #define directives, as their contents are stored in separate lines and // are not affected by this check). diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index d80cccdc467..b4f67afd9b4 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -425,5 +425,18 @@ TEST_F(FormatTestJava, BreaksStringLiterals) { format("\"some text other\";", getStyleWithColumns(14))); } +TEST_F(FormatTestJava, AlignsBlockComments) { + EXPECT_EQ("/*\n" + " * Really multi-line\n" + " * comment.\n" + " */\n" + "void f() {}", + format(" /*\n" + " * Really multi-line\n" + " * comment.\n" + " */\n" + " void f() {}")); +} + } // end namespace tooling } // end namespace clang |