summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-16 07:23:08 +0000
committerDaniel Jasper <djasper@google.com>2013-12-16 07:23:08 +0000
commitc39b56fe14683957bae2248dd0433ee4c893e054 (patch)
treed593b279ae1e28a7d7c05c77a18cb6119ff687e9 /clang/lib/Format/TokenAnnotator.cpp
parent69b899a1279d20b028f50dbf83b412b42bf095e4 (diff)
downloadbcm5719-llvm-c39b56fe14683957bae2248dd0433ee4c893e054.tar.gz
bcm5719-llvm-c39b56fe14683957bae2248dd0433ee4c893e054.zip
clang-format: Improve handling of raw string literals.
Especially try to keep existing line breaks before raw string literals, as the code author might have aligned content to it. Thereby, clang-format now keeps things like: parseStyle(R"( BasedOnStyle: Google, ColumnLimit: 100)"); parseStyle( R"(BasedOnStyle: Google, ColumnLimit: 100)"); llvm-svn: 197368
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 37ad7336513..9132ba43770 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1412,6 +1412,12 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
} else if (Right.is(tok::l_brace) && (Right.BlockKind == BK_Block)) {
return Style.BreakBeforeBraces == FormatStyle::BS_Allman ||
Style.BreakBeforeBraces == FormatStyle::BS_GNU;
+ } else if (Right.is(tok::string_literal) &&
+ Right.TokenText.startswith("R\"")) {
+ // Raw string literals are special wrt. line breaks. The author has made a
+ // deliberate choice and might have aligned the contents of the string
+ // literal accordingly. Thus, we try keep existing line breaks.
+ return Right.NewlinesBefore > 0;
}
return false;
}
OpenPOWER on IntegriCloud