Update Abseil instructions for absl::optional
Also add a presubmit check to verify we're not reintroducing it. Bug: webrtc:342905193 Change-Id: Ic7eedb6a7fb257e3fd110b84d3921feb58f799d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361282 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42912}
This commit is contained in:
parent
8037fc6ffa
commit
9212f095a0
29
PRESUBMIT.py
29
PRESUBMIT.py
@ -1046,6 +1046,9 @@ def CommonChecks(input_api, output_api):
|
||||
results.extend(
|
||||
CheckBannedAbslMakeUnique(input_api, output_api,
|
||||
non_third_party_sources))
|
||||
results.extend(
|
||||
CheckBannedAbslOptional(input_api, output_api,
|
||||
non_third_party_sources))
|
||||
results.extend(
|
||||
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
||||
return results
|
||||
@ -1128,6 +1131,32 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
||||
return []
|
||||
|
||||
|
||||
def CheckBannedAbslOptional(input_api, output_api, source_file_filter):
|
||||
absl_optional = re.compile(r'absl::(optional|make_optional|nullopt)',
|
||||
re.MULTILINE)
|
||||
absl_optional_include = re.compile(r'^#include\s*"absl/types/optional\.h"',
|
||||
input_api.re.MULTILINE)
|
||||
file_filter = lambda f: (f.LocalPath().endswith(
|
||||
('.cc', '.h')) and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
for f in input_api.AffectedFiles(include_deletes=False,
|
||||
file_filter=file_filter):
|
||||
for _, line in f.ChangedContents():
|
||||
if absl_optional.search(line) or absl_optional_include.search(
|
||||
line):
|
||||
files.append(f.LocalPath())
|
||||
break
|
||||
|
||||
if files:
|
||||
return [
|
||||
output_api.PresubmitError(
|
||||
'Please use std::optional instead of absl::optional.\n'
|
||||
'Affected files:', files)
|
||||
]
|
||||
return []
|
||||
|
||||
|
||||
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
|
||||
@ -32,7 +32,6 @@ Previously, `absl_deps` was used but been deprecated in May 2024.
|
||||
* `absl::InlinedVector`
|
||||
* `absl::Nonnull` and `absl::Nullable`
|
||||
* `absl::WrapUnique`
|
||||
* `absl::optional` and related stuff from `absl/types/optional.h`.
|
||||
* `absl::string_view`
|
||||
* The functions in `absl/strings/ascii.h`, `absl/strings/match.h`,
|
||||
and `absl/strings/str_replace.h`.
|
||||
@ -65,6 +64,10 @@ Abseil team to remove that initializer (like they already did for a
|
||||
spinlock initializer). Additionally, `absl::Mutex` handles time in a
|
||||
way that may not be compatible with the rest of WebRTC.
|
||||
|
||||
### `absl::optional`
|
||||
|
||||
*Use `std::optional` instead.*
|
||||
|
||||
### `absl::Span`
|
||||
|
||||
*Use `rtc::ArrayView` instead.*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user