Skip to content

Commit 718ea4b

Browse files
committed
replace require with the new ASSERT macro
1 parent 5bbf6d0 commit 718ea4b

File tree

5 files changed

+21
-61
lines changed

5 files changed

+21
-61
lines changed

include/swift/Basic/Require.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

include/swift/SIL/SILBitfield.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef SWIFT_SIL_SILBITFIELD_H
1818
#define SWIFT_SIL_SILBITFIELD_H
1919

20-
#include "swift/Basic/Require.h"
20+
#include "swift/Basic/Assertions.h"
2121
#include "swift/SIL/SILFunction.h"
2222

2323
namespace swift {
@@ -56,12 +56,12 @@ template <class Impl, class T> class SILBitfield {
5656
parent(parent),
5757
function(function) {
5858
assert(size > 0 && "bit field size must be > 0");
59-
require(endBit <= T::numCustomBits,
60-
"too many/large bit fields allocated in function");
61-
assert((!parent || bitfieldID > parent->bitfieldID) &&
59+
ASSERT(endBit <= T::numCustomBits &&
60+
"too many/large bit fields allocated in function");
61+
ASSERT((!parent || bitfieldID > parent->bitfieldID) &&
6262
"BasicBlockBitfield indices are not in order");
63-
require(function->currentBitfieldID < T::maxBitfieldID,
64-
"currentBitfieldID overflow");
63+
ASSERT(function->currentBitfieldID < T::maxBitfieldID &&
64+
"currentBitfieldID overflow");
6565
++function->currentBitfieldID;
6666
}
6767

lib/SIL/IR/Linker.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include "swift/AST/ProtocolConformance.h"
6161
#include "swift/AST/SubstitutionMap.h"
6262
#include "swift/Basic/Assertions.h"
63-
#include "swift/Basic/Require.h"
6463
#include "swift/ClangImporter/ClangModule.h"
6564
#include "swift/SIL/FormalLinkage.h"
6665
#include "swift/Serialization/SerializedSILLoader.h"
@@ -76,20 +75,20 @@ STATISTIC(NumFuncLinked, "Number of SIL functions linked");
7675
//===----------------------------------------------------------------------===//
7776

7877
void SILLinkerVisitor::deserializeAndPushToWorklist(SILFunction *F) {
79-
assert(F->isExternalDeclaration());
78+
ASSERT(F->isExternalDeclaration());
8079

8180
LLVM_DEBUG(llvm::dbgs() << "Imported function: "
8281
<< F->getName() << "\n");
8382
SILFunction *NewF =
8483
Mod.getSILLoader()->lookupSILFunction(F, /*onlyUpdateLinkage*/ false);
85-
assert(!NewF || NewF == F);
84+
ASSERT(!NewF || NewF == F);
8685
if (!NewF || F->isExternalDeclaration()) {
87-
assert((!hasSharedVisibility(F->getLinkage()) || F->hasForeignBody()) &&
86+
ASSERT((!hasSharedVisibility(F->getLinkage()) || F->hasForeignBody()) &&
8887
"cannot deserialize shared function");
8988
return;
9089
}
9190

92-
assert(!F->isAnySerialized() == Mod.isSerialized() &&
91+
ASSERT(!F->isAnySerialized() == Mod.isSerialized() &&
9392
"the de-serializer did set the wrong serialized flag");
9493

9594
F->setBare(IsBare);
@@ -103,9 +102,9 @@ void SILLinkerVisitor::deserializeAndPushToWorklist(SILFunction *F) {
103102
void SILLinkerVisitor::maybeAddFunctionToWorklist(
104103
SILFunction *F, SerializedKind_t callerSerializedKind) {
105104
SILLinkage linkage = F->getLinkage();
106-
require(callerSerializedKind == IsNotSerialized ||
105+
ASSERT((callerSerializedKind == IsNotSerialized ||
107106
F->hasValidLinkageForFragileRef(callerSerializedKind) ||
108-
hasSharedVisibility(linkage) || F->isExternForwardDeclaration(),
107+
hasSharedVisibility(linkage) || F->isExternForwardDeclaration()) &&
109108
"called function has wrong linkage for serialized function");
110109
if (!F->isExternalDeclaration()) {
111110
// The function is already in the module, so no need to de-serialized it.
@@ -175,7 +174,7 @@ void SILLinkerVisitor::linkInVTable(ClassDecl *D) {
175174
// vtables that might have shared linkage yet, so this is only needed in
176175
// the performance pipeline to deserialize more functions early, and expose
177176
// optimization opportunities.
178-
assert(isLinkAll());
177+
ASSERT(isLinkAll());
179178

180179
// Attempt to lookup the Vtbl from the SILModule.
181180
SILVTable *Vtbl = Mod.lookUpVTable(D);

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,8 @@ FixedSizeSlab *SwiftPassInvocation::freeSlab(FixedSizeSlab *slab) {
14221422
}
14231423

14241424
BasicBlockSet *SwiftPassInvocation::allocBlockSet() {
1425-
require(numBlockSetsAllocated < BlockSetCapacity,
1426-
"too many BasicBlockSets allocated");
1425+
ASSERT(numBlockSetsAllocated < BlockSetCapacity &&
1426+
"too many BasicBlockSets allocated");
14271427

14281428
auto *storage = (BasicBlockSet *)blockSetStorage + numBlockSetsAllocated;
14291429
BasicBlockSet *set = new (storage) BasicBlockSet(function);
@@ -1446,8 +1446,8 @@ void SwiftPassInvocation::freeBlockSet(BasicBlockSet *set) {
14461446
}
14471447

14481448
NodeSet *SwiftPassInvocation::allocNodeSet() {
1449-
require(numNodeSetsAllocated < NodeSetCapacity,
1450-
"too many NodeSets allocated");
1449+
ASSERT(numNodeSetsAllocated < NodeSetCapacity &&
1450+
"too many NodeSets allocated");
14511451

14521452
auto *storage = (NodeSet *)nodeSetStorage + numNodeSetsAllocated;
14531453
NodeSet *set = new (storage) NodeSet(function);
@@ -1470,8 +1470,8 @@ void SwiftPassInvocation::freeNodeSet(NodeSet *set) {
14701470
}
14711471

14721472
OperandSet *SwiftPassInvocation::allocOperandSet() {
1473-
require(numOperandSetsAllocated < OperandSetCapacity,
1474-
"too many OperandSets allocated");
1473+
ASSERT(numOperandSetsAllocated < OperandSetCapacity &&
1474+
"too many OperandSets allocated");
14751475

14761476
auto *storage = (OperandSet *)operandSetStorage + numOperandSetsAllocated;
14771477
OperandSet *set = new (storage) OperandSet(function);

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "swift/SILOptimizer/Utils/PerformanceInlinerUtils.h"
1616
#include "swift/AST/Module.h"
1717
#include "swift/Basic/Assertions.h"
18-
#include "swift/Basic/Require.h"
1918
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
2019
#include "llvm/Support/CommandLine.h"
2120

@@ -853,8 +852,8 @@ SILFunction *swift::getEligibleFunction(FullApplySite AI,
853852
!Callee->hasValidLinkageForFragileRef(Caller->getSerializedKind())) {
854853
llvm::errs() << "caller: " << Caller->getName() << "\n";
855854
llvm::errs() << "callee: " << Callee->getName() << "\n";
856-
require(false, "Should never be inlining a resilient function into "
857-
"a fragile function");
855+
ASSERT(false && "Should never be inlining a resilient function into "
856+
"a fragile function");
858857
}
859858
return nullptr;
860859
}

0 commit comments

Comments
 (0)