Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 4dd8558

Browse files
authored
Second attempt to add iterator_range::empty() (#174)
Doing this makes MSVC complain that `empty(someRange)` could refer to either C++17's std::empty or LLVM's llvm::empty, which previously we avoided via SFINAE because std::empty is defined in terms of an empty member rather than begin and end. So, switch callers over to the new method as it is added. https://reviews.llvm.org/D68439 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373935 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ffbe03a commit 4dd8558

File tree

15 files changed

+18
-17
lines changed

15 files changed

+18
-17
lines changed

include/llvm/ADT/iterator_range.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class iterator_range {
4444

4545
IteratorT begin() const { return begin_iterator; }
4646
IteratorT end() const { return end_iterator; }
47+
bool empty() const { return begin_iterator == end_iterator; }
4748
};
4849

4950
/// Convenience function for iterating over sub-ranges.

lib/Analysis/LazyCallGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ LazyCallGraph::RefSCC::switchInternalEdgeToCall(
631631

632632
// If the merge range is empty, then adding the edge didn't actually form any
633633
// new cycles. We're done.
634-
if (empty(MergeRange)) {
634+
if (MergeRange.empty()) {
635635
// Now that the SCC structure is finalized, flip the kind to call.
636636
SourceN->setEdgeKind(TargetN, Edge::Call);
637637
return false; // No new cycle.

lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ void DwarfDebug::finalizeModuleInfo() {
902902
// If we're splitting the dwarf out now that we've got the entire
903903
// CU then add the dwo id to it.
904904
auto *SkCU = TheCU.getSkeleton();
905-
if (useSplitDwarf() && !empty(TheCU.getUnitDie().children())) {
905+
if (useSplitDwarf() && !TheCU.getUnitDie().children().empty()) {
906906
finishUnitAttributes(TheCU.getCUNode(), TheCU);
907907
TheCU.addString(TheCU.getUnitDie(), dwarf::DW_AT_GNU_dwo_name,
908908
Asm->TM.Options.MCOptions.SplitDwarfFile);
@@ -954,7 +954,7 @@ void DwarfDebug::finalizeModuleInfo() {
954954
// is a bit pessimistic under LTO.
955955
if (!AddrPool.isEmpty() &&
956956
(getDwarfVersion() >= 5 ||
957-
(SkCU && !empty(TheCU.getUnitDie().children()))))
957+
(SkCU && !TheCU.getUnitDie().children().empty())))
958958
U.addAddrTableBase();
959959

960960
if (getDwarfVersion() >= 5) {

lib/CodeGen/GlobalISel/InstructionSelector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ bool InstructionSelector::isObviouslySafeToFold(MachineInstr &MI,
7979
return true;
8080

8181
return !MI.mayLoadOrStore() && !MI.mayRaiseFPException() &&
82-
!MI.hasUnmodeledSideEffects() && empty(MI.implicit_operands());
82+
!MI.hasUnmodeledSideEffects() && MI.implicit_operands().empty();
8383
}

lib/CodeGen/GlobalISel/LegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ LegalizeRuleSet &LegalizerInfo::getActionDefinitionsBuilder(
412412
std::initializer_list<unsigned> Opcodes) {
413413
unsigned Representative = *Opcodes.begin();
414414

415-
assert(!empty(Opcodes) && Opcodes.begin() + 1 != Opcodes.end() &&
415+
assert(!llvm::empty(Opcodes) && Opcodes.begin() + 1 != Opcodes.end() &&
416416
"Initializer list must have at least two opcodes");
417417

418418
for (auto I = Opcodes.begin() + 1, E = Opcodes.end(); I != E; ++I)

lib/CodeGen/GlobalISel/RegBankSelect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ bool RegBankSelect::repairReg(
139139
"need new vreg for each breakdown");
140140

141141
// An empty range of new register means no repairing.
142-
assert(!empty(NewVRegs) && "We should not have to repair");
142+
assert(!NewVRegs.empty() && "We should not have to repair");
143143

144144
MachineInstr *MI;
145145
if (ValMapping.NumBreakDowns == 1) {

lib/CodeGen/GlobalISel/RegisterBankInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void RegisterBankInfo::applyDefaultMapping(const OperandsMapper &OpdMapper) {
456456
"This mapping is too complex for this function");
457457
iterator_range<SmallVectorImpl<unsigned>::const_iterator> NewRegs =
458458
OpdMapper.getVRegs(OpIdx);
459-
if (empty(NewRegs)) {
459+
if (NewRegs.empty()) {
460460
LLVM_DEBUG(dbgs() << " has not been repaired, nothing to be done\n");
461461
continue;
462462
}

lib/ExecutionEngine/Orc/ExecutionUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ iterator_range<CtorDtorIterator> getDestructors(const Module &M) {
8787
}
8888

8989
void CtorDtorRunner::add(iterator_range<CtorDtorIterator> CtorDtors) {
90-
if (empty(CtorDtors))
90+
if (CtorDtors.empty())
9191
return;
9292

9393
MangleAndInterner Mangle(

lib/IR/DebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ bool DebugInfoFinder::addScope(DIScope *Scope) {
279279
}
280280

281281
static MDNode *stripDebugLocFromLoopID(MDNode *N) {
282-
assert(!empty(N->operands()) && "Missing self reference?");
282+
assert(!N->operands().empty() && "Missing self reference?");
283283

284284
// if there is no debug location, we do not have to rewrite this MDNode.
285285
if (std::none_of(N->op_begin() + 1, N->op_end(), [](const MDOperand &Op) {

lib/Target/BPF/BPFAsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool BPFAsmPrinter::doInitialization(Module &M) {
5656
AsmPrinter::doInitialization(M);
5757

5858
// Only emit BTF when debuginfo available.
59-
if (MAI->doesSupportDebugInformation() && !empty(M.debug_compile_units())) {
59+
if (MAI->doesSupportDebugInformation() && !M.debug_compile_units().empty()) {
6060
Handlers.emplace_back(llvm::make_unique<BTFDebug>(this), "emit",
6161
"Debug Info Emission", "BTF", "BTF Emission");
6262
}

0 commit comments

Comments
 (0)