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;
template <class VoteImpl>
class VoteReceipt final {
public:
using AcceptedVote = AcceptedVote<VoteImpl>;
using PassKey = util::PassKey<VoteReceipt<VoteImpl>>;
VoteReceipt();
......@@ -133,7 +132,7 @@ class VoteReceipt final {
// Returns true if this receipt is entangled with a vote.
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
// HasVote returns true.
......@@ -159,19 +158,20 @@ class VoteReceipt final {
// functions are only meant to be used by AcceptedVote.
// 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.
void MoveVote(util::PassKey<AcceptedVote>,
AcceptedVote* old_vote,
AcceptedVote* new_vote);
void MoveVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* old_vote,
AcceptedVote<VoteImpl>* new_vote);
private:
void Take(VoteReceipt&& rhs);
// A back-pointer to the accepted vote, so that it can be notified when this
// receipt is destroyed.
AcceptedVote* vote_ = nullptr;
AcceptedVote<VoteImpl>* vote_ = nullptr;
};
// A move-only wrapper for a vote and its associated receipt. AcceptedVotes
......@@ -192,7 +192,6 @@ template <class VoteImpl>
class AcceptedVote final {
public:
using PassKey = util::PassKey<AcceptedVote<VoteImpl>>;
using VoteReceipt = VoteReceipt<VoteImpl>;
AcceptedVote();
AcceptedVote(VoteConsumer<VoteImpl>* consumer,
......@@ -208,10 +207,10 @@ class AcceptedVote final {
// Returns true if this vote is associated with a receipt.
bool HasReceipt() const;
bool HasReceipt(const VoteReceipt* receipt) const;
bool HasReceipt(const VoteReceipt<VoteImpl>* receipt) const;
bool IsValid() const;
VoteReceipt IssueReceipt();
VoteReceipt<VoteImpl> IssueReceipt();
VoteConsumer<VoteImpl>* consumer() const { return consumer_; }
VoterId<VoteImpl> voter_id() const { return voter_id_; }
......@@ -225,20 +224,22 @@ class AcceptedVote final {
// functions are only meant to be used by VoteReceipt.
// 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.
void MoveReceipt(util::PassKey<VoteReceipt>,
VoteReceipt* old_receipt,
VoteReceipt* new_receipt);
void MoveReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* old_receipt,
VoteReceipt<VoteImpl>* new_receipt);
// Allows a VoteReceipt to change this vote.
void ChangeVote(util::PassKey<VoteReceipt>,
void ChangeVote(util::PassKey<VoteReceipt<VoteImpl>>,
typename VoteImpl::VoteType vote,
const char* reason);
// Allows a VoteReceipt to invalidate this vote.
void InvalidateVote(util::PassKey<VoteReceipt>, VoteReceipt* receipt);
void InvalidateVote(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt);
private:
void Take(AcceptedVote&& rhs);
......@@ -254,7 +255,7 @@ class AcceptedVote final {
VoteImpl vote_;
// The associated vote receipt.
VoteReceipt* receipt_ = nullptr;
VoteReceipt<VoteImpl>* receipt_ = nullptr;
// Set to true when an associated receipt is destroyed.
bool invalidated_ = true;
......@@ -270,7 +271,6 @@ template <class VoteImpl>
class VotingChannel final {
public:
using PassKey = util::PassKey<VotingChannel<VoteImpl>>;
using VotingChannelFactory = VotingChannelFactory<VoteImpl>;
VotingChannel();
VotingChannel(const VotingChannel& rhs) = delete;
......@@ -291,11 +291,13 @@ class VotingChannel final {
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.
VotingChannel(util::PassKey<VotingChannelFactory>,
VotingChannelFactory* factory,
VotingChannel(util::PassKey<VotingChannelFactory<VoteImpl>>,
VotingChannelFactory<VoteImpl>* factory,
VoterId<VoteImpl> voter_id);
private:
......@@ -303,7 +305,7 @@ class VotingChannel final {
// Used to reach back into the factory to decrement the outstanding
// VotingChannel count, and for routing votes to the consumer.
VotingChannelFactory* factory_ = nullptr;
VotingChannelFactory<VoteImpl>* factory_ = nullptr;
VoterId<VoteImpl> voter_id_ = kInvalidVoterId<VoteImpl>;
};
......@@ -316,15 +318,13 @@ class VotingChannel final {
template <class VoteImpl>
class VotingChannelFactory final {
public:
using VotingChannel = VotingChannel<VoteImpl>;
explicit VotingChannelFactory(VoteConsumer<VoteImpl>* consumer);
~VotingChannelFactory();
VotingChannelFactory(const VotingChannelFactory& rhs) = delete;
VotingChannelFactory& operator=(const VotingChannelFactory& rhs) = delete;
// 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_outstanding() const {
......@@ -333,9 +333,9 @@ class VotingChannelFactory final {
// Used by ~VotingChannel to notify the factory that a channel has been
// 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_;
}
......@@ -361,27 +361,25 @@ class VoteConsumer {
VoteConsumer(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.
virtual VoteReceipt<VoteImpl> SubmitVote(util::PassKey<VotingChannel>,
VoterId<VoteImpl> voter_id,
const VoteImpl& vote) = 0;
virtual VoteReceipt<VoteImpl> SubmitVote(
util::PassKey<VotingChannel<VoteImpl>>,
VoterId<VoteImpl> voter_id,
const VoteImpl& vote) = 0;
// 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
// data from |new_vote|.
virtual void ChangeVote(util::PassKey<AcceptedVote>,
AcceptedVote* old_vote,
virtual void ChangeVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* old_vote,
const VoteImpl& new_vote) = 0;
// 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
// protected as it is part of a private contract between an AcceptedVote and a
// VoteConsumer.
virtual void VoteInvalidated(util::PassKey<AcceptedVote>,
AcceptedVote* vote) = 0;
virtual void VoteInvalidated(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* vote) = 0;
};
/////////////////////////////////////////////////////////////////////
......@@ -456,7 +454,7 @@ bool VoteReceipt<VoteImpl>::HasVote() const {
}
template <class VoteImpl>
bool VoteReceipt<VoteImpl>::HasVote(const AcceptedVote* vote) const {
bool VoteReceipt<VoteImpl>::HasVote(const AcceptedVote<VoteImpl>* vote) const {
return vote_ == vote;
}
......@@ -497,9 +495,9 @@ void VoteReceipt<VoteImpl>::Reset() {
}
template <class VoteImpl>
void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote>,
AcceptedVote* old_vote,
AcceptedVote* new_vote) {
void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* old_vote,
AcceptedVote<VoteImpl>* new_vote) {
DCHECK(old_vote);
DCHECK(new_vote);
DCHECK_EQ(vote_, old_vote);
......@@ -511,8 +509,8 @@ void VoteReceipt<VoteImpl>::MoveVote(util::PassKey<AcceptedVote>,
}
template <class VoteImpl>
VoteReceipt<VoteImpl>::VoteReceipt(util::PassKey<AcceptedVote>,
AcceptedVote* vote)
VoteReceipt<VoteImpl>::VoteReceipt(util::PassKey<AcceptedVote<VoteImpl>>,
AcceptedVote<VoteImpl>* vote)
: vote_(vote) {
// The vote should be valid and not be associated with any receipt.
DCHECK(vote->IsValid());
......@@ -580,7 +578,8 @@ bool AcceptedVote<VoteImpl>::HasReceipt() const {
}
template <class VoteImpl>
bool AcceptedVote<VoteImpl>::HasReceipt(const VoteReceipt* receipt) const {
bool AcceptedVote<VoteImpl>::HasReceipt(
const VoteReceipt<VoteImpl>* receipt) const {
return receipt_ == receipt;
}
......@@ -592,7 +591,7 @@ bool AcceptedVote<VoteImpl>::IsValid() const {
template <class VoteImpl>
VoteReceipt<VoteImpl> AcceptedVote<VoteImpl>::IssueReceipt() {
return VoteReceipt(PassKey(), this);
return VoteReceipt<VoteImpl>(PassKey(), this);
}
template <class VoteImpl>
......@@ -603,8 +602,8 @@ void AcceptedVote<VoteImpl>::UpdateVote(const VoteImpl& vote) {
}
template <class VoteImpl>
void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt>,
VoteReceipt* receipt) {
void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt) {
// A receipt can only be set on a vote once in its lifetime.
DCHECK(!receipt_);
DCHECK(!invalidated_);
......@@ -616,9 +615,9 @@ void AcceptedVote<VoteImpl>::SetReceipt(util::PassKey<VoteReceipt>,
}
template <class VoteImpl>
void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt>,
VoteReceipt* old_receipt,
VoteReceipt* new_receipt) {
void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* old_receipt,
VoteReceipt<VoteImpl>* new_receipt) {
DCHECK(old_receipt);
DCHECK(new_receipt);
DCHECK_EQ(receipt_, old_receipt);
......@@ -630,7 +629,7 @@ void AcceptedVote<VoteImpl>::MoveReceipt(util::PassKey<VoteReceipt>,
}
template <class VoteImpl>
void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt>,
void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt<VoteImpl>>,
typename VoteImpl::VoteType vote,
const char* reason) {
DCHECK(!invalidated_);
......@@ -646,8 +645,9 @@ void AcceptedVote<VoteImpl>::ChangeVote(util::PassKey<VoteReceipt>,
}
template <class VoteImpl>
void AcceptedVote<VoteImpl>::InvalidateVote(util::PassKey<VoteReceipt>,
VoteReceipt* receipt) {
void AcceptedVote<VoteImpl>::InvalidateVote(
util::PassKey<VoteReceipt<VoteImpl>>,
VoteReceipt<VoteImpl>* receipt) {
DCHECK(receipt);
DCHECK_EQ(receipt_, receipt);
DCHECK(!invalidated_);
......@@ -723,9 +723,10 @@ void VotingChannel<VoteImpl>::Reset() {
}
template <class VoteImpl>
VotingChannel<VoteImpl>::VotingChannel(util::PassKey<VotingChannelFactory>,
VotingChannelFactory* factory,
VoterId<VoteImpl> voter_id)
VotingChannel<VoteImpl>::VotingChannel(
util::PassKey<VotingChannelFactory<VoteImpl>>,
VotingChannelFactory<VoteImpl>* factory,
VoterId<VoteImpl> voter_id)
: factory_(factory), voter_id_(voter_id) {}
template <class VoteImpl>
......@@ -758,13 +759,13 @@ VotingChannel<VoteImpl> VotingChannelFactory<VoteImpl>::BuildVotingChannel() {
// FromUnsafeValue.
VoterId<VoteImpl> new_voter_id =
VoterId<VoteImpl>::FromUnsafeValue(++voting_channels_issued_);
return VotingChannel(util::PassKey<VotingChannelFactory<VoteImpl>>(), this,
new_voter_id);
return VotingChannel<VoteImpl>(
util::PassKey<VotingChannelFactory<VoteImpl>>(), this, new_voter_id);
}
template <class VoteImpl>
void VotingChannelFactory<VoteImpl>::OnVotingChannelDestroyed(
util::PassKey<VotingChannel>) {
util::PassKey<VotingChannel<VoteImpl>>) {
DCHECK_LT(0u, 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