Conversation
3acbc72 to
b7fc860
Compare
|
Thanks for the fixes, the build currently fails because your changes have not been formatted according to this repos style format. Please use Uncrustify on the changed files with the forUncrustifySources.cfg config. I will look into adding git hooks to prevent such issues in the future, most likely it will be a modification of https://github.com/githubbrowser/Pre-commit-hooks |
|
@CDanU Thank you. Now it's complaining about the output of Test_more_Options.sh script. I can't find information about the purpose of this script and the best way to make it happy. Can you help me with this ? |
|
This script tests if the command line options work. Here is the script itself: Test_more_Options.sh It operates on the files in You have changed/added some option descriptions and added new option so you need to edit
|
b7fc860 to
50e2bc9
Compare
|
Ohh, I forgot: You need to remove the version strings in the mentioned files
They are already removed via sed in the generated results files. |
ca0fc00 to
996e218
Compare
CDanU
left a comment
There was a problem hiding this comment.
Ok, after the scripts had their nitpicking now it's my turn, keep in mind that I never had to deal with obj-C.
src/combine.cpp
Outdated
| chunkGroup.push_back(next); | ||
| nullability_chunks.push_back(chunkGroup); | ||
| } | ||
| else if (chunk_is_str(next, "null_unspecified", 16)) |
There was a problem hiding this comment.
This could be combined with the previous else if statement.
src/newlines.cpp
Outdated
| // identifier - the name of the enumeration that's being declared | ||
| // enum-base(C++11) - colon (:), followed by a type-specifier-seq | ||
|
|
||
|
|
There was a problem hiding this comment.
This two newlines should be removed.
src/tokenize_cleanup.cpp
Outdated
|
|
||
| void cleanup_objc_property_with_parens(chunk_t *start); | ||
| void mark_selectors_in_property(chunk_t *start); | ||
| void mark_attributes_in_property(chunk_t *start); |
There was a problem hiding this comment.
Some documentation here would be nice.
src/tokenize_cleanup.cpp
Outdated
| { | ||
| chunk_t *next = chunk_get_next_ncnl(start); | ||
|
|
||
| set_chunk_parent(next, start->type); |
There was a problem hiding this comment.
This looks like it could need a nullptr check for next and start.
There was a problem hiding this comment.
next should exist otherwise this method makes no sense, I'll put assert here
| void mark_selectors_in_property(chunk_t *start) | ||
| { | ||
| chunk_t *tmp = chunk_get_next_type(start, CT_PAREN_OPEN, start->level); | ||
|
|
There was a problem hiding this comment.
This looks like it could need a nullptr check for tmp and start.
There was a problem hiding this comment.
paren open chunk should exist for calling this method. Will put assert
src/tokenize_cleanup.cpp
Outdated
| if (tmp->type == CT_WORD && | ||
| (memcmp(tmp->str.c_str(), "setter", 6) == 0 || | ||
| memcmp(tmp->str.c_str(), "getter", 6) == 0) | ||
| && tmp->next->type == CT_ASSIGN) |
There was a problem hiding this comment.
I am not entirely sure, but this looks like it could need a nullptr check for next.
Does obj-C allow comments/newlines in between the setter and the assign ? Something like setter /* blub */ =?
There was a problem hiding this comment.
Yes, will add.
Comments - never tried, but theoretically yes.
There was a problem hiding this comment.
Ok, see if chunk_get_next_ncnl() is a better fit for such cases
Gets the next non-NEWLINE and non-comment chunk
There was a problem hiding this comment.
Good one, thank you, will think about
src/tokenize_cleanup.cpp
Outdated
| memcmp(tmp->str.c_str(), "getter", 6) == 0) | ||
| && tmp->next->type == CT_ASSIGN) | ||
| { | ||
| tmp = tmp->next->next; |
There was a problem hiding this comment.
One of both next can be nullptr or comment/newline
| void mark_attributes_in_property(chunk_t *start) | ||
| { | ||
| chunk_t *tmp = chunk_get_next_type(start, CT_PAREN_OPEN, start->level); | ||
|
|
There was a problem hiding this comment.
nullptr check for tmp and start
There was a problem hiding this comment.
paren open chunk should exist for calling this method. Will put assert
src/tokenize_cleanup.cpp
Outdated
| while (tmp->type != CT_PAREN_CLOSE) | ||
| { | ||
| if ((tmp->type == CT_COMMA || tmp->type == CT_PAREN_OPEN) && | ||
| tmp->next->type == CT_WORD) |
There was a problem hiding this comment.
Also nullptr check and the in between comment/ newline problem for next
| if ((tmp->type == CT_COMMA || tmp->type == CT_PAREN_OPEN) && | ||
| tmp->next->type == CT_WORD) | ||
| { | ||
| tmp->next->type = CT_OC_PROPERTY_ATTR; |
d660ea4 to
13e0a80
Compare
|
@CDanU Updated |
|
|
||
| void cleanup_objc_property(chunk_t *start) | ||
| { | ||
| chunk_t *open_paren = chunk_get_next_type(start, CT_PAREN_OPEN, start->level); |
There was a problem hiding this comment.
This will need a nullptr check for start.
src/tokenize_cleanup.cpp
Outdated
| { | ||
| chunk_t *tmp = open_paren; | ||
|
|
||
| assert(open_paren->type == CT_PAREN_OPEN); |
There was a problem hiding this comment.
You made sure that open_paren is not a nullptr in cleanup_objc_property(), but this function could be used somewhere else in the future where that is not going to be guaranteed anymore. A nullptr check for open_paren is needed here.
src/tokenize_cleanup.cpp
Outdated
| { | ||
| chunk_t *tmp = open_paren; | ||
|
|
||
| assert(open_paren->type == CT_PAREN_OPEN); |
There was a problem hiding this comment.
You made sure that open_paren is not a nullptr in cleanup_objc_property(), but this function could be used somewhere else in the future where that is not guaranteed anymore. A nullptr check for open_paren is needed here.
|
Ok so far the code looks ok. Could you squash your commits into one commit? @mihaipopescu could you also have a look on the changes? |
3899d70 to
99a8ba6
Compare
|
Asserts are only to detect wrong usage of the methods. They will never be executed with the current code. |
mihaipopescu
left a comment
There was a problem hiding this comment.
Very good changes! Few remarks on the PR.
| enable_processing_cmt and disable_processing_cmt). | ||
|
|
||
| There are currently 581 options and minimal documentation. | ||
| There are currently 582 options and minimal documentation. |
There was a problem hiding this comment.
Not related to this PR but generated files should never be under revision control.
| while (next != nullptr && next->type != CT_PAREN_CLOSE) | ||
| { | ||
| if (next->type == CT_WORD) | ||
| if (next->type == CT_OC_PROPERTY_ATTR) |
There was a problem hiding this comment.
Is guarded for OC only ? Can't really tell on my phone.
There was a problem hiding this comment.
Yes. It's part of the method handle_oc_property_decl, which will be called only for CT_OC_PROPERTY
| { | ||
| if (chunk_is_str(next, "atomic", 6)) | ||
| if (chunk_is_str(next, "atomic", 6) || | ||
| chunk_is_str(next, "nonatomic", 9)) |
There was a problem hiding this comment.
Not related to this PR but why do we have to pass strlen all the time instead of having a template function ?
src/tokenize_cleanup.cpp
Outdated
| while (tmp && tmp->type != CT_PAREN_CLOSE) | ||
| { | ||
| if (tmp->type == CT_WORD && | ||
| (memcmp(tmp->str.c_str(), "setter", 6) == 0 || |
There was a problem hiding this comment.
I think we have other string comparison functions.
| if ((tmp->type == CT_COMMA || tmp->type == CT_PAREN_OPEN) && | ||
| tmp->next && tmp->next->type == CT_WORD) | ||
| { | ||
| tmp->next->type = CT_OC_PROPERTY_ATTR; |
There was a problem hiding this comment.
You don't want to break the loop here ?
There was a problem hiding this comment.
No, I want to do it for every attribute ( there can be several)
Fixed work of mod_sort_oc_properties with sp_after_comma
99a8ba6 to
4891533
Compare
|
Incorporated all the comments, except for the once unrelated to this PR. |
| chunk_is_str(next, "nonnull", 7) || | ||
| chunk_is_str(next, "null_resettable", 15) || | ||
| chunk_is_str(next, "null_unspecified", 16) | ||
| ) |
There was a problem hiding this comment.
@gmaurel do we need a new rule in forUncrustifySources.cfg? I think that this paren should not be on a new line.
There was a problem hiding this comment.
Yes, we need! look at #1139
I found some more:
grep -n " )$" *
combine.cpp:2995: )
indent.cpp:1526: )
newlines.cpp:2168: )
Based on the comments to #765:
Added missing properties
Fixed work of mod_sort_oc_properties with sp_after_comma