Commit 11d95ef7 authored by Stanislav Pikulik's avatar Stanislav Pikulik Committed by Commit Bot

GCC: Scoped type name the same as name in outer scope

The compiler cannot handle a type name the same as the a type name
from an outer scope and leads to errors like the following one:

GCC(8.4.0) says

error: declaration of ‘using AcceptedVote = class performance_manager::
    voting::AcceptedVote<VoteImpl>’ [-fpermissive]
using AcceptedVote = AcceptedVote<VoteImpl>;
error: changes meaning of ‘AcceptedVote’ from ‘class performance_manager::
    voting::AcceptedVote<VoteImpl>’ [-fpermissive]
class AcceptedVote;

Bug: 819294
Change-Id: If344be8eff75cb9c5ca99b814f589595ed3c8bd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523201Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Commit-Queue: Chris Hamilton <chrisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824908}
parent 54452aac
...@@ -119,7 +119,6 @@ class AcceptedVote; ...@@ -119,7 +119,6 @@ class AcceptedVote;
template <class VoteImpl> template <class VoteImpl>
class VoteReceipt final { class VoteReceipt final {
public: public:
using AcceptedVote = AcceptedVote<VoteImpl>;
using PassKey = util::PassKey<VoteReceipt<VoteImpl>>; using PassKey = util::PassKey<VoteReceipt<VoteImpl>>;
VoteReceipt(); VoteReceipt();
...@@ -133,7 +132,7 @@ class VoteReceipt final { ...@@ -133,7 +132,7 @@ class VoteReceipt final {
// Returns true if this receipt is entangled with a vote. // Returns true if this receipt is entangled with a vote.
bool HasVote() const; bool HasVote() const;
bool HasVote(const AcceptedVote* vote) const; bool HasVote(const AcceptedVote<VoteImpl>* vote) const;
// Returns the consumer that this vote was submitted to. Can only be called if // Returns the consumer that this vote was submitted to. Can only be called if
// HasVote returns true. // HasVote returns true.
...@@ -159,19 +158,20 @@ class VoteReceipt final { ...@@ -159,19 +158,20 @@ class VoteReceipt final {
// functions are only meant to be used by AcceptedVote. // functions are only meant to be used by AcceptedVote.
// Allows an AcceptedVote to create an entangled receipt. // Allows an AcceptedVote to create an entangled receipt.
VoteReceipt(util::PassKey<AcceptedVote>, AcceptedVote* vote); VoteReceipt(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* vote);
// Allows an AcceptedVote to update its backpointer. // Allows an AcceptedVote to update its backpointer.
void MoveVote(util::PassKey<AcceptedVote>, void MoveVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote* old_vote, AcceptedVote<VoteImpl>* old_vote,
AcceptedVote* new_vote); AcceptedVote<VoteImpl>* new_vote);
private: private:
void Take(VoteReceipt&& rhs); void Take(VoteReceipt&& rhs);
// A back-pointer to the accepted vote, so that it can be notified when this // A back-pointer to the accepted vote, so that it can be notified when this
// receipt is destroyed. // receipt is destroyed.
AcceptedVote* vote_ = nullptr; AcceptedVote<VoteImpl>* vote_ = nullptr;
}; };
// A move-only wrapper for a vote and its associated receipt. AcceptedVotes // A move-only wrapper for a vote and its associated receipt. AcceptedVotes
...@@ -192,7 +192,6 @@ template <class VoteImpl> ...@@ -192,7 +192,6 @@ template <class VoteImpl>
class AcceptedVote final { class AcceptedVote final {
public: public:
using PassKey = util::PassKey<AcceptedVote<VoteImpl>>; using PassKey = util::PassKey<AcceptedVote<VoteImpl>>;
using VoteReceipt = VoteReceipt<VoteImpl>;
AcceptedVote(); AcceptedVote();
AcceptedVote(VoteConsumer<VoteImpl>* consumer, AcceptedVote(VoteConsumer<VoteImpl>* consumer,
...@@ -208,10 +207,10 @@ class AcceptedVote final { ...@@ -208,10 +207,10 @@ class AcceptedVote final {
// Returns true if this vote is associated with a receipt. // Returns true if this vote is associated with a receipt.
bool HasReceipt() const; bool HasReceipt() const;
bool HasReceipt(const VoteReceipt* receipt) const; bool HasReceipt(const VoteReceipt<VoteImpl>* receipt) const;
bool IsValid() const; bool IsValid() const;
VoteReceipt IssueReceipt(); VoteReceipt<VoteImpl> IssueReceipt();
VoteConsumer<VoteImpl>* consumer() const { return consumer_; } VoteConsumer<VoteImpl>* consumer() const { return consumer_; }
VoterId<VoteImpl> voter_id() const { return voter_id_; } VoterId<VoteImpl> voter_id() const { return voter_id_; }
...@@ -225,20 +224,22 @@ class AcceptedVote final { ...@@ -225,20 +224,22 @@ class AcceptedVote final {
// functions are only meant to be used by VoteReceipt. // functions are only meant to be used by VoteReceipt.
// Allows a VoteReceipt to associate itself with this vote. // Allows a VoteReceipt to associate itself with this vote.
void SetReceipt(util::PassKey<VoteReceipt>, VoteReceipt* receipt); void SetReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt);
// Allows a VoteReceipt to update its backpointer. // Allows a VoteReceipt to update its backpointer.
void MoveReceipt(util::PassKey<VoteReceipt>, void MoveReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt* old_receipt, VoteReceipt<VoteImpl>* old_receipt,
VoteReceipt* new_receipt); VoteReceipt<VoteImpl>* new_receipt);
// Allows a VoteReceipt to change this vote. // Allows a VoteReceipt to change this vote.
void ChangeVote(util::PassKey<VoteReceipt>, void ChangeVote(util::PassKey<VoteReceipt<VoteImpl>>,
typename VoteImpl::VoteType vote, typename VoteImpl::VoteType vote,
const char* reason); const char* reason);
// Allows a VoteReceipt to invalidate this vote. // Allows a VoteReceipt to invalidate this vote.
void InvalidateVote(util::PassKey<VoteReceipt>, VoteReceipt* receipt); void InvalidateVote(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt);
private: private:
void Take(AcceptedVote&& rhs); void Take(AcceptedVote&& rhs);
...@@ -254,7 +255,7 @@ class AcceptedVote final { ...@@ -254,7 +255,7 @@ class AcceptedVote final {
VoteImpl vote_; VoteImpl vote_;
// The associated vote receipt. // The associated vote receipt.
VoteReceipt* receipt_ = nullptr; VoteReceipt<VoteImpl>* receipt_ = nullptr;
// Set to true when an associated receipt is destroyed. // Set to true when an associated receipt is destroyed.
bool invalidated_ = true; bool invalidated_ = true;
...@@ -270,7 +271,6 @@ template <class VoteImpl> ...@@ -270,7 +271,6 @@ template <class VoteImpl>
class VotingChannel final { class VotingChannel final {
public: public:
using PassKey = util::PassKey<VotingChannel<VoteImpl>>; using PassKey = util::PassKey<VotingChannel<VoteImpl>>;
using VotingChannelFactory = VotingChannelFactory<VoteImpl>;
VotingChannel(); VotingChannel();
VotingChannel(const VotingChannel& rhs) = delete; VotingChannel(const VotingChannel& rhs) = delete;
...@@ -291,11 +291,13 @@ class VotingChannel final { ...@@ -291,11 +291,13 @@ class VotingChannel final {
VoterId<VoteImpl> voter_id() const { return voter_id_; } VoterId<VoteImpl> voter_id() const { return voter_id_; }
VotingChannelFactory* factory_for_testing() const { return factory_; } VotingChannelFactory<VoteImpl>* factory_for_testing() const {
return factory_;
}
// VotingChannelFactory is the sole producer of VotingChannels. // VotingChannelFactory is the sole producer of VotingChannels.
VotingChannel(util::PassKey<VotingChannelFactory>, VotingChannel(util::PassKey<VotingChannelFactory<VoteImpl>>,
VotingChannelFactory* factory, VotingChannelFactory<VoteImpl>* factory,
VoterId<VoteImpl> voter_id); VoterId<VoteImpl> voter_id);
private: private:
...@@ -303,7 +305,7 @@ class VotingChannel final { ...@@ -303,7 +305,7 @@ class VotingChannel final {
// Used to reach back into the factory to decrement the outstanding // Used to reach back into the factory to decrement the outstanding
// VotingChannel count, and for routing votes to the consumer. // VotingChannel count, and for routing votes to the consumer.
VotingChannelFactory* factory_ = nullptr; VotingChannelFactory<VoteImpl>* factory_ = nullptr;
VoterId<VoteImpl> voter_id_ = kInvalidVoterId<VoteImpl>; VoterId<VoteImpl> voter_id_ = kInvalidVoterId<VoteImpl>;
}; };
...@@ -316,15 +318,13 @@ class VotingChannel final { ...@@ -316,15 +318,13 @@ class VotingChannel final {
template <class VoteImpl> template <class VoteImpl>
class VotingChannelFactory final { class VotingChannelFactory final {
public: public:
using VotingChannel = VotingChannel<VoteImpl>;
explicit VotingChannelFactory(VoteConsumer<VoteImpl>* consumer); explicit VotingChannelFactory(VoteConsumer<VoteImpl>* consumer);
~VotingChannelFactory(); ~VotingChannelFactory();
VotingChannelFactory(const VotingChannelFactory& rhs) = delete; VotingChannelFactory(const VotingChannelFactory& rhs) = delete;
VotingChannelFactory& operator=(const VotingChannelFactory& rhs) = delete; VotingChannelFactory& operator=(const VotingChannelFactory& rhs) = delete;
// Builds a new VotingChannel that routes votes to the |consumer_|. // Builds a new VotingChannel that routes votes to the |consumer_|.
VotingChannel BuildVotingChannel(); VotingChannel<VoteImpl> BuildVotingChannel();
size_t voting_channels_issued() const { return voting_channels_issued_; } size_t voting_channels_issued() const { return voting_channels_issued_; }
size_t voting_channels_outstanding() const { size_t voting_channels_outstanding() const {
...@@ -333,9 +333,9 @@ class VotingChannelFactory final { ...@@ -333,9 +333,9 @@ class VotingChannelFactory final {
// Used by ~VotingChannel to notify the factory that a channel has been // Used by ~VotingChannel to notify the factory that a channel has been
// torn down. // torn down.
void OnVotingChannelDestroyed(util::PassKey<VotingChannel>); void OnVotingChannelDestroyed(util::PassKey<VotingChannel<VoteImpl>>);
VoteConsumer<VoteImpl>* GetConsumer(util::PassKey<VotingChannel>) { VoteConsumer<VoteImpl>* GetConsumer(util::PassKey<VotingChannel<VoteImpl>>) {
return consumer_; return consumer_;
} }
...@@ -361,27 +361,25 @@ class VoteConsumer { ...@@ -361,27 +361,25 @@ class VoteConsumer {
VoteConsumer(const VoteConsumer& rhs) = delete; VoteConsumer(const VoteConsumer& rhs) = delete;
VoteConsumer& operator=(const VoteConsumer& rhs) = delete; VoteConsumer& operator=(const VoteConsumer& rhs) = delete;
using AcceptedVote = AcceptedVote<VoteImpl>;
using VotingChannel = VotingChannel<VoteImpl>;
// Used by a VotingChannel to submit votes to this consumer. // Used by a VotingChannel to submit votes to this consumer.
virtual VoteReceipt<VoteImpl> SubmitVote(util::PassKey<VotingChannel>, virtual VoteReceipt<VoteImpl> SubmitVote(
VoterId<VoteImpl> voter_id, util::PassKey<VotingChannel<VoteImpl>>,
const VoteImpl& vote) = 0; VoterId<VoteImpl> voter_id,
const VoteImpl& vote) = 0;
// Used by an AcceptedVote to notify a consumer that a previously issued vote // Used by an AcceptedVote to notify a consumer that a previously issued vote
// has been changed. The consumer should update |old_vote| in-place using the // has been changed. The consumer should update |old_vote| in-place using the
// data from |new_vote|. // data from |new_vote|.
virtual void ChangeVote(util::PassKey<AcceptedVote>, virtual void ChangeVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote* old_vote, AcceptedVote<VoteImpl>* old_vote,
const VoteImpl& new_vote) = 0; const VoteImpl& new_vote) = 0;
// Used by a AcceptedVote to notify a consumer that a previously issued // Used by a AcceptedVote to notify a consumer that a previously issued
// receipt has been destroyed, and the vote is now invalidated. This is kept // receipt has been destroyed, and the vote is now invalidated. This is kept
// protected as it is part of a private contract between an AcceptedVote and a // protected as it is part of a private contract between an AcceptedVote and a
// VoteConsumer. // VoteConsumer.
virtual void VoteInvalidated(util::PassKey<AcceptedVote>, virtual void VoteInvalidated(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote* vote) = 0; AcceptedVote<VoteImpl>* vote) = 0;
}; };
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
...@@ -456,7 +454,7 @@ bool VoteReceipt<VoteImpl>::HasVote() const { ...@@ -456,7 +454,7 @@ bool VoteReceipt<VoteImpl>::HasVote() const {
} }
template <class VoteImpl> template <class VoteImpl>
bool VoteReceipt<VoteImpl>::HasVote(const AcceptedVote* vote) const { bool VoteReceipt<VoteImpl>::HasVote(const AcceptedVote<VoteImpl>* vote) const {
return vote_ == vote; return vote_ == vote;
} }
...@@ -497,9 +495,9 @@ void VoteReceipt<VoteImpl>::Reset() { ...@@ -497,9 +495,9 @@ void VoteReceipt<VoteImpl>::Reset() {
} }
template <class VoteImpl> template <class VoteImpl>
void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote>, void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote* old_vote, AcceptedVote<VoteImpl>* old_vote,
AcceptedVote* new_vote) { AcceptedVote<VoteImpl>* new_vote) {
DCHECK(old_vote); DCHECK(old_vote);
DCHECK(new_vote); DCHECK(new_vote);
DCHECK_EQ(vote_, old_vote); DCHECK_EQ(vote_, old_vote);
...@@ -511,8 +509,8 @@ void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote>, ...@@ -511,8 +509,8 @@ void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote>,
} }
template <class VoteImpl> template <class VoteImpl>
VoteReceipt<VoteImpl>::VoteReceipt(util::PassKey<AcceptedVote>, VoteReceipt<VoteImpl>::VoteReceipt(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote* vote) AcceptedVote<VoteImpl>* vote)
: vote_(vote) { : vote_(vote) {
// The vote should be valid and not be associated with any receipt. // The vote should be valid and not be associated with any receipt.
DCHECK(vote->IsValid()); DCHECK(vote->IsValid());
...@@ -580,7 +578,8 @@ bool AcceptedVote<VoteImpl>::HasReceipt() const { ...@@ -580,7 +578,8 @@ bool AcceptedVote<VoteImpl>::HasReceipt() const {
} }
template <class VoteImpl> template <class VoteImpl>
bool AcceptedVote<VoteImpl>::HasReceipt(const VoteReceipt* receipt) const { bool AcceptedVote<VoteImpl>::HasReceipt(
const VoteReceipt<VoteImpl>* receipt) const {
return receipt_ == receipt; return receipt_ == receipt;
} }
...@@ -592,7 +591,7 @@ bool AcceptedVote<VoteImpl>::IsValid() const { ...@@ -592,7 +591,7 @@ bool AcceptedVote<VoteImpl>::IsValid() const {
template <class VoteImpl> template <class VoteImpl>
VoteReceipt<VoteImpl> AcceptedVote<VoteImpl>::IssueReceipt() { VoteReceipt<VoteImpl> AcceptedVote<VoteImpl>::IssueReceipt() {
return VoteReceipt(PassKey(), this); return VoteReceipt<VoteImpl>(PassKey(), this);
} }
template <class VoteImpl> template <class VoteImpl>
...@@ -603,8 +602,8 @@ void AcceptedVote<VoteImpl>::UpdateVote(const VoteImpl& vote) { ...@@ -603,8 +602,8 @@ void AcceptedVote<VoteImpl>::UpdateVote(const VoteImpl& vote) {
} }
template <class VoteImpl> template <class VoteImpl>
void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt>, void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt* receipt) { VoteReceipt<VoteImpl>* receipt) {
// A receipt can only be set on a vote once in its lifetime. // A receipt can only be set on a vote once in its lifetime.
DCHECK(!receipt_); DCHECK(!receipt_);
DCHECK(!invalidated_); DCHECK(!invalidated_);
...@@ -616,9 +615,9 @@ void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt>, ...@@ -616,9 +615,9 @@ void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt>,
} }
template <class VoteImpl> template <class VoteImpl>
void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt>, void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt* old_receipt, VoteReceipt<VoteImpl>* old_receipt,
VoteReceipt* new_receipt) { VoteReceipt<VoteImpl>* new_receipt) {
DCHECK(old_receipt); DCHECK(old_receipt);
DCHECK(new_receipt); DCHECK(new_receipt);
DCHECK_EQ(receipt_, old_receipt); DCHECK_EQ(receipt_, old_receipt);
...@@ -630,7 +629,7 @@ void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt>, ...@@ -630,7 +629,7 @@ void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt>,
} }
template <class VoteImpl> template <class VoteImpl>
void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt>, void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt<VoteImpl>>,
typename VoteImpl::VoteType vote, typename VoteImpl::VoteType vote,
const char* reason) { const char* reason) {
DCHECK(!invalidated_); DCHECK(!invalidated_);
...@@ -646,8 +645,9 @@ void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt>, ...@@ -646,8 +645,9 @@ void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt>,
} }
template <class VoteImpl> template <class VoteImpl>
void AcceptedVote<VoteImpl>::InvalidateVote(util::PassKey<VoteReceipt>, void AcceptedVote<VoteImpl>::InvalidateVote(
VoteReceipt* receipt) { util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt) {
DCHECK(receipt); DCHECK(receipt);
DCHECK_EQ(receipt_, receipt); DCHECK_EQ(receipt_, receipt);
DCHECK(!invalidated_); DCHECK(!invalidated_);
...@@ -723,9 +723,10 @@ void VotingChannel<VoteImpl>::Reset() { ...@@ -723,9 +723,10 @@ void VotingChannel<VoteImpl>::Reset() {
} }
template <class VoteImpl> template <class VoteImpl>
VotingChannel<VoteImpl>::VotingChannel(util::PassKey<VotingChannelFactory>, VotingChannel<VoteImpl>::VotingChannel(
VotingChannelFactory* factory, util::PassKey<VotingChannelFactory<VoteImpl>>,
VoterId<VoteImpl> voter_id) VotingChannelFactory<VoteImpl>* factory,
VoterId<VoteImpl> voter_id)
: factory_(factory), voter_id_(voter_id) {} : factory_(factory), voter_id_(voter_id) {}
template <class VoteImpl> template <class VoteImpl>
...@@ -758,13 +759,13 @@ VotingChannel<VoteImpl> VotingChannelFactory<VoteImpl>::BuildVotingChannel() { ...@@ -758,13 +759,13 @@ VotingChannel<VoteImpl> VotingChannelFactory<VoteImpl>::BuildVotingChannel() {
// FromUnsafeValue. // FromUnsafeValue.
VoterId<VoteImpl> new_voter_id = VoterId<VoteImpl> new_voter_id =
VoterId<VoteImpl>::FromUnsafeValue(++voting_channels_issued_); VoterId<VoteImpl>::FromUnsafeValue(++voting_channels_issued_);
return VotingChannel(util::PassKey<VotingChannelFactory<VoteImpl>>(), this, return VotingChannel<VoteImpl>(
new_voter_id); util::PassKey<VotingChannelFactory<VoteImpl>>(), this, new_voter_id);
} }
template <class VoteImpl> template <class VoteImpl>
void VotingChannelFactory<VoteImpl>::OnVotingChannelDestroyed( void VotingChannelFactory<VoteImpl>::OnVotingChannelDestroyed(
util::PassKey<VotingChannel>) { util::PassKey<VotingChannel<VoteImpl>>) {
DCHECK_LT(0u, voting_channels_outstanding_); DCHECK_LT(0u, voting_channels_outstanding_);
--voting_channels_outstanding_; --voting_channels_outstanding_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment