Skip to content

Commit 8e15bdc

Browse files
authored
Fix all Clang-14 warnings (shader-slang#4203)
* fix all Clang-14 warnings * remove a clang-14 warning fix because it is a MSVC warning...
1 parent 52b5bb4 commit 8e15bdc

14 files changed

+25
-21
lines changed

source/slang/slang-capability.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,10 @@ bool CapabilitySet::hasSameTargets(const CapabilitySet& other) const
627627

628628

629629
// MSVC incorrectly throws warning
630+
#if defined(_MSC_VER)
630631
#pragma warning(push)
631632
#pragma warning(disable:4702)
633+
#endif
632634
/// returns true if 'this' is a better target for 'targetCaps' than 'that'
633635
/// isEqual: is `this` and `that` equal
634636
/// isIncompatible: is `this` and `that` incompatible
@@ -743,7 +745,9 @@ bool CapabilitySet::isBetterForTarget(CapabilitySet const& that, CapabilitySet c
743745
}
744746
return true;
745747
}
748+
#if defined(_MSC_VER)
746749
#pragma warning(pop)
750+
#endif
747751

748752
CapabilitySet::AtomSets::Iterator CapabilitySet::getAtomSets() const
749753
{

source/slang/slang-check-conformance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ namespace Slang
272272
sized = true;
273273
}
274274
}
275-
else if (auto intVal = arrayType->getElementCount())
275+
else if (arrayType->getElementCount())
276276
{
277277
sized = true;
278278
typeTag = (TypeTag)((int)typeTag | (int)TypeTag::LinkTimeSized);

source/slang/slang-compiler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,7 @@ namespace Slang
16691669
SLANG_UNEXPECTED("unhandled code generation target");
16701670
break;
16711671
}
1672+
return SLANG_FAIL;
16721673
}
16731674

16741675
void EndToEndCompileRequest::writeArtifactToStandardOutput(IArtifact* artifact, DiagnosticSink* sink)

source/slang/slang-ir-autodiff-unzip.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ struct DiffUnzipPass
372372
}
373373
else
374374
{
375-
if (auto inOutType = as<IRInOutType>(resolvedPrimalFuncType->getParamType(ii)))
375+
if (as<IRInOutType>(resolvedPrimalFuncType->getParamType(ii)))
376376
{
377377
// For 'inout' parameter we need to create a temp var to hold the value
378378
// before the primal call. This logic is similar to the 'inout' case for differentiable params

source/slang/slang-ir-insert-debug-value-store.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace Slang
180180
Index i = 0;
181181
for (; i < accessChain.getCount(); i++)
182182
{
183-
if (auto key = as<IRStructKey>(accessChain[i]))
183+
if (as<IRStructKey>(accessChain[i]))
184184
{
185185
continue;
186186
}

source/slang/slang-ir-lower-buffer-element-type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ namespace Slang
515515
{
516516
// If `type` is already a lowered type, no more lowering is required.
517517
LoweredElementTypeInfo info;
518-
if (auto pInfo = mapLoweredTypeToInfo->tryGetValue(type))
518+
if (mapLoweredTypeToInfo->tryGetValue(type))
519519
{
520520
info.originalType = type;
521521
info.loweredType = type;

source/slang/slang-ir-metal-legalize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Slang
3636
List<IRParam*> paramsToProcess;
3737
for (auto param : func->getParams())
3838
{
39-
if (auto structType = as<IRStructType>(param->getDataType()))
39+
if (as<IRStructType>(param->getDataType()))
4040
{
4141
paramsToProcess.add(param);
4242
}

source/slang/slang-ir-pytorch-cpp-binding.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static IRType* translateToTupleType(
8282
}
8383
return builder.getTargetTupleType((UInt)elementTypes.getCount(), elementTypes.getBuffer());
8484
}
85-
else if (auto targetTupleType = as<IRTargetTupleType>(type))
85+
else if (as<IRTargetTupleType>(type))
8686
{
8787
return type;
8888
}
@@ -192,7 +192,7 @@ static IRInst* makeTargetTuple(IRBuilder& builder, IRInst* val)
192192
auto resultType = builder.getTargetTupleType((UInt)elementTypes.getCount(), elementTypes.getBuffer());
193193
return builder.emitMakeTargetTuple(resultType, (UInt)resultElements.getCount(), resultElements.getBuffer());
194194
}
195-
else if (auto targetTupleType = as<IRTargetTupleType>(type))
195+
else if (as<IRTargetTupleType>(type))
196196
{
197197
return val;
198198
}
@@ -284,7 +284,7 @@ static IRInst* makeValueFromTargetTuple(IRBuilder& builder, IRType* type, IRInst
284284
}
285285
return builder.emitMakeStruct(type, (UInt)resultElements.getCount(), resultElements.getBuffer());
286286
}
287-
else if (auto targetTupleType = as<IRTargetTupleType>(type))
287+
else if (as<IRTargetTupleType>(type))
288288
{
289289
return val;
290290
}
@@ -1021,7 +1021,7 @@ void lowerBuiltinTypesForKernelEntryPoints(IRModule* module, DiagnosticSink*)
10211021
// Rebuild the call/dispatch inst.
10221022
IRInst* newCall = nullptr;
10231023

1024-
if (auto callInst = as<IRCall>(user))
1024+
if (as<IRCall>(user))
10251025
newCall = callBuilder.emitCallInst(user->getFullType(), func, convertedArgs);
10261026
else if (auto dispatchInst = as<IRDispatchKernel>(user))
10271027
newCall = callBuilder.emitDispatchKernelInst(

source/slang/slang-ir-uniformity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace Slang
9797
// will use the fallback behavior (result is non-uniform if any of its arguments are non-uniform).
9898
for (auto block : key.func->getBlocks())
9999
{
100-
if (auto genAsm = as<IRGenericAsm>(block->getTerminator()))
100+
if (as<IRGenericAsm>(block->getTerminator()))
101101
{
102102
return nullptr;
103103
}

source/slang/slang-lower-to-ir.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ void addVarDecorations(
22242224
{
22252225
builder->addSemanticDecoration(inst, hlslSemantic->name.getContent());
22262226
}
2227-
else if (auto dynamicUniform = as<DynamicUniformModifier>(mod))
2227+
else if (as<DynamicUniformModifier>(mod))
22282228
{
22292229
builder->addDynamicUniformDecoration(inst);
22302230
}
@@ -8629,7 +8629,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
86298629
{
86308630
lowerPackOffsetModifier(fieldKey, packOffsetModifier);
86318631
}
8632-
else if (auto dynamicUniformModifer = as<DynamicUniformModifier>(mod))
8632+
else if (as<DynamicUniformModifier>(mod))
86338633
{
86348634
subBuilder->addDynamicUniformDecoration(fieldKey);
86358635
}
@@ -9774,15 +9774,15 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
97749774
{
97759775
getBuilder()->addSimpleDecoration<IRNoInlineDecoration>(irFunc);
97769776
}
9777-
else if (auto derivativeGroupQuadMod = as<DerivativeGroupQuadAttribute>(modifier))
9777+
else if (as<DerivativeGroupQuadAttribute>(modifier))
97789778
{
97799779
derivativeGroupQuadDecor = getBuilder()->addSimpleDecoration<IRDerivativeGroupQuadDecoration>(irFunc);
97809780
}
9781-
else if (auto derivativeGroupLinearMod = as<DerivativeGroupLinearAttribute>(modifier))
9781+
else if (as<DerivativeGroupLinearAttribute>(modifier))
97829782
{
97839783
derivativeGroupLinearDecor = getBuilder()->addSimpleDecoration<IRDerivativeGroupLinearDecoration>(irFunc);
97849784
}
9785-
else if (auto noRefInlineAttribute = as<NoRefInlineAttribute>(modifier))
9785+
else if (as<NoRefInlineAttribute>(modifier))
97869786
{
97879787
getBuilder()->addSimpleDecoration<IRNoRefInlineDecoration>(irFunc);
97889788
}
@@ -9954,7 +9954,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
99549954
getBuilder()->addRequireSPIRVVersionDecoration(irFunc, spvVersion->version);
99559955
else if (auto cudasmVersion = as<RequiredCUDASMVersionModifier>(modifier))
99569956
getBuilder()->addRequireCUDASMVersionDecoration(irFunc, cudasmVersion->version);
9957-
else if (auto nonUniform= as<NonDynamicUniformAttribute>(modifier))
9957+
else if (as<NonDynamicUniformAttribute>(modifier))
99589958
getBuilder()->addDecoration(irFunc, kIROp_NonDynamicUniformReturnDecoration);
99599959
}
99609960

source/slang/slang-parser.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,6 @@ namespace Slang
45364536
parser->pendingModifiers = &modifiers;
45374537

45384538
auto loc = parser->tokenReader.peekLoc();
4539-
auto ptoken = parser->tokenReader.peekToken();
45404539
switch (peekTokenType(parser))
45414540
{
45424541
case TokenType::Identifier:

source/slang/slang-type-layout.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4131,15 +4131,15 @@ static TypeLayoutResult _createTypeLayout(
41314131
type,
41324132
rules);
41334133
}
4134-
else if (auto subpassType = as<SubpassInputType>(type))
4134+
else if (as<SubpassInputType>(type))
41354135
{
41364136
ShaderParameterKind kind = ShaderParameterKind::SubpassInput;
41374137
return createSimpleTypeLayout(
41384138
rules->GetObjectLayout(kind, context.objectLayoutOptions),
41394139
type,
41404140
rules);
41414141
}
4142-
else if (auto atomicType = as<GLSLAtomicUintType>(type))
4142+
else if (as<GLSLAtomicUintType>(type))
41434143
{
41444144
ShaderParameterKind kind = ShaderParameterKind::AtomicUint;
41454145
return createSimpleTypeLayout(

tools/gfx/vulkan/vk-device.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ Result DeviceImpl::createTextureResource(
16781678
break;
16791679
case SLANG_SCALAR_TYPE_UINT32:
16801680
for(int i = 0; i < 4; i++)
1681-
clearColor.uint32[i] = *reinterpret_cast<uint32_t*>(const_cast<void*>(initData->data)); break;
1681+
clearColor.uint32[i] = *reinterpret_cast<uint32_t*>(const_cast<void*>(initData->data));
16821682
break;
16831683
case SLANG_SCALAR_TYPE_INT64:
16841684
{

tools/slang-capability-generator/capability-generator-main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ void outputUIntSetAsBufferValues(const String& nameOfBuffer, StringBuilder& resu
418418
resultBuilder << "const static CapabilityAtomSet " << nameOfBuffer << " = CapabilityAtomSet({\n";
419419
for (auto i : set.getBuffer())
420420
{
421-
resultBuilder << " UIntSet::Element(" << i << "),\n";
421+
resultBuilder << " UIntSet::Element(" << i << "U),\n";
422422
}
423423
resultBuilder << " 0\n});\n";
424424
}

0 commit comments

Comments
 (0)