mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
Add InsertBraces: true to .clang-format
Bug: none Change-Id: I4b4f2a4abfea7adcea406f458bc4e4a13b0e8c43 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91000 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: dan sinclair <dsinclair@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
@@ -125,30 +125,36 @@ Format parse_format(const std::string& fmt) {
|
||||
(void)fmt;
|
||||
|
||||
#if TINT_BUILD_SPV_WRITER
|
||||
if (fmt == "spirv")
|
||||
if (fmt == "spirv") {
|
||||
return Format::kSpirv;
|
||||
if (fmt == "spvasm")
|
||||
}
|
||||
if (fmt == "spvasm") {
|
||||
return Format::kSpvAsm;
|
||||
}
|
||||
#endif // TINT_BUILD_SPV_WRITER
|
||||
|
||||
#if TINT_BUILD_WGSL_WRITER
|
||||
if (fmt == "wgsl")
|
||||
if (fmt == "wgsl") {
|
||||
return Format::kWgsl;
|
||||
}
|
||||
#endif // TINT_BUILD_WGSL_WRITER
|
||||
|
||||
#if TINT_BUILD_MSL_WRITER
|
||||
if (fmt == "msl")
|
||||
if (fmt == "msl") {
|
||||
return Format::kMsl;
|
||||
}
|
||||
#endif // TINT_BUILD_MSL_WRITER
|
||||
|
||||
#if TINT_BUILD_HLSL_WRITER
|
||||
if (fmt == "hlsl")
|
||||
if (fmt == "hlsl") {
|
||||
return Format::kHlsl;
|
||||
}
|
||||
#endif // TINT_BUILD_HLSL_WRITER
|
||||
|
||||
#if TINT_BUILD_GLSL_WRITER
|
||||
if (fmt == "glsl")
|
||||
if (fmt == "glsl") {
|
||||
return Format::kGlsl;
|
||||
}
|
||||
#endif // TINT_BUILD_GLSL_WRITER
|
||||
|
||||
return Format::kNone;
|
||||
|
||||
@@ -602,10 +602,12 @@ class StructuredTraverser {
|
||||
// header, we will visit its merge block, then its continue target (if any).
|
||||
// Also records the post order ordering.
|
||||
void VisitBackward(uint32_t id) {
|
||||
if (id == 0)
|
||||
if (id == 0) {
|
||||
return;
|
||||
if (visited_.count(id))
|
||||
}
|
||||
if (visited_.count(id)) {
|
||||
return;
|
||||
}
|
||||
visited_.insert(id);
|
||||
|
||||
const spvtools::opt::BasicBlock* bb = id_to_block_[id]; // non-null for valid modules
|
||||
@@ -1600,8 +1602,9 @@ bool FunctionEmitter::RegisterMerges() {
|
||||
bool is_single_block_loop = false;
|
||||
block_info->basic_block->ForEachSuccessorLabel(
|
||||
[&is_single_block_loop, block_id](const uint32_t succ) {
|
||||
if (block_id == succ)
|
||||
if (block_id == succ) {
|
||||
is_single_block_loop = true;
|
||||
}
|
||||
});
|
||||
const auto ct = block_info->continue_for_header;
|
||||
block_info->is_continue_entire_loop = ct == block_id;
|
||||
|
||||
@@ -232,8 +232,9 @@ bool Lexer::is_hex(char ch) const {
|
||||
}
|
||||
|
||||
bool Lexer::matches(size_t pos, std::string_view sub_string) {
|
||||
if (pos >= length())
|
||||
if (pos >= length()) {
|
||||
return false;
|
||||
}
|
||||
return substr(pos, sub_string.size()) == sub_string;
|
||||
}
|
||||
|
||||
@@ -265,8 +266,9 @@ Token Lexer::skip_blankspace_and_comments() {
|
||||
|
||||
// If the cursor didn't advance we didn't remove any blankspace
|
||||
// so we're done.
|
||||
if (loc == location_)
|
||||
if (loc == location_) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_eof()) {
|
||||
return {Token::Type::kEOF, begin_source()};
|
||||
@@ -1043,110 +1045,159 @@ Token Lexer::try_punctuation() {
|
||||
}
|
||||
|
||||
Token Lexer::check_keyword(const Source& source, std::string_view str) {
|
||||
if (str == "array")
|
||||
if (str == "array") {
|
||||
return {Token::Type::kArray, source, "array"};
|
||||
if (str == "atomic")
|
||||
}
|
||||
if (str == "atomic") {
|
||||
return {Token::Type::kAtomic, source, "atomic"};
|
||||
if (str == "bitcast")
|
||||
}
|
||||
if (str == "bitcast") {
|
||||
return {Token::Type::kBitcast, source, "bitcast"};
|
||||
if (str == "bool")
|
||||
}
|
||||
if (str == "bool") {
|
||||
return {Token::Type::kBool, source, "bool"};
|
||||
if (str == "break")
|
||||
}
|
||||
if (str == "break") {
|
||||
return {Token::Type::kBreak, source, "break"};
|
||||
if (str == "case")
|
||||
}
|
||||
if (str == "case") {
|
||||
return {Token::Type::kCase, source, "case"};
|
||||
if (str == "continue")
|
||||
}
|
||||
if (str == "continue") {
|
||||
return {Token::Type::kContinue, source, "continue"};
|
||||
if (str == "continuing")
|
||||
}
|
||||
if (str == "continuing") {
|
||||
return {Token::Type::kContinuing, source, "continuing"};
|
||||
if (str == "discard")
|
||||
}
|
||||
if (str == "discard") {
|
||||
return {Token::Type::kDiscard, source, "discard"};
|
||||
if (str == "default")
|
||||
}
|
||||
if (str == "default") {
|
||||
return {Token::Type::kDefault, source, "default"};
|
||||
if (str == "else")
|
||||
}
|
||||
if (str == "else") {
|
||||
return {Token::Type::kElse, source, "else"};
|
||||
if (str == "enable")
|
||||
}
|
||||
if (str == "enable") {
|
||||
return {Token::Type::kEnable, source, "enable"};
|
||||
if (str == "f16")
|
||||
}
|
||||
if (str == "f16") {
|
||||
return {Token::Type::kF16, source, "f16"};
|
||||
if (str == "f32")
|
||||
}
|
||||
if (str == "f32") {
|
||||
return {Token::Type::kF32, source, "f32"};
|
||||
if (str == "fallthrough")
|
||||
}
|
||||
if (str == "fallthrough") {
|
||||
return {Token::Type::kFallthrough, source, "fallthrough"};
|
||||
if (str == "false")
|
||||
}
|
||||
if (str == "false") {
|
||||
return {Token::Type::kFalse, source, "false"};
|
||||
if (str == "fn")
|
||||
}
|
||||
if (str == "fn") {
|
||||
return {Token::Type::kFn, source, "fn"};
|
||||
if (str == "for")
|
||||
}
|
||||
if (str == "for") {
|
||||
return {Token::Type::kFor, source, "for"};
|
||||
if (str == "function")
|
||||
}
|
||||
if (str == "function") {
|
||||
return {Token::Type::kFunction, source, "function"};
|
||||
if (str == "i32")
|
||||
}
|
||||
if (str == "i32") {
|
||||
return {Token::Type::kI32, source, "i32"};
|
||||
if (str == "if")
|
||||
}
|
||||
if (str == "if") {
|
||||
return {Token::Type::kIf, source, "if"};
|
||||
if (str == "import")
|
||||
}
|
||||
if (str == "import") {
|
||||
return {Token::Type::kImport, source, "import"};
|
||||
if (str == "let")
|
||||
}
|
||||
if (str == "let") {
|
||||
return {Token::Type::kLet, source, "let"};
|
||||
if (str == "loop")
|
||||
}
|
||||
if (str == "loop") {
|
||||
return {Token::Type::kLoop, source, "loop"};
|
||||
if (str == "mat2x2")
|
||||
}
|
||||
if (str == "mat2x2") {
|
||||
return {Token::Type::kMat2x2, source, "mat2x2"};
|
||||
if (str == "mat2x3")
|
||||
}
|
||||
if (str == "mat2x3") {
|
||||
return {Token::Type::kMat2x3, source, "mat2x3"};
|
||||
if (str == "mat2x4")
|
||||
}
|
||||
if (str == "mat2x4") {
|
||||
return {Token::Type::kMat2x4, source, "mat2x4"};
|
||||
if (str == "mat3x2")
|
||||
}
|
||||
if (str == "mat3x2") {
|
||||
return {Token::Type::kMat3x2, source, "mat3x2"};
|
||||
if (str == "mat3x3")
|
||||
}
|
||||
if (str == "mat3x3") {
|
||||
return {Token::Type::kMat3x3, source, "mat3x3"};
|
||||
if (str == "mat3x4")
|
||||
}
|
||||
if (str == "mat3x4") {
|
||||
return {Token::Type::kMat3x4, source, "mat3x4"};
|
||||
if (str == "mat4x2")
|
||||
}
|
||||
if (str == "mat4x2") {
|
||||
return {Token::Type::kMat4x2, source, "mat4x2"};
|
||||
if (str == "mat4x3")
|
||||
}
|
||||
if (str == "mat4x3") {
|
||||
return {Token::Type::kMat4x3, source, "mat4x3"};
|
||||
if (str == "mat4x4")
|
||||
}
|
||||
if (str == "mat4x4") {
|
||||
return {Token::Type::kMat4x4, source, "mat4x4"};
|
||||
if (str == "override")
|
||||
}
|
||||
if (str == "override") {
|
||||
return {Token::Type::kOverride, source, "override"};
|
||||
if (str == "private")
|
||||
}
|
||||
if (str == "private") {
|
||||
return {Token::Type::kPrivate, source, "private"};
|
||||
if (str == "ptr")
|
||||
}
|
||||
if (str == "ptr") {
|
||||
return {Token::Type::kPtr, source, "ptr"};
|
||||
if (str == "return")
|
||||
}
|
||||
if (str == "return") {
|
||||
return {Token::Type::kReturn, source, "return"};
|
||||
if (str == "sampler")
|
||||
}
|
||||
if (str == "sampler") {
|
||||
return {Token::Type::kSampler, source, "sampler"};
|
||||
if (str == "sampler_comparison")
|
||||
}
|
||||
if (str == "sampler_comparison") {
|
||||
return {Token::Type::kComparisonSampler, source, "sampler_comparison"};
|
||||
if (str == "storage_buffer" || str == "storage")
|
||||
}
|
||||
if (str == "storage_buffer" || str == "storage") {
|
||||
return {Token::Type::kStorage, source, "storage"};
|
||||
if (str == "struct")
|
||||
}
|
||||
if (str == "struct") {
|
||||
return {Token::Type::kStruct, source, "struct"};
|
||||
if (str == "switch")
|
||||
}
|
||||
if (str == "switch") {
|
||||
return {Token::Type::kSwitch, source, "switch"};
|
||||
if (str == "texture_1d")
|
||||
}
|
||||
if (str == "texture_1d") {
|
||||
return {Token::Type::kTextureSampled1d, source, "texture_1d"};
|
||||
if (str == "texture_2d")
|
||||
}
|
||||
if (str == "texture_2d") {
|
||||
return {Token::Type::kTextureSampled2d, source, "texture_2d"};
|
||||
if (str == "texture_2d_array")
|
||||
}
|
||||
if (str == "texture_2d_array") {
|
||||
return {Token::Type::kTextureSampled2dArray, source, "texture_2d_array"};
|
||||
if (str == "texture_3d")
|
||||
}
|
||||
if (str == "texture_3d") {
|
||||
return {Token::Type::kTextureSampled3d, source, "texture_3d"};
|
||||
if (str == "texture_cube")
|
||||
}
|
||||
if (str == "texture_cube") {
|
||||
return {Token::Type::kTextureSampledCube, source, "texture_cube"};
|
||||
}
|
||||
if (str == "texture_cube_array") {
|
||||
return {Token::Type::kTextureSampledCubeArray, source, "texture_cube_array"};
|
||||
}
|
||||
if (str == "texture_depth_2d")
|
||||
if (str == "texture_depth_2d") {
|
||||
return {Token::Type::kTextureDepth2d, source, "texture_depth_2d"};
|
||||
}
|
||||
if (str == "texture_depth_2d_array") {
|
||||
return {Token::Type::kTextureDepth2dArray, source, "texture_depth_2d_array"};
|
||||
}
|
||||
if (str == "texture_depth_cube")
|
||||
if (str == "texture_depth_cube") {
|
||||
return {Token::Type::kTextureDepthCube, source, "texture_depth_cube"};
|
||||
}
|
||||
if (str == "texture_depth_cube_array") {
|
||||
return {Token::Type::kTextureDepthCubeArray, source, "texture_depth_cube_array"};
|
||||
}
|
||||
@@ -1171,24 +1222,33 @@ Token Lexer::check_keyword(const Source& source, std::string_view str) {
|
||||
if (str == "texture_storage_3d") {
|
||||
return {Token::Type::kTextureStorage3d, source, "texture_storage_3d"};
|
||||
}
|
||||
if (str == "true")
|
||||
if (str == "true") {
|
||||
return {Token::Type::kTrue, source, "true"};
|
||||
if (str == "type")
|
||||
}
|
||||
if (str == "type") {
|
||||
return {Token::Type::kType, source, "type"};
|
||||
if (str == "u32")
|
||||
}
|
||||
if (str == "u32") {
|
||||
return {Token::Type::kU32, source, "u32"};
|
||||
if (str == "uniform")
|
||||
}
|
||||
if (str == "uniform") {
|
||||
return {Token::Type::kUniform, source, "uniform"};
|
||||
if (str == "var")
|
||||
}
|
||||
if (str == "var") {
|
||||
return {Token::Type::kVar, source, "var"};
|
||||
if (str == "vec2")
|
||||
}
|
||||
if (str == "vec2") {
|
||||
return {Token::Type::kVec2, source, "vec2"};
|
||||
if (str == "vec3")
|
||||
}
|
||||
if (str == "vec3") {
|
||||
return {Token::Type::kVec3, source, "vec3"};
|
||||
if (str == "vec4")
|
||||
}
|
||||
if (str == "vec4") {
|
||||
return {Token::Type::kVec4, source, "vec4"};
|
||||
if (str == "workgroup")
|
||||
}
|
||||
if (str == "workgroup") {
|
||||
return {Token::Type::kWorkgroup, source, "workgroup"};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -67,4 +67,3 @@ const char* str(CtorConvIntrinsic i) {
|
||||
}
|
||||
|
||||
} // namespace tint::resolver
|
||||
|
||||
|
||||
@@ -34,8 +34,9 @@ Symbol SymbolTable::Register(const std::string& name) {
|
||||
TINT_ASSERT(Symbol, !name.empty());
|
||||
|
||||
auto it = name_to_symbol_.find(name);
|
||||
if (it != name_to_symbol_.end())
|
||||
if (it != name_to_symbol_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
#if TINT_SYMBOL_STORE_DEBUG_NAME
|
||||
Symbol sym(next_symbol_, program_id_, name);
|
||||
|
||||
@@ -1464,8 +1464,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||
|
||||
out << "(";
|
||||
|
||||
if (!EmitExpression(out, texture))
|
||||
if (!EmitExpression(out, texture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
out << ", ";
|
||||
|
||||
@@ -2601,8 +2602,10 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||
if (storage && storage->access() != ast::Access::kRead) {
|
||||
out << "writeonly ";
|
||||
}
|
||||
auto* subtype =
|
||||
sampled ? sampled->type() : storage ? storage->type() : ms ? ms->type() : nullptr;
|
||||
auto* subtype = sampled ? sampled->type()
|
||||
: storage ? storage->type()
|
||||
: ms ? ms->type()
|
||||
: nullptr;
|
||||
if (!subtype || subtype->Is<sem::F32>()) {
|
||||
} else if (subtype->Is<sem::I32>()) {
|
||||
out << "i";
|
||||
|
||||
@@ -2324,8 +2324,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!EmitExpression(out, texture))
|
||||
if (!EmitExpression(out, texture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If pack_level_in_coords is true, then the mip level will be appended as the
|
||||
// last value of the coordinates argument. If the WGSL builtin overload does
|
||||
@@ -2397,8 +2398,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||
}
|
||||
|
||||
if (auto* sampler = arg(Usage::kSampler)) {
|
||||
if (!EmitExpression(out, sampler))
|
||||
if (!EmitExpression(out, sampler)) {
|
||||
return false;
|
||||
}
|
||||
out << ", ";
|
||||
}
|
||||
|
||||
|
||||
@@ -1043,8 +1043,9 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||
}
|
||||
}
|
||||
|
||||
if (!EmitExpression(out, e->Declaration()))
|
||||
if (!EmitExpression(out, e->Declaration())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (casted) {
|
||||
out << ")";
|
||||
|
||||
@@ -55,8 +55,9 @@ const char kGLSLstd450[] = "GLSL.std.450";
|
||||
|
||||
uint32_t size_of(const InstructionList& instructions) {
|
||||
uint32_t size = 0;
|
||||
for (const auto& inst : instructions)
|
||||
for (const auto& inst : instructions) {
|
||||
size += inst.word_length();
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user