summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-22 15:00:41 +0000
committerDaniel Jasper <djasper@google.com>2013-08-22 15:00:41 +0000
commit8de9ed05b7748ecd69b0a2f08611f456ad559c8a (patch)
tree1851727476ae8adfcdbce5cd495b7271bb3fc910 /clang/lib/Format/Format.cpp
parenteffabf96916b766b9aa2324daf006b4da281fa57 (diff)
downloadbcm5719-llvm-8de9ed05b7748ecd69b0a2f08611f456ad559c8a.tar.gz
bcm5719-llvm-8de9ed05b7748ecd69b0a2f08611f456ad559c8a.zip
clang-format: Add column layout formatting for braced lists
With this patch, braced lists (with more than 3 elements are formatted in a column layout if possible). E.g.: static const uint16_t CallerSavedRegs64Bit[] = { X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI, X86::R8, X86::R9, X86::R10, X86::R11, 0 }; Required other changes: - FormatTokens can now have a special role that contains extra data and can do special formattings. A comma separated list is currently the only implementation. - Move penalty calculation entirely into ContinuationIndenter (there was a last piece still in UnwrappedLineFormatter). Review: http://llvm-reviews.chandlerc.com/D1457 llvm-svn: 189018
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1bc0562bc0b..22833ad3293 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -438,14 +438,14 @@ private:
}
for (std::deque<StateNode *>::iterator I = Path.begin(), E = Path.end();
I != E; ++I) {
+ unsigned Penalty = Indenter->addTokenToState(State, (*I)->NewLine, false);
DEBUG({
if ((*I)->NewLine) {
- llvm::dbgs() << "Penalty for splitting before "
+ llvm::dbgs() << "Penalty for placing "
<< (*I)->Previous->State.NextToken->Tok.getName() << ": "
- << (*I)->Previous->State.NextToken->SplitPenalty << "\n";
+ << Penalty << "\n";
}
});
- Indenter->addTokenToState(State, (*I)->NewLine, false);
}
}
@@ -459,11 +459,6 @@ private:
return;
if (!NewLine && Indenter->mustBreak(PreviousNode->State))
return;
- if (NewLine) {
- if (!PreviousNode->State.Stack.back().ContainsLineBreak)
- Penalty += 15;
- Penalty += PreviousNode->State.NextToken->SplitPenalty;
- }
StateNode *Node = new (Allocator.Allocate())
StateNode(PreviousNode->State, NewLine, PreviousNode);
OpenPOWER on IntegriCloud