Presubmit warning for std::to_string and error for std::shared_ptr
std::to_string is one of the banned functions but people are
not aware of that so a presubmit warning is needed.
It is only a warning for std::string since it's already used
and I don't want to trigger presubmit errors when someone
changes something on the same line as an std::to_string().
std::shared_ptr has been banned for a while (use scoped_refptr)
but it was brought to my attention because of std::weak_ptr from
C++11 which builds on std::shared_ptr.
These updates comes as most of the rest of C++11 is removed from
the ban list and only some very few functions/types remain banned. See:
https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFDHbjTfGH0wktnDryONBEEyG2O9o-CCMVWuTYFokjrSUw%40mail.gmail.com
Change-Id: I9fb1450ee76046cb842cd5a64a55d2cc977492b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535872
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Daniel Bratell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#644250}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index b462725..6f664d09 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -448,6 +448,26 @@
(),
),
(
+ r'/\bstd::to_string\b',
+ (
+ 'std::to_string is locale dependent and slower than alternatives.',
+ 'For locale-independent strings, e.g. writing numbers to and from',
+ 'disk profiles, use base::NumberToString().',
+ 'For user-visible strings, use base::FormatNumber() and',
+ 'the related functions in base/i18n/number_formatting.h.',
+ ),
+ False, # Only a warning for now since it is already used,
+ (r'third_party/'), # Don't warn in third_party folders.
+ ),
+ (
+ r'/\bstd::shared_ptr\b',
+ (
+ 'std::shared_ptr should not be used. Use scoped_refptr instead.',
+ ),
+ True,
+ (r'third_party/'), # Not an error in third_party folders.
+ ),
+ (
(r'/base::ThreadRestrictions::(ScopedAllowIO|AssertIOAllowed|'
r'DisallowWaiting|AssertWaitAllowed|SetWaitAllowed|ScopedAllowWait)'),
(