forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add remove_unneeded_adapt_callback tool to base_bind_rewriters
This CL adds a rewriter to //tools/clang/base_bind_rewriters which removes calls to base::AdaptCallbackForRepeating when the returned base::RepeatingCallback is immediately converted to a base::OnceCallback. Change-Id: I14ca9af2b3abc095b978c2cd7cf1fea1844ef428 Reviewed-on: https://chromium-review.googlesource.com/817740 Commit-Queue: Yannic Bonenberger <contact@yannic-bonenberger.com> Reviewed-by: Taiju Tsuiki <tzik@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#571999}
- Loading branch information
Showing
5 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tools/clang/base_bind_rewriters/tests/remove-adapt-callback-for-repeating-expected.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "callback.h" | ||
|
||
void Foo(base::OnceClosure) {} | ||
|
||
void Test() { | ||
base::OnceClosure cb = base::BindOnce([] {}); | ||
Foo(base::BindOnce([] {})); | ||
|
||
using namespace base; | ||
|
||
OnceClosure cb2 = BindOnce([] {}); | ||
Foo(BindOnce([] {})); | ||
|
||
OnceClosure cb3 = base::BindOnce([] {}); | ||
} |
19 changes: 19 additions & 0 deletions
19
tools/clang/base_bind_rewriters/tests/remove-adapt-callback-for-repeating-original.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "callback.h" | ||
|
||
void Foo(base::OnceClosure) {} | ||
|
||
void Test() { | ||
base::OnceClosure cb = base::AdaptCallbackForRepeating(base::BindOnce([] {})); | ||
Foo(base::AdaptCallbackForRepeating(base::BindOnce([] {}))); | ||
|
||
using namespace base; | ||
|
||
OnceClosure cb2 = AdaptCallbackForRepeating(BindOnce([] {})); | ||
Foo(AdaptCallbackForRepeating(BindOnce([] {}))); | ||
|
||
OnceClosure cb3 = base::BindOnce([] {}); | ||
} |