djasper added a comment.
In https://reviews.llvm.org/D43183#1008784, @Typz wrote:
> A user can create an error by reasoning like this, after the code has been
> formatted this way (a long time ago) : "oh, I need to make an extra function
> call, but in all cases ah, here is the end of the
djasper added a comment.
That doesn't explain to me how this is error prone. I can't think how you'd
create an error by this that would not be caught by the compiler. Much less if
you consistently use clang-format.
It's fundamentally what you get for IndentCaseLabels: false. Even without
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Comment at: lib/Format/TokenAnnotator.cpp:2355
+ ((Right.MatchingParen->is(TT_ArrayInitializerLSquare) &&
+
djasper added a comment.
Yes, that's what I mean. What do you mean, the style is too error prone?
Repository:
rC Clang
https://reviews.llvm.org/D43183
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Thanks for the fix.
Comment at: unittests/Format/FormatTest.cpp:9453
+
+ // Bug 35641
+ Alignment.AlignConsecutiveDeclarations = true;
Make this "See
djasper added a comment.
What you are doing makes sense to me. My only hesitation is whether we should
maybe completely disallow breaking between = and { when Cpp11BracedListStyle is
false instead of solving this via penalties. Specifically,
| 80
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Ok.. I guess ;)
Repository:
rC Clang
https://reviews.llvm.org/D43294
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
In https://reviews.llvm.org/D43183#1006224, @Typz wrote:
> It is explicitly documented in google style guide:
> https://google.github.io/styleguide/cppguide.html#Loops_and_Switch_Statements
> :
>
> > case blocks in switch statements can have curly braces or not,
djasper added a comment.
In https://reviews.llvm.org/D43183#1006170, @Typz wrote:
> > We'll just format those cases in a somewhat weird way and users can either
> > accept that or change their code to not need it.
>
> I think we have a really diverging opinion on this. From my experience,
>
djasper added a comment.
To me none of these options make sense. For the case you are describing, I
agree that the current behavior is not ideal, but neither are any of the
alternatives. However, I think that's fine. We'll just format those cases in a
somewhat weird way and users can either
djasper added a comment.
Do you have a reference to style guides recommending any of this?
Repository:
rC Clang
https://reviews.llvm.org/D43183
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Cool, thanks.
Repository:
rC Clang
https://reviews.llvm.org/D43180
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added inline comments.
Comment at: unittests/Format/FormatTestTextProto.cpp:317
+
+TEST_F(FormatTestTextProto, FormatsExtensions) {
+ verifyFormat("[type] { key: value }");
It might be useful to attach a test case for what happens if the "[...]" does
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Repository:
rC Clang
https://reviews.llvm.org/D43121
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:900
+ std::max(NextNonComment->LongestObjCSelectorName,
+ unsigned(NextNonComment->TokenText.size())) -
NextNonComment->ColumnWidth;
I'd
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Repository:
rC Clang
https://reviews.llvm.org/D42957
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
No. The reason for us generally asking for a style guide is because it
unambiguously clarifies the exact style that is to be preferred. Projects that
don't have a style guide written down also often do not agree on what the style
should be.
That said, I think the
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Repository:
rC Clang
https://reviews.llvm.org/D42727
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
You still haven't addressed my comment about there not being a publicly
accessible style guide recommending these.
https://reviews.llvm.org/D32525
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
Generally, upload patches with the full file as diff context. Phabricator hides
that by default, but enables me to expand beyond the patch regions (where it
currently says "Context not available").
Comment at: lib/Format/ContinuationIndenter.cpp:756
djasper added inline comments.
Comment at: lib/Format/TokenAnnotator.cpp:82
CurrentToken->MatchingParen = Left;
-CurrentToken->Type = TT_TemplateCloser;
+if (Style.Language == FormatStyle::LK_TextProto)
+ CurrentToken->Type = TT_DictLiteral;
djasper added a comment.
- Of course you find all sorts of errors while testing clang-format on a
large-enough codebase. That doesn't mean that users run into them much.
- We have had about 10k clang-format users internally for several years. The
semicolon issue comes up but really rarely and
djasper added a comment.
Ah, Manuel and Krasimir are already on this thread, maybe they can comment? I
also added Chandler and Sam who I know care about formatting somewhat.
Repository:
rC Clang
https://reviews.llvm.org/D42787
___
cfe-commits
djasper added a comment.
I don't mean trivial with a diff. What I mean is, users will find it surprising
if whether or not a parameter gets wrapped leads to a different indentation
internal to that parameter. I have not heard of a single user that would be
surprised by this extra indentation.
djasper added a comment.
You might doubt it, but having written the code I can tell you that it's the
case. Shame on me for not writing a test, though.
I see the argument why this indentation is not necessary in exactly the case
where the last parameter is multi-line and not wrapped to a new
djasper added a comment.
I am against this change. The current behavior here is intentional and IMO more
consistent. If there is more than one precedence level in a set of parentheses,
we add the additional indentation. If you don't like it, surround it with extra
parentheses.
Generally, it'd
djasper added a comment.
I don't think cases where there is only a semicolon-less macro are particularly
frequent/important either. You probably could even add a semicolon in those
cases, right? How frequent are such cases in your codebase? Either way, they
aren't fixed by this patch, so they
djasper added a comment.
I think this case is not important enough to fix. Please tell users to just
delete the useless semicolon.
In particular, my concern is that this makes the data-flow significantly more
complicated. Early on in the development, we had separate token classes for the
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Repository:
rC Clang
https://reviews.llvm.org/D42685
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Makes sense.
Repository:
rC Clang
https://reviews.llvm.org/D42570
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good
Repository:
rC Clang
https://reviews.llvm.org/D42500
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Change the comment and possibly also the patch description along the lines of
what I have suggested. Other than that, looks good to me.
Comment at:
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Happy to go forward with this. I think we might also wanna investigate whether
entirely removing UnbreakableTailLength would be beneficial. I think we
implemented it as an optimization, but
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:1579
(Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")")))
{
+ unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+
djasper added a comment.
I am not sure we should actually do this. I agree that badly reflowing
multiline string literals is not ideal, but neither is violating the column
limit. In any case, proper reflowing would probably the best solution. How hard
would it be to implement that (for proto
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:1579
(Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")")))
{
+ unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+
djasper added a comment.
While I agree that there is probably a bug to fix, I don't (yet) agree with
what is proposed in this patch. I think a comment in between preprocessor
directives should always either:
- Be considered part of the code in between the #-lines
- Be considered to be
djasper added a comment.
I think I understand now. I think I'd prefer pulling all of the "+
UnbreakableTailLength" calculations out of getRemainingLength so that you don't
have to pass around the new parameter CanBreakAfter. Instead, only add it if
necessary outside of the function.
djasper added a comment.
I don't understand why the closing braces would count towards the string
literals UnbreakableTailLength. Isn't that a bug?
Repository:
rC Clang
https://reviews.llvm.org/D42372
___
cfe-commits mailing list
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.
Comment at: unittests/Format/FormatTestObjC.cpp:388
+ // Wrapped method parameters should be indented.
+ verifyFormat("- (VeryLongReturnTypeName)\n"
+
djasper added inline comments.
Comment at: include/clang/Format/Format.h:1375
+std::vector EnclosingFunctionNames;
+/// \brief The canonical delimiter for this language.
+std::string CanonicalDelimiter;
krasimir wrote:
> djasper wrote:
> > Can you
djasper added inline comments.
Comment at: include/clang/Format/Format.h:1216
+LK_TextProto,
+/// Do not use. Keep at last position.
+LK_End,
Lets find a way to implement without this in the public header file.
Comment at:
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Repository:
rC Clang
https://reviews.llvm.org/D40642
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D40424
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good. There is a chance that some people do not want this in their coding
style. But if so, we can add an option later.
https://reviews.llvm.org/D40178
djasper added a comment.
Is this different for C++ lambdas? I would think that we never should add an
empty line before the "}" of a child block.
https://reviews.llvm.org/D40178
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper closed this revision.
djasper added a comment.
Submitted as r317901.
https://reviews.llvm.org/D39478
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.
Comment at: lib/Format/FormatTokenLexer.cpp:344
+ size_t To = Lex->getBuffer().find_first_of('\n', From);
+ if (To == StringRef::npos) To = Lex->getBuffer().size();
djasper added a comment.
Out of curiosity, will this be able to fix the two situations that you get for
python extension?
There, you usually have a PyObject_HEAD with out semicolon in a struct and than
a PyObject_HEAD_INIT(..) in a braced init list. More info:
djasper accepted this revision.
djasper added a comment.
Looks good. Do you have submit access?
https://reviews.llvm.org/D39478
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper added a comment.
Submitted as r317473. Thank you!
https://reviews.llvm.org/D39587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper added a comment.
Looks good, thank you.
https://reviews.llvm.org/D39587
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Some minor remarks, but generally looks good. Thanks for fixing this!
Comment at: lib/Format/UsingDeclarationsSorter.cpp:136
for (size_t I = 0, E =
djasper added inline comments.
Comment at: lib/Format/UsingDeclarationsSorter.cpp:79
const SourceManager , tooling::Replacements *Fixes) {
- SmallVector SortedUsingDeclarations(
- UsingDeclarations->begin(), UsingDeclarations->end());
-
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
looks good.
https://reviews.llvm.org/D37695
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.h:270
+ // \c breakProtrudingToken.
+ bool LastBlockCommentWasBroken : 1;
+
We should be *very* careful when adding stuff to ParenState as every extra bit
of data and every extra
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D38243
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
I think doing the computation twice is fine. Or at least, I'd need a test case
where it actually shows substantial overhead before doing what you are doing
here. Understand that creating more States and making the State object itself
larger also has cost and that cost
djasper added inline comments.
Comment at: lib/Format/FormatTokenLexer.cpp:642
tok::pp_define) &&
-std::find(ForEachMacros.begin(), ForEachMacros.end(),
- FormatTok->Tok.getIdentifierInfo()) != ForEachMacros.end()) {
- FormatTok->Type
djasper added a comment.
I still don't understand yet. breakProtrudingToken has basically two options:
1. Don't wrap/reflow: In this case the penalty is determined by the number of
excess characters.
2. Wrap/reflow: I this case the penalty is determined by PenaltySplitComments
plus the
djasper added a comment.
I'd still prefer individual patches for each of these changes. If the code
review system or VCS make it hard for you to deal with two adjacent changes
this way, do them in sequence.
Adding Manuel as a reviewer who has a longer term idea on how to handle macros.
djasper added a comment.
BraceWrapping.AfterExternC makes sense to me.
https://reviews.llvm.org/D37260
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper added a comment.
I have a slightly hard time grasping what this patch now actually does? Doesn't
it simply try to decide whether or not to make a split locally be comparing the
PenaltyBreakComment against the penalty for the access characters? If so,
couldn't we simply do that as an
djasper added a comment.
I am very strongly against a flag that just leaves the line break as is. What's
the motivation?
https://reviews.llvm.org/D37260
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
Submitted as r312721. Thank you.
https://reviews.llvm.org/D37513
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good. Sorry for the delay.
https://reviews.llvm.org/D37132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Also run dump_format_style.py and keep the changed .rst file in this change.
Otherwise looks good.
https://reviews.llvm.org/D37513
___
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Thank you.
https://reviews.llvm.org/D37558
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D37531
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
This change needs to be made to include/clang/Format/Format.h and then the rst
file needs to be regenerated with docs/tools/dump_format_style.py.
https://reviews.llvm.org/D37531
___
cfe-commits mailing list
djasper added a comment.
Note that these changes need to be made to the corresponding comments in
include/clang/Format/Format.h and then this file is auto-generated with
docs/tools/dump_format_style.py.
Comment at: docs/ClangFormatStyleOptions.rst:274
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Just a few minor comments, otherwise looks good.
Comment at: lib/Format/Format.cpp:1542
+bool likelyXml(StringRef Code) {
+ return Code.ltrim().startswith("<");
djasper added a comment.
Are you changing the line endings here? Phabricator tells me that basically all
the lines change. If so, please don't ;).
Comment at: lib/Format/TokenAnnotator.cpp:345
+
+FormatToken *PreviousNoneOfConstVolatileReference = Parent;
+while
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good. Thank you.
https://reviews.llvm.org/D37143
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:1139
+
+ // On lines containing template strings, propagate NoLineBreak even for dict
+ // and array literals. This is to force wrapping an initial function call if
mprobst wrote:
>
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:1139
+
+ // On lines containing template strings, propagate NoLineBreak even for dict
+ // and array literals. This is to force wrapping an initial function call if
This is not the
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Yay for *removing* complexity for a change :).
Let me know how it goes in practice.
https://reviews.llvm.org/D37142
___
cfe-commits mailing
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
Comment at: lib/Format/UnwrappedLineParser.cpp:2099
+ // After a protocol list, we can have a category (Obj-C generic
+ // category).
nit:
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
From my side this looks good for now (we can always improve more later).
Krasimir, what do you think?
https://reviews.llvm.org/D35955
___
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Does the test still test the same thing if you set the column limit to 60 and
remove 20 spaces? If not, this is fine.
https://reviews.llvm.org/D37109
djasper added inline comments.
Comment at: unittests/Format/FormatTest.cpp:2297
+ "#include \n"
+ "#define MACRO
"
+ "\\\n"
Please just set
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D36956
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
Krasimir: Can you actually give this a round of review? I will also try to do
so tomorrow.
https://reviews.llvm.org/D35955
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
If no tests break with this, lets just go for it. We can follow up and fix
individual cases if we find undesired behavior.
https://reviews.llvm.org/D37007
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Thank you
https://reviews.llvm.org/D37011
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added inline comments.
Comment at: lib/Format/FormatToken.h:397
+ (!Previous ||
+ Previous->isOneOf(tok::comma, tok::equal, tok::l_brace) ||
+ Next->is(tok::r_brace;
Is this list coming from existing tests?
djasper added inline comments.
Comment at: lib/Format/BreakableToken.cpp:553
StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks);
- return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
-ColumnLimit);
+ Split TrimmedSplit =
djasper added inline comments.
Comment at: unittests/Format/FormatTest.cpp:2281
TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
verifyFormat("#define A \\\n"
mzeren-vmw wrote:
> mzeren-vmw wrote:
> > Experimenting with the patch
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D36142
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D36684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good. Thank you!
https://reviews.llvm.org/D34324
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
LG
https://reviews.llvm.org/D36491
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
Manuel: Can you take a look at the last comment here? Why does PPBranchLevel
start at -1?
https://reviews.llvm.org/D35955
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Thanks you.
Comment at: lib/Format/WhitespaceManager.cpp:650
+for (unsigned i = 0; i < Newlines; ++i)
+ Text.append(UseCRLF ? " \\\r\n" : " \\\n");
+return;
djasper added inline comments.
Comment at: lib/Format/WhitespaceManager.cpp:650
+for (unsigned i = 0; i < Newlines; ++i)
+ Text.append(UseCRLF ? " \\\r\n" : " \\\n");
+return;
Note that when you have an empty line, this would turn into:
#define A
djasper added inline comments.
Comment at: lib/Format/ContinuationIndenter.cpp:383
+ Current.Previous->is(tok::hash) && State.FirstIndent > 0) {
+// subtract 1 so indent lines up with non-preprocessor code
+Spaces += State.FirstIndent;
euhlmann
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.
Looks good.
https://reviews.llvm.org/D36148
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
djasper added a comment.
Generally, please upload patches with full context to phabricator. (or use arc)
I think this approach is a bit inside out. We are in a codepath where we try to
find a lambda introducer and we the look one or two tokens back to see that we
aren't as we have seen "auto".
djasper added inline comments.
Comment at: lib/Format/TokenAnnotator.cpp:2009
+// Prefer breaking call chains (".foo") over empty "{}", "[]" or "()".
+if ((Left.is(tok::l_brace) && Right.is(tok::r_brace)) ||
+(Left.is(tok::l_square) && Right.is(tok::r_square)) ||
djasper added inline comments.
Comment at: lib/Format/TokenAnnotator.cpp:2355
+(Left.Tok.getIdentifierInfo() ||
+ Left.isOneOf(tok::kw_switch, tok::kw_case, tok::kw_delete)))
+ return false;
Why is instanceof not required in this list?
101 - 200 of 406 matches
Mail list logo