summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-01-21 08:56:09 +0000
committerDaniel Jasper <djasper@google.com>2014-01-21 08:56:09 +0000
commita63f66ffa92d9b5e199f9af7cc470e6b92fe0a31 (patch)
tree2c37e22c109e99ac75d03b9618a04bf70190dbb2
parenteb9453dbbe7cdac95832cd01c39b0ff348dc2200 (diff)
clang-format: text following #if is likely an expression.
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
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 7b2c595403..418a7c5048 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -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).
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index e43d17fa05..a029176eef 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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"