r199713 - clang-format: text following #if is likely an expression.
Daniel Jasper
djasper at google.com
Tue Jan 21 00:56:10 PST 2014
Author: djasper
Date: Tue Jan 21 02:56:09 2014
New Revision: 199713
URL: http://llvm.org/viewvc/llvm-project?rev=199713&view=rev
Log:
clang-format: text following #if is likely an expression.
Before:
#if AAAA &&BBBB
After:
#if AAAA && BBBB
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=199713&r1=199712&r2=199713&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jan 21 02:56:09 2014
@@ -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).
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=199713&r1=199712&r2=199713&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan 21 02:56:09 2014
@@ -5112,6 +5112,7 @@ TEST_F(FormatTest, DoNotInterfereWithErr
}
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"
More information about the cfe-commits
mailing list