Avoid use-after-move warning for PendingRemote::InitWithNewPipe...
This CL annotates mojo::PendingRemote::InitWithNewPipeAndPassReceiver with clang's [[clang::reinitializes]] attribute to suppress the use-after-move lint warning - see the example here: https://crrev.com/c/2824128/2..4/content/browser/renderer_host/render_frame_host_impl.cc#b7754 Bug: 1198689 Change-Id: Ic451e5fd126ff43b36314dda55492902cc72becd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2824016 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Commit-Position: refs/heads/master@{#872568}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0772fa76a0
commit
3be38fbb7c
base
mojo/public/cpp/bindings
@ -373,4 +373,13 @@ inline constexpr bool AnalyzerAssumeTrue(bool arg) {
|
||||
#define TRIVIAL_ABI
|
||||
#endif
|
||||
|
||||
// Marks a member function as reinitializing a moved-from variable.
|
||||
// See also
|
||||
// https://clang.llvm.org/extra/clang-tidy/checks/bugprone-use-after-move.html#reinitialization
|
||||
#if defined(__clang__) && __has_attribute(reinitializes)
|
||||
#define REINITIALIZES_AFTER_MOVE [[clang::reinitializes]]
|
||||
#else
|
||||
#define REINITIALIZES_AFTER_MOVE
|
||||
#endif
|
||||
|
||||
#endif // BASE_COMPILER_SPECIFIC_H_
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "mojo/public/cpp/bindings/associated_interface_request.h"
|
||||
@ -90,8 +91,8 @@ class PendingAssociatedReceiver {
|
||||
handle_.ResetWithReason(custom_reason, description);
|
||||
}
|
||||
|
||||
PendingAssociatedRemote<Interface> InitWithNewEndpointAndPassRemote()
|
||||
WARN_UNUSED_RESULT;
|
||||
REINITIALIZES_AFTER_MOVE PendingAssociatedRemote<Interface>
|
||||
InitWithNewEndpointAndPassRemote() WARN_UNUSED_RESULT;
|
||||
|
||||
// Associates this endpoint with a dedicated message pipe. This allows the
|
||||
// entangled AssociatedReceiver/AssociatedRemote endpoints to be used without
|
||||
|
@ -87,8 +87,8 @@ class PendingAssociatedRemote {
|
||||
uint32_t version() const { return version_; }
|
||||
void set_version(uint32_t version) { version_ = version; }
|
||||
|
||||
PendingAssociatedReceiver<Interface> InitWithNewEndpointAndPassReceiver()
|
||||
WARN_UNUSED_RESULT;
|
||||
REINITIALIZES_AFTER_MOVE PendingAssociatedReceiver<Interface>
|
||||
InitWithNewEndpointAndPassReceiver() WARN_UNUSED_RESULT;
|
||||
|
||||
// Associates this endpoint with a dedicated message pipe. This allows the
|
||||
// entangled AssociatedReceiver/AssociatedRemote endpoints to be used
|
||||
|
@ -136,7 +136,8 @@ class PendingReceiver {
|
||||
// Creates a new message pipe, retaining one end in the PendingReceiver
|
||||
// (making it valid) and returning the other end as its entangled
|
||||
// PendingRemote. May only be called on an invalid PendingReceiver.
|
||||
PendingRemote<Interface> InitWithNewPipeAndPassRemote() WARN_UNUSED_RESULT;
|
||||
REINITIALIZES_AFTER_MOVE PendingRemote<Interface>
|
||||
InitWithNewPipeAndPassRemote() WARN_UNUSED_RESULT;
|
||||
|
||||
// For internal Mojo use only.
|
||||
internal::PendingReceiverState* internal_state() { return &state_; }
|
||||
|
@ -121,8 +121,8 @@ class PendingRemote {
|
||||
// Creates a new message pipe, retaining one end in the PendingRemote (making
|
||||
// it valid) and returning the other end as its entangled PendingReceiver. May
|
||||
// only be called on an invalid PendingRemote.
|
||||
PendingReceiver<Interface> InitWithNewPipeAndPassReceiver()
|
||||
WARN_UNUSED_RESULT;
|
||||
REINITIALIZES_AFTER_MOVE PendingReceiver<Interface>
|
||||
InitWithNewPipeAndPassReceiver() WARN_UNUSED_RESULT;
|
||||
|
||||
// For internal Mojo use only.
|
||||
internal::PendingRemoteState* internal_state() { return &state_; }
|
||||
|
Reference in New Issue
Block a user