[PATCH] Don't break string literals inside preprocessor directives.
Daniel Jasper
djasper at google.com
Fri Oct 11 13:37:39 PDT 2013
Just a few nits, otherwise looks good.
================
Comment at: lib/Format/ContinuationIndenter.cpp:700
@@ -693,4 +699,3 @@
// likely want to terminate the string before any line breaking is done.
- if (Current.IsUnterminatedLiteral)
- return 0;
+ if (Current.IsUnterminatedLiteral) return 0;
----------------
same as above
================
Comment at: lib/Format/ContinuationIndenter.cpp:697
@@ -692,1 +696,3 @@
+ // preprocessor directives that contain long string literals.
+ if (State.Line->Type == LT_PreprocessorDirective) return 0;
// Exempts unterminated string literals from line breaking. The user will
----------------
We don't do one-line ifs in LLVM style.
================
Comment at: lib/Format/TokenAnnotator.cpp:1049-1052
@@ -1044,5 +1048,6 @@
Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
else
Current->SpacesRequiredBefore =
- spaceRequiredBefore(Line, *Current) ? 1 : 0;
+ std::max(Current->SpacesRequiredBefore,
+ spaceRequiredBefore(Line, *Current) ? 1U : 0);
----------------
How about instead:
else if (Current->SpacesRequiredBefore == 0 && spaceRequiredBefore(Line, *Current))
Current->SpacesRequiredBefore = 1;
http://llvm-reviews.chandlerc.com/D1813
BRANCH
svn
ARCANIST PROJECT
clang
More information about the cfe-commits
mailing list