Use [[fallthrough]] attribute instead of comments.

Now that we require C++17, the [[fallthrough]] attribute is available as
an alternative to load-bearing comments.
This commit is contained in:
Arcady Goldmints-Orlov 2024-02-19 18:42:55 -05:00 committed by arcady-lunarg
parent 8ca24e7cf1
commit 606209e07d
9 changed files with 22 additions and 21 deletions

View file

@ -3052,7 +3052,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpConstructF16Mat4x3:
case glslang::EOpConstructF16Mat4x4:
isMatrix = true;
// fall through
[[fallthrough]];
case glslang::EOpConstructFloat:
case glslang::EOpConstructVec2:
case glslang::EOpConstructVec3:
@ -3223,7 +3223,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpAtomicStore:
noReturnValue = true;
// fallthrough
[[fallthrough]];
case glslang::EOpAtomicLoad:
atomic = true;
break;
@ -3326,7 +3326,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpHitObjectRecordHitWithIndexMotionNV:
case glslang::EOpReorderThreadNV:
noReturnValue = true;
//Fallthrough
[[fallthrough]];
case glslang::EOpHitObjectIsEmptyNV:
case glslang::EOpHitObjectIsMissNV:
case glslang::EOpHitObjectIsHitNV:

View file

@ -360,7 +360,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
switch (stream[word]) {
case 8: idDescriptor[resultId] = "int8_t"; break;
case 16: idDescriptor[resultId] = "int16_t"; break;
default: assert(0); // fallthrough
default: assert(0); [[fallthrough]];
case 32: idDescriptor[resultId] = "int"; break;
case 64: idDescriptor[resultId] = "int64_t"; break;
}
@ -368,7 +368,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
case OpTypeFloat:
switch (stream[word]) {
case 16: idDescriptor[resultId] = "float16_t"; break;
default: assert(0); // fallthrough
default: assert(0); [[fallthrough]];
case 32: idDescriptor[resultId] = "float"; break;
case 64: idDescriptor[resultId] = "float64_t"; break;
}

View file

@ -402,7 +402,7 @@ TIntermTyped* HlslParseContext::handleLvalue(const TSourceLoc& loc, const char*
case EOpLeftShiftAssign:
case EOpRightShiftAssign:
isModifyOp = true;
// fall through...
[[fallthrough]];
case EOpAssign:
{
// Since this is an lvalue, we'll convert an image load to a sequence like this
@ -4507,13 +4507,13 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
int cmpValues = 0; // 1 if there is a compare value (handier than a bool below)
switch (op) {
case EOpMethodGatherCmpRed: cmpValues = 1; // fall through
case EOpMethodGatherCmpRed: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherRed: channel = 0; break;
case EOpMethodGatherCmpGreen: cmpValues = 1; // fall through
case EOpMethodGatherCmpGreen: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherGreen: channel = 1; break;
case EOpMethodGatherCmpBlue: cmpValues = 1; // fall through
case EOpMethodGatherCmpBlue: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherBlue: channel = 2; break;
case EOpMethodGatherCmpAlpha: cmpValues = 1; // fall through
case EOpMethodGatherCmpAlpha: cmpValues = 1; [[fallthrough]];
case EOpMethodGatherAlpha: channel = 3; break;
default: assert(0); break;
}

View file

@ -8126,7 +8126,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("texture2DArrayLod", 1, &E_GL_EXT_texture_array);
symbolTable.setFunctionExtensions("shadow1DArrayLod", 1, &E_GL_EXT_texture_array);
}
// Fall through
[[fallthrough]];
case EShLangTessControl:
if (profile == EEsProfile && version >= 310) {
@ -8141,7 +8141,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_BoundingBox", EbvBoundingBox, symbolTable);
}
}
// Fall through
[[fallthrough]];
case EShLangTessEvaluation:
case EShLangGeometry:
@ -10231,7 +10231,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
if (profile != EEsProfile && version >= 460) {
symbolTable.relateToOperator("fetchMicroTriangleVertexPositionNV", EOpFetchMicroTriangleVertexPositionNV);
symbolTable.relateToOperator("fetchMicroTriangleVertexBarycentricNV", EOpFetchMicroTriangleVertexBarycentricNV);
} // fallthrough
}
[[fallthrough]];
case EShLangClosestHit:
case EShLangMiss:
if (profile != EEsProfile && version >= 460) {

View file

@ -3533,7 +3533,7 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
if (left->getType() == right->getType())
return true;
// Fall through
[[fallthrough]];
case EOpMul:
case EOpMulAssign:
@ -3682,7 +3682,7 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
case EOpAssign:
if (left->getVectorSize() != right->getVectorSize() || left->getMatrixCols() != right->getMatrixCols() || left->getMatrixRows() != right->getMatrixRows())
return false;
// fall through
[[fallthrough]];
case EOpAdd:
case EOpSub:

View file

@ -6260,7 +6260,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
error(loc, "needs a literal integer", "max_primitives", "");
return;
}
// Fall through
[[fallthrough]];
case EShLangTask:
// Fall through
@ -8609,7 +8609,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvPtrToUint64, true, node, type);
return newNode;
}
// fall through
[[fallthrough]];
case EOpConstructU64Vec2:
case EOpConstructU64Vec3:
case EOpConstructU64Vec4:
@ -9674,7 +9674,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
error(loc, "cannot apply to 'out'", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
break;
}
// Fall through
[[fallthrough]];
case ElgPoints:
case ElgLineStrip:
case ElgTriangleStrip:

View file

@ -766,7 +766,7 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
switch (getExtensionBehavior(extensions[i])) {
case EBhWarn:
infoSink.info.message(EPrefixWarning, ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), loc);
// fall through
[[fallthrough]];
case EBhRequire:
case EBhEnable:
okay = true;

View file

@ -1587,7 +1587,7 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
infoSink.debug << "max_vertices = " << vertices << "\n";
infoSink.debug << "max_primitives = " << primitives << "\n";
infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
// Fall through
[[fallthrough]];
case EShLangTask:
// Fall through
case EShLangCompute:

View file

@ -1350,7 +1350,7 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
if (primitives == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_primitives = value)");
// fall through
[[fallthrough]];
case EShLangTask:
if (numTaskNVBlocks > 1)
error(infoSink, "Only one taskNV interface block is allowed per shader");