Skip to content

Commit 2b04e9f

Browse files
Suppress a number of warnings in no-assert builds (#17721)
* Supress a number of warnings about things used only in asserts * Re-use a couple of variables instead of supressing the warning
1 parent 0f1ac21 commit 2b04e9f

33 files changed

+44
-2
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ void ASTMangler::appendDeclName(const ValueDecl *decl) {
654654
assert(((relatedEntityKind[0] >= 'a' && relatedEntityKind[0] <= 'j') ||
655655
(relatedEntityKind[0] >= 'A' && relatedEntityKind[0] <= 'J')) &&
656656
"Only [a-jA-J] are reserved for related entity kinds");
657-
return appendOperatorParam("L", synthesizedTypeAttr->getManglingName());
657+
return appendOperatorParam("L", relatedEntityKind);
658658
}
659659

660660
StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary(decl);

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ class Verifier : public ASTWalker {
934934
void verifyChecked(DeferStmt *S) {
935935
auto FT = S->getTempDecl()->getInterfaceType()->castTo<AnyFunctionType>();
936936
assert(FT->isNoEscape() && "Defer statements must not escape");
937+
(void)FT;
937938
verifyCheckedBase(S);
938939
}
939940

lib/AST/Expr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,7 @@ TupleExpr *TupleExpr::create(ASTContext &ctx,
15441544
assert((Implicit || ElementNames.size() == ElementNameLocs.size() ||
15451545
(!hasNonEmptyIdentifier(ElementNames) && ElementNameLocs.empty())) &&
15461546
"trying to create non-implicit tuple-expr without name locations");
1547+
(void)hasNonEmptyIdentifier;
15471548

15481549
size_t size =
15491550
totalSizeToAlloc<Expr *, Identifier, SourceLoc>(SubExprs.size(),

lib/Basic/Unix/TaskQueue.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ void TaskMonitor::verifyEvents(const short events) const {
556556
assert((events & POLLNVAL) == 0 && "Asked poll() to watch a closed fd");
557557
const short expectedEvents = POLLIN | POLLPRI | POLLHUP | POLLERR;
558558
assert((events & ~expectedEvents) == 0 && "Received unexpected event");
559+
(void)expectedEvents;
559560
}
560561

561562
void TaskMonitor::readDataIfAvailable(const short events, const int fd,

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7908,6 +7908,7 @@ recursivelySubstituteBaseType(const NormalProtocolConformance *conformance,
79087908

79097909
const ProtocolDecl *proto = conformance->getProtocol();
79107910
assert(origBase->isEqual(proto->getSelfInterfaceType()));
7911+
(void)proto;
79117912
return conformance->getTypeWitness(depMemTy->getAssocType(),
79127913
/*resolver=*/nullptr);
79137914
}

lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ sortJobsToMatchCompilationInputs(ArrayRef<const Job *> unsortedJobs,
297297
auto R =
298298
jobsByInput.insert(std::make_pair(IA->getInputArg().getValue(), J));
299299
assert(R.second);
300+
(void)R;
300301
}
301302
for (const InputPair &P : C.getInputFiles()) {
302303
auto I = jobsByInput.find(P.second->getValue());

lib/Frontend/FrontendInputsAndOutputs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void FrontendInputsAndOutputs::setMainAndSupplementaryOutputs(
293293
assert(outputFiles.size() == N && "Must have one main output per primary");
294294
assert(supplementaryOutputs.size() == N &&
295295
"Must have one set of supplementary outputs per primary");
296+
(void)N;
296297

297298
unsigned i = 0;
298299
for (auto &input : AllInputs) {

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ namespace {
878878
auto *dc = fn.getDecl()->getDeclContext();
879879
assert(!isa<ExtensionDecl>(dc));
880880

881-
if (fn.getDecl()->getDeclContext() == getType()) {
881+
if (dc == getType()) {
882882
if (auto entry = VTable->getEntry(IGM.getSILModule(), fn)) {
883883
assert(entry->TheKind == SILVTable::Entry::Kind::Normal);
884884
auto *implFn = IGM.getAddrOfSILFunction(entry->Implementation,

lib/IRGen/GenProto.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,7 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
26142614
return /*finished?*/ false;
26152615
});
26162616
assert(found && "too many conditional conformances");
2617+
(void)found;
26172618

26182619
sourceKey.Kind =
26192620
LocalTypeDataKind::forAbstractProtocolWitnessTable(conformingProto);

lib/IRGen/GenValueWitness.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,4 +1400,5 @@ void TypeInfo::collectMetadataForOutlining(OutliningMetadataCollector &c,
14001400
SILType T) const {
14011401
auto canType = T.getASTType();
14021402
assert(!canType->is<ArchetypeType>() && "Did not expect an ArchetypeType");
1403+
(void)canType;
14031404
}

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,13 +3956,15 @@ void IRGenSILFunction::visitIsEscapingClosureInst(
39563956

39573957
auto fnType = operandType.getAs<SILFunctionType>();
39583958
assert(fnType->getExtInfo().hasContext() && "Must have a closure operand");
3959+
(void)fnType;
39593960

39603961
// This code relies on that an optional<()->()>'s tag fits in the function
39613962
// pointer.
39623963
auto &TI = cast<LoadableTypeInfo>(getTypeInfo(operandType));
39633964
assert(TI.mayHaveExtraInhabitants(IGM) &&
39643965
"Must have extra inhabitants to be able to handle the optional "
39653966
"closure case");
3967+
(void)TI;
39663968

39673969
Explosion closure = getLoweredExplosion(i->getOperand());
39683970
auto func = closure.claimNext();

lib/IRGen/LoadableByAddress.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ void LargeValueVisitor::visitDeallocInst(DeallocStackInst *instr) {
949949
assert(pass.allocToApplyRetMap.find(opAsInstr) !=
950950
pass.allocToApplyRetMap.end() &&
951951
"Unexpected dealloc instr!");
952+
(void)opAsInstr;
952953
}
953954
}
954955

@@ -1377,6 +1378,7 @@ void LoadableStorageAllocation::convertApplyResults() {
13771378
"Expected SILFunctionType or Optional for the result type");
13781379
assert(optionalType.is<SILFunctionType>() &&
13791380
"Expected a SILFunctionType inside the optional Type");
1381+
(void)optionalType;
13801382
}
13811383
continue;
13821384
}
@@ -2018,6 +2020,8 @@ static void rewriteFunction(StructLoweringState &pass,
20182020
assert(srcType && "Expected an address-type source");
20192021
assert(tgtType.isAddress() && "Expected an address-type target");
20202022
assert(srcType == tgtType && "Source and target type do not match");
2023+
(void)srcType;
2024+
(void)tgtType;
20212025

20222026
SILBuilderWithScope copyBuilder(instr);
20232027
createOutlinedCopyCall(copyBuilder, src, tgt, pass);
@@ -2406,6 +2410,7 @@ void LoadableByAddress::recreateSingleApply(SILInstruction *applyInst) {
24062410
assert(oldYields.size() == newYields.size() &&
24072411
oldYields.size() == oldYieldedValues.size() &&
24082412
newYields.size() == newYieldedValues.size());
2413+
(void)newYields;
24092414
for (auto i : indices(oldYields)) {
24102415
SILValue oldValue = oldYieldedValues[i];
24112416
SILValue newValue = newYieldedValues[i];

lib/ParseSIL/ParseSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ void SILParser::convertRequirements(SILFunction *F,
847847

848848
auto *GenericEnv = F->getGenericEnvironment();
849849
assert(GenericEnv);
850+
(void)GenericEnv;
850851

851852
IdentTypeReprLookup PerformLookup(P);
852853
// Use parser lexical scopes to resolve references

lib/SIL/InstructionUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ SILValue swift::isPartialApplyOfReabstractionThunk(PartialApplyInst *PAI) {
355355
static SILValue findClosureStoredIntoBlock(SILValue V) {
356356
auto FnType = V->getType().castTo<SILFunctionType>();
357357
assert(FnType->getRepresentation() == SILFunctionTypeRepresentation::Block);
358+
(void)FnType;
358359

359360
// Given a no escape block argument to a function,
360361
// pattern match to find the noescape closure that invoking the block

lib/SIL/SILCoverageMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SILCoverageMap::create(SILModule &M, StringRef Filename, StringRef Name,
4545

4646
// Assert that this coverage map is unique.
4747
assert(result.second && "Duplicate coverage mapping for function");
48+
(void)result;
4849

4950
return CM;
5051
}

lib/SIL/SILFunctionType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,7 @@ const SILConstantInfo &TypeConverter::getConstantInfo(SILDeclRef constant) {
21222122

21232123
auto inserted = ConstantTypes.insert({constant, result});
21242124
assert(inserted.second);
2125+
(void)inserted;
21252126
return *result;
21262127
}
21272128

@@ -2289,6 +2290,7 @@ TypeConverter::getConstantOverrideInfo(SILDeclRef derived, SILDeclRef base) {
22892290

22902291
auto inserted = ConstantOverrideTypes.insert({{derived, base}, result});
22912292
assert(inserted.second);
2293+
(void)inserted;
22922294
return *result;
22932295
}
22942296

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static bool isGuaranteedForwardingInst(SILInstruction *I) {
129129
return isGuaranteedForwardingValueKind(SILNodeKind(I->getKind()));
130130
}
131131

132+
LLVM_ATTRIBUTE_UNUSED
132133
static bool isOwnershipForwardingInst(SILInstruction *I) {
133134
return isOwnershipForwardingValueKind(SILNodeKind(I->getKind()));
134135
}
@@ -154,7 +155,9 @@ class OwnershipCompatibilityUseChecker
154155
OwnershipUseCheckerResult> {
155156
public:
156157
private:
158+
LLVM_ATTRIBUTE_UNUSED
157159
SILModule &Mod;
160+
158161
const Operand &Op;
159162
SILValue BaseValue;
160163
ErrorBehaviorKind ErrorBehavior;

lib/SIL/SILProfiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bool doesASTRequireProfiling(SILModule &M, ASTNode N) {
8686
} // namespace swift
8787

8888
/// Check that the input AST has at least been type-checked.
89+
LLVM_ATTRIBUTE_UNUSED
8990
static bool hasASTBeenTypeChecked(ASTNode N) {
9091
DeclContext *DC = N.getAsDeclContext();
9192
assert(DC && "Invalid AST node for profiling");

lib/SIL/SILVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4984,6 +4984,8 @@ void SILWitnessTable::verify(const SILModule &M) const {
49844984
"Witnesses must either have a concrete Self, or an "
49854985
"an abstract Self that is constrained to their "
49864986
"protocol.");
4987+
(void)protocol;
4988+
(void)witnessSelfProtocol;
49874989
}
49884990
}
49894991
}

lib/SILGen/SILGenApply.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,6 +3857,7 @@ CallEmission::applyEnumElementConstructor(SGFContext C) {
38573857
}
38583858

38593859
assert(substFnType->getNumResults() == 1);
3860+
(void)substFnType;
38603861
ManagedValue resultMV = SGF.emitInjectEnum(
38613862
uncurriedLoc, std::move(payload), SGF.getLoweredType(formalResultType),
38623863
element, uncurriedContext);
@@ -5198,6 +5199,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
51985199
auto subscriptsTupleType = cast<TupleType>(subscripts.getType());
51995200
assert(accessType.getParams().size()
52005201
== 1 + subscriptsTupleType->getNumElements());
5202+
(void)subscriptsTupleType;
52015203
SmallVector<RValue, 8> eltRVs;
52025204
std::move(subscripts).extractElements(eltRVs);
52035205
for (auto &elt : eltRVs)

lib/SILGen/SILGenBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(
219219
SILFunctionTypeRepresentation::Thick &&
220220
!fnType->isNoEscape() && resultFnType->isNoEscape() &&
221221
"Expect a escaping to noescape conversion");
222+
(void)fnType;
223+
(void)resultFnType;
222224
SILValue fnValue = fn.getValue();
223225
SILValue result = createConvertEscapeToNoEscape(
224226
loc, fnValue, resultTy, isEscapedByUser, false);

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static ManagedValue emitBuiltinValueToBridgeObject(SILGenFunction &SGF,
901901
"ValueToBridgeObject should have one sub");
902902
auto &fromTL = SGF.getTypeLowering(subs.getReplacementTypes()[0]);
903903
assert(fromTL.isTrivial() && "Expected a trivial type");
904+
(void)fromTL;
904905

905906
SILValue result = SGF.B.createValueToBridgeObject(loc, args[0].getValue());
906907
return SGF.emitManagedRetain(loc, result);

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4584,6 +4584,7 @@ namespace {
45844584
void visitTupleExpr(TupleExpr *E) {
45854585
auto *TTy = E->getType()->castTo<TupleType>();
45864586
assert(TTy->hasLValueType() || TTy->isVoid());
4587+
(void)TTy;
45874588
for (auto &elt : E->getElements()) {
45884589
visit(elt);
45894590
}

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
498498
// Fix up the string parameters to have the right type.
499499
SILType nameArgTy = fnConv.getSILArgumentType(3);
500500
assert(nameArgTy == fnConv.getSILArgumentType(2));
501+
(void)nameArgTy;
501502
auto managedName = ManagedValue::forUnmanaged(optName);
502503
SILValue nilValue;
503504
assert(optName->getType() == nameArgTy);

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
105105
== parent->getParent()->mapTypeIntoContext(
106106
SGF.getSILType(parameterInfo))
107107
&& "argument does not have same type as specified by parameter info");
108+
(void)parameterInfo;
108109

109110
ManagedValue mv = SGF.B.createInputFunctionArgument(
110111
argType, loc.getAsASTNode<ValueDecl>());

lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct AddressCapture {
8181
bool isValid() const { return bool(site); }
8282
};
8383

84+
LLVM_ATTRIBUTE_UNUSED
8485
raw_ostream &operator<<(raw_ostream &os, const AddressCapture &capture) {
8586
os << *capture.site.getInstruction() << " captures Arg #"
8687
<< capture.calleeArgIdx;

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ void SILPassManager::execute() {
516516
SILTransform *Tr = Transformations[Idx];
517517
assert((isa<SILFunctionTransform>(Tr) || isa<SILModuleTransform>(Tr)) &&
518518
"Unexpected pass kind!");
519+
(void)Tr;
519520

520521
unsigned FirstFuncTrans = Idx;
521522
while (Idx < NumTransforms && isa<SILFunctionTransform>(Transformations[Idx]))

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ SILInstruction *PartialApplyCombiner::combine() {
393393
ConvertCalleeTy->getExtInfo().withNoEscape(false));
394394
assert(Use->get()->getType().castTo<SILFunctionType>() ==
395395
EscapingCalleeTy);
396+
(void)EscapingCalleeTy;
396397
Uses.append(CFI->getUses().begin(), CFI->getUses().end());
397398
continue;
398399
}

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ static void createPropertyStoreOrCallSuperclassSetter(AccessorDecl *accessor,
808808
IsImplicit));
809809
}
810810

811+
LLVM_ATTRIBUTE_UNUSED
811812
static bool isSynthesizedComputedProperty(AbstractStorageDecl *storage) {
812813
return (storage->getAttrs().hasAttribute<LazyAttr>() ||
813814
storage->getAttrs().hasAttribute<NSManagedAttr>());

lib/Sema/TypeCheckPattern.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,7 @@ bool TypeChecker::coercePatternToType(Pattern *&P, DeclContext *dc, Type type,
14971497
} else {
14981498
auto parenTy = dyn_cast<ParenType>(elementType.getPointer());
14991499
assert(parenTy && "Associated value type is neither paren nor tuple?");
1500+
(void)parenTy;
15001501

15011502
auto *subPattern = new (Context) AnyPattern(SourceLoc());
15021503
elements.push_back(TuplePatternElt(Identifier(), SourceLoc(),

lib/Serialization/DeserializeSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
14281428
assert(expectedType == getSILType(Ty, (SILValueCategory)TyCategory) &&
14291429
"Type of a global variable does not match GlobalAddr.");
14301430
(void)Ty;
1431+
(void)expectedType;
14311432
if (OpCode == SILInstructionKind::GlobalAddrInst) {
14321433
ResultVal = Builder.createGlobalAddr(Loc, g);
14331434
} else {

lib/Serialization/SerializeSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,7 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) {
24332433
// FIXME: Resilience: could write out vtable for fragile classes.
24342434
const DeclContext *assocDC = SILMod->getAssociatedContext();
24352435
assert(assocDC && "cannot serialize SIL without an associated DeclContext");
2436+
(void)assocDC;
24362437
for (const SILVTable &vt : SILMod->getVTables()) {
24372438
if ((ShouldSerializeAll || vt.isSerialized()) &&
24382439
SILMod->shouldSerializeEntitiesAssociatedWithDeclContext(vt.getClass()))

stdlib/public/runtime/Metadata.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,7 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
33903390
size_t numRequirements =
33913391
protocol->NumRequirements + WitnessTableFirstRequirementOffset;
33923392
assert(numPatternWitnesses <= numRequirements);
3393+
(void)numRequirements;
33933394

33943395
// Number of bytes for any private storage used by the conformance itself.
33953396
size_t privateSizeInWords = genericTable->WitnessTablePrivateSizeInWords;

0 commit comments

Comments
 (0)