]> granicus.if.org Git - clang/commitdiff
clang-format: text following #if is likely an expression.
authorDaniel Jasper <djasper@google.com>
Tue, 21 Jan 2014 08:56:09 +0000 (08:56 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 21 Jan 2014 08:56:09 +0000 (08:56 +0000)
Before:
  #if AAAA &&BBBB

After:
  #if AAAA && BBBB

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199713 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 7b2c595403a23a8d36eaff31bf88b9c0f93a06eb..418a7c50480b17176f22b85a7772cd58f2d36243 100644 (file)
@@ -516,6 +516,7 @@ private:
       break;
     case tok::pp_if:
     case tok::pp_elif:
+      Contexts.back().IsExpression = true;
       parseLine();
       break;
     default:
@@ -531,7 +532,7 @@ public:
       parsePreprocessorDirective();
       return LT_PreprocessorDirective;
     }
-  
+
     // Directly allow to 'import <string-literal>' to support protocol buffer
     // definitions (code.google.com/p/protobuf) or missing "#" (either way we
     // should not break the line).
index e43d17fa05cc90c46af225ef963b5f4d81edae8b..a029176eefa1a3f9a250c1b5315c3281058af645 100644 (file)
@@ -5112,6 +5112,7 @@ TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {
 }
 
 TEST_F(FormatTest, FormatHashIfExpressions) {
+  verifyFormat("#if AAAA && BBBB");
   // FIXME: Come up with a better indentation for #elif.
   verifyFormat(
       "#if !defined(AAAAAAA) && (defined CCCCCC || defined DDDDDD) &&  \\\n"