Cleanup formatting and linter.

This CL cleans up various formatting and lint errors.

Change-Id: Ieee14db90e36acc8b469d58abb84fcf3595321bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23224
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair
2020-06-16 15:02:50 +00:00
committed by dan sinclair
parent 93e39b451b
commit c7b66da6ad
9 changed files with 142 additions and 116 deletions

View File

@@ -19,6 +19,7 @@
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <vector>
namespace tint {

View File

@@ -896,8 +896,9 @@ bool FunctionEmitter::LabelControlFlowConstructs() {
assert(parent->kind == Construct::kContinue);
parent = parent->parent;
}
constructs_.push_back(std::make_unique<Construct>(
parent, int(depth), k, begin_id, end_id, begin_pos, end_pos));
constructs_.push_back(
std::make_unique<Construct>(parent, static_cast<int>(depth), k,
begin_id, end_id, begin_pos, end_pos));
Construct* result = constructs_.back().get();
enclosing.push_back(result);
return result;
@@ -1433,7 +1434,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
// dominated by its own (different) header.
return Fail() << "Block " << true_head
<< " is the true branch for if-selection header "
<< construct->begin_id << " and also the merge block for header block "
<< construct->begin_id
<< " and also the merge block for header block "
<< true_head_info->header_for_merge
<< " (violates dominance rule)";
}
@@ -1444,7 +1446,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
// dominated by its own (different) header.
return Fail() << "Block " << false_head
<< " is the false branch for if-selection header "
<< construct->begin_id << " and also the merge block for header block "
<< construct->begin_id
<< " and also the merge block for header block "
<< false_head_info->header_for_merge
<< " (violates dominance rule)";
}
@@ -1530,8 +1533,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
// hence the merge block is not dominated by its own (different)
// header.
return Fail()
<< "Block " << premerge_id
<< " is the merge block for " << dest_block_info->header_for_merge
<< "Block " << premerge_id << " is the merge block for "
<< dest_block_info->header_for_merge
<< " but has alternate paths reaching it, starting from"
<< " blocks " << true_head << " and " << false_head
<< " which are the true and false branches for the"
@@ -1697,7 +1700,7 @@ bool FunctionEmitter::EmitBasicBlock(const BlockInfo& block_info) {
// test DISABLED_BlockIsContinueForMoreThanOneHeader. If we generalize this,
// then by a dominance argument, the inner loop continue target can only be
// a single-block loop.
// TODO(dneto): Handle this case.
// TODO(dneto): Handle this case.
// - All that's left is a kContinue and one of kIfSelection, kSwitchSelection,
// kLoop.
//

View File

@@ -18,6 +18,7 @@
#include <functional>
#include <memory>
#include <ostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

View File

@@ -2733,7 +2733,7 @@ TEST_F(SpvParserTest,
TEST_F(
SpvParserTest,
VerifyHeaderContinueMergeOrder_HeaderDoesNotStrictlyDominateContinueTarget) {
VerifyHeaderContinueMergeOrder_HeaderDoesNotStrictlyDominateContinueTarget) { // NOLINT
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@@ -4240,7 +4240,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BranchEscapesIfConstruct) {
FunctionEmitter fe(p, *spirv_function(100));
EXPECT_FALSE(FlowClassifyCFGEdges(&fe)) << p->error();
// Some further processing
EXPECT_THAT(p->error(), Eq("Branch from block 30 to block 80 is an invalid exit from construct starting at block 20; branch bypasses merge block 50"));
EXPECT_THAT(
p->error(),
Eq("Branch from block 30 to block 80 is an invalid exit from construct "
"starting at block 20; branch bypasses merge block 50"));
}
TEST_F(SpvParserTest, ClassifyCFGEdges_ReturnInContinueConstruct) {
@@ -5852,7 +5855,7 @@ TEST_F(SpvParserTest,
TEST_F(
SpvParserTest,
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnOutside_IsError) {
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnOutside_IsError) { // NOLINT
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
// with kBack.
//
@@ -5899,7 +5902,7 @@ TEST_F(
TEST_F(
SpvParserTest,
FindSwitchCaseSelectionHeaders_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsMerge_IsError) {
FindSwitchCaseSelectionHeaders_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsMerge_IsError) { // NOLINT
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
// with kBack.
//
@@ -5938,7 +5941,7 @@ TEST_F(
TEST_F(
SpvParserTest,
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsNotMerge_IsError) {
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsNotMerge_IsError) { // NOLINT
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
// with kBack.
//
@@ -5979,7 +5982,7 @@ TEST_F(
TEST_F(
SpvParserTest,
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_NestedMerge_IsError) {
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_NestedMerge_IsError) { // NOLINT
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
// with kBack.
//
@@ -6416,7 +6419,7 @@ TEST_F(SpvParserTest,
TEST_F(
SpvParserTest,
FindSwitchCaseHeaders_DomViolation_SwitchCase_CantBeMergeForOtherConstruct) {
FindSwitchCaseHeaders_DomViolation_SwitchCase_CantBeMergeForOtherConstruct) { // NOLINT
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@@ -7100,7 +7103,8 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_WithForwardToPremerge) {
EXPECT_THAT(p->error(), Eq(""));
}
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTrueHeader) {
TEST_F(SpvParserTest,
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTrueHeader) {
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@@ -7125,10 +7129,14 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTr
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
FunctionEmitter fe(p, *spirv_function(100));
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
EXPECT_THAT(p->error(), Eq("Block 40 is the true branch for if-selection header 10 and also the merge block for header block 20 (violates dominance rule)"));
EXPECT_THAT(
p->error(),
Eq("Block 40 is the true branch for if-selection header 10 and also the "
"merge block for header block 20 (violates dominance rule)"));
}
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFalseHeader) {
TEST_F(SpvParserTest,
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFalseHeader) {
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@@ -7153,10 +7161,14 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFa
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
FunctionEmitter fe(p, *spirv_function(100));
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
EXPECT_THAT(p->error(), Eq("Block 40 is the false branch for if-selection header 10 and also the merge block for header block 20 (violates dominance rule)"));
EXPECT_THAT(
p->error(),
Eq("Block 40 is the false branch for if-selection header 10 and also the "
"merge block for header block 20 (violates dominance rule)"));
}
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePremerge) {
TEST_F(SpvParserTest,
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePremerge) {
auto assembly = CommonTypes() + R"(
%100 = OpFunction %void None %voidfn
@@ -7187,7 +7199,11 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePr
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
FunctionEmitter fe(p, *spirv_function(100));
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
EXPECT_THAT(p->error(), Eq("Block 70 is the merge block for 50 but has alternate paths reaching it, starting from blocks 20 and 50 which are the true and false branches for the if-selection header block 10 (violates dominance rule)"));
EXPECT_THAT(p->error(),
Eq("Block 70 is the merge block for 50 but has alternate paths "
"reaching it, starting from blocks 20 and 50 which are the "
"true and false branches for the if-selection header block 10 "
"(violates dominance rule)"));
}
TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) {
@@ -12218,7 +12234,7 @@ Return{}
TEST_F(
SpvParserTest,
EmitBody_BranchConditional_Continue_Continue_AfterHeader_Conditional_EmptyContinuing) {
EmitBody_BranchConditional_Continue_Continue_AfterHeader_Conditional_EmptyContinuing) { // NOLINT
// Like the previous tests, but with an empty continuing clause.
auto* p = parser(test::Assemble(CommonTypes() + R"(
%100 = OpFunction %void None %voidfn

View File

@@ -260,7 +260,8 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
Identifier{y}
}
}
})")) << ToString(fe.ast_body());
})"))
<< ToString(fe.ast_body());
}
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {

View File

@@ -52,7 +52,7 @@ namespace spirv {
using Decoration = std::vector<uint32_t>;
using DecorationList = std::vector<Decoration>;
// An AST expression with its type.
/// An AST expression with its type.
struct TypedExpression {
/// Dummy constructor
TypedExpression();