New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 672902 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Apr 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 578344



Sign in to add a comment

std-like names in WTF containers should NOT be rewritten (i.e. pop_back -> Pop_back)

Project Member Reported by lukasza@chromium.org, Dec 9 2016

Issue description

Today, the rewrite_to_chrome_style tool will make the following, undesired changes:
- WTF::Vector<T>
  - pop_back -> Pop_back
  - emplace_back -> Emplace_back
  - front -> Front
  - back -> Back

See also the following PSA about WTF:: container method names in blink-dev: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/UjgsNYcB3Qc
 
Easiest thing to do would be to
1) gather affected method names
and
2) blacklist renaming via IsBlacklistedMethod in RewriteToChromeStyle.cpp

We can also try to be smart and:
1b) We can broadly blacklist renaming of methods that contain an underscore character in their name
2b) We can limit blacklisting to only apply in some situations (methods in a templated class in WTF namespace)?

I think I would personally vote for 1b (+ listing affected method names without an underscore) and just unconditional blacklisting (2, not 2b).

FWIW, I think the following method names are considered for WTF/std alignment and should be considered for blacklisting during the "big rename":
- push_back = append
- erase = remove
- empty = isEmpty
- emplace_back = emplaceAppend
- pop_back = removeLast
- front = first
- back = last

Summary: std-like names in WTF containers should NOT be rewritten (i.e. pop_back -> Pop_back) (was: std-like names in WTF containers should be rewritten (i.e. pop_back -> Pop_back))
sgtm: let's coordinate with pilgrim@ and make sure the tool knows about all the planned replacements in advance.

Comment 4 by dcheng@chromium.org, Dec 19 2016

Blocking: 578344
Owner: lukasza@chromium.org
Status: Started (was: Available)

Comment 7 by dcheng@chromium.org, Dec 29 2016

Status: Fixed (was: Started)
Status: Started (was: Fixed)
There is at least one more std-like thing:

- We shouldn't rename |size()| to |Size()| (e.g. this is used in a template that accepts std:: and WTF:: things in mojo/public/cpp/bindings/lib/serialization.h:76)

One quirk here is that blacklisting done by IsBlacklistedInstanceMethodName doesn't look at parameters.  This is okay for |insert|, but we might want to consider only blacklisting if there are 0 parameters (which will be true for accessors like |back|, |empty|, |front|, |size| and also for |erase|).


And maybe we shouldn't rename |length()|

- for compatibility between std::string and WTF::String assumed by the code generator from third_party/inspector_protocol

- for not having to blacklist individual length methods assumed by DOM bindings (see https://chromium.googlesource.com/chromium/src/+/c96e02d34a39e6a3e790c563cb506b73aa134e2b/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl#23)
Project Member

Comment 10 by bugdroid1@chromium.org, Jan 27 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/265ae0467148c0872ccae6c862813d27f21ce031

commit 265ae0467148c0872ccae6c862813d27f21ce031
Author: lukasza <lukasza@chromium.org>
Date: Fri Jan 27 15:07:58 2017

Blacklisting renaming of |size()| and |length()| methods.

BUG= 672902 

Review-Url: https://codereview.chromium.org/2657773003
Cr-Commit-Position: refs/heads/master@{#446667}

[modify] https://crrev.com/265ae0467148c0872ccae6c862813d27f21ce031/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Status: Fixed (was: Started)
Status: Available (was: Fixed)
There are some more cases of STL-like names that we should take into account.

For sure, we should skip renaming "at".  I don't know if there are others.
Cc: -pilgrim@chromium.org lukasza@chromium.org
Owner: pilgrim@chromium.org
pilgrim@: Could you please review the list of STL-like method names that should not be renamed to Chromium style by the rewriter tool?  Currently IsBlacklistedInstanceMethodName in tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp has:

  static const char* kBlacklistedNames[] = {
      // We should avoid renaming the method names listed below, because
      // 1. They are used in templated code (e.g. in <algorithms>)
      // 2. They (begin+end) are used in range-based for syntax sugar
      //    - for (auto x : foo) { ... }  // <- foo.begin() will be called.
      "begin", "end", "rbegin", "rend", "lock", "unlock", "try_lock",

      //  https://crbug.com/672902 : Should not rewrite names that mimick methods
      // from std library.
      "back", "empty", "erase", "front", "insert", "length", "size",
  }; 

Can you please help us identify other methods that should not be renamed?  We accidentally found |at| (which should probably not be renamed to |At|), but you probably know better which other STL-like method names we should special case.
https://crbug.com/662431 contains all the STL-related changes I've made to WTF. Searching the committed CL descriptions for the string "() to ::" yields the following list of new or updated method names:

push_back
insert
erase
at
front
back
pop_back
pop_front
push_front

Project Member

Comment 15 by bugdroid1@chromium.org, Apr 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5ecbba9425dfba1578ec8e2ff884130a2a2d2b9e

commit 5ecbba9425dfba1578ec8e2ff884130a2a2d2b9e
Author: lukasza <lukasza@chromium.org>
Date: Thu Apr 06 19:25:03 2017

Stop renaming |at| method to maintain compatibility with STL algorithms.

BUG= 672902 

Review-Url: https://codereview.chromium.org/2796413004
Cr-Commit-Position: refs/heads/master@{#462581}

[modify] https://crrev.com/5ecbba9425dfba1578ec8e2ff884130a2a2d2b9e/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp

Status: Fixed (was: Available)

Sign in to add a comment