Ignoring |SomeClass *ptr_field1, *ptr_field2|.
Consider the example fixed by this CL in tests/basics-original.cc: struct MyStruct { SomeClass *ptr_field1, *ptr_field2; }; Before this CL, the rewriter would generate a separate replacement for |ptr_field1| and another one for |ptr_field2|. Such replacements would cover overlapping ranges of the source file, leading to butchered, incorrect edits. Note that in the example above |git cl format| places the "*" character above next to the field names (e.g. |*ptr_field1|) rather than next to the type name (e.g. |SomeClass*|). For a single field |git cl format| places the "*" character next to the type name, but the CL adds a single-field test to also cover the non-standard placement. After this CL: *) apply_edits.py detects overlapping replacements and reports them as an error. Simple unit tests have been added to apply_edits_test.py *) RewriteRawPtrFields.cpp defines and uses a custom |hasUniqueTypeLoc| matcher that can be used to ignore fields with a non-unique type location *) RewriteRawPtrFields.cpp tweaks slightly the |replacement_range| and |replacement_text| so that non-standard placement of the "*" character is handled correctly. Bug: 1069567 Change-Id: I5e0a90de6d8c7dc5d16ef68012509508c84b6ccf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157992 Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Reviewed-by:Bartek Nowierski <bartekn@chromium.org> Reviewed-by:
Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#771040}
Showing
Please register or sign in to comment