• Lukasz Anforowicz's avatar
    Ignoring |SomeClass *ptr_field1, *ptr_field2|. · a8159aed
    Lukasz Anforowicz authored
    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: default avatarBartek Nowierski <bartekn@chromium.org>
    Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#771040}
    a8159aed
apply_edits.py 11.8 KB