mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 11:40:05 +00:00
Fix readbility/braces warnings (#1804)
This commit is contained in:
parent
eda2cfbe12
commit
9991d661f8
@ -20,7 +20,6 @@ for more details about the presubmit API built into depot_tools.
|
|||||||
|
|
||||||
LINT_FILTERS = [
|
LINT_FILTERS = [
|
||||||
"-build/storage_class",
|
"-build/storage_class",
|
||||||
"-readability/braces",
|
|
||||||
"-readability/casting",
|
"-readability/casting",
|
||||||
"-readability/fn_size",
|
"-readability/fn_size",
|
||||||
"-readability/inheritance",
|
"-readability/inheritance",
|
||||||
|
@ -765,7 +765,7 @@ class MarkvDecoder : public MarkvCodecBase {
|
|||||||
const bool result = reader_.ReadBits(&bits, 1);
|
const bool result = reader_.ReadBits(&bits, 1);
|
||||||
if (result) *bit = bits ? true : false;
|
if (result) *bit = bits ? true : false;
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Returns ReadBit bound to the class object.
|
// Returns ReadBit bound to the class object.
|
||||||
std::function<bool(bool*)> GetReadBitCallback() {
|
std::function<bool(bool*)> GetReadBitCallback() {
|
||||||
|
@ -284,7 +284,7 @@ bool CommonUniformElimPass::UniformAccessChainConvert(Function* func) {
|
|||||||
inst = ReplaceAndDeleteLoad(inst, replId, ptrInst);
|
inst = ReplaceAndDeleteLoad(inst, replId, ptrInst);
|
||||||
inst = inst->InsertBefore(std::move(newInsts));
|
inst = inst->InsertBefore(std::move(newInsts));
|
||||||
modified = true;
|
modified = true;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ class Constant {
|
|||||||
int64_t GetS64() const;
|
int64_t GetS64() const;
|
||||||
|
|
||||||
// Returns true if the constant is a zero or a composite containing 0s.
|
// Returns true if the constant is a zero or a composite containing 0s.
|
||||||
virtual bool IsZero() const { return false; };
|
virtual bool IsZero() const { return false; }
|
||||||
|
|
||||||
const Type* type() const { return type_; }
|
const Type* type() const { return type_; }
|
||||||
|
|
||||||
@ -481,10 +481,11 @@ struct ConstantEqual {
|
|||||||
const auto& composite2 = c2->AsCompositeConstant();
|
const auto& composite2 = c2->AsCompositeConstant();
|
||||||
return composite2 &&
|
return composite2 &&
|
||||||
composite1->GetComponents() == composite2->GetComponents();
|
composite1->GetComponents() == composite2->GetComponents();
|
||||||
} else if (c1->AsNullConstant())
|
} else if (c1->AsNullConstant()) {
|
||||||
return c2->AsNullConstant() != nullptr;
|
return c2->AsNullConstant() != nullptr;
|
||||||
else
|
} else {
|
||||||
assert(false && "Tried to compare two invalid Constant instances.");
|
assert(false && "Tried to compare two invalid Constant instances.");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -278,8 +278,9 @@ DominatorTreeNode* DominatorTree::GetOrInsertNode(BasicBlock* bb) {
|
|||||||
if (node_iter == nodes_.end()) {
|
if (node_iter == nodes_.end()) {
|
||||||
dtn = &nodes_.emplace(std::make_pair(bb->id(), DominatorTreeNode{bb}))
|
dtn = &nodes_.emplace(std::make_pair(bb->id(), DominatorTreeNode{bb}))
|
||||||
.first->second;
|
.first->second;
|
||||||
} else
|
} else {
|
||||||
dtn = &node_iter->second;
|
dtn = &node_iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
return dtn;
|
return dtn;
|
||||||
}
|
}
|
||||||
|
@ -302,9 +302,9 @@ bool IsValidTypeForComponentWiseOperation(const analysis::Type* type) {
|
|||||||
} else if (auto* it = type->AsInteger()) {
|
} else if (auto* it = type->AsInteger()) {
|
||||||
if (it->width() == 32) return true;
|
if (it->width() == 32) return true;
|
||||||
} else if (auto* vt = type->AsVector()) {
|
} else if (auto* vt = type->AsVector()) {
|
||||||
if (vt->element_type()->AsBool())
|
if (vt->element_type()->AsBool()) {
|
||||||
return true;
|
return true;
|
||||||
else if (auto* vit = vt->element_type()->AsInteger()) {
|
} else if (auto* vit = vt->element_type()->AsInteger()) {
|
||||||
if (vit->width() == 32) return true;
|
if (vit->width() == 32) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ bool IRContext::ReplaceAllUsesWith(uint32_t before, uint32_t after) {
|
|||||||
user->SetInOperand(in_operand_pos, {after});
|
user->SetInOperand(in_operand_pos, {after});
|
||||||
}
|
}
|
||||||
AnalyzeUses(user);
|
AnalyzeUses(user);
|
||||||
};
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ class IRContext {
|
|||||||
BuildDecorationManager();
|
BuildDecorationManager();
|
||||||
}
|
}
|
||||||
return decoration_mgr_.get();
|
return decoration_mgr_.get();
|
||||||
};
|
}
|
||||||
|
|
||||||
// Returns a pointer to the constant manager. If no constant manager has been
|
// Returns a pointer to the constant manager. If no constant manager has been
|
||||||
// created yet, it creates one. NOTE: Once created, the constant manager
|
// created yet, it creates one. NOTE: Once created, the constant manager
|
||||||
|
@ -731,8 +731,10 @@ class LoopUnswitch {
|
|||||||
context_->KillInst(merge);
|
context_->KillInst(merge);
|
||||||
}
|
}
|
||||||
dead_loops[loop] = loop->GetParent();
|
dead_loops[loop] = loop->GetParent();
|
||||||
} else
|
} else {
|
||||||
dead_loops[loop] = loop;
|
dead_loops[loop] = loop;
|
||||||
|
}
|
||||||
|
|
||||||
// For each loop, check if we killed it. If we did, find a suitable parent
|
// For each loop, check if we killed it. If we did, find a suitable parent
|
||||||
// for its children.
|
// for its children.
|
||||||
for (Loop& sub_loop :
|
for (Loop& sub_loop :
|
||||||
|
@ -107,9 +107,9 @@ spv_result_t getWord(spv_text text, spv_position position, std::string* word) {
|
|||||||
return SPV_SUCCESS;
|
return SPV_SUCCESS;
|
||||||
}
|
}
|
||||||
const char ch = text->str[position->index];
|
const char ch = text->str[position->index];
|
||||||
if (ch == '\\')
|
if (ch == '\\') {
|
||||||
escaping = !escaping;
|
escaping = !escaping;
|
||||||
else {
|
} else {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '"':
|
case '"':
|
||||||
if (!escaping) quoting = !quoting;
|
if (!escaping) quoting = !quoting;
|
||||||
|
@ -118,7 +118,7 @@ bool IsImplicitLod(SpvOp opcode) {
|
|||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ bool IsExplicitLod(SpvOp opcode) {
|
|||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ bool IsProj(SpvOp opcode) {
|
|||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
|||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image Operands Offset, ConstOffset, ConstOffsets cannot be used "
|
<< "Image Operands Offset, ConstOffset, ConstOffsets cannot be used "
|
||||||
<< "together";
|
<< "together";
|
||||||
};
|
}
|
||||||
|
|
||||||
const bool is_implicit_lod = IsImplicitLod(opcode);
|
const bool is_implicit_lod = IsImplicitLod(opcode);
|
||||||
const bool is_explicit_lod = IsExplicitLod(opcode);
|
const bool is_explicit_lod = IsExplicitLod(opcode);
|
||||||
@ -238,7 +238,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
|||||||
if (!is_implicit_lod) {
|
if (!is_implicit_lod) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image Operand Bias can only be used with ImplicitLod opcodes";
|
<< "Image Operand Bias can only be used with ImplicitLod opcodes";
|
||||||
};
|
}
|
||||||
|
|
||||||
const uint32_t type_id = _.GetTypeId(inst->word(word_index++));
|
const uint32_t type_id = _.GetTypeId(inst->word(word_index++));
|
||||||
if (!_.IsFloatScalarType(type_id)) {
|
if (!_.IsFloatScalarType(type_id)) {
|
||||||
@ -265,7 +265,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
|||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image Operand Lod can only be used with ExplicitLod opcodes "
|
<< "Image Operand Lod can only be used with ExplicitLod opcodes "
|
||||||
<< "and OpImageFetch";
|
<< "and OpImageFetch";
|
||||||
};
|
}
|
||||||
|
|
||||||
if (mask & SpvImageOperandsGradMask) {
|
if (mask & SpvImageOperandsGradMask) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
@ -305,7 +305,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
|||||||
if (!is_explicit_lod) {
|
if (!is_explicit_lod) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image Operand Grad can only be used with ExplicitLod opcodes";
|
<< "Image Operand Grad can only be used with ExplicitLod opcodes";
|
||||||
};
|
}
|
||||||
|
|
||||||
const uint32_t dx_type_id = _.GetTypeId(inst->word(word_index++));
|
const uint32_t dx_type_id = _.GetTypeId(inst->word(word_index++));
|
||||||
const uint32_t dy_type_id = _.GetTypeId(inst->word(word_index++));
|
const uint32_t dy_type_id = _.GetTypeId(inst->word(word_index++));
|
||||||
@ -465,7 +465,7 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
|||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image Operand MinLod can only be used with ImplicitLod "
|
<< "Image Operand MinLod can only be used with ImplicitLod "
|
||||||
<< "opcodes or together with Image Operand Grad";
|
<< "opcodes or together with Image Operand Grad";
|
||||||
};
|
}
|
||||||
|
|
||||||
const uint32_t type_id = _.GetTypeId(inst->word(word_index++));
|
const uint32_t type_id = _.GetTypeId(inst->word(word_index++));
|
||||||
if (!_.IsFloatScalarType(type_id)) {
|
if (!_.IsFloatScalarType(type_id)) {
|
||||||
@ -1281,7 +1281,7 @@ spv_result_t ValidateImageQuerySizeLod(ValidationState_t& _,
|
|||||||
default:
|
default:
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image 'Dim' must be 1D, 2D, 3D or Cube";
|
<< "Image 'Dim' must be 1D, 2D, 3D or Cube";
|
||||||
};
|
}
|
||||||
|
|
||||||
if (info.multisampled != 0) {
|
if (info.multisampled != 0) {
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Image 'MS' must be 0";
|
return _.diag(SPV_ERROR_INVALID_DATA, inst) << "Image 'MS' must be 0";
|
||||||
@ -1352,7 +1352,7 @@ spv_result_t ValidateImageQuerySize(ValidationState_t& _,
|
|||||||
default:
|
default:
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Image 'Dim' must be Buffer, 2D, 3D or Rect";
|
<< "Image 'Dim' must be Buffer, 2D, 3D or Rect";
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
if (info.multisampled != 0) {
|
if (info.multisampled != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user