Skip to content

Commit 692529b

Browse files
authored
[NFC] Apply small clang-tidy fixes (#5709)
* [NFC] Apply small clang-tidy fixes - const for passed-by-value has no effect on prototypes. - transitive includes. - dead stores - uses after move Signed-off-by: Nathan Gauër <brioche@google.com> * pr-feedback Signed-off-by: Nathan Gauër <brioche@google.com> --------- Signed-off-by: Nathan Gauër <brioche@google.com>
1 parent 707da36 commit 692529b

11 files changed

Lines changed: 20 additions & 14 deletions

source/disassemble.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
#include <cassert>
2424
#include <cstring>
2525
#include <iomanip>
26+
#include <ios>
2627
#include <memory>
2728
#include <set>
29+
#include <sstream>
2830
#include <stack>
2931
#include <unordered_map>
3032
#include <utility>

source/disassemble.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef SOURCE_DISASSEMBLE_H_
1616
#define SOURCE_DISASSEMBLE_H_
1717

18-
#include <iosfwd>
18+
#include <ios>
1919
#include <sstream>
2020
#include <string>
2121

@@ -94,11 +94,11 @@ class InstructionDisassembler {
9494
// Emits an operand for the given instruction, where the instruction
9595
// is at offset words from the start of the binary.
9696
void EmitOperand(std::ostream& stream, const spv_parsed_instruction_t& inst,
97-
const uint16_t operand_index) const;
97+
uint16_t operand_index) const;
9898

9999
// Emits a mask expression for the given mask word of the specified type.
100-
void EmitMaskOperand(std::ostream& stream, const spv_operand_type_t type,
101-
const uint32_t word) const;
100+
void EmitMaskOperand(std::ostream& stream, spv_operand_type_t type,
101+
uint32_t word) const;
102102

103103
// Generate part of the instruction as a comment to be added to
104104
// |id_comments_|.

source/opt/folding_rules.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,7 @@ bool CompositeExtractFeedingConstruct(
17901790
return false;
17911791
}
17921792
}
1793+
assert(first_element_inst != nullptr);
17931794

17941795
// The last check it to see that the object being extracted from is the
17951796
// correct type.

source/opt/loop_fission.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ Pass::Status LoopFissionPass::Process() {
499499
// next iteration.
500500
if (split_multiple_times_) {
501501
inner_most_loops = std::move(new_loops_to_split);
502+
new_loops_to_split = {};
502503
} else {
503504
break;
504505
}

source/val/validate_decorations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ uint32_t getBaseAlignment(uint32_t member_id, bool roundUp,
169169
case spv::Op::OpTypeSampler:
170170
case spv::Op::OpTypeImage:
171171
if (vstate.HasCapability(spv::Capability::BindlessTextureNV))
172-
return baseAlignment = vstate.samplerimage_variable_address_mode() / 8;
172+
return vstate.samplerimage_variable_address_mode() / 8;
173173
assert(0);
174174
return 0;
175175
case spv::Op::OpTypeInt:

source/val/validate_function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _,
283283
function_type->GetOperandAs<uint32_t>(param_index);
284284
const auto parameter_type = _.FindDef(parameter_type_id);
285285
if (!parameter_type || argument_type->id() != parameter_type->id()) {
286-
if (!_.options()->before_hlsl_legalization ||
286+
if (!parameter_type || !_.options()->before_hlsl_legalization ||
287287
!DoPointeesLogicallyMatch(argument_type, parameter_type, _)) {
288288
return _.diag(SPV_ERROR_INVALID_ID, inst)
289289
<< "OpFunctionCall Argument <id> " << _.getIdName(argument_id)

source/val/validate_non_uniform.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,8 @@ spv_result_t ValidateGroupNonUniformRotateKHR(ValidationState_t& _,
390390
if (inst->words().size() > 6) {
391391
const uint32_t cluster_size_op_id = inst->GetOperandAs<uint32_t>(5);
392392
const Instruction* cluster_size_inst = _.FindDef(cluster_size_op_id);
393-
const uint32_t cluster_size_type =
394-
cluster_size_inst ? cluster_size_inst->type_id() : 0;
395-
if (!_.IsUnsignedIntScalarType(cluster_size_type)) {
393+
if (!cluster_size_inst ||
394+
!_.IsUnsignedIntScalarType(cluster_size_inst->type_id())) {
396395
return _.diag(SPV_ERROR_INVALID_DATA, inst)
397396
<< "ClusterSize must be a scalar of integer type, whose "
398397
"Signedness operand is 0.";

test/enum_set_test.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,6 @@ TEST_P(CapabilitySetForEachTest, MoveConstructor) {
846846
CapabilitySet copy(GetParam().capabilities);
847847
CapabilitySet moved(std::move(copy));
848848
EXPECT_THAT(ElementsIn(moved), Eq(GetParam().expected));
849-
850-
// The moved-from set is empty.
851-
EXPECT_THAT(ElementsIn(copy), Eq(std::vector<spv::Capability>{}));
852849
}
853850

854851
TEST_P(CapabilitySetForEachTest, OperatorEquals) {
@@ -858,7 +855,7 @@ TEST_P(CapabilitySetForEachTest, OperatorEquals) {
858855

859856
TEST_P(CapabilitySetForEachTest, OperatorEqualsSelfAssign) {
860857
CapabilitySet assigned{GetParam().capabilities};
861-
assigned = assigned;
858+
assigned = assigned; // NOLINT
862859
EXPECT_THAT(ElementsIn(assigned), Eq(GetParam().expected));
863860
}
864861

test/opt/ir_context_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ TEST_F(IRContextTest, AsanErrorTest) {
871871
opt::Function* fun =
872872
context->cfg()->block(5)->GetParent(); // Computes the CFG analysis
873873
opt::DominatorAnalysis* dom = nullptr;
874+
// NOLINTNEXTLINE
874875
dom = context->GetDominatorAnalysis(fun); // Computes the dominator analysis,
875876
// which depends on the CFG
876877
// analysis

test/opt/propagator_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ TEST_F(PropagatorTest, PropagateThroughPhis) {
184184
}
185185
} else if (instr->opcode() == spv::Op::OpPhi) {
186186
phi_instr = instr;
187-
SSAPropagator::PropStatus retval;
187+
SSAPropagator::PropStatus retval = SSAPropagator::kNotInteresting;
188188
for (uint32_t i = 2; i < instr->NumOperands(); i += 2) {
189189
uint32_t phi_arg_id = instr->GetSingleWordOperand(i);
190190
auto it = values_.find(phi_arg_id);

0 commit comments

Comments
 (0)