Refresh WebRTC style guide

Remove advice to keep legacy style for consistency because it condridicts a recent addition to style guide goals
Remove debatable reason for banning std::shared_ptr, keep main reason
to ban it as the only one.

Bug: None
Change-Id: I4c31f9247a33430df0b286a15f1a35ab23060d1c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247183
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35720}
This commit is contained in:
Danil Chapovalov 2022-01-17 16:11:02 +01:00 committed by WebRTC LUCI CQ
parent 66891bd414
commit 80569ea2be

View File

@ -1,16 +1,12 @@
# WebRTC coding style guide # WebRTC coding style guide
<?% config.freshness.owner = 'danilchap' %?> <?% config.freshness.owner = 'danilchap' %?>
<?% config.freshness.reviewed = '2021-05-12' %?> <?% config.freshness.reviewed = '2022-01-17' %?>
## General advice ## General advice
Some older parts of the code violate the style guide in various ways. Some older parts of the code violate the style guide in various ways.
If making large changes to such code, consider first cleaning it up in a
* If making small changes to such code, follow the style guide when it's
reasonable to do so, but in matters of formatting etc., it is often better to
be consistent with the surrounding code.
* If making large changes to such code, consider first cleaning it up in a
separate CL. separate CL.
## C++ ## C++
@ -141,9 +137,7 @@ The following smart pointer types are recommended:
* `rtc::scoped_refptr` for all objects with shared ownership * `rtc::scoped_refptr` for all objects with shared ownership
Use of `std::shared_ptr` is *not permitted*. It is banned in the Chromium style Use of `std::shared_ptr` is *not permitted*. It is banned in the Chromium style
guide (overriding the Google style guide), and offers no compelling advantage guide (overriding the Google style guide). See the
over `rtc::scoped_refptr` (which is cloned from the corresponding Chromium
type). See the
[list of banned C++ library features in Chromium][chr-std-shared-ptr] for more [list of banned C++ library features in Chromium][chr-std-shared-ptr] for more
information. information.
@ -152,7 +146,7 @@ In most cases, one will want to explicitly control lifetimes, and therefore use
exist both from the API users and internally, with no way to invalidate pointers exist both from the API users and internally, with no way to invalidate pointers
held by the API user, `rtc::scoped_refptr` can be appropriate. held by the API user, `rtc::scoped_refptr` can be appropriate.
[chr-std-shared-ptr]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++11.md#shared-pointers [chr-std-shared-ptr]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++11.md#shared-pointers-banned
### `std::bind` ### `std::bind`
@ -180,11 +174,8 @@ headers you need.
There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old There's a substantial chunk of legacy C code in WebRTC, and a lot of it is old
enough that it violates the parts of the C++ style guide that also applies to C enough that it violates the parts of the C++ style guide that also applies to C
(naming etc.) for the simple reason that it pre-dates the use of the current C++ (naming etc.) for the simple reason that it pre-dates the use of the current C++
style guide for this code base. style guide for this code base. If making large changes to C code, consider
converting the whole thing to C++ first.
* If making small changes to C code, mimic the style of the surrounding code.
* If making large changes to C code, consider converting the whole thing to C++
first.
## Java ## Java