From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- source/slang/slang-ir-operator-shift-overflow.cpp | 64 +++++++++++++---------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'source/slang/slang-ir-operator-shift-overflow.cpp') diff --git a/source/slang/slang-ir-operator-shift-overflow.cpp b/source/slang/slang-ir-operator-shift-overflow.cpp index 5f829f05a..8a19da3d0 100644 --- a/source/slang/slang-ir-operator-shift-overflow.cpp +++ b/source/slang/slang-ir-operator-shift-overflow.cpp @@ -1,30 +1,31 @@ // slang-ir-operator-shift-overflow.cpp #include "slang-ir-operator-shift-overflow.h" -#include "slang.h" -#include "slang-ir.h" #include "slang-ir-insts.h" #include "slang-ir-layout.h" +#include "slang-ir.h" +#include "slang.h" -namespace Slang { +namespace Slang +{ - class DiagnosticSink; - struct IRModule; +class DiagnosticSink; +struct IRModule; - void checkForOperatorShiftOverflowRecursive( - IRInst* inst, - CompilerOptionSet& optionSet, - DiagnosticSink* sink) +void checkForOperatorShiftOverflowRecursive( + IRInst* inst, + CompilerOptionSet& optionSet, + DiagnosticSink* sink) +{ + if (auto code = as(inst)) { - if (auto code = as(inst)) + for (auto block : code->getBlocks()) { - for (auto block : code->getBlocks()) + for (auto opInst : block->getChildren()) { - for (auto opInst : block->getChildren()) + switch (opInst->getOp()) { - switch (opInst->getOp()) - { - case kIROp_Lsh: + case kIROp_Lsh: { SLANG_ASSERT(opInst->getOperandCount() == 2); @@ -37,34 +38,39 @@ namespace Slang { IRType* lhsType = lhs->getDataType(); IRSizeAndAlignment sizeAlignment; - if (SLANG_FAILED(getNaturalSizeAndAlignment(optionSet, lhsType, &sizeAlignment))) + if (SLANG_FAILED( + getNaturalSizeAndAlignment(optionSet, lhsType, &sizeAlignment))) continue; IRIntegerValue shiftAmount = rhsLit->getValue(); if (sizeAlignment.size * 8 <= shiftAmount) { - sink->diagnose(opInst, Diagnostics::operatorShiftLeftOverflow, lhsType, shiftAmount); + sink->diagnose( + opInst, + Diagnostics::operatorShiftLeftOverflow, + lhsType, + shiftAmount); } break; } - } } } } - - for (auto childInst : inst->getChildren()) - { - checkForOperatorShiftOverflowRecursive(childInst, optionSet, sink); - } } - void checkForOperatorShiftOverflow( - IRModule* module, - CompilerOptionSet& optionSet, - DiagnosticSink* sink) + for (auto childInst : inst->getChildren()) { - // Look for `operator<<` instructions - checkForOperatorShiftOverflowRecursive(module->getModuleInst(), optionSet, sink); + checkForOperatorShiftOverflowRecursive(childInst, optionSet, sink); } +} +void checkForOperatorShiftOverflow( + IRModule* module, + CompilerOptionSet& optionSet, + DiagnosticSink* sink) +{ + // Look for `operator<<` instructions + checkForOperatorShiftOverflowRecursive(module->getModuleInst(), optionSet, sink); } + +} // namespace Slang -- cgit v1.2.3