Skip to content

Commit

Permalink
Fix all Clang-14 warnings (shader-slang#4203)
Browse files Browse the repository at this point in the history
* fix all Clang-14 warnings

* remove a clang-14 warning fix because it is a MSVC warning...
  • Loading branch information
ArielG-NV authored May 22, 2024
1 parent 52b5bb4 commit 8e15bdc
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions source/slang/slang-capability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,10 @@ bool CapabilitySet::hasSameTargets(const CapabilitySet& other) const


// MSVC incorrectly throws warning
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4702)
#endif
/// returns true if 'this' is a better target for 'targetCaps' than 'that'
/// isEqual: is `this` and `that` equal
/// isIncompatible: is `this` and `that` incompatible
Expand Down Expand Up @@ -743,7 +745,9 @@ bool CapabilitySet::isBetterForTarget(CapabilitySet const& that, CapabilitySet c
}
return true;
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

CapabilitySet::AtomSets::Iterator CapabilitySet::getAtomSets() const
{
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-check-conformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace Slang
sized = true;
}
}
else if (auto intVal = arrayType->getElementCount())
else if (arrayType->getElementCount())
{
sized = true;
typeTag = (TypeTag)((int)typeTag | (int)TypeTag::LinkTimeSized);
Expand Down
1 change: 1 addition & 0 deletions source/slang/slang-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@ namespace Slang
SLANG_UNEXPECTED("unhandled code generation target");
break;
}
return SLANG_FAIL;
}

void EndToEndCompileRequest::writeArtifactToStandardOutput(IArtifact* artifact, DiagnosticSink* sink)
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-autodiff-unzip.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ struct DiffUnzipPass
}
else
{
if (auto inOutType = as<IRInOutType>(resolvedPrimalFuncType->getParamType(ii)))
if (as<IRInOutType>(resolvedPrimalFuncType->getParamType(ii)))
{
// For 'inout' parameter we need to create a temp var to hold the value
// before the primal call. This logic is similar to the 'inout' case for differentiable params
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-insert-debug-value-store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Slang
Index i = 0;
for (; i < accessChain.getCount(); i++)
{
if (auto key = as<IRStructKey>(accessChain[i]))
if (as<IRStructKey>(accessChain[i]))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-lower-buffer-element-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace Slang
{
// If `type` is already a lowered type, no more lowering is required.
LoweredElementTypeInfo info;
if (auto pInfo = mapLoweredTypeToInfo->tryGetValue(type))
if (mapLoweredTypeToInfo->tryGetValue(type))
{
info.originalType = type;
info.loweredType = type;
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-metal-legalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Slang
List<IRParam*> paramsToProcess;
for (auto param : func->getParams())
{
if (auto structType = as<IRStructType>(param->getDataType()))
if (as<IRStructType>(param->getDataType()))
{
paramsToProcess.add(param);
}
Expand Down
8 changes: 4 additions & 4 deletions source/slang/slang-ir-pytorch-cpp-binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static IRType* translateToTupleType(
}
return builder.getTargetTupleType((UInt)elementTypes.getCount(), elementTypes.getBuffer());
}
else if (auto targetTupleType = as<IRTargetTupleType>(type))
else if (as<IRTargetTupleType>(type))
{
return type;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ static IRInst* makeTargetTuple(IRBuilder& builder, IRInst* val)
auto resultType = builder.getTargetTupleType((UInt)elementTypes.getCount(), elementTypes.getBuffer());
return builder.emitMakeTargetTuple(resultType, (UInt)resultElements.getCount(), resultElements.getBuffer());
}
else if (auto targetTupleType = as<IRTargetTupleType>(type))
else if (as<IRTargetTupleType>(type))
{
return val;
}
Expand Down Expand Up @@ -284,7 +284,7 @@ static IRInst* makeValueFromTargetTuple(IRBuilder& builder, IRType* type, IRInst
}
return builder.emitMakeStruct(type, (UInt)resultElements.getCount(), resultElements.getBuffer());
}
else if (auto targetTupleType = as<IRTargetTupleType>(type))
else if (as<IRTargetTupleType>(type))
{
return val;
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@ void lowerBuiltinTypesForKernelEntryPoints(IRModule* module, DiagnosticSink*)
// Rebuild the call/dispatch inst.
IRInst* newCall = nullptr;

if (auto callInst = as<IRCall>(user))
if (as<IRCall>(user))
newCall = callBuilder.emitCallInst(user->getFullType(), func, convertedArgs);
else if (auto dispatchInst = as<IRDispatchKernel>(user))
newCall = callBuilder.emitDispatchKernelInst(
Expand Down
2 changes: 1 addition & 1 deletion source/slang/slang-ir-uniformity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Slang
// will use the fallback behavior (result is non-uniform if any of its arguments are non-uniform).
for (auto block : key.func->getBlocks())
{
if (auto genAsm = as<IRGenericAsm>(block->getTerminator()))
if (as<IRGenericAsm>(block->getTerminator()))
{
return nullptr;
}
Expand Down
12 changes: 6 additions & 6 deletions source/slang/slang-lower-to-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ void addVarDecorations(
{
builder->addSemanticDecoration(inst, hlslSemantic->name.getContent());
}
else if (auto dynamicUniform = as<DynamicUniformModifier>(mod))
else if (as<DynamicUniformModifier>(mod))
{
builder->addDynamicUniformDecoration(inst);
}
Expand Down Expand Up @@ -8629,7 +8629,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
lowerPackOffsetModifier(fieldKey, packOffsetModifier);
}
else if (auto dynamicUniformModifer = as<DynamicUniformModifier>(mod))
else if (as<DynamicUniformModifier>(mod))
{
subBuilder->addDynamicUniformDecoration(fieldKey);
}
Expand Down Expand Up @@ -9774,15 +9774,15 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
{
getBuilder()->addSimpleDecoration<IRNoInlineDecoration>(irFunc);
}
else if (auto derivativeGroupQuadMod = as<DerivativeGroupQuadAttribute>(modifier))
else if (as<DerivativeGroupQuadAttribute>(modifier))
{
derivativeGroupQuadDecor = getBuilder()->addSimpleDecoration<IRDerivativeGroupQuadDecoration>(irFunc);
}
else if (auto derivativeGroupLinearMod = as<DerivativeGroupLinearAttribute>(modifier))
else if (as<DerivativeGroupLinearAttribute>(modifier))
{
derivativeGroupLinearDecor = getBuilder()->addSimpleDecoration<IRDerivativeGroupLinearDecoration>(irFunc);
}
else if (auto noRefInlineAttribute = as<NoRefInlineAttribute>(modifier))
else if (as<NoRefInlineAttribute>(modifier))
{
getBuilder()->addSimpleDecoration<IRNoRefInlineDecoration>(irFunc);
}
Expand Down Expand Up @@ -9954,7 +9954,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
getBuilder()->addRequireSPIRVVersionDecoration(irFunc, spvVersion->version);
else if (auto cudasmVersion = as<RequiredCUDASMVersionModifier>(modifier))
getBuilder()->addRequireCUDASMVersionDecoration(irFunc, cudasmVersion->version);
else if (auto nonUniform= as<NonDynamicUniformAttribute>(modifier))
else if (as<NonDynamicUniformAttribute>(modifier))
getBuilder()->addDecoration(irFunc, kIROp_NonDynamicUniformReturnDecoration);
}

Expand Down
1 change: 0 additions & 1 deletion source/slang/slang-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,6 @@ namespace Slang
parser->pendingModifiers = &modifiers;

auto loc = parser->tokenReader.peekLoc();
auto ptoken = parser->tokenReader.peekToken();
switch (peekTokenType(parser))
{
case TokenType::Identifier:
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang-type-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4131,15 +4131,15 @@ static TypeLayoutResult _createTypeLayout(
type,
rules);
}
else if (auto subpassType = as<SubpassInputType>(type))
else if (as<SubpassInputType>(type))
{
ShaderParameterKind kind = ShaderParameterKind::SubpassInput;
return createSimpleTypeLayout(
rules->GetObjectLayout(kind, context.objectLayoutOptions),
type,
rules);
}
else if (auto atomicType = as<GLSLAtomicUintType>(type))
else if (as<GLSLAtomicUintType>(type))
{
ShaderParameterKind kind = ShaderParameterKind::AtomicUint;
return createSimpleTypeLayout(
Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/vulkan/vk-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ Result DeviceImpl::createTextureResource(
break;
case SLANG_SCALAR_TYPE_UINT32:
for(int i = 0; i < 4; i++)
clearColor.uint32[i] = *reinterpret_cast<uint32_t*>(const_cast<void*>(initData->data)); break;
clearColor.uint32[i] = *reinterpret_cast<uint32_t*>(const_cast<void*>(initData->data));
break;
case SLANG_SCALAR_TYPE_INT64:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void outputUIntSetAsBufferValues(const String& nameOfBuffer, StringBuilder& resu
resultBuilder << "const static CapabilityAtomSet " << nameOfBuffer << " = CapabilityAtomSet({\n";
for (auto i : set.getBuffer())
{
resultBuilder << " UIntSet::Element(" << i << "),\n";
resultBuilder << " UIntSet::Element(" << i << "U),\n";
}
resultBuilder << " 0\n});\n";
}
Expand Down

0 comments on commit 8e15bdc

Please sign in to comment.