diff options
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 5 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 3a432c57e0..276921795a 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -457,6 +457,10 @@ private: case tok::pp_warning: parseWarningOrError(); break; + case tok::pp_if: + case tok::pp_elif: + parseLine(); + break; default: break; } @@ -1181,6 +1185,7 @@ void TokenAnnotator::printDebugInfo(const AnnotatedLine &Line) { llvm::errs() << " M=" << Tok->MustBreakBefore << " C=" << Tok->CanBreakBefore << " T=" << Tok->Type << " S=" << Tok->SpacesRequiredBefore + << " P=" << Tok->SplitPenalty << " Name=" << Tok->FormatTok.Tok.getName() << " FakeLParens="; for (unsigned i = 0, e = Tok->FakeLParens.size(); i != e; ++i) llvm::errs() << Tok->FakeLParens[i] << "/"; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index a64a5bc2ad..0095d58c6b 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2946,6 +2946,17 @@ TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) { EXPECT_EQ("#warning 1", format(" # warning 1")); } +TEST_F(FormatTest, FormatHashIfExpressions) { + // FIXME: Come up with a better indentation for #elif. + verifyFormat( + "#if !defined(AAAAAAA) && (defined CCCCCC || defined DDDDDD) && \\\n" + " defined(BBBBBBBB)\n" + "#elif !defined(AAAAAA) && (defined CCCCC || defined DDDDDD) && \\\n" + " defined(BBBBBBBB)\n" + "#endif", + getLLVMStyleWithColumns(65)); +} + TEST_F(FormatTest, MergeHandlingInTheFaceOfPreprocessorDirectives) { FormatStyle AllowsMergedIf = getGoogleStyle(); AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true; |