summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-12 10:16:02 +0000
committerDaniel Jasper <djasper@google.com>2015-05-12 10:16:02 +0000
commit5fc133e71e62090d72a631aa576ac85100a26772 (patch)
treeefeb8ad196b6f1578797d6ea93df75d162fc178e /clang/lib/Format
parent6f30dc18d3bc25de7c3891de8de6fb764f04c2e5 (diff)
downloadbcm5719-llvm-5fc133e71e62090d72a631aa576ac85100a26772.tar.gz
bcm5719-llvm-5fc133e71e62090d72a631aa576ac85100a26772.zip
clang-format: Fix hanging nested blocks in macros.
Before: #define MACRO() \ Debug(aaa, /* force line break */ \ { \ int i; \ int j; \ }) After: #define MACRO() \ Debug(aaa, /* force line break */ \ { \ int i; \ int j; \ }) llvm-svn: 237108
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/UnwrappedLineFormatter.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index b01d989f88f..43f65dd04b2 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -39,7 +39,7 @@ public:
LevelIndentTracker(const FormatStyle &Style,
const AdditionalKeywords &Keywords, unsigned StartLevel,
int AdditionalIndent)
- : Style(Style), Keywords(Keywords) {
+ : Style(Style), Keywords(Keywords), AdditionalIndent(AdditionalIndent) {
for (unsigned i = 0; i != StartLevel; ++i)
IndentForLevel.push_back(Style.IndentWidth * i + AdditionalIndent);
}
@@ -52,7 +52,7 @@ public:
void nextLine(const AnnotatedLine &Line) {
Offset = getIndentOffset(*Line.First);
if (Line.InPPDirective) {
- Indent = Line.Level * Style.IndentWidth;
+ Indent = Line.Level * Style.IndentWidth + AdditionalIndent;
} else {
while (IndentForLevel.size() <= Line.Level)
IndentForLevel.push_back(-1);
@@ -110,6 +110,8 @@ private:
const FormatStyle &Style;
const AdditionalKeywords &Keywords;
+ unsigned AdditionalIndent;
+
/// \brief The indent in characters for each level.
std::vector<int> IndentForLevel;
OpenPOWER on IntegriCloud