mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
2fc9f32ca3
Part of the <=> changes in C++20 make certain patterns of writing equality operators ambiguous with themselves (sorry!). This patch goes through and adjusts all the comparison operators such that they should work in both C++17 and C++20 modes. It also makes two other small C++20-specific changes (adding a constructor to a type that cases to be an aggregate, and adding casts from u8 literals which no longer have type const char*). There were four categories of errors that this review fixes. Here are canonical examples of them, ordered from most to least common: // 1) Missing const namespace missing_const { struct A { #ifndef FIXED bool operator==(A const&); #else bool operator==(A const&) const; #endif }; bool a = A{} == A{}; // error } // 2) Type mismatch on CRTP namespace crtp_mismatch { template <typename Derived> struct Base { #ifndef FIXED bool operator==(Derived const&) const; #else // in one case changed to taking Base const& friend bool operator==(Derived const&, Derived const&); #endif }; struct D : Base<D> { }; bool b = D{} == D{}; // error } // 3) iterator/const_iterator with only mixed comparison namespace iter_const_iter { template <bool Const> struct iterator { using const_iterator = iterator<true>; iterator(); template <bool B, std::enable_if_t<(Const && !B), int> = 0> iterator(iterator<B> const&); #ifndef FIXED bool operator==(const_iterator const&) const; #else friend bool operator==(iterator const&, iterator const&); #endif }; bool c = iterator<false>{} == iterator<false>{} // error || iterator<false>{} == iterator<true>{} || iterator<true>{} == iterator<false>{} || iterator<true>{} == iterator<true>{}; } // 4) Same-type comparison but only have mixed-type operator namespace ambiguous_choice { enum Color { Red }; struct C { C(); C(Color); operator Color() const; bool operator==(Color) const; friend bool operator==(C, C); }; bool c = C{} == C{}; // error bool d = C{} == Red; } Differential revision: https://reviews.llvm.org/D78938 |
||
---|---|---|
.. | ||
GlobalISel | ||
MIRParser | ||
PBQP | ||
AccelTable.h | ||
Analysis.h | ||
AntiDepBreaker.h | ||
AsmPrinter.h | ||
AsmPrinterHandler.h | ||
AtomicExpandUtils.h | ||
BasicBlockSectionUtils.h | ||
BasicTTIImpl.h | ||
BuiltinGCs.h | ||
CalcSpillWeights.h | ||
CallingConvLower.h | ||
CommandFlags.h | ||
CostTable.h | ||
CSEConfigBase.h | ||
DAGCombine.h | ||
DbgEntityHistoryCalculator.h | ||
DebugHandlerBase.h | ||
DFAPacketizer.h | ||
DIE.h | ||
DIEValue.def | ||
DwarfStringPoolEntry.h | ||
EdgeBundles.h | ||
ExecutionDomainFix.h | ||
ExpandReductions.h | ||
FastISel.h | ||
FaultMaps.h | ||
FunctionLoweringInfo.h | ||
GCMetadata.h | ||
GCMetadataPrinter.h | ||
GCStrategy.h | ||
IndirectThunks.h | ||
IntrinsicLowering.h | ||
ISDOpcodes.h | ||
LatencyPriorityQueue.h | ||
LazyMachineBlockFrequencyInfo.h | ||
LexicalScopes.h | ||
LinkAllAsmWriterComponents.h | ||
LinkAllCodegenComponents.h | ||
LiveInterval.h | ||
LiveIntervalCalc.h | ||
LiveIntervals.h | ||
LiveIntervalUnion.h | ||
LivePhysRegs.h | ||
LiveRangeCalc.h | ||
LiveRangeEdit.h | ||
LiveRegMatrix.h | ||
LiveRegUnits.h | ||
LiveStacks.h | ||
LiveVariables.h | ||
LoopTraversal.h | ||
LowLevelType.h | ||
MachineBasicBlock.h | ||
MachineBlockFrequencyInfo.h | ||
MachineBranchProbabilityInfo.h | ||
MachineCombinerPattern.h | ||
MachineConstantPool.h | ||
MachineDominanceFrontier.h | ||
MachineDominators.h | ||
MachineFrameInfo.h | ||
MachineFunction.h | ||
MachineFunctionPass.h | ||
MachineInstr.h | ||
MachineInstrBuilder.h | ||
MachineInstrBundle.h | ||
MachineInstrBundleIterator.h | ||
MachineJumpTableInfo.h | ||
MachineLoopInfo.h | ||
MachineLoopUtils.h | ||
MachineMemOperand.h | ||
MachineModuleInfo.h | ||
MachineModuleInfoImpls.h | ||
MachineOperand.h | ||
MachineOptimizationRemarkEmitter.h | ||
MachineOutliner.h | ||
MachinePassManager.h | ||
MachinePassRegistry.h | ||
MachinePipeliner.h | ||
MachinePostDominators.h | ||
MachineRegionInfo.h | ||
MachineRegisterInfo.h | ||
MachineScheduler.h | ||
MachineSizeOpts.h | ||
MachineSSAUpdater.h | ||
MachineStableHash.h | ||
MachineTraceMetrics.h | ||
MachORelocation.h | ||
MacroFusion.h | ||
MBFIWrapper.h | ||
MIRFormatter.h | ||
MIRPrinter.h | ||
MIRYamlMapping.h | ||
ModuloSchedule.h | ||
MultiHazardRecognizer.h | ||
NonRelocatableStringpool.h | ||
ParallelCG.h | ||
Passes.h | ||
PBQPRAConstraint.h | ||
PreISelIntrinsicLowering.h | ||
PseudoSourceValue.h | ||
RDFGraph.h | ||
RDFLiveness.h | ||
RDFRegisters.h | ||
ReachingDefAnalysis.h | ||
RegAllocPBQP.h | ||
RegAllocRegistry.h | ||
Register.h | ||
RegisterClassInfo.h | ||
RegisterPressure.h | ||
RegisterScavenging.h | ||
RegisterUsageInfo.h | ||
ResourcePriorityQueue.h | ||
RuntimeLibcalls.h | ||
ScheduleDAG.h | ||
ScheduleDAGInstrs.h | ||
ScheduleDAGMutation.h | ||
ScheduleDFS.h | ||
ScheduleHazardRecognizer.h | ||
SchedulerRegistry.h | ||
ScoreboardHazardRecognizer.h | ||
SDNodeProperties.td | ||
SelectionDAG.h | ||
SelectionDAGAddressAnalysis.h | ||
SelectionDAGISel.h | ||
SelectionDAGNodes.h | ||
SelectionDAGTargetInfo.h | ||
SlotIndexes.h | ||
Spiller.h | ||
StableHashing.h | ||
StackMaps.h | ||
StackProtector.h | ||
SwiftErrorValueTracking.h | ||
SwitchLoweringUtils.h | ||
TailDuplicator.h | ||
TargetCallingConv.h | ||
TargetFrameLowering.h | ||
TargetInstrInfo.h | ||
TargetLowering.h | ||
TargetLoweringObjectFileImpl.h | ||
TargetOpcodes.h | ||
TargetPassConfig.h | ||
TargetRegisterInfo.h | ||
TargetSchedule.h | ||
TargetSubtargetInfo.h | ||
TileShapeInfo.h | ||
UnreachableBlockElim.h | ||
ValueTypes.h | ||
ValueTypes.td | ||
VirtRegMap.h | ||
WasmEHFuncInfo.h | ||
WinEHFuncInfo.h |