Skip to content

Suppress a number of warnings in no-assert builds #17721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void ASTMangler::appendDeclName(const ValueDecl *decl) {
assert(((relatedEntityKind[0] >= 'a' && relatedEntityKind[0] <= 'j') ||
(relatedEntityKind[0] >= 'A' && relatedEntityKind[0] <= 'J')) &&
"Only [a-jA-J] are reserved for related entity kinds");
return appendOperatorParam("L", synthesizedTypeAttr->getManglingName());
return appendOperatorParam("L", relatedEntityKind);
}

StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary(decl);
Expand Down
1 change: 1 addition & 0 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ class Verifier : public ASTWalker {
void verifyChecked(DeferStmt *S) {
auto FT = S->getTempDecl()->getInterfaceType()->castTo<AnyFunctionType>();
assert(FT->isNoEscape() && "Defer statements must not escape");
(void)FT;
verifyCheckedBase(S);
}

Expand Down
1 change: 1 addition & 0 deletions lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ TupleExpr *TupleExpr::create(ASTContext &ctx,
assert((Implicit || ElementNames.size() == ElementNameLocs.size() ||
(!hasNonEmptyIdentifier(ElementNames) && ElementNameLocs.empty())) &&
"trying to create non-implicit tuple-expr without name locations");
(void)hasNonEmptyIdentifier;

size_t size =
totalSizeToAlloc<Expr *, Identifier, SourceLoc>(SubExprs.size(),
Expand Down
1 change: 1 addition & 0 deletions lib/Basic/Unix/TaskQueue.inc
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ void TaskMonitor::verifyEvents(const short events) const {
assert((events & POLLNVAL) == 0 && "Asked poll() to watch a closed fd");
const short expectedEvents = POLLIN | POLLPRI | POLLHUP | POLLERR;
assert((events & ~expectedEvents) == 0 && "Received unexpected event");
(void)expectedEvents;
}

void TaskMonitor::readDataIfAvailable(const short events, const int fd,
Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7900,6 +7900,7 @@ recursivelySubstituteBaseType(const NormalProtocolConformance *conformance,

const ProtocolDecl *proto = conformance->getProtocol();
assert(origBase->isEqual(proto->getSelfInterfaceType()));
(void)proto;
return conformance->getTypeWitness(depMemTy->getAssocType(),
/*resolver=*/nullptr);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ sortJobsToMatchCompilationInputs(ArrayRef<const Job *> unsortedJobs,
auto R =
jobsByInput.insert(std::make_pair(IA->getInputArg().getValue(), J));
assert(R.second);
(void)R;
}
for (const InputPair &P : C.getInputFiles()) {
auto I = jobsByInput.find(P.second->getValue());
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/FrontendInputsAndOutputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ void FrontendInputsAndOutputs::setMainAndSupplementaryOutputs(
assert(outputFiles.size() == N && "Must have one main output per primary");
assert(supplementaryOutputs.size() == N &&
"Must have one set of supplementary outputs per primary");
(void)N;

unsigned i = 0;
for (auto &input : AllInputs) {
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ namespace {
auto *dc = fn.getDecl()->getDeclContext();
assert(!isa<ExtensionDecl>(dc));

if (fn.getDecl()->getDeclContext() == getType()) {
if (dc == getType()) {
if (auto entry = VTable->getEntry(IGM.getSILModule(), fn)) {
assert(entry->TheKind == SILVTable::Entry::Kind::Normal);
auto *implFn = IGM.getAddrOfSILFunction(entry->Implementation,
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2614,6 +2614,7 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
return /*finished?*/ false;
});
assert(found && "too many conditional conformances");
(void)found;

sourceKey.Kind =
LocalTypeDataKind::forAbstractProtocolWitnessTable(conformingProto);
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/GenValueWitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,4 +1400,5 @@ void TypeInfo::collectMetadataForOutlining(OutliningMetadataCollector &c,
SILType T) const {
auto canType = T.getASTType();
assert(!canType->is<ArchetypeType>() && "Did not expect an ArchetypeType");
(void)canType;
}
2 changes: 2 additions & 0 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3956,13 +3956,15 @@ void IRGenSILFunction::visitIsEscapingClosureInst(

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

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

Explosion closure = getLoweredExplosion(i->getOperand());
auto func = closure.claimNext();
Expand Down
5 changes: 5 additions & 0 deletions lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ void LargeValueVisitor::visitDeallocInst(DeallocStackInst *instr) {
assert(pass.allocToApplyRetMap.find(opAsInstr) !=
pass.allocToApplyRetMap.end() &&
"Unexpected dealloc instr!");
(void)opAsInstr;
}
}

Expand Down Expand Up @@ -1377,6 +1378,7 @@ void LoadableStorageAllocation::convertApplyResults() {
"Expected SILFunctionType or Optional for the result type");
assert(optionalType.is<SILFunctionType>() &&
"Expected a SILFunctionType inside the optional Type");
(void)optionalType;
}
continue;
}
Expand Down Expand Up @@ -2018,6 +2020,8 @@ static void rewriteFunction(StructLoweringState &pass,
assert(srcType && "Expected an address-type source");
assert(tgtType.isAddress() && "Expected an address-type target");
assert(srcType == tgtType && "Source and target type do not match");
(void)srcType;
(void)tgtType;

SILBuilderWithScope copyBuilder(instr);
createOutlinedCopyCall(copyBuilder, src, tgt, pass);
Expand Down Expand Up @@ -2406,6 +2410,7 @@ void LoadableByAddress::recreateSingleApply(SILInstruction *applyInst) {
assert(oldYields.size() == newYields.size() &&
oldYields.size() == oldYieldedValues.size() &&
newYields.size() == newYieldedValues.size());
(void)newYields;
for (auto i : indices(oldYields)) {
SILValue oldValue = oldYieldedValues[i];
SILValue newValue = newYieldedValues[i];
Expand Down
1 change: 1 addition & 0 deletions lib/ParseSIL/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ void SILParser::convertRequirements(SILFunction *F,

auto *GenericEnv = F->getGenericEnvironment();
assert(GenericEnv);
(void)GenericEnv;

IdentTypeReprLookup PerformLookup(P);
// Use parser lexical scopes to resolve references
Expand Down
1 change: 1 addition & 0 deletions lib/SIL/InstructionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ SILValue swift::isPartialApplyOfReabstractionThunk(PartialApplyInst *PAI) {
static SILValue findClosureStoredIntoBlock(SILValue V) {
auto FnType = V->getType().castTo<SILFunctionType>();
assert(FnType->getRepresentation() == SILFunctionTypeRepresentation::Block);
(void)FnType;

// Given a no escape block argument to a function,
// pattern match to find the noescape closure that invoking the block
Expand Down
1 change: 1 addition & 0 deletions lib/SIL/SILCoverageMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SILCoverageMap::create(SILModule &M, StringRef Filename, StringRef Name,

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

return CM;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SIL/SILFunctionType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,7 @@ const SILConstantInfo &TypeConverter::getConstantInfo(SILDeclRef constant) {

auto inserted = ConstantTypes.insert({constant, result});
assert(inserted.second);
(void)inserted;
return *result;
}

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

auto inserted = ConstantOverrideTypes.insert({{derived, base}, result});
assert(inserted.second);
(void)inserted;
return *result;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/SIL/SILOwnershipVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static bool isGuaranteedForwardingInst(SILInstruction *I) {
return isGuaranteedForwardingValueKind(SILNodeKind(I->getKind()));
}

LLVM_ATTRIBUTE_UNUSED
static bool isOwnershipForwardingInst(SILInstruction *I) {
return isOwnershipForwardingValueKind(SILNodeKind(I->getKind()));
}
Expand All @@ -154,7 +155,9 @@ class OwnershipCompatibilityUseChecker
OwnershipUseCheckerResult> {
public:
private:
LLVM_ATTRIBUTE_UNUSED
SILModule &Mod;

const Operand &Op;
SILValue BaseValue;
ErrorBehaviorKind ErrorBehavior;
Expand Down
1 change: 1 addition & 0 deletions lib/SIL/SILProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ bool doesASTRequireProfiling(SILModule &M, ASTNode N) {
} // namespace swift

/// Check that the input AST has at least been type-checked.
LLVM_ATTRIBUTE_UNUSED
static bool hasASTBeenTypeChecked(ASTNode N) {
DeclContext *DC = N.getAsDeclContext();
assert(DC && "Invalid AST node for profiling");
Expand Down
2 changes: 2 additions & 0 deletions lib/SIL/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4984,6 +4984,8 @@ void SILWitnessTable::verify(const SILModule &M) const {
"Witnesses must either have a concrete Self, or an "
"an abstract Self that is constrained to their "
"protocol.");
(void)protocol;
(void)witnessSelfProtocol;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3857,6 +3857,7 @@ CallEmission::applyEnumElementConstructor(SGFContext C) {
}

assert(substFnType->getNumResults() == 1);
(void)substFnType;
ManagedValue resultMV = SGF.emitInjectEnum(
uncurriedLoc, std::move(payload), SGF.getLoweredType(formalResultType),
element, uncurriedContext);
Expand Down Expand Up @@ -5198,6 +5199,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
auto subscriptsTupleType = cast<TupleType>(subscripts.getType());
assert(accessType.getParams().size()
== 1 + subscriptsTupleType->getNumElements());
(void)subscriptsTupleType;
SmallVector<RValue, 8> eltRVs;
std::move(subscripts).extractElements(eltRVs);
for (auto &elt : eltRVs)
Expand Down
2 changes: 2 additions & 0 deletions lib/SILGen/SILGenBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ ManagedValue SILGenBuilder::createConvertEscapeToNoEscape(
SILFunctionTypeRepresentation::Thick &&
!fnType->isNoEscape() && resultFnType->isNoEscape() &&
"Expect a escaping to noescape conversion");
(void)fnType;
(void)resultFnType;
SILValue fnValue = fn.getValue();
SILValue result = createConvertEscapeToNoEscape(
loc, fnValue, resultTy, isEscapedByUser, false);
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ static ManagedValue emitBuiltinValueToBridgeObject(SILGenFunction &SGF,
"ValueToBridgeObject should have one sub");
auto &fromTL = SGF.getTypeLowering(subs.getReplacementTypes()[0]);
assert(fromTL.isTrivial() && "Expected a trivial type");
(void)fromTL;

SILValue result = SGF.B.createValueToBridgeObject(loc, args[0].getValue());
return SGF.emitManagedRetain(loc, result);
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,6 +4765,7 @@ namespace {
void visitTupleExpr(TupleExpr *E) {
auto *TTy = E->getType()->castTo<TupleType>();
assert(TTy->hasLValueType() || TTy->isVoid());
(void)TTy;
for (auto &elt : E->getElements()) {
visit(elt);
}
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
// Fix up the string parameters to have the right type.
SILType nameArgTy = fnConv.getSILArgumentType(3);
assert(nameArgTy == fnConv.getSILArgumentType(2));
(void)nameArgTy;
auto managedName = ManagedValue::forUnmanaged(optName);
SILValue nilValue;
assert(optName->getType() == nameArgTy);
Expand Down
1 change: 1 addition & 0 deletions lib/SILGen/SILGenProlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
== parent->getParent()->mapTypeIntoContext(
SGF.getSILType(parameterInfo))
&& "argument does not have same type as specified by parameter info");
(void)parameterInfo;

ManagedValue mv = SGF.B.createInputFunctionArgument(
argType, loc.getAsASTNode<ValueDecl>());
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct AddressCapture {
bool isValid() const { return bool(site); }
};

LLVM_ATTRIBUTE_UNUSED
raw_ostream &operator<<(raw_ostream &os, const AddressCapture &capture) {
os << *capture.site.getInstruction() << " captures Arg #"
<< capture.calleeArgIdx;
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/PassManager/PassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ void SILPassManager::execute() {
SILTransform *Tr = Transformations[Idx];
assert((isa<SILFunctionTransform>(Tr) || isa<SILModuleTransform>(Tr)) &&
"Unexpected pass kind!");
(void)Tr;

unsigned FirstFuncTrans = Idx;
while (Idx < NumTransforms && isa<SILFunctionTransform>(Transformations[Idx]))
Expand Down
1 change: 1 addition & 0 deletions lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ SILInstruction *PartialApplyCombiner::combine() {
ConvertCalleeTy->getExtInfo().withNoEscape(false));
assert(Use->get()->getType().castTo<SILFunctionType>() ==
EscapingCalleeTy);
(void)EscapingCalleeTy;
Uses.append(CFI->getUses().begin(), CFI->getUses().end());
continue;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CodeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ static void createPropertyStoreOrCallSuperclassSetter(AccessorDecl *accessor,
IsImplicit));
}

LLVM_ATTRIBUTE_UNUSED
static bool isSynthesizedComputedProperty(AbstractStorageDecl *storage) {
return (storage->getAttrs().hasAttribute<LazyAttr>() ||
storage->getAttrs().hasAttribute<NSManagedAttr>());
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/TypeCheckPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ bool TypeChecker::coercePatternToType(Pattern *&P, DeclContext *dc, Type type,
} else {
auto parenTy = dyn_cast<ParenType>(elementType.getPointer());
assert(parenTy && "Associated value type is neither paren nor tuple?");
(void)parenTy;

auto *subPattern = new (Context) AnyPattern(SourceLoc());
elements.push_back(TuplePatternElt(Identifier(), SourceLoc(),
Expand Down
1 change: 1 addition & 0 deletions lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
assert(expectedType == getSILType(Ty, (SILValueCategory)TyCategory) &&
"Type of a global variable does not match GlobalAddr.");
(void)Ty;
(void)expectedType;
if (OpCode == SILInstructionKind::GlobalAddrInst) {
ResultVal = Builder.createGlobalAddr(Loc, g);
} else {
Expand Down
1 change: 1 addition & 0 deletions lib/Serialization/SerializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,7 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) {
// FIXME: Resilience: could write out vtable for fragile classes.
const DeclContext *assocDC = SILMod->getAssociatedContext();
assert(assocDC && "cannot serialize SIL without an associated DeclContext");
(void)assocDC;
for (const SILVTable &vt : SILMod->getVTables()) {
if ((ShouldSerializeAll || vt.isSerialized()) &&
SILMod->shouldSerializeEntitiesAssociatedWithDeclContext(vt.getClass()))
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3390,6 +3390,7 @@ WitnessTableCacheEntry::allocate(GenericWitnessTable *genericTable,
size_t numRequirements =
protocol->NumRequirements + WitnessTableFirstRequirementOffset;
assert(numPatternWitnesses <= numRequirements);
(void)numRequirements;

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