Re-format source tree - NFC.
authorDiego Novillo <dnovillo@google.com>
Mon, 27 Nov 2017 15:16:41 +0000 (10:16 -0500)
committerDiego Novillo <dnovillo@google.com>
Mon, 27 Nov 2017 19:31:49 +0000 (14:31 -0500)
Re-formatted the source tree with the command:

$ /usr/bin/clang-format -style=file -i \
    $(find include source tools test utils -name '*.cpp' -or -name '*.h')

This required a fix to source/val/decoration.h.  It was not including
spirv.h, which broke builds when the #include headers were re-ordered by
clang-format.

158 files changed:
source/assembly_grammar.h
source/comp/markv_model.h
source/id_descriptor.cpp
source/link/linker.cpp
source/name_mapper.cpp
source/opt/basic_block.cpp
source/opt/block_merge_pass.cpp
source/opt/build_module.cpp
source/opt/build_module.h
source/opt/cfg.cpp
source/opt/cfg.h
source/opt/cfg_cleanup_pass.cpp
source/opt/common_uniform_elim_pass.cpp
source/opt/dead_branch_elim_pass.cpp
source/opt/dead_variable_elimination.cpp
source/opt/decoration_manager.cpp
source/opt/decoration_manager.h
source/opt/def_use_manager.cpp
source/opt/def_use_manager.h
source/opt/eliminate_dead_constant_pass.cpp
source/opt/eliminate_dead_functions_pass.cpp
source/opt/fold_spec_constant_op_and_composite_pass.cpp
source/opt/function.cpp
source/opt/inline_pass.cpp
source/opt/inline_pass.h
source/opt/insert_extract_elim.cpp
source/opt/insert_extract_elim.h
source/opt/instruction.h
source/opt/ir_context.cpp
source/opt/ir_context.h
source/opt/local_access_chain_convert_pass.cpp
source/opt/local_single_block_elim_pass.cpp
source/opt/local_single_block_elim_pass.h
source/opt/local_single_store_elim_pass.cpp
source/opt/local_single_store_elim_pass.h
source/opt/local_ssa_elim_pass.cpp
source/opt/mem_pass.cpp
source/opt/passes.h
source/opt/remove_duplicates_pass.cpp
source/opt/set_spec_constant_default_value_pass.cpp
source/opt/strength_reduction_pass.cpp
source/opt/unify_const_pass.cpp
source/opt/value_number_table.cpp
source/text_handler.h
source/util/parse_number.cpp
source/val/basic_block.h
source/val/construct.cpp
source/val/construct.h
source/val/decoration.h
source/val/function.cpp
source/val/function.h
source/val/instruction.h
source/val/validation_state.cpp
source/val/validation_state.h
source/validate.cpp
source/validate_arithmetics.cpp
source/validate_bitwise.cpp
source/validate_derivatives.cpp
source/validate_id.cpp
source/validate_image.cpp
source/validate_layout.cpp
source/validate_logicals.cpp
test/assembly_context_test.cpp
test/binary_parse_test.cpp
test/binary_to_text_test.cpp
test/bit_stream.cpp
test/comp/markv_codec_test.cpp
test/diagnostic_test.cpp
test/enum_set_test.cpp
test/enum_string_mapping_test.cpp
test/ext_inst.glsl_test.cpp
test/ext_inst.opencl_test.cpp
test/generator_magic_number_test.cpp
test/hex_float_test.cpp
test/huffman_codec.cpp
test/immediate_int_test.cpp
test/link/binary_version_test.cpp
test/link/ids_limit_test.cpp
test/link/unique_ids_test.cpp
test/move_to_front_test.cpp
test/name_mapper_test.cpp
test/named_id_test.cpp
test/operand_capabilities_test.cpp
test/operand_pattern_test.cpp
test/operand_test.cpp
test/opt/aggressive_dead_code_elim_test.cpp
test/opt/assembly_builder.h
test/opt/assembly_builder_test.cpp
test/opt/block_merge_test.cpp
test/opt/cfg_cleanup_test.cpp
test/opt/common_uniform_elim_test.cpp
test/opt/compact_ids_test.cpp
test/opt/dead_branch_elim_test.cpp
test/opt/def_use_test.cpp
test/opt/eliminate_dead_const_test.cpp
test/opt/inline_opaque_test.cpp
test/opt/inline_test.cpp
test/opt/insert_extract_elim_test.cpp
test/opt/instruction_test.cpp
test/opt/ir_loader_test.cpp
test/opt/local_access_chain_convert_test.cpp
test/opt/local_redundancy_elimination_test.cpp
test/opt/local_single_block_elim.cpp
test/opt/local_single_store_elim_test.cpp
test/opt/local_ssa_elim_test.cpp
test/opt/module_test.cpp
test/opt/module_utils.h
test/opt/pass_fixture.h
test/opt/pass_manager_test.cpp
test/opt/set_spec_const_default_value_test.cpp
test/opt/strip_debug_info_test.cpp
test/opt/unify_const_test.cpp
test/opt/utils_test.cpp
test/opt/value_table_test.cpp
test/parse_number_test.cpp
test/preserve_numeric_ids_test.cpp
test/stats/stats_aggregate_test.cpp
test/stats/stats_analyzer_test.cpp
test/target_env_test.cpp
test/text_literal_test.cpp
test/text_to_binary.annotation_test.cpp
test/text_to_binary.barrier_test.cpp
test/text_to_binary.constant_test.cpp
test/text_to_binary.control_flow_test.cpp
test/text_to_binary.debug_test.cpp
test/text_to_binary.device_side_enqueue_test.cpp
test/text_to_binary.extension_test.cpp
test/text_to_binary.image_test.cpp
test/text_to_binary.memory_test.cpp
test/text_to_binary.misc_test.cpp
test/text_to_binary.mode_setting_test.cpp
test/text_to_binary.pipe_storage_test.cpp
test/text_to_binary.subgroup_dispatch_test.cpp
test/text_to_binary.type_declaration_test.cpp
test/text_to_binary_test.cpp
test/unit_spirv.h
test/util/ilist_test.cpp
test/val/val_arithmetics_test.cpp
test/val/val_bitwise_test.cpp
test/val/val_capability_test.cpp
test/val/val_cfg_test.cpp
test/val/val_conversion_test.cpp
test/val/val_data_test.cpp
test/val/val_decoration_test.cpp
test/val/val_derivatives_test.cpp
test/val/val_extensions_test.cpp
test/val/val_fixtures.cpp
test/val/val_fixtures.h
test/val/val_id_test.cpp
test/val/val_image_test.cpp
test/val/val_instructions_test.cpp
test/val/val_layout_test.cpp
test/val/val_limits_test.cpp
test/val/val_logicals_test.cpp
test/val/val_ssa_test.cpp
test/val/val_state_test.cpp
test/val/val_storage_test.cpp
test/val/val_type_unique_test.cpp

index cd89a1b..bfbfe76 100644 (file)
@@ -115,6 +115,6 @@ class AssemblyGrammar {
   const spv_opcode_table opcodeTable_;
   const spv_ext_inst_table extInstTable_;
 };
-}
+}  // namespace libspirv
 
 #endif  // LIBSPIRV_ASSEMBLY_GRAMMAR_H_
index c219096..630942c 100644 (file)
@@ -220,7 +220,8 @@ class MarkvModel {
   uint32_t s64_chunk_length_ = 8;
   uint32_t s64_block_exponent_ = 10;
 
-  IdFallbackStrategy id_fallback_strategy_ = IdFallbackStrategy::kShortDescriptor;
+  IdFallbackStrategy id_fallback_strategy_ =
+      IdFallbackStrategy::kShortDescriptor;
 
   uint32_t model_type_ = 0;
   uint32_t model_version_ = 0;
index 9395169..7697c29 100644 (file)
@@ -63,10 +63,9 @@ uint32_t IdDescriptorCollection::ProcessInstruction(
     }
   }
 
-  uint32_t descriptor = custom_hash_func_ ?
-      custom_hash_func_(words_) : HashU32Array(words_);
-  if (descriptor == 0)
-    descriptor = 1;
+  uint32_t descriptor =
+      custom_hash_func_ ? custom_hash_func_(words_) : HashU32Array(words_);
+  if (descriptor == 0) descriptor = 1;
   assert(descriptor);
 
   words_.clear();
index 732ff9a..730ec37 100644 (file)
@@ -72,9 +72,9 @@ using LinkageTable = std::vector<LinkageEntry>;
 // Both |modules| and |max_id_bound| should not be null, and |modules| should
 // not be empty either. Furthermore |modules| should not contain any null
 // pointers.
-static spv_result_t ShiftIdsInModules(
-    const MessageConsumer& consumer,
-    std::vector<ir::Module*>* modules, uint32_t* max_id_bound);
+static spv_result_t ShiftIdsInModules(const MessageConsumer& consumer,
+                                      std::vector<ir::Module*>* modules,
+                                      uint32_t* max_id_bound);
 
 // Generates the header for the linked module and returns it in |header|.
 //
@@ -84,20 +84,19 @@ static spv_result_t ShiftIdsInModules(
 // TODO(pierremoreau): What to do when binaries use different versions of
 //                     SPIR-V? For now, use the max of all versions found in
 //                     the input modules.
-static spv_result_t GenerateHeader(
-    const MessageConsumer& consumer,
-    const std::vector<ir::Module*>& modules,
-    uint32_t max_id_bound, ir::ModuleHeader* header);
+static spv_result_t GenerateHeader(const MessageConsumer& consumer,
+                                   const std::vector<ir::Module*>& modules,
+                                   uint32_t max_id_bound,
+                                   ir::ModuleHeader* header);
 
 // Merge all the modules from |inModules| into a single module owned by
 // |linked_context|.
 //
 // |linked_context| should not be null.
-static spv_result_t MergeModules(
-    const MessageConsumer& consumer,
-    const std::vector<Module*>& inModules,
-    const libspirv::AssemblyGrammar& grammar,
-    IRContext* linked_context);
+static spv_result_t MergeModules(const MessageConsumer& consumer,
+                                 const std::vector<Module*>& inModules,
+                                 const libspirv::AssemblyGrammar& grammar,
+                                 IRContext* linked_context);
 
 // Compute all pairs of import and export and return it in |linkings_to_do|.
 //
@@ -283,9 +282,9 @@ spv_result_t Linker::Link(const uint32_t* const* binaries,
   return SPV_SUCCESS;
 }
 
-static spv_result_t ShiftIdsInModules(
-    const MessageConsumer& consumer,
-    std::vector<ir::Module*>* modules, uint32_t* max_id_bound) {
+static spv_result_t ShiftIdsInModules(const MessageConsumer& consumer,
+                                      std::vector<ir::Module*>* modules,
+                                      uint32_t* max_id_bound) {
   spv_position_t position = {};
 
   if (modules == nullptr)
@@ -329,10 +328,10 @@ static spv_result_t ShiftIdsInModules(
   return SPV_SUCCESS;
 }
 
-static spv_result_t GenerateHeader(
-    const MessageConsumer& consumer,
-    const std::vector<ir::Module*>& modules,
-    uint32_t max_id_bound, ir::ModuleHeader* header) {
+static spv_result_t GenerateHeader(const MessageConsumer& consumer,
+                                   const std::vector<ir::Module*>& modules,
+                                   uint32_t max_id_bound,
+                                   ir::ModuleHeader* header) {
   spv_position_t position = {};
 
   if (modules.empty())
@@ -357,10 +356,10 @@ static spv_result_t GenerateHeader(
   return SPV_SUCCESS;
 }
 
-static spv_result_t MergeModules(
-    const MessageConsumer& consumer,
-    const std::vector<Module*>& input_modules,
-    const libspirv::AssemblyGrammar& grammar, IRContext* linked_context) {
+static spv_result_t MergeModules(const MessageConsumer& consumer,
+                                 const std::vector<Module*>& input_modules,
+                                 const libspirv::AssemblyGrammar& grammar,
+                                 IRContext* linked_context) {
   spv_position_t position = {};
 
   if (linked_context == nullptr)
@@ -423,8 +422,8 @@ static spv_result_t MergeModules(
     }
 
     if (memory_model_inst != nullptr)
-      linked_module->SetMemoryModel(
-          std::unique_ptr<Instruction>(memory_model_inst->Clone(linked_context)));
+      linked_module->SetMemoryModel(std::unique_ptr<Instruction>(
+          memory_model_inst->Clone(linked_context)));
   } while (false);
 
   std::vector<std::pair<uint32_t, const char*>> entry_points;
@@ -707,7 +706,8 @@ static spv_result_t RemoveLinkageSpecificInstructions(
   // Remove declarations of imported variables
   for (const auto& linking_entry : linkings_to_do) {
     for (auto& inst : linked_context->types_values())
-      if (inst.result_id() == linking_entry.imported_symbol.id) linked_context->KillInst(&inst);
+      if (inst.result_id() == linking_entry.imported_symbol.id)
+        linked_context->KillInst(&inst);
   }
 
   // Remove import linkage attributes
@@ -738,12 +738,14 @@ static spv_result_t RemoveLinkageSpecificInstructions(
   return SPV_SUCCESS;
 }
 
-spv_result_t VerifyIds(const MessageConsumer& consumer, ir::IRContext* linked_context) {
+spv_result_t VerifyIds(const MessageConsumer& consumer,
+                       ir::IRContext* linked_context) {
   std::unordered_set<uint32_t> ids;
   bool ok = true;
-  linked_context->module()->ForEachInst([&ids,&ok](const ir::Instruction* inst) {
-    ok &= ids.insert(inst->unique_id()).second;
-  });
+  linked_context->module()->ForEachInst(
+      [&ids, &ok](const ir::Instruction* inst) {
+        ok &= ids.insert(inst->unique_id()).second;
+      });
 
   if (!ok) {
     consumer(SPV_MSG_INTERNAL_ERROR, "", {}, "Non-unique id in merged module");
index a169621..8b25cb4 100644 (file)
@@ -234,30 +234,26 @@ spv_result_t FriendlyNameMapper::ParseInstruction(
       }
     } break;
     case SpvOpTypeVector:
-      SaveName(result_id,
-               std::string("v") + to_string(inst.words[3]) +
-                   NameForId(inst.words[2]));
+      SaveName(result_id, std::string("v") + to_string(inst.words[3]) +
+                              NameForId(inst.words[2]));
       break;
     case SpvOpTypeMatrix:
-      SaveName(result_id,
-               std::string("mat") + to_string(inst.words[3]) +
-                   NameForId(inst.words[2]));
+      SaveName(result_id, std::string("mat") + to_string(inst.words[3]) +
+                              NameForId(inst.words[2]));
       break;
     case SpvOpTypeArray:
-      SaveName(result_id,
-               std::string("_arr_") + NameForId(inst.words[2]) + "_" +
-                   NameForId(inst.words[3]));
+      SaveName(result_id, std::string("_arr_") + NameForId(inst.words[2]) +
+                              "_" + NameForId(inst.words[3]));
       break;
     case SpvOpTypeRuntimeArray:
       SaveName(result_id,
                std::string("_runtimearr_") + NameForId(inst.words[2]));
       break;
     case SpvOpTypePointer:
-      SaveName(result_id,
-               std::string("_ptr_") +
-                   NameForEnumOperand(SPV_OPERAND_TYPE_STORAGE_CLASS,
-                                      inst.words[2]) +
-                   "_" + NameForId(inst.words[3]));
+      SaveName(result_id, std::string("_ptr_") +
+                              NameForEnumOperand(SPV_OPERAND_TYPE_STORAGE_CLASS,
+                                                 inst.words[2]) +
+                              "_" + NameForId(inst.words[3]));
       break;
     case SpvOpTypePipe:
       SaveName(result_id,
index fccd396..e120bab 100644 (file)
@@ -30,8 +30,8 @@ const uint32_t kSelectionMergeMergeBlockIdInIdx = 0;
 }  // namespace
 
 BasicBlock* BasicBlock::Clone(IRContext* context) const {
-  BasicBlock* clone =
-      new BasicBlock(std::unique_ptr<Instruction>(GetLabelInst().Clone(context)));
+  BasicBlock* clone = new BasicBlock(
+      std::unique_ptr<Instruction>(GetLabelInst().Clone(context)));
   for (const auto& inst : insts_)
     // Use the incoming context
     clone->AddInstruction(std::unique_ptr<Instruction>(inst.Clone(context)));
index 9a72b14..24d19f6 100644 (file)
@@ -24,12 +24,11 @@ namespace opt {
 
 bool BlockMergePass::HasMultipleRefs(uint32_t labId) {
   int rcnt = 0;
-  get_def_use_mgr()->ForEachUser(
-      labId, [&rcnt](ir::Instruction* user) {
-        if (user->opcode() != SpvOpName) {
-          ++rcnt;
-        }
-      });
+  get_def_use_mgr()->ForEachUser(labId, [&rcnt](ir::Instruction* user) {
+    if (user->opcode() != SpvOpName) {
+      ++rcnt;
+    }
+  });
   return rcnt > 1;
 }
 
@@ -40,7 +39,7 @@ void BlockMergePass::KillInstAndName(ir::Instruction* inst) {
       to_kill.push_back(user);
     }
   });
-  for (auto i: to_kill) {
+  for (auto i : to_kill) {
     context()->KillInst(i);
   }
   context()->KillInst(inst);
index d7a4271..7978646 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "build_module.h"
 
-#include"ir_context.h"
+#include "ir_context.h"
 #include "ir_loader.h"
 #include "make_unique.h"
 #include "table.h"
@@ -42,12 +42,12 @@ spv_result_t SetSpvInst(void* builder, const spv_parsed_instruction_t* inst) {
   return SPV_ERROR_INVALID_BINARY;
 };
 
-}  // annoymous namespace
+}  // namespace
 
 std::unique_ptr<ir::IRContext> BuildModule(spv_target_env env,
-                                        MessageConsumer consumer,
-                                        const uint32_t* binary,
-                                        const size_t size) {
+                                           MessageConsumer consumer,
+                                           const uint32_t* binary,
+                                           const size_t size) {
   auto context = spvContextCreate(env);
   libspirv::SetContextMessageConsumer(context, consumer);
 
index 3ee6607..7e94936 100644 (file)
@@ -29,8 +29,8 @@ namespace spvtools {
 // decoded according to the given target |env|. Returns nullptr if errors occur
 // and sends the errors to |consumer|.
 std::unique_ptr<ir::IRContext> BuildModule(spv_target_env env,
-                                        MessageConsumer consumer,
-                                        const uint32_t* binary, size_t size);
+                                           MessageConsumer consumer,
+                                           const uint32_t* binary, size_t size);
 
 // Builds an ir::Module and returns the owning ir::IRContext from the given
 // SPIR-V assembly |text|.  The |text| will be encoded according to the given
index a0b78c7..bf46236 100644 (file)
@@ -30,8 +30,8 @@ CFG::CFG(ir::Module* module)
     : module_(module),
       pseudo_entry_block_(std::unique_ptr<ir::Instruction>(
           new ir::Instruction(module->context(), SpvOpLabel, 0, 0, {}))),
-      pseudo_exit_block_(std::unique_ptr<ir::Instruction>(
-          new ir::Instruction(module->context(), SpvOpLabel, 0, kInvalidId, {}))) {
+      pseudo_exit_block_(std::unique_ptr<ir::Instruction>(new ir::Instruction(
+          module->context(), SpvOpLabel, 0, kInvalidId, {}))) {
   for (auto& fn : *module) {
     for (auto& blk : fn) {
       uint32_t blkId = blk.id();
@@ -88,5 +88,5 @@ void CFG::ComputeStructuredSuccessors(ir::Function* func) {
   }
 }
 
-}  // namespace opt
+}  // namespace ir
 }  // namespace spvtools
index 6043b6e..f8f3c6c 100644 (file)
@@ -104,7 +104,7 @@ class CFG {
   std::unordered_map<uint32_t, ir::BasicBlock*> id2block_;
 };
 
-}  // namespace opt
+}  // namespace ir
 }  // namespace spvtools
 
 #endif  // LIBSPIRV_OPT_CFG_H_
index a74b6d3..2565225 100644 (file)
@@ -27,9 +27,7 @@
 namespace spvtools {
 namespace opt {
 
-void CFGCleanupPass::Initialize(ir::IRContext* c) {
-  InitializeProcessing(c);
-}
+void CFGCleanupPass::Initialize(ir::IRContext* c) { InitializeProcessing(c); }
 
 Pass::Status CFGCleanupPass::Process(ir::IRContext* c) {
   Initialize(c);
index 9b8b1ac..721b953 100644 (file)
@@ -99,10 +99,11 @@ ir::Instruction* CommonUniformElimPass::GetPtr(ir::Instruction* ip,
 bool CommonUniformElimPass::IsVolatileStruct(uint32_t type_id) {
   assert(get_def_use_mgr()->GetDef(type_id)->opcode() == SpvOpTypeStruct);
   bool has_volatile_deco = false;
-  get_decoration_mgr()->ForEachDecoration(type_id, SpvDecorationVolatile,
-                              [&has_volatile_deco](const ir::Instruction&) {
-                                has_volatile_deco = true;
-                              });
+  get_decoration_mgr()->ForEachDecoration(
+      type_id, SpvDecorationVolatile,
+      [&has_volatile_deco](const ir::Instruction&) {
+        has_volatile_deco = true;
+      });
   return has_volatile_deco;
 }
 
@@ -256,8 +257,9 @@ void CommonUniformElimPass::GenACLoadRepl(
     }
     ++iidIdx;
   });
-  std::unique_ptr<ir::Instruction> newExt(new ir::Instruction(
-      context(), SpvOpCompositeExtract, ptrPteTypeId, extResultId, ext_in_opnds));
+  std::unique_ptr<ir::Instruction> newExt(
+      new ir::Instruction(context(), SpvOpCompositeExtract, ptrPteTypeId,
+                          extResultId, ext_in_opnds));
   get_def_use_mgr()->AnalyzeInstDefUse(&*newExt);
   newInsts->emplace_back(std::move(newExt));
   *resultId = extResultId;
@@ -553,18 +555,27 @@ void CommonUniformElimPass::InitExtensions() {
   extensions_whitelist_.clear();
   extensions_whitelist_.insert({
       "SPV_AMD_shader_explicit_vertex_parameter",
-      "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
-      "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
-      "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
-      "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage", "SPV_KHR_device_group",
-      "SPV_KHR_multiview", "SPV_NVX_multiview_per_view_attributes",
-      "SPV_NV_viewport_array2", "SPV_NV_stereo_view_rendering",
+      "SPV_AMD_shader_trinary_minmax",
+      "SPV_AMD_gcn_shader",
+      "SPV_KHR_shader_ballot",
+      "SPV_AMD_shader_ballot",
+      "SPV_AMD_gpu_shader_half_float",
+      "SPV_KHR_shader_draw_parameters",
+      "SPV_KHR_subgroup_vote",
+      "SPV_KHR_16bit_storage",
+      "SPV_KHR_device_group",
+      "SPV_KHR_multiview",
+      "SPV_NVX_multiview_per_view_attributes",
+      "SPV_NV_viewport_array2",
+      "SPV_NV_stereo_view_rendering",
       "SPV_NV_sample_mask_override_coverage",
-      "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+      "SPV_NV_geometry_shader_passthrough",
+      "SPV_AMD_texture_gather_bias_lod",
       "SPV_KHR_storage_buffer_storage_class",
       // SPV_KHR_variable_pointers
       //   Currently do not support extended pointer expressions
-      "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+      "SPV_AMD_gpu_shader_int16",
+      "SPV_KHR_post_depth_coverage",
       "SPV_KHR_shader_atomic_counter_ops",
   });
 }
index b9c6562..90ef32d 100644 (file)
@@ -17,8 +17,8 @@
 #include "dead_branch_elim_pass.h"
 
 #include "cfa.h"
-#include "iterator.h"
 #include "ir_context.h"
+#include "iterator.h"
 
 namespace spvtools {
 namespace opt {
index 01ff04f..1fec3a4 100644 (file)
@@ -14,8 +14,8 @@
 
 #include "dead_variable_elimination.h"
 
-#include "reflect.h"
 #include "ir_context.h"
+#include "reflect.h"
 
 namespace spvtools {
 namespace opt {
index 42c4e77..4b557f3 100644 (file)
@@ -261,7 +261,8 @@ void DecorationManager::CloneDecorations(
       case SpvOpMemberDecorate:
       case SpvOpDecorateId: {
         // simply clone decoration and change |target-id| to |to|
-        std::unique_ptr<ir::Instruction> new_inst(inst->Clone(module_->context()));
+        std::unique_ptr<ir::Instruction> new_inst(
+            inst->Clone(module_->context()));
         new_inst->SetInOperand(0, {to});
         id_to_decoration_insts_[to].push_back(new_inst.get());
         module_->AddAnnotationInst(std::move(new_inst));
index a87a8f9..fca78d3 100644 (file)
@@ -71,7 +71,8 @@ class DecorationManager {
   // Function |f| can be used to update context information and is called
   // with |false|, before an instruction is going to be changed and
   // with |true| afterwards.
-  void CloneDecorations(uint32_t from, uint32_t to, std::function<void(ir::Instruction&, bool)> f);
+  void CloneDecorations(uint32_t from, uint32_t to,
+                        std::function<void(ir::Instruction&, bool)> f);
 
   // Informs the decoration manager of a new decoration that it needs to track.
   void AddDecoration(ir::Instruction* inst);
index 94935f0..be9dc6c 100644 (file)
@@ -95,40 +95,44 @@ bool DefUseManager::UsersNotEnd(const IdToUsersMap::const_iterator& iter,
   return UsersNotEnd(iter, id_to_users_.end(), inst);
 }
 
-void DefUseManager::ForEachUser(const ir::Instruction* def,
-                                const std::function<void(ir::Instruction*)>& f) const {
+void DefUseManager::ForEachUser(
+    const ir::Instruction* def,
+    const std::function<void(ir::Instruction*)>& f) const {
   // Ensure that |def| has been registered.
-  assert(def && def == GetDef(def->result_id()) && "Definition is not registered.");
+  assert(def && def == GetDef(def->result_id()) &&
+         "Definition is not registered.");
   auto end = id_to_users_.end();
   for (auto iter = UsersBegin(def); UsersNotEnd(iter, end, def); ++iter) {
     f(iter->second);
   }
 }
 
-void DefUseManager::ForEachUser(uint32_t id,
-                                const std::function<void(ir::Instruction*)>& f) const {
+void DefUseManager::ForEachUser(
+    uint32_t id, const std::function<void(ir::Instruction*)>& f) const {
   ForEachUser(GetDef(id), f);
 }
 
-void DefUseManager::ForEachUse(const ir::Instruction* def,
-                               const std::function<void(ir::Instruction*, uint32_t)>& f) const {
+void DefUseManager::ForEachUse(
+    const ir::Instruction* def,
+    const std::function<void(ir::Instruction*, uint32_t)>& f) const {
   // Ensure that |def| has been registered.
-  assert(def && def == GetDef(def->result_id()) && "Definition is not registered.");
+  assert(def && def == GetDef(def->result_id()) &&
+         "Definition is not registered.");
   auto end = id_to_users_.end();
   for (auto iter = UsersBegin(def); UsersNotEnd(iter, end, def); ++iter) {
     ir::Instruction* user = iter->second;
     for (uint32_t idx = 0; idx != user->NumOperands(); ++idx) {
       const ir::Operand& op = user->GetOperand(idx);
       if (op.type != SPV_OPERAND_TYPE_RESULT_ID && spvIsIdType(op.type)) {
-        if (def->result_id() == op.words[0])
-          f(user, idx);
+        if (def->result_id() == op.words[0]) f(user, idx);
       }
     }
   }
 }
 
-void DefUseManager::ForEachUse(uint32_t id,
-                               const std::function<void(ir::Instruction*, uint32_t)>& f) const {
+void DefUseManager::ForEachUse(
+    uint32_t id,
+    const std::function<void(ir::Instruction*, uint32_t)>& f) const {
   ForEachUse(GetDef(id), f);
 }
 
@@ -148,10 +152,10 @@ std::vector<ir::Instruction*> DefUseManager::GetAnnotations(uint32_t id) const {
 void DefUseManager::AnalyzeDefUse(ir::Module* module) {
   if (!module) return;
   // Analyze all the defs before any uses to catch forward references.
-  module->ForEachInst(std::bind(&DefUseManager::AnalyzeInstDef, this,
-                                std::placeholders::_1));
-  module->ForEachInst(std::bind(&DefUseManager::AnalyzeInstUse, this,
-                                std::placeholders::_1));
+  module->ForEachInst(
+      std::bind(&DefUseManager::AnalyzeInstDef, this, std::placeholders::_1));
+  module->ForEachInst(
+      std::bind(&DefUseManager::AnalyzeInstUse, this, std::placeholders::_1));
 }
 
 void DefUseManager::ClearInst(ir::Instruction* inst) {
@@ -163,7 +167,8 @@ void DefUseManager::ClearInst(ir::Instruction* inst) {
       auto users_begin = UsersBegin(inst);
       auto end = id_to_users_.end();
       auto new_end = users_begin;
-      for (; UsersNotEnd(new_end, end, inst); ++new_end) {}
+      for (; UsersNotEnd(new_end, end, inst); ++new_end) {
+      }
       id_to_users_.erase(users_begin, new_end);
       id_to_def_.erase(inst->result_id());
     }
@@ -176,7 +181,8 @@ void DefUseManager::EraseUseRecordsOfOperandIds(const ir::Instruction* inst) {
   auto iter = inst_to_used_ids_.find(inst);
   if (iter != inst_to_used_ids_.end()) {
     for (auto use_id : iter->second) {
-      id_to_users_.erase(UserEntry(GetDef(use_id), const_cast<ir::Instruction*>(inst)));
+      id_to_users_.erase(
+          UserEntry(GetDef(use_id), const_cast<ir::Instruction*>(inst)));
     }
     inst_to_used_ids_.erase(inst);
   }
index 1f67305..0d81452 100644 (file)
@@ -42,15 +42,11 @@ inline bool operator==(const Use& lhs, const Use& rhs) {
   return lhs.inst == rhs.inst && lhs.operand_index == rhs.operand_index;
 }
 
-inline bool operator!=(const Use& lhs, const Use& rhs) {
-  return !(lhs == rhs);
-}
+inline bool operator!=(const Use& lhs, const Use& rhs) { return !(lhs == rhs); }
 
 inline bool operator<(const Use& lhs, const Use& rhs) {
-  if (lhs.inst < rhs.inst)
-    return true;
-  if (lhs.inst > rhs.inst)
-    return false;
+  if (lhs.inst < rhs.inst) return true;
+  if (lhs.inst > rhs.inst) return false;
   return lhs.operand_index < rhs.operand_index;
 }
 
@@ -77,26 +73,19 @@ struct UserEntryLess {
   bool operator()(const UserEntry& lhs, const UserEntry& rhs) const {
     // If lhs.first and rhs.first are both null, fall through to checking the
     // second entries.
-    if (!lhs.first && rhs.first)
-      return true;
-    if (lhs.first && !rhs.first)
-      return false;
+    if (!lhs.first && rhs.first) return true;
+    if (lhs.first && !rhs.first) return false;
 
     // If neither defintion is null, then compare unique ids.
     if (lhs.first && rhs.first) {
-      if (lhs.first->unique_id() < rhs.first->unique_id())
-        return true;
-      if (rhs.first->unique_id() < lhs.first->unique_id())
-        return false;
+      if (lhs.first->unique_id() < rhs.first->unique_id()) return true;
+      if (rhs.first->unique_id() < lhs.first->unique_id()) return false;
     }
 
     // Return false on equality.
-    if (!lhs.second && !rhs.second)
-      return false;
-    if (!lhs.second)
-      return true;
-    if (!rhs.second)
-      return false;
+    if (!lhs.second && !rhs.second) return false;
+    if (!lhs.second) return true;
+    if (!rhs.second) return false;
 
     // If neither user is null then compare unique ids.
     return lhs.second->unique_id() < rhs.second->unique_id();
@@ -155,12 +144,12 @@ class DefUseManager {
   // visited separately.
   //
   // |def| (or |id|) must be registered as a definition.
-  void ForEachUse(
-      const ir::Instruction* def,
-      const std::function<void(ir::Instruction*, uint32_t operand_index)>& f) const;
-  void ForEachUse(
-      uint32_t id,
-      const std::function<void(ir::Instruction*, uint32_t operand_index)>& f) const;
+  void ForEachUse(const ir::Instruction* def,
+                  const std::function<void(ir::Instruction*,
+                                           uint32_t operand_index)>& f) const;
+  void ForEachUse(uint32_t id,
+                  const std::function<void(ir::Instruction*,
+                                           uint32_t operand_index)>& f) const;
 
   // Returns the annotation instrunctions which are a direct use of the given
   // |id|. This means when the decorations are applied through decoration
@@ -184,8 +173,8 @@ class DefUseManager {
   // Erases the records that a given instruction uses its operand ids.
   void EraseUseRecordsOfOperandIds(const ir::Instruction* inst);
 
-  friend  bool operator==(const DefUseManager&, const DefUseManager&);
-  friend  bool operator!=(const DefUseManager& lhs, const DefUseManager& rhs) {
+  friend bool operator==(const DefUseManager&, const DefUseManager&);
+  friend bool operator!=(const DefUseManager& lhs, const DefUseManager& rhs) {
     return !(lhs == rhs);
   }
 
@@ -213,11 +202,10 @@ class DefUseManager {
   // structures in this class. Does nothing if |module| is nullptr.
   void AnalyzeDefUse(ir::Module* module);
 
-  IdToDefMap id_to_def_;    // Mapping from ids to their definitions
-  IdToUsersMap id_to_users_; // Mapping from ids to their users
+  IdToDefMap id_to_def_;      // Mapping from ids to their definitions
+  IdToUsersMap id_to_users_;  // Mapping from ids to their users
   // Mapping from instructions to the ids used in the instruction.
   InstToUsedIdsMap inst_to_used_ids_;
-
 };
 
 }  // namespace analysis
index 3c4e7f9..5c60f34 100644 (file)
@@ -95,15 +95,14 @@ Pass::Status EliminateDeadConstantPass::Process(ir::IRContext* irContext) {
   // constants.
   std::unordered_set<ir::Instruction*> dead_others;
   for (auto* dc : dead_consts) {
-    irContext->get_def_use_mgr()->ForEachUser(dc, [&dead_others](ir::Instruction* user) {
-      SpvOp op = user->opcode();
-      if (ir::IsAnnotationInst(op) ||
-          ir::IsDebug1Inst(op) ||
-          ir::IsDebug2Inst(op) ||
-          ir::IsDebug3Inst(op)) {
-        dead_others.insert(user);
-      }
-    });
+    irContext->get_def_use_mgr()->ForEachUser(
+        dc, [&dead_others](ir::Instruction* user) {
+          SpvOp op = user->opcode();
+          if (ir::IsAnnotationInst(op) || ir::IsDebug1Inst(op) ||
+              ir::IsDebug2Inst(op) || ir::IsDebug3Inst(op)) {
+            dead_others.insert(user);
+          }
+        });
   }
 
   // Turn all dead instructions and uses of them to nop
index 8c7d02f..8f9748a 100644 (file)
@@ -51,10 +51,7 @@ Pass::Status EliminateDeadFunctionsPass::Process(ir::IRContext* c) {
 void EliminateDeadFunctionsPass::EliminateFunction(ir::Function* func) {
   // Remove all of the instruction in the function body
   func->ForEachInst(
-      [this](ir::Instruction* inst) {
-        context()->KillInst(inst);
-      },
-      true);
+      [this](ir::Instruction* inst) { context()->KillInst(inst); }, true);
 }
 }  // namespace opt
 }  // namespace spvtools
index e91d1fb..dc33eda 100644 (file)
@@ -515,7 +515,7 @@ bool IsValidTypeForComponentWiseOperation(const analysis::Type* type) {
   }
   return false;
 }
-}
+}  // namespace
 
 ir::Instruction* FoldSpecConstantOpAndCompositePass::DoComponentWiseOperation(
     ir::Module::inst_iterator* pos) {
@@ -766,8 +766,7 @@ FoldSpecConstantOpAndCompositePass::CreateCompositeInstruction(
     operands.emplace_back(spv_operand_type_t::SPV_OPERAND_TYPE_ID,
                           std::initializer_list<uint32_t>{id});
   }
-  return MakeUnique<ir::Instruction>(context(),
-                                     SpvOp::SpvOpConstantComposite,
+  return MakeUnique<ir::Instruction>(context(), SpvOp::SpvOpConstantComposite,
                                      type_mgr_->GetId(cc->type()), result_id,
                                      std::move(operands));
 }
index dc5320f..d70d7f8 100644 (file)
@@ -24,7 +24,7 @@ Function* Function::Clone(IRContext* context) const {
       new Function(std::unique_ptr<Instruction>(DefInst().Clone(context)));
   clone->params_.reserve(params_.size());
   ForEachParam(
-      [clone,context](const Instruction* inst) {
+      [clone, context](const Instruction* inst) {
         clone->AddParameter(std::unique_ptr<Instruction>(inst->Clone(context)));
       },
       true);
@@ -36,7 +36,8 @@ Function* Function::Clone(IRContext* context) const {
     clone->AddBasicBlock(std::move(bb));
   }
 
-  clone->SetFunctionEnd(std::unique_ptr<Instruction>(function_end().Clone(context)));
+  clone->SetFunctionEnd(
+      std::unique_ptr<Instruction>(function_end().Clone(context)));
   return clone;
 }
 
index f813f99..4b1ba58 100644 (file)
@@ -146,7 +146,8 @@ void InlinePass::CloneAndMapLocals(
     std::unique_ptr<ir::Instruction> var_inst(
         callee_var_itr->Clone(callee_var_itr->context()));
     uint32_t newId = TakeNextId();
-    get_decoration_mgr()->CloneDecorations(callee_var_itr->result_id(), newId, update_def_use_mgr_);
+    get_decoration_mgr()->CloneDecorations(callee_var_itr->result_id(), newId,
+                                           update_def_use_mgr_);
     var_inst->SetResultId(newId);
     (*callee2caller)[callee_var_itr->result_id()] = newId;
     new_vars->push_back(std::move(var_inst));
@@ -175,7 +176,8 @@ uint32_t InlinePass::CreateReturnVar(
           {SpvStorageClassFunction}}}));
     new_vars->push_back(std::move(var_inst));
   }
-  get_decoration_mgr()->CloneDecorations(calleeFn->result_id(), returnVarId, update_def_use_mgr_);
+  get_decoration_mgr()->CloneDecorations(calleeFn->result_id(), returnVarId,
+                                         update_def_use_mgr_);
   return returnVarId;
 }
 
@@ -188,30 +190,30 @@ void InlinePass::CloneSameBlockOps(
     std::unordered_map<uint32_t, uint32_t>* postCallSB,
     std::unordered_map<uint32_t, ir::Instruction*>* preCallSB,
     std::unique_ptr<ir::BasicBlock>* block_ptr) {
-  (*inst)->ForEachInId(
-      [&postCallSB, &preCallSB, &block_ptr, this](uint32_t* iid) {
-        const auto mapItr = (*postCallSB).find(*iid);
-        if (mapItr == (*postCallSB).end()) {
-          const auto mapItr2 = (*preCallSB).find(*iid);
-          if (mapItr2 != (*preCallSB).end()) {
-            // Clone pre-call same-block ops, map result id.
-            const ir::Instruction* inInst = mapItr2->second;
-            std::unique_ptr<ir::Instruction> sb_inst(
-                inInst->Clone(inInst->context()));
-            CloneSameBlockOps(&sb_inst, postCallSB, preCallSB, block_ptr);
-            const uint32_t rid = sb_inst->result_id();
-            const uint32_t nid = this->TakeNextId();
-            get_decoration_mgr()->CloneDecorations(rid, nid, update_def_use_mgr_);
-            sb_inst->SetResultId(nid);
-            (*postCallSB)[rid] = nid;
-            *iid = nid;
-            (*block_ptr)->AddInstruction(std::move(sb_inst));
-          }
-        } else {
-          // Reset same-block op operand.
-          *iid = mapItr->second;
-        }
-      });
+  (*inst)->ForEachInId([&postCallSB, &preCallSB, &block_ptr,
+                        this](uint32_t* iid) {
+    const auto mapItr = (*postCallSB).find(*iid);
+    if (mapItr == (*postCallSB).end()) {
+      const auto mapItr2 = (*preCallSB).find(*iid);
+      if (mapItr2 != (*preCallSB).end()) {
+        // Clone pre-call same-block ops, map result id.
+        const ir::Instruction* inInst = mapItr2->second;
+        std::unique_ptr<ir::Instruction> sb_inst(
+            inInst->Clone(inInst->context()));
+        CloneSameBlockOps(&sb_inst, postCallSB, preCallSB, block_ptr);
+        const uint32_t rid = sb_inst->result_id();
+        const uint32_t nid = this->TakeNextId();
+        get_decoration_mgr()->CloneDecorations(rid, nid, update_def_use_mgr_);
+        sb_inst->SetResultId(nid);
+        (*postCallSB)[rid] = nid;
+        *iid = nid;
+        (*block_ptr)->AddInstruction(std::move(sb_inst));
+      }
+    } else {
+      // Reset same-block op operand.
+      *iid = mapItr->second;
+    }
+  });
 }
 
 void InlinePass::GenInlineCode(
@@ -649,7 +651,7 @@ void InlinePass::InitializeInline(ir::IRContext* c) {
   InitializeProcessing(c);
 
   // Don't bother updating the DefUseManger
-  update_def_use_mgr_ = [this] (ir::Instruction&, bool) {};
+  update_def_use_mgr_ = [this](ir::Instruction&, bool) {};
 
   false_id_ = 0;
 
index 7ecf772..0b037bc 100644 (file)
@@ -23,8 +23,8 @@
 #include <unordered_map>
 #include <vector>
 
-#include "def_use_manager.h"
 #include "decoration_manager.h"
+#include "def_use_manager.h"
 #include "module.h"
 #include "pass.h"
 
index b506d9e..d249e42 100644 (file)
@@ -43,9 +43,9 @@ bool InsertExtractElimPass::ExtInsMatch(const ir::Instruction* extInst,
   return true;
 }
 
-bool InsertExtractElimPass::ExtInsConflict(
-    const ir::Instruction* extInst, const ir::Instruction* insInst,
-    const uint32_t extOffset) const {
+bool InsertExtractElimPass::ExtInsConflict(const ir::Instruction* extInst,
+                                           const ir::Instruction* insInst,
+                                           const uint32_t extOffset) const {
   if (extInst->NumInOperands() - extOffset == insInst->NumInOperands() - 1)
     return false;
   uint32_t extNumIdx = extInst->NumInOperands() - 1 - extOffset;
@@ -80,21 +80,18 @@ bool InsertExtractElimPass::EliminateInsertExtract(ir::Function* func) {
               // Match! Use inserted value as replacement
               replId = cinst->GetSingleWordInOperand(kInsertObjectIdInIdx);
               break;
-            }
-            else if (ExtInsConflict(&*ii, cinst, extOffset)) {
+            } else if (ExtInsConflict(&*ii, cinst, extOffset)) {
               // If extract has fewer indices than the insert, stop searching.
               // Otherwise increment offset of extract indices considered and
               // continue searching through the inserted value
               if (ii->NumInOperands() - extOffset <
                   cinst->NumInOperands() - 1) {
                 break;
-              }
-              else {
+              } else {
                 extOffset += cinst->NumInOperands() - 2;
                 cid = cinst->GetSingleWordInOperand(kInsertObjectIdInIdx);
               }
-            }
-            else {
+            } else {
               // Consider next composite in insert chain
               cid = cinst->GetSingleWordInOperand(kInsertCompositeIdInIdx);
             }
index cb0f4f3..ab3d8f4 100644 (file)
@@ -41,7 +41,7 @@ class InsertExtractElimPass : public Pass {
 
  private:
   // Return true if indices of extract |extInst| starting at |extOffset|
-  // match indices of insert |insInst|. 
+  // match indices of insert |insInst|.
   bool ExtInsMatch(const ir::Instruction* extInst,
                    const ir::Instruction* insInst,
                    const uint32_t extOffset) const;
index 962b66b..a046e8d 100644 (file)
@@ -126,7 +126,7 @@ class Instruction : public utils::IntrusiveNodeBase<Instruction> {
   // It is the responsibility of the caller to make sure that the storage is
   // removed. It is the caller's responsibility to make sure that there is only
   // one instruction for each result id.
-  Instruction* Clone(IRContext *c) const;
+  Instruction* Clone(IRContextc) const;
 
   IRContext* context() const { return context_; }
 
index 2dd947e..3afdd64 100644 (file)
@@ -93,12 +93,14 @@ bool IRContext::ReplaceAllUsesWith(uint32_t before, uint32_t after) {
   if (before == after) return false;
 
   // Ensure that |after| has been registered as def.
-  assert(get_def_use_mgr()->GetDef(after) && "'after' is not a registered def.");
+  assert(get_def_use_mgr()->GetDef(after) &&
+         "'after' is not a registered def.");
 
-  std::vector<std::pair<ir::Instruction*,uint32_t>> uses_to_update;
-  get_def_use_mgr()->ForEachUse(before, [&uses_to_update](ir::Instruction* user, uint32_t index) {
-    uses_to_update.emplace_back(user, index);
-  });
+  std::vector<std::pair<ir::Instruction*, uint32_t>> uses_to_update;
+  get_def_use_mgr()->ForEachUse(
+      before, [&uses_to_update](ir::Instruction* user, uint32_t index) {
+        uses_to_update.emplace_back(user, index);
+      });
 
   ir::Instruction* prev = nullptr;
   for (auto p : uses_to_update) {
@@ -421,11 +423,11 @@ void IRContext::AddCombinatorsForExtension(ir::Instruction* extension) {
 }
 
 void IRContext::InitializeCombinators() {
-  forauto& capability : module()->capabilities()) {
+  for (auto& capability : module()->capabilities()) {
     AddCombinatorsForCapability(capability.GetSingleWordInOperand(0));
   }
 
-  forauto& extension : module()->ext_inst_imports()) {
+  for (auto& extension : module()->ext_inst_imports()) {
     AddCombinatorsForExtension(&extension);
   }
 
index 468dbc5..12499be 100644 (file)
@@ -343,7 +343,7 @@ class IRContext {
 
   // Opcodes of shader capability core executable instructions
   // without side-effect.
-  std::unordered_map<uint32_t, std::unordered_set<uint32_t>>  combinator_ops_;
+  std::unordered_map<uint32_t, std::unordered_set<uint32_t>> combinator_ops_;
 };
 
 inline ir::IRContext::Analysis operator|(ir::IRContext::Analysis lhs,
index db7bf95..b5729bb 100644 (file)
@@ -16,8 +16,8 @@
 
 #include "local_access_chain_convert_pass.h"
 
-#include "iterator.h"
 #include "ir_context.h"
+#include "iterator.h"
 
 namespace spvtools {
 namespace opt {
@@ -139,17 +139,18 @@ bool LocalAccessChainConvertPass::IsConstantIndexAccessChain(
 bool LocalAccessChainConvertPass::HasOnlySupportedRefs(uint32_t ptrId) {
   if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end()) return true;
   bool hasOnlySupportedRefs = true;
-  get_def_use_mgr()->ForEachUser(ptrId, [this,&hasOnlySupportedRefs](ir::Instruction* user) {
-    SpvOp op = user->opcode();
-    if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
-      if (!HasOnlySupportedRefs(user->result_id())) {
-        hasOnlySupportedRefs = false;
-      }
-    } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
-               !IsNonTypeDecorate(op)) {
-      hasOnlySupportedRefs = false;
-    }
-  });
+  get_def_use_mgr()->ForEachUser(
+      ptrId, [this, &hasOnlySupportedRefs](ir::Instruction* user) {
+        SpvOp op = user->opcode();
+        if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
+          if (!HasOnlySupportedRefs(user->result_id())) {
+            hasOnlySupportedRefs = false;
+          }
+        } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
+                   !IsNonTypeDecorate(op)) {
+          hasOnlySupportedRefs = false;
+        }
+      });
   if (hasOnlySupportedRefs) {
     supported_ref_ptrs_.insert(ptrId);
   }
@@ -174,9 +175,8 @@ void LocalAccessChainConvertPass::FindTargetVars(ir::Function* func) {
           }
           // Rule out variables with nested access chains
           // TODO(): Convert nested access chains
-          if (IsNonPtrAccessChain(op) &&
-              ptrInst->GetSingleWordInOperand(kAccessChainPtrIdInIdx) !=
-                  varId) {
+          if (IsNonPtrAccessChain(op) && ptrInst->GetSingleWordInOperand(
+                                             kAccessChainPtrIdInIdx) != varId) {
             seen_non_target_vars_.insert(varId);
             seen_target_vars_.erase(varId);
             break;
@@ -298,18 +298,27 @@ void LocalAccessChainConvertPass::InitExtensions() {
   extensions_whitelist_.clear();
   extensions_whitelist_.insert({
       "SPV_AMD_shader_explicit_vertex_parameter",
-      "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
-      "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
-      "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
-      "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage", "SPV_KHR_device_group",
-      "SPV_KHR_multiview", "SPV_NVX_multiview_per_view_attributes",
-      "SPV_NV_viewport_array2", "SPV_NV_stereo_view_rendering",
+      "SPV_AMD_shader_trinary_minmax",
+      "SPV_AMD_gcn_shader",
+      "SPV_KHR_shader_ballot",
+      "SPV_AMD_shader_ballot",
+      "SPV_AMD_gpu_shader_half_float",
+      "SPV_KHR_shader_draw_parameters",
+      "SPV_KHR_subgroup_vote",
+      "SPV_KHR_16bit_storage",
+      "SPV_KHR_device_group",
+      "SPV_KHR_multiview",
+      "SPV_NVX_multiview_per_view_attributes",
+      "SPV_NV_viewport_array2",
+      "SPV_NV_stereo_view_rendering",
       "SPV_NV_sample_mask_override_coverage",
-      "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+      "SPV_NV_geometry_shader_passthrough",
+      "SPV_AMD_texture_gather_bias_lod",
       "SPV_KHR_storage_buffer_storage_class",
       // SPV_KHR_variable_pointers
       //   Currently do not support extended pointer expressions
-      "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+      "SPV_AMD_gpu_shader_int16",
+      "SPV_KHR_post_depth_coverage",
       "SPV_KHR_shader_atomic_counter_ops",
   });
 }
index 95e9179..3ef8e0d 100644 (file)
@@ -30,17 +30,18 @@ const uint32_t kStoreValIdInIdx = 1;
 bool LocalSingleBlockLoadStoreElimPass::HasOnlySupportedRefs(uint32_t ptrId) {
   if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end()) return true;
   bool hasOnlySupportedRefs = true;
-  get_def_use_mgr()->ForEachUser(ptrId, [this,&hasOnlySupportedRefs](ir::Instruction* user) {
-    SpvOp op = user->opcode();
-    if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
-      if (!HasOnlySupportedRefs(user->result_id())) {
-        hasOnlySupportedRefs = false;
-      }
-    } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
-               !this->IsNonTypeDecorate(op)) {
-      hasOnlySupportedRefs = false;
-    }
-  });
+  get_def_use_mgr()->ForEachUser(
+      ptrId, [this, &hasOnlySupportedRefs](ir::Instruction* user) {
+        SpvOp op = user->opcode();
+        if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
+          if (!HasOnlySupportedRefs(user->result_id())) {
+            hasOnlySupportedRefs = false;
+          }
+        } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
+                   !this->IsNonTypeDecorate(op)) {
+          hasOnlySupportedRefs = false;
+        }
+      });
   if (hasOnlySupportedRefs) {
     supported_ref_ptrs_.insert(ptrId);
   }
@@ -187,18 +188,27 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
   extensions_whitelist_.clear();
   extensions_whitelist_.insert({
       "SPV_AMD_shader_explicit_vertex_parameter",
-      "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
-      "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
-      "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
-      "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage", "SPV_KHR_device_group",
-      "SPV_KHR_multiview", "SPV_NVX_multiview_per_view_attributes",
-      "SPV_NV_viewport_array2", "SPV_NV_stereo_view_rendering",
+      "SPV_AMD_shader_trinary_minmax",
+      "SPV_AMD_gcn_shader",
+      "SPV_KHR_shader_ballot",
+      "SPV_AMD_shader_ballot",
+      "SPV_AMD_gpu_shader_half_float",
+      "SPV_KHR_shader_draw_parameters",
+      "SPV_KHR_subgroup_vote",
+      "SPV_KHR_16bit_storage",
+      "SPV_KHR_device_group",
+      "SPV_KHR_multiview",
+      "SPV_NVX_multiview_per_view_attributes",
+      "SPV_NV_viewport_array2",
+      "SPV_NV_stereo_view_rendering",
       "SPV_NV_sample_mask_override_coverage",
-      "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+      "SPV_NV_geometry_shader_passthrough",
+      "SPV_AMD_texture_gather_bias_lod",
       "SPV_KHR_storage_buffer_storage_class",
       // SPV_KHR_variable_pointers
       //   Currently do not support extended pointer expressions
-      "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+      "SPV_AMD_gpu_shader_int16",
+      "SPV_KHR_post_depth_coverage",
       "SPV_KHR_shader_atomic_counter_ops",
   });
 }
index 4edf116..fa68788 100644 (file)
@@ -42,7 +42,7 @@ class LocalSingleBlockLoadStoreElimPass : public MemPass {
   ir::IRContext::Analysis GetPreservedAnalyses() override {
     return ir::IRContext::kAnalysisDefUse;
   }
-  
+
  private:
   // Return true if all uses of |varId| are only through supported reference
   // operations ie. loads and store. Also cache in supported_ref_ptrs_.
index b613f8a..c7bda38 100644 (file)
@@ -32,17 +32,18 @@ const uint32_t kStoreValIdInIdx = 1;
 bool LocalSingleStoreElimPass::HasOnlySupportedRefs(uint32_t ptrId) {
   if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end()) return true;
   bool hasOnlySupportedRefs = true;
-  get_def_use_mgr()->ForEachUser(ptrId, [this,&hasOnlySupportedRefs](ir::Instruction* user) {
-    SpvOp op = user->opcode();
-    if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
-      if (!HasOnlySupportedRefs(user->result_id())) {
-        hasOnlySupportedRefs = false;
-      }
-    } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
-               !IsNonTypeDecorate(op)) {
-      hasOnlySupportedRefs = false;
-    }
-  });
+  get_def_use_mgr()->ForEachUser(
+      ptrId, [this, &hasOnlySupportedRefs](ir::Instruction* user) {
+        SpvOp op = user->opcode();
+        if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) {
+          if (!HasOnlySupportedRefs(user->result_id())) {
+            hasOnlySupportedRefs = false;
+          }
+        } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
+                   !IsNonTypeDecorate(op)) {
+          hasOnlySupportedRefs = false;
+        }
+      });
   if (hasOnlySupportedRefs) {
     supported_ref_ptrs_.insert(ptrId);
   }
@@ -283,18 +284,27 @@ void LocalSingleStoreElimPass::InitExtensions() {
   extensions_whitelist_.clear();
   extensions_whitelist_.insert({
       "SPV_AMD_shader_explicit_vertex_parameter",
-      "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
-      "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
-      "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
-      "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage", "SPV_KHR_device_group",
-      "SPV_KHR_multiview", "SPV_NVX_multiview_per_view_attributes",
-      "SPV_NV_viewport_array2", "SPV_NV_stereo_view_rendering",
+      "SPV_AMD_shader_trinary_minmax",
+      "SPV_AMD_gcn_shader",
+      "SPV_KHR_shader_ballot",
+      "SPV_AMD_shader_ballot",
+      "SPV_AMD_gpu_shader_half_float",
+      "SPV_KHR_shader_draw_parameters",
+      "SPV_KHR_subgroup_vote",
+      "SPV_KHR_16bit_storage",
+      "SPV_KHR_device_group",
+      "SPV_KHR_multiview",
+      "SPV_NVX_multiview_per_view_attributes",
+      "SPV_NV_viewport_array2",
+      "SPV_NV_stereo_view_rendering",
       "SPV_NV_sample_mask_override_coverage",
-      "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+      "SPV_NV_geometry_shader_passthrough",
+      "SPV_AMD_texture_gather_bias_lod",
       "SPV_KHR_storage_buffer_storage_class",
       // SPV_KHR_variable_pointers
       //   Currently do not support extended pointer expressions
-      "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+      "SPV_AMD_gpu_shader_int16",
+      "SPV_KHR_post_depth_coverage",
       "SPV_KHR_shader_atomic_counter_ops",
   });
 }
index 1ecc867..80175f0 100644 (file)
@@ -40,7 +40,7 @@ class LocalSingleStoreElimPass : public MemPass {
   LocalSingleStoreElimPass();
   const char* name() const override { return "eliminate-local-single-store"; }
   Status Process(ir::IRContext* irContext) override;
-  
+
   ir::IRContext::Analysis GetPreservedAnalyses() override {
     return ir::IRContext::kAnalysisDefUse;
   }
index f0aaee7..02ee979 100644 (file)
@@ -96,18 +96,27 @@ void LocalMultiStoreElimPass::InitExtensions() {
   extensions_whitelist_.clear();
   extensions_whitelist_.insert({
       "SPV_AMD_shader_explicit_vertex_parameter",
-      "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
-      "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
-      "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
-      "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage", "SPV_KHR_device_group",
-      "SPV_KHR_multiview", "SPV_NVX_multiview_per_view_attributes",
-      "SPV_NV_viewport_array2", "SPV_NV_stereo_view_rendering",
+      "SPV_AMD_shader_trinary_minmax",
+      "SPV_AMD_gcn_shader",
+      "SPV_KHR_shader_ballot",
+      "SPV_AMD_shader_ballot",
+      "SPV_AMD_gpu_shader_half_float",
+      "SPV_KHR_shader_draw_parameters",
+      "SPV_KHR_subgroup_vote",
+      "SPV_KHR_16bit_storage",
+      "SPV_KHR_device_group",
+      "SPV_KHR_multiview",
+      "SPV_NVX_multiview_per_view_attributes",
+      "SPV_NV_viewport_array2",
+      "SPV_NV_stereo_view_rendering",
       "SPV_NV_sample_mask_override_coverage",
-      "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+      "SPV_NV_geometry_shader_passthrough",
+      "SPV_AMD_texture_gather_bias_lod",
       "SPV_KHR_storage_buffer_storage_class",
       // SPV_KHR_variable_pointers
       //   Currently do not support extended pointer expressions
-      "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+      "SPV_AMD_gpu_shader_int16",
+      "SPV_KHR_post_depth_coverage",
       "SPV_KHR_shader_atomic_counter_ops",
   });
 }
index 848cbb5..8062e0f 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "basic_block.h"
 #include "cfa.h"
-#include "iterator.h"
 #include "ir_context.h"
+#include "iterator.h"
 
 namespace spvtools {
 namespace opt {
@@ -119,24 +119,24 @@ ir::Instruction* MemPass::GetPtr(ir::Instruction* ip, uint32_t* varId) {
 
 bool MemPass::HasOnlyNamesAndDecorates(uint32_t id) const {
   bool hasOnlyNamesAndDecorates = true;
-  get_def_use_mgr()->ForEachUser(id, [this, &hasOnlyNamesAndDecorates](ir::Instruction* user) {
-    SpvOp op = user->opcode();
-    if (op != SpvOpName && !IsNonTypeDecorate(op)) {
-      hasOnlyNamesAndDecorates = false;
-    }
-  });
+  get_def_use_mgr()->ForEachUser(
+      id, [this, &hasOnlyNamesAndDecorates](ir::Instruction* user) {
+        SpvOp op = user->opcode();
+        if (op != SpvOpName && !IsNonTypeDecorate(op)) {
+          hasOnlyNamesAndDecorates = false;
+        }
+      });
   return hasOnlyNamesAndDecorates;
 }
 
 void MemPass::KillAllInsts(ir::BasicBlock* bp) {
-  bp->ForEachInst([this](ir::Instruction* ip) {
-    context()->KillInst(ip);
-  });
+  bp->ForEachInst([this](ir::Instruction* ip) { context()->KillInst(ip); });
 }
 
 bool MemPass::HasLoads(uint32_t varId) const {
   bool hasLoads = false;
-  get_def_use_mgr()->ForEachUser(varId, [this, &hasLoads](ir::Instruction* user) {
+  get_def_use_mgr()->ForEachUser(varId, [this,
+                                         &hasLoads](ir::Instruction* user) {
     SpvOp op = user->opcode();
     // TODO(): The following is slightly conservative. Could be
     // better handling of non-store/name.
@@ -173,7 +173,7 @@ bool MemPass::IsLiveStore(ir::Instruction* storeInst) {
 }
 
 void MemPass::AddStores(uint32_t ptr_id, std::queue<ir::Instruction*>* insts) {
-  get_def_use_mgr()->ForEachUser(ptr_id, [this,insts](ir::Instruction* user) {
+  get_def_use_mgr()->ForEachUser(ptr_id, [this, insts](ir::Instruction* user) {
     SpvOp op = user->opcode();
     if (IsNonPtrAccessChain(op)) {
       AddStores(user->result_id(), insts);
@@ -224,13 +224,14 @@ MemPass::MemPass() {}
 bool MemPass::HasOnlySupportedRefs(uint32_t varId) {
   if (supported_ref_vars_.find(varId) != supported_ref_vars_.end()) return true;
   bool hasOnlySupportedRefs = true;
-  get_def_use_mgr()->ForEachUser(varId, [this,&hasOnlySupportedRefs](ir::Instruction* user) {
-    SpvOp op = user->opcode();
-    if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
-        !IsNonTypeDecorate(op)) {
-      hasOnlySupportedRefs = false;
-    }
-  });
+  get_def_use_mgr()->ForEachUser(
+      varId, [this, &hasOnlySupportedRefs](ir::Instruction* user) {
+        SpvOp op = user->opcode();
+        if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName &&
+            !IsNonTypeDecorate(op)) {
+          hasOnlySupportedRefs = false;
+        }
+      });
   return hasOnlySupportedRefs;
 }
 
@@ -402,8 +403,8 @@ void MemPass::SSABlockInitLoopHeader(
           {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {predLabel}});
     }
     const uint32_t phiId = TakeNextId();
-    std::unique_ptr<ir::Instruction> newPhi(
-        new ir::Instruction(context(), SpvOpPhi, typeId, phiId, phi_in_operands));
+    std::unique_ptr<ir::Instruction> newPhi(new ir::Instruction(
+        context(), SpvOpPhi, typeId, phiId, phi_in_operands));
     // The only phis requiring patching are the ones we create.
     phis_to_patch_.insert(phiId);
     // Only analyze the phi define now; analyze the phi uses after the
@@ -470,8 +471,8 @@ void MemPass::SSABlockInitMultiPred(ir::BasicBlock* block_ptr) {
           {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {predLabel}});
     }
     const uint32_t phiId = TakeNextId();
-    std::unique_ptr<ir::Instruction> newPhi(
-        new ir::Instruction(context(), SpvOpPhi, typeId, phiId, phi_in_operands));
+    std::unique_ptr<ir::Instruction> newPhi(new ir::Instruction(
+        context(), SpvOpPhi, typeId, phiId, phi_in_operands));
     get_def_use_mgr()->AnalyzeInstDefUse(&*newPhi);
     insertItr = insertItr.InsertBefore(std::move(newPhi));
     ++insertItr;
@@ -699,7 +700,7 @@ void MemPass::RemovePhiOperands(
 
     // In all other cases, the operand must be kept but may need to be changed.
     uint32_t arg_id = phi->GetSingleWordOperand(i);
-    ir::Instruction *arg_def_instr = get_def_use_mgr()->GetDef(arg_id);
+    ir::Instructionarg_def_instr = get_def_use_mgr()->GetDef(arg_id);
     ir::BasicBlock* def_block = context()->get_instr_block(arg_def_instr);
     if (def_block &&
         reachable_blocks.find(def_block) == reachable_blocks.end()) {
@@ -794,8 +795,10 @@ bool MemPass::RemoveUnreachableBlocks(ir::Function* func) {
     // If the block is reachable and has Phi instructions, remove all
     // operands from its Phi instructions that reference unreachable blocks.
     // If the block has no Phi instructions, this is a no-op.
-    block.ForEachPhiInst([&block, &reachable_blocks, this](
-        ir::Instruction* phi) { RemovePhiOperands(phi, reachable_blocks); });
+    block.ForEachPhiInst(
+        [&block, &reachable_blocks, this](ir::Instruction* phi) {
+          RemovePhiOperands(phi, reachable_blocks);
+        });
   }
 
   // Erase unreachable blocks.
index 3a6e17e..da5f910 100644 (file)
 #include "inline_opaque_pass.h"
 #include "insert_extract_elim.h"
 #include "local_access_chain_convert_pass.h"
+#include "local_redundancy_elimination.h"
 #include "local_single_block_elim_pass.h"
 #include "local_single_store_elim_pass.h"
 #include "local_ssa_elim_pass.h"
+#include "merge_return_pass.h"
 #include "null_pass.h"
 #include "set_spec_constant_default_value_pass.h"
 #include "strength_reduction_pass.h"
 #include "strip_debug_info_pass.h"
 #include "unify_const_pass.h"
-#include "merge_return_pass.h"
-#include "local_redundancy_elimination.h"
 
 #endif  // LIBSPIRV_OPT_PASSES_H_
index ee6104d..168c322 100644 (file)
@@ -32,8 +32,8 @@ namespace opt {
 using ir::Instruction;
 using ir::Module;
 using ir::Operand;
-using opt::analysis::DefUseManager;
 using opt::analysis::DecorationManager;
+using opt::analysis::DefUseManager;
 
 Pass::Status RemoveDuplicatesPass::Process(ir::IRContext* irContext) {
   bool modified = RemoveDuplicateCapabilities(irContext);
@@ -92,7 +92,8 @@ bool RemoveDuplicatesPass::RemoveDuplicatesExtInstImports(
   return modified;
 }
 
-bool RemoveDuplicatesPass::RemoveDuplicateTypes(ir::IRContext* irContext) const {
+bool RemoveDuplicatesPass::RemoveDuplicateTypes(
+    ir::IRContext* irContext) const {
   bool modified = false;
 
   std::vector<Instruction> visitedTypes;
@@ -109,7 +110,8 @@ bool RemoveDuplicatesPass::RemoveDuplicateTypes(ir::IRContext* irContext) const
     // Is the current type equal to one of the types we have aready visited?
     SpvId idToKeep = 0u;
     for (auto j : visitedTypes) {
-      if (AreTypesEqual(*i, j, *irContext->get_def_use_mgr(), *irContext->get_decoration_mgr())) {
+      if (AreTypesEqual(*i, j, *irContext->get_def_use_mgr(),
+                        *irContext->get_decoration_mgr())) {
         idToKeep = j.result_id();
         break;
       }
index a8f3e03..3ec786f 100644 (file)
@@ -32,10 +32,10 @@ namespace spvtools {
 namespace opt {
 
 namespace {
-using spvutils::NumberType;
 using spvutils::EncodeNumberStatus;
-using spvutils::ParseNumber;
+using spvutils::NumberType;
 using spvutils::ParseAndEncodeNumber;
+using spvutils::ParseNumber;
 
 // Given a numeric value in a null-terminated c string and the expected type of
 // the value, parses the string and encodes it in a vector of words. If the
@@ -137,11 +137,12 @@ ir::Instruction* GetSpecIdTargetFromDecorationGroup(
   // the first OpGroupDecoration instruction that uses the given decoration
   // group.
   ir::Instruction* group_decorate_inst = nullptr;
-  def_use_mgr->ForEachUser(&decoration_group_defining_inst, [&group_decorate_inst](ir::Instruction* user) {
-    if (user->opcode() == SpvOp::SpvOpGroupDecorate) {
-      group_decorate_inst = user;
-    }
-  });
+  def_use_mgr->ForEachUser(&decoration_group_defining_inst,
+                           [&group_decorate_inst](ir::Instruction* user) {
+                             if (user->opcode() == SpvOp::SpvOpGroupDecorate) {
+                               group_decorate_inst = user;
+                             }
+                           });
   if (!group_decorate_inst) return nullptr;
 
   // Scan through the target ids of the OpGroupDecorate instruction. There
@@ -184,7 +185,7 @@ ir::Instruction* GetSpecIdTargetFromDecorationGroup(
   }
   return target_inst;
 }
-};
+};  // namespace
 
 Pass::Status SetSpecConstantDefaultValuePass::Process(
     ir::IRContext* irContext) {
index 28da788..75118a3 100644 (file)
@@ -100,8 +100,8 @@ bool StrengthReductionPass::ReplaceMultiplyByPowerOf2(
                                  {shiftConstResultId});
         newOperands.push_back(shiftOperand);
         std::unique_ptr<ir::Instruction> newInstruction(
-            new ir::Instruction(context(), SpvOp::SpvOpShiftLeftLogical, inst->type_id(),
-                                newResultId, newOperands));
+            new ir::Instruction(context(), SpvOp::SpvOpShiftLeftLogical,
+                                inst->type_id(), newResultId, newOperands));
 
         // Insert the new instruction and update the data structures.
         inst = inst.InsertBefore(std::move(newInstruction));
@@ -160,8 +160,9 @@ uint32_t StrengthReductionPass::GetConstantId(uint32_t val) {
     uint32_t resultId = TakeNextId();
     ir::Operand constant(spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER,
                          {val});
-    std::unique_ptr<ir::Instruction> newConstant(new ir::Instruction(
-        context(), SpvOp::SpvOpConstant, uint32_type_id_, resultId, {constant}));
+    std::unique_ptr<ir::Instruction> newConstant(
+        new ir::Instruction(context(), SpvOp::SpvOpConstant, uint32_type_id_,
+                            resultId, {constant}));
     get_module()->AddGlobalValue(std::move(newConstant));
 
     // Notify the DefUseManager about this constant.
index 088e102..ace53de 100644 (file)
@@ -168,5 +168,5 @@ Pass::Status UnifyConstantPass::Process(ir::IRContext* c) {
   return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange;
 }
 
-}  // opt
+}  // namespace opt
 }  // namespace spvtools
index 8df2297..d4dabf2 100644 (file)
@@ -92,7 +92,8 @@ bool ComputeSameValue::operator()(const ir::Instruction& lhs,
     }
   }
 
-  return lhs.context()->get_decoration_mgr()->HaveTheSameDecorations(lhs.result_id(), rhs.result_id());
+  return lhs.context()->get_decoration_mgr()->HaveTheSameDecorations(
+      lhs.result_id(), rhs.result_id());
 }
 
 std::size_t ValueTableHash::operator()(
index 40bfe6c..e49b51b 100644 (file)
@@ -255,5 +255,5 @@ class AssemblyContext {
   uint32_t next_id_;
   std::set<uint32_t> ids_to_preserve_;
 };
-}
+}  // namespace libspirv
 #endif  // _LIBSPIRV_TEXT_HANDLER_H_
index 5ec905d..bb87b3d 100644 (file)
@@ -50,7 +50,7 @@ class ErrorMsgStream {
   // destructor is called.
   std::string* error_msg_sink_;
 };
-}
+}  // namespace
 
 EncodeNumberStatus ParseAndEncodeIntegerNumber(
     const char* text, const NumberType& type,
index 70b2eec..f42d624 100644 (file)
@@ -221,6 +221,6 @@ bool operator==(const BasicBlock::DominatorIterator& lhs,
 bool operator!=(const BasicBlock::DominatorIterator& lhs,
                 const BasicBlock::DominatorIterator& rhs);
 
-}  /// namespace libspirv
+}  // namespace libspirv
 
 #endif  /// LIBSPIRV_VAL_BASICBLOCK_H_
index e3ad7f0..c5f01df 100644 (file)
@@ -64,4 +64,4 @@ const BasicBlock* Construct::exit_block() const { return exit_block_; }
 BasicBlock* Construct::exit_block() { return exit_block_; }
 
 void Construct::set_exit(BasicBlock* block) { exit_block_ = block; }
-}  /// namespace libspirv
+}  // namespace libspirv
index bca87d6..594d8d1 100644 (file)
@@ -127,6 +127,6 @@ class Construct {
   BasicBlock* exit_block_;
 };
 
-}  /// namespace libspirv
+}  // namespace libspirv
 
 #endif  /// LIBSPIRV_VAL_CONSTRUCT_H_
index d77b068..ce74990 100644 (file)
@@ -18,6 +18,8 @@
 #include <unordered_map>
 #include <vector>
 
+#include "spirv/1.2/spirv.h"
+
 namespace libspirv {
 
 // An object of this class represents a specific decoration including its
index d7ac741..f67acc4 100644 (file)
@@ -356,8 +356,7 @@ bool Function::IsCompatibleWithExecutionModel(SpvExecutionModel model,
 
   for (const auto& kv : execution_model_limitations_) {
     if (kv.first != model) {
-      if (!reason)
-        return false;
+      if (!reason) return false;
       is_compatible = false;
       ss_reason << kv.second << "\n";
     }
@@ -370,4 +369,4 @@ bool Function::IsCompatibleWithExecutionModel(SpvExecutionModel model,
   return is_compatible;
 }
 
-}  /// namespace libspirv
+}  // namespace libspirv
index 4d53b04..eb23201 100644 (file)
@@ -346,6 +346,6 @@ class Function {
   std::set<uint32_t> function_call_targets_;
 };
 
-}  /// namespace libspirv
+}  // namespace libspirv
 
 #endif  /// LIBSPIRV_VAL_FUNCTION_H_
index 5ae89e2..9613632 100644 (file)
@@ -121,6 +121,6 @@ struct hash<libspirv::Instruction> {
     return hash<uint32_t>()(inst.id());
   }
 };
-}  /// namespace std
+}  // namespace std
 
 #endif  // LIBSPIRV_VAL_INSTRUCTION_H_
index 02b3646..4e8db28 100644 (file)
@@ -266,8 +266,7 @@ const Function& ValidationState_t::current_function() const {
 
 const Function* ValidationState_t::function(uint32_t id) const {
   const auto it = id_to_function_.find(id);
-  if (it == id_to_function_.end())
-    return nullptr;
+  if (it == id_to_function_.end()) return nullptr;
   return it->second;
 }
 
@@ -740,8 +739,7 @@ bool ValidationState_t::GetConstantValUint64(uint32_t id, uint64_t* val) const {
   if (inst->opcode() != SpvOpConstant && inst->opcode() != SpvOpSpecConstant)
     return false;
 
-  if (!IsIntScalarType(inst->type_id()))
-    return false;
+  if (!IsIntScalarType(inst->type_id())) return false;
 
   if (inst->words().size() == 4) {
     *val = inst->word(3);
index d57eac7..48bc3be 100644 (file)
@@ -505,6 +505,6 @@ class ValidationState_t {
   std::unordered_map<uint32_t, Function*> id_to_function_;
 };
 
-}  /// namespace libspirv
+}  // namespace libspirv
 
 #endif  /// LIBSPIRV_VAL_VALIDATIONSTATE_H_
index 741364a..7c786fe 100644 (file)
 
 using std::function;
 using std::ostream_iterator;
-using std::placeholders::_1;
 using std::string;
 using std::stringstream;
 using std::transform;
 using std::vector;
+using std::placeholders::_1;
 
 using libspirv::CfgPass;
+using libspirv::DataRulesPass;
 using libspirv::Extension;
+using libspirv::IdPass;
 using libspirv::InstructionPass;
 using libspirv::ModuleLayoutPass;
-using libspirv::DataRulesPass;
-using libspirv::IdPass;
 using libspirv::ValidationState_t;
 
 spv_result_t spvValidateIDs(const spv_instruction_t* pInsts,
index 42399fc..783dbf4 100644 (file)
@@ -42,7 +42,7 @@ inline uint32_t GetOperandTypeId(ValidationState_t& _,
                                  size_t operand_index) {
   return _.GetTypeId(GetOperandWord(inst, operand_index));
 }
-}
+}  // namespace
 
 // Validates correctness of arithmetic instructions.
 spv_result_t ArithmeticsPass(ValidationState_t& _,
index e717138..94978d9 100644 (file)
@@ -42,7 +42,7 @@ inline uint32_t GetOperandTypeId(ValidationState_t& _,
                                  size_t operand_index) {
   return _.GetTypeId(GetOperandWord(inst, operand_index));
 }
-}
+}  // namespace
 
 // Validates correctness of bitwise instructions.
 spv_result_t BitwisePass(ValidationState_t& _,
index 7987d45..299f027 100644 (file)
@@ -25,7 +25,7 @@ namespace libspirv {
 
 // Validates correctness of derivative instructions.
 spv_result_t DerivativesPass(ValidationState_t& _,
-                          const spv_parsed_instruction_t* inst) {
+                             const spv_parsed_instruction_t* inst) {
   const SpvOp opcode = static_cast<SpvOp>(inst->opcode);
   const uint32_t result_type = inst->type_id;
 
index e936ea6..08fe7a4 100644 (file)
@@ -694,9 +694,8 @@ bool idUsage::isValid<SpvOpConstantComposite>(const spv_instruction_t* inst,
       for (size_t constituentIndex = 3; constituentIndex < inst->words.size();
            constituentIndex++) {
         auto constituent = module_.FindDef(inst->words[constituentIndex]);
-        if (!constituent ||
-            !(SpvOpConstantComposite == constituent->opcode() ||
-              SpvOpUndef == constituent->opcode())) {
+        if (!constituent || !(SpvOpConstantComposite == constituent->opcode() ||
+                              SpvOpUndef == constituent->opcode())) {
           // The message says "... or undef" because the spec does not say
           // undef is a constant.
           DIAG(constituentIndex) << "OpConstantComposite Constituent <id> '"
@@ -924,8 +923,9 @@ bool idUsage::isValid<SpvOpSampledImage>(const spv_instruction_t* inst,
             << "All OpSampledImage instructions must be in the same block in "
                "which their Result <id> are consumed. OpSampledImage Result "
                "Type <id> '"
-            << resultID << "' has a consumer in a different basic "
-                           "block. The consumer instruction <id> is '"
+            << resultID
+            << "' has a consumer in a different basic "
+               "block. The consumer instruction <id> is '"
             << consumer_id << "'.";
         return false;
       }
@@ -1023,10 +1023,9 @@ bool idUsage::isValid<SpvOpSpecConstantComposite>(const spv_instruction_t* inst,
            constituentIndex++) {
         auto constituent = module_.FindDef(inst->words[constituentIndex]);
         auto constituentOpCode = constituent->opcode();
-        if (!constituent ||
-            !(SpvOpSpecConstantComposite == constituentOpCode ||
-              SpvOpConstantComposite == constituentOpCode ||
-              SpvOpUndef == constituentOpCode)) {
+        if (!constituent || !(SpvOpSpecConstantComposite == constituentOpCode ||
+                              SpvOpConstantComposite == constituentOpCode ||
+                              SpvOpUndef == constituentOpCode)) {
           // The message says "... or undef" because the spec does not say
           // undef is a constant.
           DIAG(constituentIndex) << "OpSpecConstantComposite Constituent <id> '"
@@ -1524,8 +1523,9 @@ bool idUsage::isValid<SpvOpAccessChain>(const spv_instruction_t* inst,
       }
       default: {
         // Give an error. reached non-composite type while indexes still remain.
-        DIAG(i) << instr_name << " reached non-composite type while indexes "
-                                 "still remain to be traversed.";
+        DIAG(i) << instr_name
+                << " reached non-composite type while indexes "
+                   "still remain to be traversed.";
         return false;
       }
     }
@@ -1744,8 +1744,9 @@ bool idUsage::isValid<SpvOpVectorShuffle>(const spv_instruction_t* inst,
   auto resultVectorDimension = resultType->words()[vectorComponentCountIndex];
   if (componentCount != resultVectorDimension) {
     DIAG(inst->words.size() - 1)
-        << instr_name() << " component literals count does not match "
-                           "Result Type <id> '"
+        << instr_name()
+        << " component literals count does not match "
+           "Result Type <id> '"
         << resultType->id() << "'s vector component count.";
     return false;
   }
@@ -1858,8 +1859,9 @@ bool walkCompositeTypeHierarchy(
       }
       default: {
         // Give an error. reached non-composite type while indexes still remain.
-        *error << instr_name() << " reached non-composite type while indexes "
-                                  "still remain to be traversed.";
+        *error << instr_name()
+               << " reached non-composite type while indexes "
+                  "still remain to be traversed.";
         return false;
       }
     }
@@ -1986,8 +1988,9 @@ bool idUsage::isValid<SpvOpCompositeInsert>(const spv_instruction_t* inst,
     DIAG(objectIdIndex)
         << "The Object type (Op"
         << spvOpcodeString(static_cast<SpvOp>(objectTypeInstr->opcode()))
-        << ") in " << instr_name() << " does not match the type that results "
-                                      "from indexing into the Composite (Op"
+        << ") in " << instr_name()
+        << " does not match the type that results "
+           "from indexing into the Composite (Op"
         << spvOpcodeString(static_cast<SpvOp>(indexedTypeInstr->opcode()))
         << ").";
     return false;
index c2eef22..6d9913c 100644 (file)
@@ -83,8 +83,7 @@ struct ImageTypeInfo {
 // (not a valid id, failed to parse the instruction, etc).
 bool GetImageTypeInfo(const ValidationState_t& _, uint32_t id,
                       ImageTypeInfo* info) {
-  if (!id || !info)
-    return false;
+  if (!id || !info) return false;
 
   const Instruction* inst = _.FindDef(id);
   assert(inst);
@@ -94,12 +93,10 @@ bool GetImageTypeInfo(const ValidationState_t& _, uint32_t id,
     assert(inst);
   }
 
-  if (inst->opcode() != SpvOpTypeImage)
-    return false;
+  if (inst->opcode() != SpvOpTypeImage) return false;
 
   const size_t num_words = inst->words().size();
-  if (num_words != 9 && num_words != 10)
-    return false;
+  if (num_words != 9 && num_words != 10) return false;
 
   info->sampled_type = inst->word(2);
   info->dim = static_cast<SpvDim>(inst->word(3));
@@ -108,8 +105,9 @@ bool GetImageTypeInfo(const ValidationState_t& _, uint32_t id,
   info->multisampled = inst->word(6);
   info->sampled = inst->word(7);
   info->format = static_cast<SpvImageFormat>(inst->word(8));
-  info->access_qualifier = num_words < 10 ? SpvAccessQualifierMax :
-      static_cast<SpvAccessQualifier>(inst->word(9));
+  info->access_qualifier = num_words < 10
+                               ? SpvAccessQualifierMax
+                               : static_cast<SpvAccessQualifier>(inst->word(9));
   return true;
 }
 
@@ -209,8 +207,8 @@ uint32_t GetMinCoordSize(SpvOp opcode, const ImageTypeInfo& info) {
 // Checks ImageOperand bitfield and respective operands.
 spv_result_t ValidateImageOperands(ValidationState_t& _,
                                    const spv_parsed_instruction_t& inst,
-                                   const ImageTypeInfo& info,
-                                   uint32_t mask, uint32_t word_index) {
+                                   const ImageTypeInfo& info, uint32_t mask,
+                                   uint32_t word_index) {
   static const bool kAllImageOperandsHandled = CheckAllImageOperandsHandled();
   (void)kAllImageOperandsHandled;
 
@@ -225,16 +223,16 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
 
   if (expected_num_image_operand_words != num_words - word_index) {
     return _.diag(SPV_ERROR_INVALID_DATA)
-        << "Number of image operand ids doesn't correspond to the bit mask: "
-        << spvOpcodeString(opcode);
+           << "Number of image operand ids doesn't correspond to the bit mask: "
+           << spvOpcodeString(opcode);
   }
 
   if (CountSetBits(mask & (SpvImageOperandsOffsetMask |
                            SpvImageOperandsConstOffsetMask |
                            SpvImageOperandsConstOffsetsMask)) > 1) {
     return _.diag(SPV_ERROR_INVALID_DATA)
-        << "Image Operands Offset, ConstOffset, ConstOffsets cannot be used "
-        << "together: " << spvOpcodeString(opcode);
+           << "Image Operands Offset, ConstOffset, ConstOffsets cannot be used "
+           << "together: " << spvOpcodeString(opcode);
   };
 
   const bool is_implicit_lod = IsImplicitLod(opcode);
@@ -244,29 +242,30 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
 
   if (mask & SpvImageOperandsBiasMask) {
     if (!is_implicit_lod) {
-        return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image Operand Bias can only be used with ImplicitLod opcodes: "
-            << spvOpcodeString(opcode);
+      return _.diag(SPV_ERROR_INVALID_DATA)
+             << "Image Operand Bias can only be used with ImplicitLod opcodes: "
+             << spvOpcodeString(opcode);
     };
 
     const uint32_t type_id = _.GetTypeId(inst.words[word_index++]);
     if (!_.IsFloatScalarType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Bias to be float scalar: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Bias to be float scalar: "
+             << spvOpcodeString(opcode);
     }
 
     if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D &&
         info.dim != SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Bias requires 'Dim' parameter to be 1D, 2D, 3D or "
-          << "Cube: " << spvOpcodeString(opcode);
+             << "Image Operand Bias requires 'Dim' parameter to be 1D, 2D, 3D "
+                "or "
+             << "Cube: " << spvOpcodeString(opcode);
     }
 
     if (info.multisampled != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Bias requires 'MS' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Operand Bias requires 'MS' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
   }
 
@@ -274,15 +273,16 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
     // TODO(atgoo@github.com) Check which opcodes are allowed to use this
     // ImageOperand.
     if (is_implicit_lod) {
-        return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image Operand Lod cannot be used with ImplicitLod opcodes: "
-            << spvOpcodeString(opcode);
+      return _.diag(SPV_ERROR_INVALID_DATA)
+             << "Image Operand Lod cannot be used with ImplicitLod opcodes: "
+             << spvOpcodeString(opcode);
     };
 
     if (mask & SpvImageOperandsGradMask) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand bits Lod and Grad cannot be set at the same time: "
-          << spvOpcodeString(opcode);
+             << "Image Operand bits Lod and Grad cannot be set at the same "
+                "time: "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t type_id = _.GetTypeId(inst.words[word_index++]);
@@ -290,29 +290,30 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
     // with ints. The spec is unclear.
     if (!_.IsFloatScalarType(type_id) && !_.IsIntScalarType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Lod to be int or float scalar: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Lod to be int or float scalar: "
+             << spvOpcodeString(opcode);
     }
 
     if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D &&
         info.dim != SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Lod requires 'Dim' parameter to be 1D, 2D, 3D or "
-          << "Cube: " << spvOpcodeString(opcode);
+             << "Image Operand Lod requires 'Dim' parameter to be 1D, 2D, 3D "
+                "or "
+             << "Cube: " << spvOpcodeString(opcode);
     }
 
     if (info.multisampled != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Lod requires 'MS' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Operand Lod requires 'MS' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
   }
 
   if (mask & SpvImageOperandsGradMask) {
     if (!is_explicit_lod) {
-        return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image Operand Grad can only be used with ExplicitLod opcodes: "
-            << spvOpcodeString(opcode);
+      return _.diag(SPV_ERROR_INVALID_DATA)
+             << "Image Operand Grad can only be used with ExplicitLod opcodes: "
+             << spvOpcodeString(opcode);
     };
 
     const uint32_t dx_type_id = _.GetTypeId(inst.words[word_index++]);
@@ -320,8 +321,8 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
     if (!_.IsFloatScalarOrVectorType(dx_type_id) ||
         !_.IsFloatScalarOrVectorType(dy_type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected both Image Operand Grad ids to be float scalars or "
-          << "vectors: " << spvOpcodeString(opcode);
+             << "Expected both Image Operand Grad ids to be float scalars or "
+             << "vectors: " << spvOpcodeString(opcode);
     }
 
     const uint32_t plane_size = GetPlaneCoordSize(info);
@@ -329,92 +330,95 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
     const uint32_t dy_size = _.GetDimension(dy_type_id);
     if (plane_size != dx_size) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Grad dx to have " << plane_size
-          << " components, but given " << dx_size << ": "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Grad dx to have " << plane_size
+             << " components, but given " << dx_size << ": "
+             << spvOpcodeString(opcode);
     }
 
     if (plane_size != dy_size) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Grad dy to have " << plane_size
-          << " components, but given " << dy_size << ": "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Grad dy to have " << plane_size
+             << " components, but given " << dy_size << ": "
+             << spvOpcodeString(opcode);
     }
 
     if (info.multisampled != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Grad requires 'MS' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Operand Grad requires 'MS' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
   }
 
   if (mask & SpvImageOperandsConstOffsetMask) {
     if (info.dim == SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand ConstOffset cannot be used with Cube Image 'Dim': "
-          << spvOpcodeString(opcode);
+             << "Image Operand ConstOffset cannot be used with Cube Image "
+                "'Dim': "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t id = inst.words[word_index++];
     const uint32_t type_id = _.GetTypeId(id);
     if (!_.IsIntScalarOrVectorType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffset to be int scalar or "
-          << "vector: " << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffset to be int scalar or "
+             << "vector: " << spvOpcodeString(opcode);
     }
 
     if (!spvOpcodeIsConstant(_.GetIdOpcode(id))) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffset to be a const object: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffset to be a const object: "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t plane_size = GetPlaneCoordSize(info);
     const uint32_t offset_size = _.GetDimension(type_id);
     if (plane_size != offset_size) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffset to have " << plane_size
-          << " components, but given " << offset_size << ": "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffset to have " << plane_size
+             << " components, but given " << offset_size << ": "
+             << spvOpcodeString(opcode);
     }
   }
 
   if (mask & SpvImageOperandsOffsetMask) {
     if (info.dim == SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Offset cannot be used with Cube Image 'Dim': "
-          << spvOpcodeString(opcode);
+             << "Image Operand Offset cannot be used with Cube Image 'Dim': "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t id = inst.words[word_index++];
     const uint32_t type_id = _.GetTypeId(id);
     if (!_.IsIntScalarOrVectorType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Offset to be int scalar or "
-          << "vector: " << spvOpcodeString(opcode);
+             << "Expected Image Operand Offset to be int scalar or "
+             << "vector: " << spvOpcodeString(opcode);
     }
 
     const uint32_t plane_size = GetPlaneCoordSize(info);
     const uint32_t offset_size = _.GetDimension(type_id);
     if (plane_size != offset_size) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Offset to have " << plane_size
-          << " components, but given " << offset_size << ": "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Offset to have " << plane_size
+             << " components, but given " << offset_size << ": "
+             << spvOpcodeString(opcode);
     }
   }
 
   if (mask & SpvImageOperandsConstOffsetsMask) {
     if (opcode != SpvOpImageGather && opcode != SpvOpImageDrefGather) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand ConstOffsets can only be used with OpImageGather "
-          << "and OpImageDrefGather: " << spvOpcodeString(opcode);
+             << "Image Operand ConstOffsets can only be used with "
+                "OpImageGather "
+             << "and OpImageDrefGather: " << spvOpcodeString(opcode);
     }
 
     if (info.dim == SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand ConstOffsets cannot be used with Cube Image 'Dim': "
-          << spvOpcodeString(opcode);
+             << "Image Operand ConstOffsets cannot be used with Cube Image "
+                "'Dim': "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t id = inst.words[word_index++];
@@ -424,8 +428,8 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
 
     if (type_inst->opcode() != SpvOpTypeArray) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffsets to be an array of size 4: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffsets to be an array of size 4: "
+             << spvOpcodeString(opcode);
     }
 
     uint64_t array_size = 0;
@@ -435,22 +439,23 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
 
     if (array_size != 4) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffsets to be an array of size 4: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffsets to be an array of size 4: "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t component_type = type_inst->word(2);
     if (!_.IsIntVectorType(component_type) ||
         _.GetDimension(component_type) != 2) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffsets array componenets to be int "
-          << "vectors of size 2: " << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffsets array componenets to be "
+                "int "
+             << "vectors of size 2: " << spvOpcodeString(opcode);
     }
 
     if (!spvOpcodeIsConstant(_.GetIdOpcode(id))) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand ConstOffsets to be a const object: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand ConstOffsets to be a const object: "
+             << spvOpcodeString(opcode);
     }
   }
 
@@ -458,50 +463,51 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
     if (opcode != SpvOpImageFetch && opcode != SpvOpImageRead &&
         opcode != SpvOpImageWrite) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Sample can only be used with OpImageFetch, "
-          << "OpImageRead and OpImageWrite: " << spvOpcodeString(opcode);
+             << "Image Operand Sample can only be used with OpImageFetch, "
+             << "OpImageRead and OpImageWrite: " << spvOpcodeString(opcode);
     }
 
     if (info.multisampled == 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand Sample requires non-zero 'MS' parameter: "
-          << spvOpcodeString(opcode);
+             << "Image Operand Sample requires non-zero 'MS' parameter: "
+             << spvOpcodeString(opcode);
     }
 
     const uint32_t type_id = _.GetTypeId(inst.words[word_index++]);
     if (!_.IsIntScalarType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand Sample to be int scalar: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand Sample to be int scalar: "
+             << spvOpcodeString(opcode);
     }
   }
 
   if (mask & SpvImageOperandsMinLodMask) {
     if (!is_implicit_lod && !(mask & SpvImageOperandsGradMask)) {
-        return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image Operand MinLod can only be used with ImplicitLod "
-            << "opcodes or together with Image Operand Grad: "
-            << spvOpcodeString(opcode);
+      return _.diag(SPV_ERROR_INVALID_DATA)
+             << "Image Operand MinLod can only be used with ImplicitLod "
+             << "opcodes or together with Image Operand Grad: "
+             << spvOpcodeString(opcode);
     };
 
     const uint32_t type_id = _.GetTypeId(inst.words[word_index++]);
     if (!_.IsFloatScalarType(type_id)) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image Operand MinLod to be float scalar: "
-          << spvOpcodeString(opcode);
+             << "Expected Image Operand MinLod to be float scalar: "
+             << spvOpcodeString(opcode);
     }
 
     if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D &&
         info.dim != SpvDimCube) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand MinLod requires 'Dim' parameter to be 1D, 2D, 3D "
-          << "or Cube: " << spvOpcodeString(opcode);
+             << "Image Operand MinLod requires 'Dim' parameter to be 1D, 2D, "
+                "3D "
+             << "or Cube: " << spvOpcodeString(opcode);
     }
 
     if (info.multisampled != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Operand MinLod requires 'MS' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Operand MinLod requires 'MS' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
   }
 
@@ -514,23 +520,23 @@ spv_result_t ValidateImageCommon(ValidationState_t& _,
                                  const ImageTypeInfo& info) {
   const SpvOp opcode = static_cast<SpvOp>(inst.opcode);
   if (IsProj(opcode)) {
-    if (info.dim != SpvDim1D && info.dim != SpvDim2D &&
-        info.dim != SpvDim3D && info.dim != SpvDimRect) {
+    if (info.dim != SpvDim1D && info.dim != SpvDim2D && info.dim != SpvDim3D &&
+        info.dim != SpvDimRect) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image 'Dim' parameter to be 1D, 2D, 3D or Rect: "
-          << spvOpcodeString(opcode);
+             << "Expected Image 'Dim' parameter to be 1D, 2D, 3D or Rect: "
+             << spvOpcodeString(opcode);
     }
 
     if (info.multisampled != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Image 'MS' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Image 'MS' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
 
     if (info.arrayed != 0) {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Image Image 'arrayed' parameter to be 0: "
-          << spvOpcodeString(opcode);
+             << "Image Image 'arrayed' parameter to be 0: "
+             << spvOpcodeString(opcode);
     }
   }
 
@@ -539,23 +545,23 @@ spv_result_t ValidateImageCommon(ValidationState_t& _,
     } else if (info.sampled == 2) {
       if (info.dim == SpvDim1D && !_.HasCapability(SpvCapabilityImage1D)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability Image1D is required to access storage image: "
-            << spvOpcodeString(opcode);
+               << "Capability Image1D is required to access storage image: "
+               << spvOpcodeString(opcode);
       } else if (info.dim == SpvDimRect &&
                  !_.HasCapability(SpvCapabilityImageRect)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability ImageRect is required to access storage image: "
-            << spvOpcodeString(opcode);
+               << "Capability ImageRect is required to access storage image: "
+               << spvOpcodeString(opcode);
       } else if (info.dim == SpvDimBuffer &&
                  !_.HasCapability(SpvCapabilityImageBuffer)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability ImageBuffer is required to access storage image: "
-            << spvOpcodeString(opcode);
+               << "Capability ImageBuffer is required to access storage image: "
+               << spvOpcodeString(opcode);
       } else if (info.dim == SpvDimCube && info.arrayed == 1 &&
                  !_.HasCapability(SpvCapabilityImageCubeArray)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability ImageCubeArray is required to access storage "
-            << "image: " << spvOpcodeString(opcode);
+               << "Capability ImageCubeArray is required to access storage "
+               << "image: " << spvOpcodeString(opcode);
       }
 
       if (info.multisampled == 1 &&
@@ -571,8 +577,8 @@ spv_result_t ValidateImageCommon(ValidationState_t& _,
       }
     } else {
       return _.diag(SPV_ERROR_INVALID_DATA)
-          << "Expected Image 'Sampled' parameter to be 0 or 2: "
-          << spvOpcodeString(opcode);
+             << "Expected Image 'Sampled' parameter to be 0 or 2: "
+             << spvOpcodeString(opcode);
     }
   }
 
@@ -597,21 +603,21 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpSampledImage: {
       if (_.GetIdOpcode(result_type) != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be OpTypeSampledImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be OpTypeSampledImage: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       // TODO(atgoo@github.com) Check compatibility of result type and received
@@ -619,20 +625,20 @@ spv_result_t ImagePass(ValidationState_t& _,
 
       if (info.sampled != 0 && info.sampled != 1) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image 'Sampled' parameter to be 0 or 1: "
-            << spvOpcodeString(opcode);
+               << "Expected Image 'Sampled' parameter to be 0 or 1: "
+               << spvOpcodeString(opcode);
       }
 
       if (info.dim == SpvDimSubpassData) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image 'Dim' parameter to be not SubpassData: "
-            << spvOpcodeString(opcode);
+               << "Expected Image 'Dim' parameter to be not SubpassData: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetIdOpcode(_.GetOperandTypeId(inst, 3)) != SpvOpTypeSampler) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sampler to be of type OpTypeSampler: "
-            << spvOpcodeString(opcode);
+               << "Expected Sampler to be of type OpTypeSampler: "
+               << spvOpcodeString(opcode);
       }
 
       break;
@@ -645,27 +651,27 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntVectorType(result_type) &&
           !_.IsFloatVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int or float vector type: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetDimension(result_type) != 4) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to have 4 components: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to have 4 components: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sampled Image to be of type OpTypeSampledImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Sampled Image to be of type OpTypeSampledImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (spv_result_t result = ValidateImageCommon(_, *inst, info))
@@ -675,8 +681,9 @@ spv_result_t ImagePass(ValidationState_t& _,
         const uint32_t result_component_type = _.GetComponentType(result_type);
         if (result_component_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Image 'Sampled Type' to be the same as Result Type "
-              << "components: " << spvOpcodeString(opcode);
+                 << "Expected Image 'Sampled Type' to be the same as Result "
+                    "Type "
+                 << "components: " << spvOpcodeString(opcode);
         }
       }
 
@@ -686,14 +693,14 @@ spv_result_t ImagePass(ValidationState_t& _,
         if (!_.IsFloatScalarOrVectorType(coord_type) &&
             !_.IsIntScalarOrVectorType(coord_type)) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Coordinate to be int or float scalar or vector: "
-              << spvOpcodeString(opcode);
+                 << "Expected Coordinate to be int or float scalar or vector: "
+                 << spvOpcodeString(opcode);
         }
       } else {
         if (!_.IsFloatScalarOrVectorType(coord_type)) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Coordinate to be float scalar or vector: "
-              << spvOpcodeString(opcode);
+                 << "Expected Coordinate to be float scalar or vector: "
+                 << spvOpcodeString(opcode);
         }
       }
 
@@ -701,9 +708,9 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
       if (inst->num_words <= 5) {
@@ -712,8 +719,8 @@ spv_result_t ImagePass(ValidationState_t& _,
       }
 
       const uint32_t mask = inst->words[5];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 6))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 6))
         return result;
 
       break;
@@ -726,21 +733,21 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntScalarType(result_type) &&
           !_.IsFloatScalarType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float scalar type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int or float scalar type: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sampled Image to be of type OpTypeSampledImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Sampled Image to be of type OpTypeSampledImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (spv_result_t result = ValidateImageCommon(_, *inst, info))
@@ -748,42 +755,42 @@ spv_result_t ImagePass(ValidationState_t& _,
 
       if (result_type != info.sampled_type) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image 'Sampled Type' to be the same as Result Type: "
-            << spvOpcodeString(opcode);
+               << "Expected Image 'Sampled Type' to be the same as Result "
+                  "Type: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t coord_type = _.GetOperandTypeId(inst, 3);
       if (!_.IsFloatScalarOrVectorType(coord_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to be float scalar or vector: "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to be float scalar or vector: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t min_coord_size = GetMinCoordSize(opcode, info);
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t dref_type = _.GetOperandTypeId(inst, 4);
       if (dref_type != info.sampled_type) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Dref to be of Image 'Sampled Type': "
-            << spvOpcodeString(opcode);
+               << "Expected Dref to be of Image 'Sampled Type': "
+               << spvOpcodeString(opcode);
       }
 
-
       if (inst->num_words <= 6) {
         assert(IsImplicitLod(opcode));
         break;
       }
 
       const uint32_t mask = inst->words[6];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 7))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 7))
         return result;
 
       break;
@@ -793,72 +800,71 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntVectorType(result_type) &&
           !_.IsFloatVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int or float vector type: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetDimension(result_type) != 4) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to have 4 components: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to have 4 components: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (_.GetIdOpcode(info.sampled_type) != SpvOpTypeVoid) {
         const uint32_t result_component_type = _.GetComponentType(result_type);
         if (result_component_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Image 'Sampled Type' to be the same as Result Type "
-              << "components: " << spvOpcodeString(opcode);
+                 << "Expected Image 'Sampled Type' to be the same as Result "
+                    "Type "
+                 << "components: " << spvOpcodeString(opcode);
         }
       }
 
       if (info.dim == SpvDimCube) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image 'Dim' cannot be Cube: "
-            << spvOpcodeString(opcode);
+               << "Image 'Dim' cannot be Cube: " << spvOpcodeString(opcode);
       }
 
       if (info.sampled != 1) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image 'Sampled' parameter to be 1: "
-            << spvOpcodeString(opcode);
+               << "Expected Image 'Sampled' parameter to be 1: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t coord_type = _.GetOperandTypeId(inst, 3);
       if (!_.IsIntScalarOrVectorType(coord_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to be int scalar or vector: "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to be int scalar or vector: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t min_coord_size = GetMinCoordSize(opcode, info);
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
-      if (inst->num_words <= 5)
-        break;
+      if (inst->num_words <= 5) break;
 
       const uint32_t mask = inst->words[5];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 6))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 6))
         return result;
 
       break;
@@ -869,27 +875,27 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntVectorType(result_type) &&
           !_.IsFloatVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int or float vector type: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetDimension(result_type) != 4) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to have 4 components: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to have 4 components: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sampled Image to be of type OpTypeSampledImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Sampled Image to be of type OpTypeSampledImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (opcode == SpvOpImageDrefGather ||
@@ -897,57 +903,57 @@ spv_result_t ImagePass(ValidationState_t& _,
         const uint32_t result_component_type = _.GetComponentType(result_type);
         if (result_component_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Image 'Sampled Type' to be the same as Result Type "
-              << "components: " << spvOpcodeString(opcode);
+                 << "Expected Image 'Sampled Type' to be the same as Result "
+                    "Type "
+                 << "components: " << spvOpcodeString(opcode);
         }
       }
 
       if (info.dim != SpvDim2D && info.dim != SpvDimCube &&
           info.dim != SpvDimRect) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image 'Dim' cannot be Cube: "
-            << spvOpcodeString(opcode);
+               << "Expected Image 'Dim' cannot be Cube: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t coord_type = _.GetOperandTypeId(inst, 3);
       if (!_.IsFloatScalarOrVectorType(coord_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to be float scalar or vector: "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to be float scalar or vector: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t min_coord_size = GetMinCoordSize(opcode, info);
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
       if (opcode == SpvOpImageGather) {
         const uint32_t component_index_type = _.GetOperandTypeId(inst, 4);
         if (!_.IsIntScalarType(component_index_type)) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Component to be int scalar: "
-              << spvOpcodeString(opcode);
+                 << "Expected Component to be int scalar: "
+                 << spvOpcodeString(opcode);
         }
       } else {
         assert(opcode == SpvOpImageDrefGather);
         const uint32_t dref_type = _.GetOperandTypeId(inst, 4);
         if (dref_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Dref to be of Image 'Sampled Type': "
-              << spvOpcodeString(opcode);
+                 << "Expected Dref to be of Image 'Sampled Type': "
+                 << spvOpcodeString(opcode);
         }
       }
 
-      if (inst->num_words <= 6)
-        break;
+      if (inst->num_words <= 6) break;
 
       const uint32_t mask = inst->words[6];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 7))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 7))
         return result;
 
       break;
@@ -957,8 +963,9 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntScalarOrVectorType(result_type) &&
           !_.IsFloatScalarOrVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int or float scalar or vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int or float scalar or vector "
+                  "type: "
+               << spvOpcodeString(opcode);
       }
 
 #if 0
@@ -973,22 +980,23 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (_.GetIdOpcode(info.sampled_type) != SpvOpTypeVoid) {
         const uint32_t result_component_type = _.GetComponentType(result_type);
         if (result_component_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Image 'Sampled Type' to be the same as Result Type "
-              << "components: " << spvOpcodeString(opcode);
+                 << "Expected Image 'Sampled Type' to be the same as Result "
+                    "Type "
+                 << "components: " << spvOpcodeString(opcode);
         }
       }
 
@@ -998,33 +1006,33 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t coord_type = _.GetOperandTypeId(inst, 3);
       if (!_.IsIntScalarOrVectorType(coord_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to be int scalar or vector: "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to be int scalar or vector: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t min_coord_size = GetMinCoordSize(opcode, info);
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
       if (info.format == SpvImageFormatUnknown &&
           info.dim != SpvDimSubpassData &&
           !_.HasCapability(SpvCapabilityStorageImageReadWithoutFormat)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability StorageImageReadWithoutFormat is required to read "
-            << "storage image: " << spvOpcodeString(opcode);
+               << "Capability StorageImageReadWithoutFormat is required to "
+                  "read "
+               << "storage image: " << spvOpcodeString(opcode);
       }
 
-      if (inst->num_words <= 5)
-        break;
+      if (inst->num_words <= 5) break;
 
       const uint32_t mask = inst->words[5];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 6))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 6))
         return result;
 
       break;
@@ -1034,19 +1042,20 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t image_type = _.GetOperandTypeId(inst, 0);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (info.dim == SpvDimSubpassData) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image 'Dim' cannot be SubpassData: " << spvOpcodeString(opcode);
+               << "Image 'Dim' cannot be SubpassData: "
+               << spvOpcodeString(opcode);
       }
 
       if (spv_result_t result = ValidateImageCommon(_, *inst, info))
@@ -1055,17 +1064,17 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t coord_type = _.GetOperandTypeId(inst, 1);
       if (!_.IsIntScalarOrVectorType(coord_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to be int scalar or vector: "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to be int scalar or vector: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t min_coord_size = GetMinCoordSize(opcode, info);
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
 
       // TODO(atgoo@github.com) The spec doesn't explicitely say what the type
@@ -1074,8 +1083,8 @@ spv_result_t ImagePass(ValidationState_t& _,
       if (!_.IsIntScalarOrVectorType(texel_type) &&
           !_.IsFloatScalarOrVectorType(texel_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Texel to be int or float vector or scalar: "
-            << spvOpcodeString(opcode);
+               << "Expected Texel to be int or float vector or scalar: "
+               << spvOpcodeString(opcode);
       }
 
 #if 0
@@ -1091,8 +1100,8 @@ spv_result_t ImagePass(ValidationState_t& _,
         const uint32_t texel_component_type = _.GetComponentType(texel_type);
         if (texel_component_type != info.sampled_type) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Image 'Sampled Type' to be the same as Texel "
-              << "components: " << spvOpcodeString(opcode);
+                 << "Expected Image 'Sampled Type' to be the same as Texel "
+                 << "components: " << spvOpcodeString(opcode);
         }
       }
 
@@ -1100,16 +1109,16 @@ spv_result_t ImagePass(ValidationState_t& _,
           info.dim != SpvDimSubpassData &&
           !_.HasCapability(SpvCapabilityStorageImageWriteWithoutFormat)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Capability StorageImageWriteWithoutFormat is required to write "
-            << "to storage image: " << spvOpcodeString(opcode);
+               << "Capability StorageImageWriteWithoutFormat is required to "
+                  "write "
+               << "to storage image: " << spvOpcodeString(opcode);
       }
 
-      if (inst->num_words <= 4)
-        break;
+      if (inst->num_words <= 4) break;
 
       const uint32_t mask = inst->words[4];
-      if (spv_result_t result = ValidateImageOperands(
-          _, *inst, info, mask, /* word_index = */ 5))
+      if (spv_result_t result =
+              ValidateImageOperands(_, *inst, info, mask, /* word_index = */ 5))
         return result;
 
       break;
@@ -1118,8 +1127,8 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpImage: {
       if (_.GetIdOpcode(result_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t sampled_image_type = _.GetOperandTypeId(inst, 2);
@@ -1129,14 +1138,15 @@ spv_result_t ImagePass(ValidationState_t& _,
 
       if (sampled_image_type_inst->opcode() != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sample Image to be of type OpTypeSampleImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Sample Image to be of type OpTypeSampleImage: "
+               << spvOpcodeString(opcode);
       }
 
       if (sampled_image_type_inst->word(2) != result_type) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Sample Image image type to be equal to Result Type: "
-            << spvOpcodeString(opcode);
+               << "Expected Sample Image image type to be equal to Result "
+                  "Type: "
+               << spvOpcodeString(opcode);
       }
 
       break;
@@ -1146,14 +1156,14 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpImageQueryOrder: {
       if (!_.IsIntScalarType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int scalar type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int scalar type: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetIdOpcode(_.GetOperandTypeId(inst, 2)) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected operand to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected operand to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
       break;
     }
@@ -1161,21 +1171,21 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpImageQuerySizeLod: {
       if (!_.IsIntScalarOrVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int scalar or vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int scalar or vector type: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       uint32_t expected_num_components = info.arrayed;
@@ -1192,28 +1202,28 @@ spv_result_t ImagePass(ValidationState_t& _,
           break;
         default:
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
-              << spvOpcodeString(opcode);
+                 << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
+                 << spvOpcodeString(opcode);
       };
 
       if (info.multisampled != 0) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image 'MS' must be 0: " << spvOpcodeString(opcode);
+               << "Image 'MS' must be 0: " << spvOpcodeString(opcode);
       }
 
       uint32_t result_num_components = _.GetDimension(result_type);
       if (result_num_components != expected_num_components) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Result Type has " << result_num_components << " components, "
-            << "but " << expected_num_components << " expected: "
-            << spvOpcodeString(opcode);
+               << "Result Type has " << result_num_components << " components, "
+               << "but " << expected_num_components
+               << " expected: " << spvOpcodeString(opcode);
       }
 
       const uint32_t lod_type = _.GetOperandTypeId(inst, 3);
       if (!_.IsIntScalarType(lod_type) && !_.IsFloatScalarType(lod_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Level of Detail to be int or float scalar: "
-            << spvOpcodeString(opcode);
+               << "Expected Level of Detail to be int or float scalar: "
+               << spvOpcodeString(opcode);
       }
 
       break;
@@ -1222,15 +1232,15 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpImageQuerySize: {
       if (!_.IsIntScalarOrVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int scalar or vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int scalar or vector type: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
 #if 0
@@ -1296,34 +1306,34 @@ spv_result_t ImagePass(ValidationState_t& _,
 
       if (!_.IsFloatVectorType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be float vector type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be float vector type: "
+               << spvOpcodeString(opcode);
       }
 
       if (_.GetDimension(result_type) != 2) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to have 2 components: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to have 2 components: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeSampledImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image operand to be of type OpTypeSampledImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image operand to be of type OpTypeSampledImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
-      if (info.dim != SpvDim1D && info.dim != SpvDim2D
-          && info.dim != SpvDim3D && info.dim != SpvDimCube) {
+      if (info.dim != SpvDim1D && info.dim != SpvDim2D &&
+          info.dim != SpvDim3D && info.dim != SpvDimCube) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
-            << spvOpcodeString(opcode);
+               << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t coord_type = _.GetOperandTypeId(inst, 3);
@@ -1331,14 +1341,14 @@ spv_result_t ImagePass(ValidationState_t& _,
         if (!_.IsFloatScalarOrVectorType(coord_type) &&
             !_.IsIntScalarOrVectorType(coord_type)) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Coordinate to be int or float scalar or vector: "
-              << spvOpcodeString(opcode);
+                 << "Expected Coordinate to be int or float scalar or vector: "
+                 << spvOpcodeString(opcode);
         }
       } else {
         if (!_.IsFloatScalarOrVectorType(coord_type)) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Expected Coordinate to be float scalar or vector: "
-              << spvOpcodeString(opcode);
+                 << "Expected Coordinate to be float scalar or vector: "
+                 << spvOpcodeString(opcode);
         }
       }
 
@@ -1346,9 +1356,9 @@ spv_result_t ImagePass(ValidationState_t& _,
       const uint32_t actual_coord_size = _.GetDimension(coord_type);
       if (min_coord_size > actual_coord_size) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Coordinate to have at least " << min_coord_size
-            << " components, but given only " << actual_coord_size << ": "
-            << spvOpcodeString(opcode);
+               << "Expected Coordinate to have at least " << min_coord_size
+               << " components, but given only " << actual_coord_size << ": "
+               << spvOpcodeString(opcode);
       }
       break;
     }
@@ -1357,40 +1367,40 @@ spv_result_t ImagePass(ValidationState_t& _,
     case SpvOpImageQuerySamples: {
       if (!_.IsIntScalarType(result_type)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Result Type to be int scalar type: "
-            << spvOpcodeString(opcode);
+               << "Expected Result Type to be int scalar type: "
+               << spvOpcodeString(opcode);
       }
 
       const uint32_t image_type = _.GetOperandTypeId(inst, 2);
       if (_.GetIdOpcode(image_type) != SpvOpTypeImage) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Expected Image to be of type OpTypeImage: "
-            << spvOpcodeString(opcode);
+               << "Expected Image to be of type OpTypeImage: "
+               << spvOpcodeString(opcode);
       }
 
       ImageTypeInfo info;
       if (!GetImageTypeInfo(_, image_type, &info)) {
         return _.diag(SPV_ERROR_INVALID_DATA)
-            << "Corrupt image type definition";
+               << "Corrupt image type definition";
       }
 
       if (opcode == SpvOpImageQueryLevels) {
-        if (info.dim != SpvDim1D && info.dim != SpvDim2D
-            && info.dim != SpvDim3D && info.dim != SpvDimCube) {
+        if (info.dim != SpvDim1D && info.dim != SpvDim2D &&
+            info.dim != SpvDim3D && info.dim != SpvDimCube) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
-              << spvOpcodeString(opcode);
+                 << "Image 'Dim' must be 1D, 2D, 3D or Cube: "
+                 << spvOpcodeString(opcode);
         }
       } else {
         assert(opcode == SpvOpImageQuerySamples);
         if (info.dim != SpvDim2D) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Image 'Dim' must be 2D: " << spvOpcodeString(opcode);
+                 << "Image 'Dim' must be 2D: " << spvOpcodeString(opcode);
         }
 
         if (info.multisampled != 1) {
           return _.diag(SPV_ERROR_INVALID_DATA)
-              << "Image 'MS' must be 1: " << spvOpcodeString(opcode);
+                 << "Image 'MS' must be 1: " << spvOpcodeString(opcode);
         }
       }
 
index 4718b91..37c49be 100644 (file)
 #include "val/function.h"
 #include "val/validation_state.h"
 
-using libspirv::ValidationState_t;
-using libspirv::kLayoutMemoryModel;
+using libspirv::FunctionDecl;
 using libspirv::kLayoutFunctionDeclarations;
 using libspirv::kLayoutFunctionDefinitions;
-using libspirv::FunctionDecl;
+using libspirv::kLayoutMemoryModel;
+using libspirv::ValidationState_t;
 
 namespace {
 // Module scoped instructions are processed by determining if the opcode
@@ -170,7 +170,7 @@ spv_result_t FunctionScopedInstructions(ValidationState_t& _,
   }
   return SPV_SUCCESS;
 }
-}  /// namespace
+}  // namespace
 
 namespace libspirv {
 // TODO(umar): Check linkage capabilities for function declarations
@@ -204,4 +204,4 @@ spv_result_t ModuleLayoutPass(ValidationState_t& _,
   }
   return SPV_SUCCESS;
 }
-}  /// namespace libspirv
+}  // namespace libspirv
index 766fd26..5a6c034 100644 (file)
@@ -42,7 +42,7 @@ inline uint32_t GetOperandTypeId(ValidationState_t& _,
                                  size_t operand_index) {
   return _.GetTypeId(GetOperandWord(inst, operand_index));
 }
-}
+}  // namespace
 
 // Validates correctness of logical instructions.
 spv_result_t LogicalsPass(ValidationState_t& _,
index 219a76a..65a40aa 100644 (file)
@@ -14,8 +14,8 @@
 
 #include "unit_spirv.h"
 
-#include <vector>
 #include <gmock/gmock.h>
+#include <vector>
 
 #include "source/instruction.h"
 
index d90e480..c979751 100644 (file)
 #include <string>
 #include <vector>
 
-#include "test_fixture.h"
-#include "unit_spirv.h"
 #include "gmock/gmock.h"
 #include "source/message.h"
 #include "source/table.h"
 #include "spirv/1.0/OpenCL.std.h"
+#include "test_fixture.h"
+#include "unit_spirv.h"
 
 // Returns true if two spv_parsed_operand_t values are equal.
 // To use this operator, this definition must appear in the same namespace
@@ -40,11 +40,11 @@ using ::spvtest::Concatenate;
 using ::spvtest::MakeInstruction;
 using ::spvtest::MakeVector;
 using ::spvtest::ScopedContext;
+using ::testing::_;
 using ::testing::AnyOf;
 using ::testing::Eq;
 using ::testing::InSequence;
 using ::testing::Return;
-using ::testing::_;
 
 // An easily-constructible and comparable object for the contents of an
 // spv_parsed_instruction_t.  Unlike spv_parsed_instruction_t, owns the memory
@@ -818,7 +818,8 @@ INSTANTIATE_TEST_CASE_P(
          }),
          "Type Id 2 is not a type"},
         {Concatenate({
-             ExpectedHeaderForBound(3), MakeInstruction(SpvOpTypeBool, {1}),
+             ExpectedHeaderForBound(3),
+             MakeInstruction(SpvOpTypeBool, {1}),
              MakeInstruction(SpvOpConstant, {1, 2, 42}),
          }),
          "Type Id 1 is not a scalar numeric type"},
index fcbf883..d7adae3 100644 (file)
 
 #include "gmock/gmock.h"
 
-#include "test_fixture.h"
 #include "source/spirv_constant.h"
+#include "test_fixture.h"
 
 namespace {
 
-using ::testing::Combine;
-using ::testing::Eq;
-using ::testing::HasSubstr;
 using spvtest::AutoText;
 using spvtest::ScopedContext;
 using spvtest::TextToBinaryTest;
 using std::get;
 using std::tuple;
+using ::testing::Combine;
+using ::testing::Eq;
+using ::testing::HasSubstr;
 
 class BinaryToText : public ::testing::Test {
  public:
@@ -278,7 +278,8 @@ INSTANTIATE_TEST_CASE_P(
             ::testing::ValuesIn(std::vector<std::string>{
                 "OpStore %1 %2\n",       // 3 words long.
                 "OpStore %1 %2 None\n",  // 4 words long, explicit final 0.
-                "OpStore %1 %2 Volatile\n", "OpStore %1 %2 Aligned 8\n",
+                "OpStore %1 %2 Volatile\n",
+                "OpStore %1 %2 Aligned 8\n",
                 "OpStore %1 %2 Nontemporal\n",
                 // Combinations show the names from LSB to MSB
                 "OpStore %1 %2 Volatile|Aligned 16\n",
@@ -304,15 +305,16 @@ INSTANTIATE_TEST_CASE_P(
             "OpDecorate %1 FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|Fast\n",
         })), );
 
-INSTANTIATE_TEST_CASE_P(
-    LoopControlMasks, RoundTripInstructionsTest,
-    Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                              SPV_ENV_UNIVERSAL_1_2),
-            ::testing::ValuesIn(std::vector<std::string>{
-                "OpLoopMerge %1 %2 None\n", "OpLoopMerge %1 %2 Unroll\n",
-                "OpLoopMerge %1 %2 DontUnroll\n",
-                "OpLoopMerge %1 %2 Unroll|DontUnroll\n",
-            })), );
+INSTANTIATE_TEST_CASE_P(LoopControlMasks, RoundTripInstructionsTest,
+                        Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0,
+                                                  SPV_ENV_UNIVERSAL_1_1,
+                                                  SPV_ENV_UNIVERSAL_1_2),
+                                ::testing::ValuesIn(std::vector<std::string>{
+                                    "OpLoopMerge %1 %2 None\n",
+                                    "OpLoopMerge %1 %2 Unroll\n",
+                                    "OpLoopMerge %1 %2 DontUnroll\n",
+                                    "OpLoopMerge %1 %2 Unroll|DontUnroll\n",
+                                })), );
 
 INSTANTIATE_TEST_CASE_P(LoopControlMasksV11, RoundTripInstructionsTest,
                         Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_1,
@@ -322,28 +324,30 @@ INSTANTIATE_TEST_CASE_P(LoopControlMasksV11, RoundTripInstructionsTest,
                                     "OpLoopMerge %1 %2 DependencyLength 8\n",
                                 })), );
 
-INSTANTIATE_TEST_CASE_P(
-    SelectionControlMasks, RoundTripInstructionsTest,
-    Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                              SPV_ENV_UNIVERSAL_1_2),
-            ::testing::ValuesIn(std::vector<std::string>{
-                "OpSelectionMerge %1 None\n", "OpSelectionMerge %1 Flatten\n",
-                "OpSelectionMerge %1 DontFlatten\n",
-                "OpSelectionMerge %1 Flatten|DontFlatten\n",
-            })), );
+INSTANTIATE_TEST_CASE_P(SelectionControlMasks, RoundTripInstructionsTest,
+                        Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0,
+                                                  SPV_ENV_UNIVERSAL_1_1,
+                                                  SPV_ENV_UNIVERSAL_1_2),
+                                ::testing::ValuesIn(std::vector<std::string>{
+                                    "OpSelectionMerge %1 None\n",
+                                    "OpSelectionMerge %1 Flatten\n",
+                                    "OpSelectionMerge %1 DontFlatten\n",
+                                    "OpSelectionMerge %1 Flatten|DontFlatten\n",
+                                })), );
 
-INSTANTIATE_TEST_CASE_P(
-    FunctionControlMasks, RoundTripInstructionsTest,
-    Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                              SPV_ENV_UNIVERSAL_1_2),
-            ::testing::ValuesIn(std::vector<std::string>{
-                "%2 = OpFunction %1 None %3\n",
-                "%2 = OpFunction %1 Inline %3\n",
-                "%2 = OpFunction %1 DontInline %3\n",
-                "%2 = OpFunction %1 Pure %3\n", "%2 = OpFunction %1 Const %3\n",
-                "%2 = OpFunction %1 Inline|Pure|Const %3\n",
-                "%2 = OpFunction %1 DontInline|Const %3\n",
-            })), );
+INSTANTIATE_TEST_CASE_P(FunctionControlMasks, RoundTripInstructionsTest,
+                        Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0,
+                                                  SPV_ENV_UNIVERSAL_1_1,
+                                                  SPV_ENV_UNIVERSAL_1_2),
+                                ::testing::ValuesIn(std::vector<std::string>{
+                                    "%2 = OpFunction %1 None %3\n",
+                                    "%2 = OpFunction %1 Inline %3\n",
+                                    "%2 = OpFunction %1 DontInline %3\n",
+                                    "%2 = OpFunction %1 Pure %3\n",
+                                    "%2 = OpFunction %1 Const %3\n",
+                                    "%2 = OpFunction %1 Inline|Pure|Const %3\n",
+                                    "%2 = OpFunction %1 DontInline|Const %3\n",
+                                })), );
 
 INSTANTIATE_TEST_CASE_P(
     ImageMasks, RoundTripInstructionsTest,
@@ -530,8 +534,7 @@ INSTANTIATE_TEST_CASE_P(GeneratorStrings, GeneratorStringTest,
                             {SPV_GENERATOR_KHRONOS, 12, "Khronos; 12"},
                             {SPV_GENERATOR_LUNARG, 99, "LunarG; 99"},
                             {SPV_GENERATOR_VALVE, 1, "Valve; 1"},
-                            {SPV_GENERATOR_CODEPLAY, 65535,
-                             "Codeplay; 65535"},
+                            {SPV_GENERATOR_CODEPLAY, 65535, "Codeplay; 65535"},
                             {SPV_GENERATOR_NVIDIA, 19, "NVIDIA; 19"},
                             {SPV_GENERATOR_ARM, 1000, "ARM; 1000"},
                             {SPV_GENERATOR_KHRONOS_LLVM_TRANSLATOR, 38,
index dfc6d18..d30a79f 100644 (file)
 
 namespace {
 
-using spvutils::BitWriterInterface;
 using spvutils::BitReaderInterface;
-using spvutils::BitWriterWord64;
 using spvutils::BitReaderWord64;
-using spvutils::StreamToBuffer;
-using spvutils::BufferToStream;
-using spvutils::NumBitsToNumWords;
-using spvutils::PadToWord;
-using spvutils::StreamToBitset;
 using spvutils::BitsetToStream;
 using spvutils::BitsToStream;
-using spvutils::StreamToBits;
-using spvutils::GetLowerBits;
-using spvutils::EncodeZigZag;
+using spvutils::BitWriterInterface;
+using spvutils::BitWriterWord64;
+using spvutils::BufferToStream;
 using spvutils::DecodeZigZag;
+using spvutils::EncodeZigZag;
+using spvutils::GetLowerBits;
 using spvutils::Log2U64;
+using spvutils::NumBitsToNumWords;
+using spvutils::PadToWord;
+using spvutils::StreamToBits;
+using spvutils::StreamToBitset;
+using spvutils::StreamToBuffer;
 
 // A simple and inefficient implementatition of BitWriterInterface,
 // using std::stringstream. Intended for tests only.
 class BitWriterStringStream : public BitWriterInterface {
  public:
-  void WriteStream(const std::string& bits) override {
-    ss_ << bits;
-  }
+  void WriteStream(const std::string& bits) override { ss_ << bits; }
 
   void WriteBits(uint64_t bits, size_t num_bits) override {
     assert(num_bits <= 64);
     ss_ << BitsToStream(bits, num_bits);
   }
 
-  size_t GetNumBits() const override {
-    return ss_.str().size();
-  }
+  size_t GetNumBits() const override { return ss_.str().size(); }
 
   std::vector<uint8_t> GetDataCopy() const override {
     return StreamToBuffer<uint8_t>(ss_.str());
   }
 
-  std::string GetStreamRaw() const {
-    return ss_.str();
-  }
+  std::string GetStreamRaw() const { return ss_.str(); }
 
  private:
   std::stringstream ss_;
@@ -81,25 +75,18 @@ class BitReaderFromString : public BitReaderInterface {
       : str_(PadToWord<64>(BufferToStream(buffer))), pos_(0) {}
 
   size_t ReadBits(uint64_t* bits, size_t num_bits) override {
-    if (ReachedEnd())
-      return 0;
+    if (ReachedEnd()) return 0;
     std::string sub = str_.substr(pos_, num_bits);
     *bits = StreamToBits(sub);
     pos_ += sub.length();
     return sub.length();
   }
 
-  size_t GetNumReadBits() const override {
-    return pos_;
-  }
+  size_t GetNumReadBits() const override { return pos_; }
 
-  bool ReachedEnd() const override {
-    return pos_ >= str_.length();
-  }
+  bool ReachedEnd() const override { return pos_ >= str_.length(); }
 
-  const std::string& GetStreamPadded64() const {
-    return str_;
-  }
+  const std::string& GetStreamPadded64() const { return str_; }
 
  private:
   std::string str_;
@@ -325,7 +312,7 @@ TEST(ZigZagCoding, Encode63) {
   EXPECT_EQ(0u, EncodeZigZag(0, 63));
 
   for (int64_t i = 0; i < 0xFFFFFFFF; i += 1234567) {
-    const int64_t positive_val = GetLowerBits(i * i  * i + i * i, 63) | 1UL;
+    const int64_t positive_val = GetLowerBits(i * i * i + i * i, 63) | 1UL;
     ASSERT_EQ(static_cast<uint64_t>(positive_val),
               EncodeZigZag(positive_val, 63));
     ASSERT_EQ((1ULL << 63) - 1 + positive_val, EncodeZigZag(-positive_val, 63));
@@ -350,24 +337,27 @@ TEST(BufToStream, UInt8_Empty) {
 TEST(BufToStream, UInt8_OneWord) {
   const std::string expected_bits = "00101100";
   std::vector<uint8_t> buffer = StreamToBuffer<uint8_t>(expected_bits);
-  EXPECT_EQ(
-      std::vector<uint8_t>(
-          {static_cast<uint8_t>(StreamToBitset<8>(expected_bits).to_ulong())}),
-      buffer);
+  EXPECT_EQ(std::vector<uint8_t>({static_cast<uint8_t>(
+                StreamToBitset<8>(expected_bits).to_ulong())}),
+            buffer);
   const std::string result_bits = BufferToStream(buffer);
   EXPECT_EQ(expected_bits, result_bits);
 }
 
 TEST(BufToStream, UInt8_MultipleWords) {
-  const std::string expected_bits = "00100010""01101010""01111101""00100010";
+  const std::string expected_bits =
+      "00100010"
+      "01101010"
+      "01111101"
+      "00100010";
   std::vector<uint8_t> buffer = StreamToBuffer<uint8_t>(expected_bits);
-  EXPECT_EQ(
-      std::vector<uint8_t>({
-            static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
-            static_cast<uint8_t>(StreamToBitset<8>("01101010").to_ulong()),
-            static_cast<uint8_t>(StreamToBitset<8>("01111101").to_ulong()),
-            static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
-      }), buffer);
+  EXPECT_EQ(std::vector<uint8_t>({
+                static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
+                static_cast<uint8_t>(StreamToBitset<8>("01101010").to_ulong()),
+                static_cast<uint8_t>(StreamToBitset<8>("01111101").to_ulong()),
+                static_cast<uint8_t>(StreamToBitset<8>("00100010").to_ulong()),
+            }),
+            buffer);
   const std::string result_bits = BufferToStream(buffer);
   EXPECT_EQ(expected_bits, result_bits);
 }
@@ -396,9 +386,10 @@ TEST(BufToStream, UInt64_Unaligned) {
       "0010001001101010011111111111111111111111";
   std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
   EXPECT_EQ(std::vector<uint64_t>({
-    StreamToBits(expected_bits.substr(0, 64)),
-    StreamToBits(expected_bits.substr(64, 64)),
-  }), buffer);
+                StreamToBits(expected_bits.substr(0, 64)),
+                StreamToBits(expected_bits.substr(64, 64)),
+            }),
+            buffer);
   const std::string result_bits = BufferToStream(buffer);
   EXPECT_EQ(PadToWord<64>(expected_bits), result_bits);
 }
@@ -410,22 +401,37 @@ TEST(BufToStream, UInt64_MultipleWords) {
       "0000000000000000000000000000000000000000000000000010010011111111";
   std::vector<uint64_t> buffer = StreamToBuffer<uint64_t>(expected_bits);
   EXPECT_EQ(std::vector<uint64_t>({
-    StreamToBits(expected_bits.substr(0, 64)),
-    StreamToBits(expected_bits.substr(64, 64)),
-    StreamToBits(expected_bits.substr(128, 64)),
-  }), buffer);
+                StreamToBits(expected_bits.substr(0, 64)),
+                StreamToBits(expected_bits.substr(64, 64)),
+                StreamToBits(expected_bits.substr(128, 64)),
+            }),
+            buffer);
   const std::string result_bits = BufferToStream(buffer);
   EXPECT_EQ(expected_bits, result_bits);
 }
 
 TEST(PadToWord, Test) {
   EXPECT_EQ("10100000", PadToWord<8>("101"));
-  EXPECT_EQ("10100000""00000000", PadToWord<16>("101"));
-  EXPECT_EQ("10100000""00000000""00000000""00000000",
-            PadToWord<32>("101"));
-  EXPECT_EQ("10100000""00000000""00000000""00000000"
-            "00000000""00000000""00000000""00000000",
-            PadToWord<64>("101"));
+  EXPECT_EQ(
+      "10100000"
+      "00000000",
+      PadToWord<16>("101"));
+  EXPECT_EQ(
+      "10100000"
+      "00000000"
+      "00000000"
+      "00000000",
+      PadToWord<32>("101"));
+  EXPECT_EQ(
+      "10100000"
+      "00000000"
+      "00000000"
+      "00000000"
+      "00000000"
+      "00000000"
+      "00000000"
+      "00000000",
+      PadToWord<64>("101"));
 }
 
 TEST(BitWriterStringStream, Empty) {
@@ -578,10 +584,12 @@ TEST(BitWriterWord64, WriteZeroBits) {
   writer.WriteBits(0, 0);
   writer.WriteBits(7, 3);
   writer.WriteBits(0, 0);
-  EXPECT_EQ(PadToWord<64>(
+  EXPECT_EQ(
+      PadToWord<64>(
           "1"
           "000000000000000000000000000000000000000000000000000000000000000"
-          "111"), writer.GetStreamPadded64());
+          "111"),
+      writer.GetStreamPadded64());
 }
 
 TEST(BitWriterWord64, ComparisonTestWriteLotsOfBits) {
@@ -594,8 +602,7 @@ TEST(BitWriterWord64, ComparisonTestWriteLotsOfBits) {
     ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
   }
 
-  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
-            writer2.GetStreamPadded64());
+  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()), writer2.GetStreamPadded64());
 }
 
 TEST(BitWriterWord64, ComparisonTestWriteLotsOfStreams) {
@@ -604,19 +611,15 @@ TEST(BitWriterWord64, ComparisonTestWriteLotsOfStreams) {
 
   for (int i = 0; i < 1000; ++i) {
     std::string bits = "1111100000";
-    if (i % 2)
-      bits += "101010";
-    if (i % 3)
-      bits += "1110100";
-    if (i % 5)
-      bits += "1110100111111111111";
+    if (i % 2) bits += "101010";
+    if (i % 3) bits += "1110100";
+    if (i % 5) bits += "1110100111111111111";
     writer1.WriteStream(bits);
     writer2.WriteStream(bits);
     ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
   }
 
-  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
-            writer2.GetStreamPadded64());
+  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()), writer2.GetStreamPadded64());
 }
 
 TEST(BitWriterWord64, ComparisonTestWriteLotsOfBitsets) {
@@ -633,8 +636,7 @@ TEST(BitWriterWord64, ComparisonTestWriteLotsOfBitsets) {
     ASSERT_EQ(writer1.GetNumBits(), writer2.GetNumBits());
   }
 
-  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()),
-            writer2.GetStreamPadded64());
+  EXPECT_EQ(PadToWord<64>(writer1.GetStreamRaw()), writer2.GetStreamPadded64());
 }
 
 TEST(GetLowerBits, Test) {
@@ -654,17 +656,22 @@ TEST(GetLowerBits, Test) {
   EXPECT_EQ(0xFFFFFFFFFFFFFFFFu,
             GetLowerBits<uint64_t>(0xFFFFFFFFFFFFFFFFu, 64));
   EXPECT_EQ(StreamToBits("1010001110"),
-            GetLowerBits<uint64_t>(
-                StreamToBits("1010001110111101111111"), 10));
+            GetLowerBits<uint64_t>(StreamToBits("1010001110111101111111"), 10));
 }
 
 TEST(BitReaderFromString, FromU8) {
   std::vector<uint8_t> buffer = {
-    0xAA, 0xBB, 0xCC, 0xDD,
+      0xAA,
+      0xBB,
+      0xCC,
+      0xDD,
   };
 
   const std::string total_stream =
-      "01010101""11011101""00110011""10111011";
+      "01010101"
+      "11011101"
+      "00110011"
+      "10111011";
 
   BitReaderFromString reader(buffer);
   EXPECT_EQ(PadToWord<64>(total_stream), reader.GetStreamPadded64());
@@ -683,10 +690,10 @@ TEST(BitReaderFromString, FromU8) {
 
 TEST(BitReaderFromString, FromU64) {
   std::vector<uint64_t> buffer = {
-    0xAAAAAAAAAAAAAAAA,
-    0xBBBBBBBBBBBBBBBB,
-    0xCCCCCCCCCCCCCCCC,
-    0xDDDDDDDDDDDDDDDD,
+      0xAAAAAAAAAAAAAAAA,
+      0xBBBBBBBBBBBBBBBB,
+      0xCCCCCCCCCCCCCCCC,
+      0xDDDDDDDDDDDDDDDD,
   };
 
   const std::string total_stream =
@@ -769,10 +776,7 @@ TEST(BitReaderWord64, ReadStreamEmpty) {
 }
 
 TEST(BitReaderWord64, ReadBitsTwoWords) {
-  std::vector<uint64_t> buffer = {
-    0x0000000000000001,
-    0x0000000000FFFFFF
-  };
+  std::vector<uint64_t> buffer = {0x0000000000000001, 0x0000000000FFFFFF};
 
   BitReaderWord64 reader(std::move(buffer));
 
@@ -820,7 +824,10 @@ TEST(BitReaderFromString, ReadUnencodedS64) {
 
 TEST(BitReaderWord64, FromU8) {
   std::vector<uint8_t> buffer = {
-    0xAA, 0xBB, 0xCC, 0xDD,
+      0xAA,
+      0xBB,
+      0xCC,
+      0xDD,
   };
 
   BitReaderWord64 reader(std::move(buffer));
@@ -839,10 +846,10 @@ TEST(BitReaderWord64, FromU8) {
 
 TEST(BitReaderWord64, FromU64) {
   std::vector<uint64_t> buffer = {
-    0xAAAAAAAAAAAAAAAA,
-    0xBBBBBBBBBBBBBBBB,
-    0xCCCCCCCCCCCCCCCC,
-    0xDDDDDDDDDDDDDDDD,
+      0xAAAAAAAAAAAAAAAA,
+      0xBBBBBBBBBBBBBBBB,
+      0xCCCCCCCCCCCCCCCC,
+      0xDDDDDDDDDDDDDDDD,
   };
 
   const std::string total_stream =
@@ -867,7 +874,7 @@ TEST(BitReaderWord64, FromU64) {
 
 TEST(BitReaderWord64, ComparisonLotsOfU8) {
   std::vector<uint8_t> buffer;
-  for(uint32_t i = 0; i < 10003; ++i) {
+  for (uint32_t i = 0; i < 10003; ++i) {
     buffer.push_back(static_cast<uint8_t>(i % 255));
   }
 
@@ -887,7 +894,7 @@ TEST(BitReaderWord64, ComparisonLotsOfU8) {
 
 TEST(BitReaderWord64, ComparisonLotsOfU64) {
   std::vector<uint64_t> buffer;
-  for(uint64_t i = 0; i < 1000; ++i) {
+  for (uint64_t i = 0; i < 1000; ++i) {
     buffer.push_back(i);
   }
 
@@ -928,126 +935,238 @@ TEST(ReadWriteWord64, ReadWriteLotsOfBits) {
 TEST(VariableWidthWrite, Write0U) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU64(0, 2);
-  EXPECT_EQ("000", writer.GetStreamRaw ());
+  EXPECT_EQ("000", writer.GetStreamRaw());
   writer.WriteVariableWidthU32(0, 2);
-  EXPECT_EQ("000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthU16(0, 2);
-  EXPECT_EQ("000""000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000"
+      "000",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthU8(0, 2);
-  EXPECT_EQ("000""000""000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000"
+      "000"
+      "000",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, Write0S) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthS64(0, 2, 0);
-  EXPECT_EQ("000", writer.GetStreamRaw ());
+  EXPECT_EQ("000", writer.GetStreamRaw());
   writer.WriteVariableWidthS32(0, 2, 0);
-  EXPECT_EQ("000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthS16(0, 2, 0);
-  EXPECT_EQ("000""000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000"
+      "000",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthS8(0, 2, 0);
-  EXPECT_EQ("000""000""000""000", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "000"
+      "000"
+      "000"
+      "000",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, WriteSmallUnsigned) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU64(1, 2);
-  EXPECT_EQ("100", writer.GetStreamRaw ());
+  EXPECT_EQ("100", writer.GetStreamRaw());
   writer.WriteVariableWidthU32(2, 2);
-  EXPECT_EQ("100""010", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "100"
+      "010",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthU16(3, 2);
-  EXPECT_EQ("100""010""110", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "100"
+      "010"
+      "110",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthU8(4, 2);
-  EXPECT_EQ("100""010""110""001100", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "100"
+      "010"
+      "110"
+      "001100",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, WriteSmallSigned) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthS64(1, 2, 0);
-  EXPECT_EQ("010", writer.GetStreamRaw ());
+  EXPECT_EQ("010", writer.GetStreamRaw());
   writer.WriteVariableWidthS64(-1, 2, 0);
-  EXPECT_EQ("010""100", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "010"
+      "100",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthS16(3, 2, 0);
-  EXPECT_EQ("010""100""011100", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "010"
+      "100"
+      "011100",
+      writer.GetStreamRaw());
   writer.WriteVariableWidthS8(-4, 2, 0);
-  EXPECT_EQ("010""100""011100""111100", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "010"
+      "100"
+      "011100"
+      "111100",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, U64Val127ChunkLength7) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU64(127, 7);
-  EXPECT_EQ("1111111""0", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "1111111"
+      "0",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, U32Val255ChunkLength7) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU32(255, 7);
-  EXPECT_EQ("1111111""1""1000000""0", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "1111111"
+      "1"
+      "1000000"
+      "0",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, U16Val2ChunkLength4) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU16(2, 4);
-  EXPECT_EQ("0100""0", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "0100"
+      "0",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, U8Val128ChunkLength7) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU8(128, 7);
-  EXPECT_EQ("0000000""1""1", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "0000000"
+      "1"
+      "1",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, U64ValAAAAChunkLength2) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthU64(0xAAAA, 2);
-  EXPECT_EQ("01""1""01""1""01""1""01""1"
-            "01""1""01""1""01""1""01""0", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "0",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthWrite, S8ValM128ChunkLength7) {
   BitWriterStringStream writer;
   writer.WriteVariableWidthS8(-128, 7, 0);
-  EXPECT_EQ("1111111""1""1", writer.GetStreamRaw());
+  EXPECT_EQ(
+      "1111111"
+      "1"
+      "1",
+      writer.GetStreamRaw());
 }
 
 TEST(VariableWidthRead, U64Val127ChunkLength7) {
-  BitReaderFromString reader("1111111""0");
+  BitReaderFromString reader(
+      "1111111"
+      "0");
   uint64_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 7));
   EXPECT_EQ(127u, val);
 }
 
 TEST(VariableWidthRead, U32Val255ChunkLength7) {
-  BitReaderFromString reader("1111111""1""1000000""0");
+  BitReaderFromString reader(
+      "1111111"
+      "1"
+      "1000000"
+      "0");
   uint32_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthU32(&val, 7));
   EXPECT_EQ(255u, val);
 }
 
 TEST(VariableWidthRead, U16Val2ChunkLength4) {
-  BitReaderFromString reader("0100""0");
+  BitReaderFromString reader(
+      "0100"
+      "0");
   uint16_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthU16(&val, 4));
   EXPECT_EQ(2u, val);
 }
 
 TEST(VariableWidthRead, U8Val128ChunkLength7) {
-  BitReaderFromString reader("0000000""1""1");
+  BitReaderFromString reader(
+      "0000000"
+      "1"
+      "1");
   uint8_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthU8(&val, 7));
   EXPECT_EQ(128u, val);
 }
 
 TEST(VariableWidthRead, U64ValAAAAChunkLength2) {
-  BitReaderFromString reader("01""1""01""1""01""1""01""1"
-                             "01""1""01""1""01""1""01""0");
+  BitReaderFromString reader(
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "1"
+      "01"
+      "0");
   uint64_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 2));
   EXPECT_EQ(0xAAAAu, val);
 }
 
 TEST(VariableWidthRead, S8ValM128ChunkLength7) {
-  BitReaderFromString reader("1111111""1""1");
+  BitReaderFromString reader(
+      "1111111"
+      "1"
+      "1");
   int8_t val = 0;
   ASSERT_TRUE(reader.ReadVariableWidthS8(&val, 7, 0));
   EXPECT_EQ(-128, val);
@@ -1086,8 +1205,8 @@ TEST(VariableWidthWriteRead, SingleWriteReadS64) {
 
     BitReaderWord64 reader(writer.GetDataCopy());
     int64_t read_val = 0;
-    ASSERT_TRUE(reader.ReadVariableWidthS64(&read_val, chunk_length,
-                                            zigzag_exponent));
+    ASSERT_TRUE(
+        reader.ReadVariableWidthS64(&read_val, chunk_length, zigzag_exponent));
 
     ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
   }
@@ -1120,8 +1239,8 @@ TEST(VariableWidthWriteRead, SingleWriteReadS32) {
 
     BitReaderWord64 reader(writer.GetDataCopy());
     int32_t read_val = 0;
-    ASSERT_TRUE(reader.ReadVariableWidthS32(
-        &read_val, chunk_length, zigzag_exponent));
+    ASSERT_TRUE(
+        reader.ReadVariableWidthS32(&read_val, chunk_length, zigzag_exponent));
 
     ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
   }
@@ -1154,8 +1273,8 @@ TEST(VariableWidthWriteRead, SingleWriteReadS16) {
 
     BitReaderWord64 reader(writer.GetDataCopy());
     int16_t read_val = 0;
-    ASSERT_TRUE(reader.ReadVariableWidthS16(&read_val, chunk_length,
-                                            zigzag_exponent));
+    ASSERT_TRUE(
+        reader.ReadVariableWidthS16(&read_val, chunk_length, zigzag_exponent));
 
     ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
   }
@@ -1188,8 +1307,8 @@ TEST(VariableWidthWriteRead, SingleWriteReadS8) {
 
     BitReaderWord64 reader(writer.GetDataCopy());
     int8_t read_val = 0;
-    ASSERT_TRUE(reader.ReadVariableWidthS8(&read_val, chunk_length,
-                                           zigzag_exponent));
+    ASSERT_TRUE(
+        reader.ReadVariableWidthS8(&read_val, chunk_length, zigzag_exponent));
 
     ASSERT_EQ(val, read_val) << "Chunk length " << chunk_length;
   }
@@ -1207,7 +1326,7 @@ TEST(VariableWidthWriteRead, SmallNumbersChunkLength4) {
 
   std::vector<uint64_t> actual_values;
   BitReaderWord64 reader(writer.GetDataCopy());
-  while(!reader.OnlyZeroesLeft()) {
+  while (!reader.OnlyZeroesLeft()) {
     uint64_t val = 0;
     ASSERT_TRUE(reader.ReadVariableWidthU64(&val, 4));
     actual_values.push_back(val);
index 1cb39da..a313d6e 100644 (file)
@@ -27,8 +27,8 @@
 namespace {
 
 using libspirv::SetContextMessageConsumer;
-using spvtools::MarkvModelType;
 using spvtest::ScopedContext;
+using spvtools::MarkvModelType;
 using MarkvTest = ::testing::TestWithParam<MarkvModelType>;
 
 void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
@@ -38,8 +38,7 @@ void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
     case SPV_MSG_FATAL:
     case SPV_MSG_INTERNAL_ERROR:
     case SPV_MSG_ERROR:
-      std::cerr << "error: " << position.index << ": " << message
-                << std::endl;
+      std::cerr << "error: " << position.index << ": " << message << std::endl;
       break;
     case SPV_MSG_WARNING:
       std::cout << "warning: " << position.index << ": " << message
@@ -61,18 +60,18 @@ void Compile(const std::string& code, std::vector<uint32_t>* words,
   SetContextMessageConsumer(ctx.context, DiagnosticsMessageHandler);
 
   spv_binary spirv_binary;
-  ASSERT_EQ(SPV_SUCCESS, spvTextToBinaryWithOptions(
-      ctx.context, code.c_str(), code.size(), options, &spirv_binary, nullptr));
+  ASSERT_EQ(SPV_SUCCESS,
+            spvTextToBinaryWithOptions(ctx.context, code.c_str(), code.size(),
+                                       options, &spirv_binary, nullptr));
 
-  *words = std::vector<uint32_t>(
-      spirv_binary->code, spirv_binary->code + spirv_binary->wordCount);
+  *words = std::vector<uint32_t>(spirv_binary->code,
+                                 spirv_binary->code + spirv_binary->wordCount);
 
   spvBinaryDestroy(spirv_binary);
 }
 
 // Disassembles SPIR-V |words| to |out_text|.
-void Disassemble(const std::vector<uint32_t>& words,
-                 std::string* out_text,
+void Disassemble(const std::vector<uint32_t>& words, std::string* out_text,
                  spv_target_env env = SPV_ENV_UNIVERSAL_1_2) {
   ScopedContext ctx(env);
   SetContextMessageConsumer(ctx.context, DiagnosticsMessageHandler);
@@ -110,22 +109,21 @@ void TestEncodeDecode(MarkvModelType model_type,
 
   std::stringstream encoder_comments;
   const auto output_to_string_stream =
-      [&encoder_comments](const std::string& str) {
-    encoder_comments << str;
-  };
+      [&encoder_comments](const std::string& str) { encoder_comments << str; };
 
   std::vector<uint8_t> markv;
   ASSERT_EQ(SPV_SUCCESS, spvtools::SpirvToMarkv(
-      ctx.context, binary_to_encode, options, *model,
-      DiagnosticsMessageHandler, output_to_string_stream,
-      spvtools::MarkvDebugConsumer(), &markv));
+                             ctx.context, binary_to_encode, options, *model,
+                             DiagnosticsMessageHandler, output_to_string_stream,
+                             spvtools::MarkvDebugConsumer(), &markv));
   ASSERT_FALSE(markv.empty());
 
   std::vector<uint32_t> decoded_binary;
-  ASSERT_EQ(SPV_SUCCESS, spvtools::MarkvToSpirv(
-      ctx.context, markv, options, *model,
-      DiagnosticsMessageHandler, spvtools::MarkvLogConsumer(),
-      spvtools::MarkvDebugConsumer(), &decoded_binary));
+  ASSERT_EQ(SPV_SUCCESS,
+            spvtools::MarkvToSpirv(
+                ctx.context, markv, options, *model, DiagnosticsMessageHandler,
+                spvtools::MarkvLogConsumer(), spvtools::MarkvDebugConsumer(),
+                &decoded_binary));
   ASSERT_FALSE(decoded_binary.empty());
 
   EXPECT_EQ(expected_binary, decoded_binary) << encoder_comments.str();
@@ -140,7 +138,7 @@ void TestEncodeDecode(MarkvModelType model_type,
 void TestEncodeDecodeShaderMainBody(MarkvModelType model_type,
                                     const std::string& body) {
   const std::string prefix =
-R"(
+      R"(
 OpCapability Shader
 OpCapability Int64
 OpCapability Float64
@@ -217,7 +215,7 @@ OpEntryPoint Fragment %main "main"
 %main_entry = OpLabel)";
 
   const std::string suffix =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
@@ -820,12 +818,11 @@ OpFunctionEnd
 )");
 }
 
-INSTANTIATE_TEST_CASE_P(
-    AllMarkvModels, MarkvTest,
-    ::testing::ValuesIn(std::vector<MarkvModelType>{
-        spvtools::kMarkvModelShaderLite,
-        spvtools::kMarkvModelShaderMid,
-        spvtools::kMarkvModelShaderMax,
-    }),);
+INSTANTIATE_TEST_CASE_P(AllMarkvModels, MarkvTest,
+                        ::testing::ValuesIn(std::vector<MarkvModelType>{
+                            spvtools::kMarkvModelShaderLite,
+                            spvtools::kMarkvModelShaderMid,
+                            spvtools::kMarkvModelShaderMax,
+                        }), );
 
 }  // namespace
index f023730..8b8dbbe 100644 (file)
@@ -80,7 +80,9 @@ TEST(DiagnosticStream, ConversionToResultType) {
             spv_result_t(DiagnosticStream({}, nullptr, SPV_FAILED_MATCH)));
 }
 
-TEST(DiagnosticStream, MoveConstructorPreservesPreviousMessagesAndPreventsOutputFromExpiringValue) {
+TEST(
+    DiagnosticStream,
+    MoveConstructorPreservesPreviousMessagesAndPreventsOutputFromExpiringValue) {
   std::ostringstream messages;
   int message_count = 0;
   auto consumer = [&messages, &message_count](spv_message_level_t, const char*,
index 86207fe..81671e6 100644 (file)
@@ -20,8 +20,8 @@
 
 namespace {
 
-using libspirv::EnumSet;
 using libspirv::CapabilitySet;
+using libspirv::EnumSet;
 using spvtest::ElementsIn;
 using ::testing::Eq;
 using ::testing::ValuesIn;
index 265a483..01d3227 100644 (file)
@@ -27,16 +27,19 @@ using ::libspirv::Extension;
 using ::testing::Values;
 using ::testing::ValuesIn;
 
-using ExtensionTest = ::testing::TestWithParam<std::pair<Extension, std::string>>;
+using ExtensionTest =
+    ::testing::TestWithParam<std::pair<Extension, std::string>>;
 using UnknownExtensionTest = ::testing::TestWithParam<std::string>;
-using CapabilityTest = ::testing::TestWithParam<std::pair<SpvCapability, std::string>>;
+using CapabilityTest =
+    ::testing::TestWithParam<std::pair<SpvCapability, std::string>>;
 
 TEST_P(ExtensionTest, TestExtensionFromString) {
   const std::pair<Extension, std::string>& param = GetParam();
   const Extension extension = param.first;
   const std::string extension_str = param.second;
   Extension result_extension;
-  ASSERT_TRUE(libspirv::GetExtensionFromString(extension_str, &result_extension));
+  ASSERT_TRUE(
+      libspirv::GetExtensionFromString(extension_str, &result_extension));
   EXPECT_EQ(extension, result_extension);
 }
 
@@ -61,196 +64,124 @@ TEST_P(CapabilityTest, TestCapabilityToString) {
   EXPECT_EQ(capability_str, result_str);
 }
 
-INSTANTIATE_TEST_CASE_P(AllExtensions, ExtensionTest,
-    ValuesIn(std::vector<std::pair<Extension, std::string>>({
-      {Extension::kSPV_KHR_16bit_storage,
-        "SPV_KHR_16bit_storage"},
-      {Extension::kSPV_KHR_device_group,
-        "SPV_KHR_device_group"},
-      {Extension::kSPV_KHR_multiview,
-        "SPV_KHR_multiview"},
-      {Extension::kSPV_KHR_shader_ballot,
-        "SPV_KHR_shader_ballot"},
-      {Extension::kSPV_KHR_shader_draw_parameters,
-        "SPV_KHR_shader_draw_parameters"},
-      {Extension::kSPV_KHR_subgroup_vote,
-        "SPV_KHR_subgroup_vote"},
-      {Extension::kSPV_NVX_multiview_per_view_attributes,
-        "SPV_NVX_multiview_per_view_attributes"},
-      {Extension::kSPV_NV_geometry_shader_passthrough,
-        "SPV_NV_geometry_shader_passthrough"},
-      {Extension::kSPV_NV_sample_mask_override_coverage,
-        "SPV_NV_sample_mask_override_coverage"},
-      {Extension::kSPV_NV_stereo_view_rendering,
-        "SPV_NV_stereo_view_rendering"},
-      {Extension::kSPV_NV_viewport_array2,
-        "SPV_NV_viewport_array2"}
-    })));
+INSTANTIATE_TEST_CASE_P(
+    AllExtensions, ExtensionTest,
+    ValuesIn(std::vector<std::pair<Extension, std::string>>(
+        {{Extension::kSPV_KHR_16bit_storage, "SPV_KHR_16bit_storage"},
+         {Extension::kSPV_KHR_device_group, "SPV_KHR_device_group"},
+         {Extension::kSPV_KHR_multiview, "SPV_KHR_multiview"},
+         {Extension::kSPV_KHR_shader_ballot, "SPV_KHR_shader_ballot"},
+         {Extension::kSPV_KHR_shader_draw_parameters,
+          "SPV_KHR_shader_draw_parameters"},
+         {Extension::kSPV_KHR_subgroup_vote, "SPV_KHR_subgroup_vote"},
+         {Extension::kSPV_NVX_multiview_per_view_attributes,
+          "SPV_NVX_multiview_per_view_attributes"},
+         {Extension::kSPV_NV_geometry_shader_passthrough,
+          "SPV_NV_geometry_shader_passthrough"},
+         {Extension::kSPV_NV_sample_mask_override_coverage,
+          "SPV_NV_sample_mask_override_coverage"},
+         {Extension::kSPV_NV_stereo_view_rendering,
+          "SPV_NV_stereo_view_rendering"},
+         {Extension::kSPV_NV_viewport_array2, "SPV_NV_viewport_array2"}})));
 
-INSTANTIATE_TEST_CASE_P(UnknownExtensions, UnknownExtensionTest, Values(
-      "",
-      "SPV_KHR_",
-      "SPV_KHR_device_group_ERROR",
-      "SPV_ERROR_random_string_hfsdklhlktherh"
-    ));
+INSTANTIATE_TEST_CASE_P(UnknownExtensions, UnknownExtensionTest,
+                        Values("", "SPV_KHR_", "SPV_KHR_device_group_ERROR",
+                               "SPV_ERROR_random_string_hfsdklhlktherh"));
 
-INSTANTIATE_TEST_CASE_P(AllCapabilities, CapabilityTest,
-    ValuesIn(std::vector<std::pair<SpvCapability, std::string>>({
-      {SpvCapabilityMatrix,
-       "Matrix"},
-      {SpvCapabilityShader,
-       "Shader"},
-      {SpvCapabilityGeometry,
-       "Geometry"},
-      {SpvCapabilityTessellation,
-       "Tessellation"},
-      {SpvCapabilityAddresses,
-       "Addresses"},
-      {SpvCapabilityLinkage,
-       "Linkage"},
-      {SpvCapabilityKernel,
-       "Kernel"},
-      {SpvCapabilityVector16,
-       "Vector16"},
-      {SpvCapabilityFloat16Buffer,
-       "Float16Buffer"},
-      {SpvCapabilityFloat16,
-       "Float16"},
-      {SpvCapabilityFloat64,
-       "Float64"},
-      {SpvCapabilityInt64,
-       "Int64"},
-      {SpvCapabilityInt64Atomics,
-       "Int64Atomics"},
-      {SpvCapabilityImageBasic,
-       "ImageBasic"},
-      {SpvCapabilityImageReadWrite,
-       "ImageReadWrite"},
-      {SpvCapabilityImageMipmap,
-       "ImageMipmap"},
-      {SpvCapabilityPipes,
-       "Pipes"},
-      {SpvCapabilityGroups,
-       "Groups"},
-      {SpvCapabilityDeviceEnqueue,
-       "DeviceEnqueue"},
-      {SpvCapabilityLiteralSampler,
-       "LiteralSampler"},
-      {SpvCapabilityAtomicStorage,
-       "AtomicStorage"},
-      {SpvCapabilityInt16,
-       "Int16"},
-      {SpvCapabilityTessellationPointSize,
-       "TessellationPointSize"},
-      {SpvCapabilityGeometryPointSize,
-       "GeometryPointSize"},
-      {SpvCapabilityImageGatherExtended,
-       "ImageGatherExtended"},
-      {SpvCapabilityStorageImageMultisample,
-       "StorageImageMultisample"},
-      {SpvCapabilityUniformBufferArrayDynamicIndexing,
-       "UniformBufferArrayDynamicIndexing"},
-      {SpvCapabilitySampledImageArrayDynamicIndexing,
-       "SampledImageArrayDynamicIndexing"},
-      {SpvCapabilityStorageBufferArrayDynamicIndexing,
-       "StorageBufferArrayDynamicIndexing"},
-      {SpvCapabilityStorageImageArrayDynamicIndexing,
-       "StorageImageArrayDynamicIndexing"},
-      {SpvCapabilityClipDistance,
-       "ClipDistance"},
-      {SpvCapabilityCullDistance,
-       "CullDistance"},
-      {SpvCapabilityImageCubeArray,
-       "ImageCubeArray"},
-      {SpvCapabilitySampleRateShading,
-       "SampleRateShading"},
-      {SpvCapabilityImageRect,
-       "ImageRect"},
-      {SpvCapabilitySampledRect,
-       "SampledRect"},
-      {SpvCapabilityGenericPointer,
-       "GenericPointer"},
-      {SpvCapabilityInt8,
-       "Int8"},
-      {SpvCapabilityInputAttachment,
-       "InputAttachment"},
-      {SpvCapabilitySparseResidency,
-       "SparseResidency"},
-      {SpvCapabilityMinLod,
-       "MinLod"},
-      {SpvCapabilitySampled1D,
-       "Sampled1D"},
-      {SpvCapabilityImage1D,
-       "Image1D"},
-      {SpvCapabilitySampledCubeArray,
-       "SampledCubeArray"},
-      {SpvCapabilitySampledBuffer,
-       "SampledBuffer"},
-      {SpvCapabilityImageBuffer,
-       "ImageBuffer"},
-      {SpvCapabilityImageMSArray,
-       "ImageMSArray"},
-      {SpvCapabilityStorageImageExtendedFormats,
-       "StorageImageExtendedFormats"},
-      {SpvCapabilityImageQuery,
-       "ImageQuery"},
-      {SpvCapabilityDerivativeControl,
-       "DerivativeControl"},
-      {SpvCapabilityInterpolationFunction,
-       "InterpolationFunction"},
-      {SpvCapabilityTransformFeedback,
-       "TransformFeedback"},
-      {SpvCapabilityGeometryStreams,
-       "GeometryStreams"},
-      {SpvCapabilityStorageImageReadWithoutFormat,
-       "StorageImageReadWithoutFormat"},
-      {SpvCapabilityStorageImageWriteWithoutFormat,
-       "StorageImageWriteWithoutFormat"},
-      {SpvCapabilityMultiViewport,
-       "MultiViewport"},
-      {SpvCapabilitySubgroupDispatch,
-       "SubgroupDispatch"},
-      {SpvCapabilityNamedBarrier,
-       "NamedBarrier"},
-      {SpvCapabilityPipeStorage,
-       "PipeStorage"},
-      {SpvCapabilitySubgroupBallotKHR,
-       "SubgroupBallotKHR"},
-      {SpvCapabilityDrawParameters,
-       "DrawParameters"},
-      {SpvCapabilitySubgroupVoteKHR,
-       "SubgroupVoteKHR"},
-      {SpvCapabilityStorageBuffer16BitAccess,
-       "StorageBuffer16BitAccess"},
-      {SpvCapabilityStorageUniformBufferBlock16,
-       "StorageBuffer16BitAccess"}, // Preferred name
-      {SpvCapabilityUniformAndStorageBuffer16BitAccess,
-       "UniformAndStorageBuffer16BitAccess"},
-      {SpvCapabilityStorageUniform16,
-       "UniformAndStorageBuffer16BitAccess"}, // Preferred name
-      {SpvCapabilityStoragePushConstant16,
-       "StoragePushConstant16"},
-      {SpvCapabilityStorageInputOutput16,
-       "StorageInputOutput16"},
-      {SpvCapabilityDeviceGroup,
-       "DeviceGroup"},
-      {SpvCapabilityMultiView,
-       "MultiView"},
-      {SpvCapabilitySampleMaskOverrideCoverageNV,
-       "SampleMaskOverrideCoverageNV"},
-      {SpvCapabilityGeometryShaderPassthroughNV,
-       "GeometryShaderPassthroughNV"},
-      // The next two are different names for the same token.
-      {SpvCapabilityShaderViewportIndexLayerNV,
-       "ShaderViewportIndexLayerEXT"},
-      {SpvCapabilityShaderViewportIndexLayerEXT,
-       "ShaderViewportIndexLayerEXT"},
-      {SpvCapabilityShaderViewportMaskNV,
-       "ShaderViewportMaskNV"},
-      {SpvCapabilityShaderStereoViewNV,
-       "ShaderStereoViewNV"},
-      {SpvCapabilityPerViewAttributesNV,
-       "PerViewAttributesNV"}
-    })), );
+INSTANTIATE_TEST_CASE_P(
+    AllCapabilities, CapabilityTest,
+    ValuesIn(std::vector<std::pair<SpvCapability, std::string>>(
+        {{SpvCapabilityMatrix, "Matrix"},
+         {SpvCapabilityShader, "Shader"},
+         {SpvCapabilityGeometry, "Geometry"},
+         {SpvCapabilityTessellation, "Tessellation"},
+         {SpvCapabilityAddresses, "Addresses"},
+         {SpvCapabilityLinkage, "Linkage"},
+         {SpvCapabilityKernel, "Kernel"},
+         {SpvCapabilityVector16, "Vector16"},
+         {SpvCapabilityFloat16Buffer, "Float16Buffer"},
+         {SpvCapabilityFloat16, "Float16"},
+         {SpvCapabilityFloat64, "Float64"},
+         {SpvCapabilityInt64, "Int64"},
+         {SpvCapabilityInt64Atomics, "Int64Atomics"},
+         {SpvCapabilityImageBasic, "ImageBasic"},
+         {SpvCapabilityImageReadWrite, "ImageReadWrite"},
+         {SpvCapabilityImageMipmap, "ImageMipmap"},
+         {SpvCapabilityPipes, "Pipes"},
+         {SpvCapabilityGroups, "Groups"},
+         {SpvCapabilityDeviceEnqueue, "DeviceEnqueue"},
+         {SpvCapabilityLiteralSampler, "LiteralSampler"},
+         {SpvCapabilityAtomicStorage, "AtomicStorage"},
+         {SpvCapabilityInt16, "Int16"},
+         {SpvCapabilityTessellationPointSize, "TessellationPointSize"},
+         {SpvCapabilityGeometryPointSize, "GeometryPointSize"},
+         {SpvCapabilityImageGatherExtended, "ImageGatherExtended"},
+         {SpvCapabilityStorageImageMultisample, "StorageImageMultisample"},
+         {SpvCapabilityUniformBufferArrayDynamicIndexing,
+          "UniformBufferArrayDynamicIndexing"},
+         {SpvCapabilitySampledImageArrayDynamicIndexing,
+          "SampledImageArrayDynamicIndexing"},
+         {SpvCapabilityStorageBufferArrayDynamicIndexing,
+          "StorageBufferArrayDynamicIndexing"},
+         {SpvCapabilityStorageImageArrayDynamicIndexing,
+          "StorageImageArrayDynamicIndexing"},
+         {SpvCapabilityClipDistance, "ClipDistance"},
+         {SpvCapabilityCullDistance, "CullDistance"},
+         {SpvCapabilityImageCubeArray, "ImageCubeArray"},
+         {SpvCapabilitySampleRateShading, "SampleRateShading"},
+         {SpvCapabilityImageRect, "ImageRect"},
+         {SpvCapabilitySampledRect, "SampledRect"},
+         {SpvCapabilityGenericPointer, "GenericPointer"},
+         {SpvCapabilityInt8, "Int8"},
+         {SpvCapabilityInputAttachment, "InputAttachment"},
+         {SpvCapabilitySparseResidency, "SparseResidency"},
+         {SpvCapabilityMinLod, "MinLod"},
+         {SpvCapabilitySampled1D, "Sampled1D"},
+         {SpvCapabilityImage1D, "Image1D"},
+         {SpvCapabilitySampledCubeArray, "SampledCubeArray"},
+         {SpvCapabilitySampledBuffer, "SampledBuffer"},
+         {SpvCapabilityImageBuffer, "ImageBuffer"},
+         {SpvCapabilityImageMSArray, "ImageMSArray"},
+         {SpvCapabilityStorageImageExtendedFormats,
+          "StorageImageExtendedFormats"},
+         {SpvCapabilityImageQuery, "ImageQuery"},
+         {SpvCapabilityDerivativeControl, "DerivativeControl"},
+         {SpvCapabilityInterpolationFunction, "InterpolationFunction"},
+         {SpvCapabilityTransformFeedback, "TransformFeedback"},
+         {SpvCapabilityGeometryStreams, "GeometryStreams"},
+         {SpvCapabilityStorageImageReadWithoutFormat,
+          "StorageImageReadWithoutFormat"},
+         {SpvCapabilityStorageImageWriteWithoutFormat,
+          "StorageImageWriteWithoutFormat"},
+         {SpvCapabilityMultiViewport, "MultiViewport"},
+         {SpvCapabilitySubgroupDispatch, "SubgroupDispatch"},
+         {SpvCapabilityNamedBarrier, "NamedBarrier"},
+         {SpvCapabilityPipeStorage, "PipeStorage"},
+         {SpvCapabilitySubgroupBallotKHR, "SubgroupBallotKHR"},
+         {SpvCapabilityDrawParameters, "DrawParameters"},
+         {SpvCapabilitySubgroupVoteKHR, "SubgroupVoteKHR"},
+         {SpvCapabilityStorageBuffer16BitAccess, "StorageBuffer16BitAccess"},
+         {SpvCapabilityStorageUniformBufferBlock16,
+          "StorageBuffer16BitAccess"},  // Preferred name
+         {SpvCapabilityUniformAndStorageBuffer16BitAccess,
+          "UniformAndStorageBuffer16BitAccess"},
+         {SpvCapabilityStorageUniform16,
+          "UniformAndStorageBuffer16BitAccess"},  // Preferred name
+         {SpvCapabilityStoragePushConstant16, "StoragePushConstant16"},
+         {SpvCapabilityStorageInputOutput16, "StorageInputOutput16"},
+         {SpvCapabilityDeviceGroup, "DeviceGroup"},
+         {SpvCapabilityMultiView, "MultiView"},
+         {SpvCapabilitySampleMaskOverrideCoverageNV,
+          "SampleMaskOverrideCoverageNV"},
+         {SpvCapabilityGeometryShaderPassthroughNV,
+          "GeometryShaderPassthroughNV"},
+         // The next two are different names for the same token.
+         {SpvCapabilityShaderViewportIndexLayerNV,
+          "ShaderViewportIndexLayerEXT"},
+         {SpvCapabilityShaderViewportIndexLayerEXT,
+          "ShaderViewportIndexLayerEXT"},
+         {SpvCapabilityShaderViewportMaskNV, "ShaderViewportMaskNV"},
+         {SpvCapabilityShaderStereoViewNV, "ShaderStereoViewNV"},
+         {SpvCapabilityPerViewAttributesNV, "PerViewAttributesNV"}})), );
 
 }  // anonymous namespace
index 8502cfd..e1da2f9 100644 (file)
@@ -15,8 +15,8 @@
 #include <algorithm>
 #include <vector>
 
-#include "unit_spirv.h"
 #include "spirv/1.0/GLSL.std.450.h"
+#include "unit_spirv.h"
 
 namespace {
 
index 3685415..af739f6 100644 (file)
@@ -15,8 +15,8 @@
 #include "unit_spirv.h"
 
 #include <gmock/gmock.h>
-#include "test_fixture.h"
 #include "spirv/1.0/OpenCL.std.h"
+#include "test_fixture.h"
 
 namespace {
 
index c78c7b0..c880228 100644 (file)
@@ -44,7 +44,7 @@ INSTANTIATE_TEST_CASE_P(
          "Khronos LLVM/SPIR-V Translator"},
         {SPV_GENERATOR_KHRONOS_ASSEMBLER, "Khronos SPIR-V Tools Assembler"},
         {SPV_GENERATOR_KHRONOS_GLSLANG, "Khronos Glslang Reference Front End"},
-    }),);
+    }), );
 
 INSTANTIATE_TEST_CASE_P(
     Unregistered, GeneratorMagicNumberTest,
@@ -53,5 +53,5 @@ INSTANTIATE_TEST_CASE_P(
         // which can change over time.
         {spv_generator_t(1000), "Unknown"},
         {spv_generator_t(9999), "Unknown"},
-    }),);
+    }), );
 }  // anonymous namespace
index 33933df..c537a28 100644 (file)
 #include "unit_spirv.h"
 
 namespace {
-using ::testing::Eq;
 using spvutils::BitwiseCast;
 using spvutils::Float16;
 using spvutils::FloatProxy;
 using spvutils::HexFloat;
 using spvutils::ParseNormalFloat;
+using ::testing::Eq;
 
 // In this file "encode" means converting a number into a string,
 // and "decode" means converting a string into a number.
@@ -129,7 +129,7 @@ INSTANTIATE_TEST_CASE_P(
         {float(ldexp(1.0, -127) / 2.0 + (ldexp(1.0, -127) / 4.0f)),
          "0x1.8p-128"},
 
-    })),);
+    })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float32NanTests, HexFloatTest,
@@ -147,7 +147,7 @@ INSTANTIATE_TEST_CASE_P(
         {uint32_t(0x7f800c00), "0x1.0018p+128"},     // +nan
         {uint32_t(0x7F80F000), "0x1.01ep+128"},      // +nan
         {uint32_t(0x7FFFFFFF), "0x1.fffffep+128"},   // +nan
-    })),);
+    })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float64Tests, HexDoubleTest,
@@ -220,7 +220,7 @@ INSTANTIATE_TEST_CASE_P(
             {ldexp(1.0, -1023) / 2.0 + (ldexp(1.0, -1023) / 4.0),
              "0x1.8p-1024"},
 
-        })),);
+        })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float64NanTests, HexDoubleTest,
@@ -239,7 +239,7 @@ INSTANTIATE_TEST_CASE_P(
         {uint64_t(0x7FF0000000000001LL), "0x1.0000000000001p+1024"},   // -nan
         {uint64_t(0x7FF0000300000000LL), "0x1.00003p+1024"},           // -nan
         {uint64_t(0x7FFFFFFFFFFFFFFFLL), "0x1.fffffffffffffp+1024"},   // -nan
-    })),);
+    })), );
 
 TEST(HexFloatStreamTest, OperatorLeftShiftPreservesFloatAndFill) {
   std::stringstream s;
@@ -284,7 +284,7 @@ INSTANTIATE_TEST_CASE_P(
         {"0xFFp+0", 255.f},
         {"0x0.8p+0", 0.5f},
         {"0x0.4p+0", 0.25f},
-    })),);
+    })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float32DecodeInfTests, DecodeHexFloatTest,
@@ -294,7 +294,7 @@ INSTANTIATE_TEST_CASE_P(
         {"0x32p+127", uint32_t(0x7F800000)},   // inf
         {"0x32p+500", uint32_t(0x7F800000)},   // inf
         {"-0x32p+127", uint32_t(0xFF800000)},  // -inf
-    })),);
+    })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float64DecodeTests, DecodeHexDoubleTest,
@@ -317,7 +317,7 @@ INSTANTIATE_TEST_CASE_P(
             {"0xFFp+0", 255.},
             {"0x0.8p+0", 0.5},
             {"0x0.4p+0", 0.25},
-        })),);
+        })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float64DecodeInfTests, DecodeHexDoubleTest,
@@ -328,7 +328,7 @@ INSTANTIATE_TEST_CASE_P(
             {"0x32p+1023", uint64_t(0x7FF0000000000000)},   // inf
             {"0x32p+5000", uint64_t(0x7FF0000000000000)},   // inf
             {"-0x32p+1023", uint64_t(0xFFF0000000000000)},  // -inf
-        })),);
+        })), );
 
 TEST(FloatProxy, ValidConversion) {
   EXPECT_THAT(FloatProxy<float>(1.f).getAsFloat(), Eq(1.0f));
@@ -497,7 +497,7 @@ INSTANTIATE_TEST_CASE_P(
 
         {std::numeric_limits<float>::infinity(), "0x1p+128"},
         {-std::numeric_limits<float>::infinity(), "-0x1p+128"},
-    })),);
+    })), );
 
 INSTANTIATE_TEST_CASE_P(
     Float64Tests, FloatProxyDoubleTest,
@@ -534,13 +534,13 @@ INSTANTIATE_TEST_CASE_P(
             {std::numeric_limits<double>::infinity(), "0x1p+1024"},
             {-std::numeric_limits<double>::infinity(), "-0x1p+1024"},
 
-        })),);
+        })), );
 
 // double is used so that unbiased_exponent can be used with the output
 // of ldexp directly.
 int32_t unbiased_exponent(double f) {
-  return spvutils::HexFloat<spvutils::FloatProxy<float>>(
-      static_cast<float>(f)).getUnbiasedNormalizedExponent();
+  return spvutils::HexFloat<spvutils::FloatProxy<float>>(static_cast<float>(f))
+      .getUnbiasedNormalizedExponent();
 }
 
 int16_t unbiased_half_exponent(uint16_t f) {
@@ -558,7 +558,7 @@ TEST(HexFloatOperationTest, UnbiasedExponent) {
   EXPECT_EQ(128, unbiased_exponent(ldexp(1.0f, 256)));
 
   EXPECT_EQ(-100, unbiased_exponent(ldexp(1.0f, -100)));
-  EXPECT_EQ(-127, unbiased_exponent(ldexp(1.0f, -127))); // First denorm
+  EXPECT_EQ(-127, unbiased_exponent(ldexp(1.0f, -127)));  // First denorm
   EXPECT_EQ(-128, unbiased_exponent(ldexp(1.0f, -128)));
   EXPECT_EQ(-129, unbiased_exponent(ldexp(1.0f, -129)));
   EXPECT_EQ(-140, unbiased_exponent(ldexp(1.0f, -140)));
@@ -584,7 +584,7 @@ TEST(HexFloatOperationTest, UnbiasedExponent) {
 // Creates a float that is the sum of 1/(2 ^ fractions[i]) for i in factions
 float float_fractions(const std::vector<uint32_t>& fractions) {
   float f = 0;
-  for(int32_t i: fractions) {
+  for (int32_t i : fractions) {
     f += std::ldexp(1.0f, -i);
   }
   return f;
@@ -593,7 +593,8 @@ float float_fractions(const std::vector<uint32_t>& fractions) {
 // Returns the normalized significand of a HexFloat<FloatProxy<float>>
 // that was created by calling float_fractions with the input fractions,
 // raised to the power of exp.
-uint32_t normalized_significand(const std::vector<uint32_t>& fractions, uint32_t exp) {
+uint32_t normalized_significand(const std::vector<uint32_t>& fractions,
+                                uint32_t exp) {
   return spvutils::HexFloat<spvutils::FloatProxy<float>>(
              static_cast<float>(ldexp(float_fractions(fractions), exp)))
       .getNormalizedSignificand();
@@ -604,8 +605,8 @@ uint32_t normalized_significand(const std::vector<uint32_t>& fractions, uint32_t
 // and 1 would set the 22nd bit.
 uint32_t bits_set(const std::vector<uint32_t>& bits) {
   const uint32_t top_bit = 1u << 22u;
-  uint32_t val= 0;
-  for(uint32_t i: bits) {
+  uint32_t val = 0;
+  for (uint32_t i : bits) {
     val |= top_bit >> i;
   }
   return val;
@@ -615,8 +616,8 @@ uint32_t bits_set(const std::vector<uint32_t>& bits) {
 // point.
 uint16_t half_bits_set(const std::vector<uint32_t>& bits) {
   const uint32_t top_bit = 1u << 9u;
-  uint32_t val= 0;
-  for(uint32_t i: bits) {
+  uint32_t val = 0;
+  for (uint32_t i : bits) {
     val |= top_bit >> i;
   }
   return static_cast<uint16_t>(val);
@@ -646,8 +647,8 @@ TEST(HexFloatOperationTest, NormalizedSignificand) {
 // calling setFromSignUnbiasedExponentAndNormalizedSignificand
 // on a HexFloat<FloatProxy<float>>
 float set_from_sign(bool negative, int32_t unbiased_exponent,
-                   uint32_t significand, bool round_denorm_up) {
-  spvutils::HexFloat<spvutils::FloatProxy<float>>  f(0.f);
+                    uint32_t significand, bool round_denorm_up) {
+  spvutils::HexFloat<spvutils::FloatProxy<float>> f(0.f);
   f.setFromSignUnbiasedExponentAndNormalizedSignificand(
       negative, unbiased_exponent, significand, round_denorm_up);
   return f.value().getAsFloat();
@@ -655,14 +656,16 @@ float set_from_sign(bool negative, int32_t unbiased_exponent,
 
 TEST(HexFloatOperationTests,
      SetFromSignUnbiasedExponentAndNormalizedSignificand) {
-
   EXPECT_EQ(1.f, set_from_sign(false, 0, 0, false));
 
   // Tests insertion of various denormalized numbers with and without round up.
-  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)), set_from_sign(false, -149, 0, false));
-  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)), set_from_sign(false, -149, 0, true));
+  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)),
+            set_from_sign(false, -149, 0, false));
+  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)),
+            set_from_sign(false, -149, 0, true));
   EXPECT_EQ(0.f, set_from_sign(false, -150, 1, false));
-  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)), set_from_sign(false, -150, 1, true));
+  EXPECT_EQ(static_cast<float>(ldexp(1.f, -149)),
+            set_from_sign(false, -150, 1, true));
 
   EXPECT_EQ(ldexp(1.0f, -127), set_from_sign(false, -127, 0, false));
   EXPECT_EQ(ldexp(1.0f, -128), set_from_sign(false, -128, 0, false));
@@ -699,8 +702,8 @@ TEST(HexFloatOperationTests, NonRounding) {
 
   // Everything fits, so this should be straight-forward
   for (spvutils::round_direction round : rounding) {
-    EXPECT_EQ(bits_set({}), HF(0.f).getRoundedNormalizedSignificand<HF>(
-                                round, &carry_bit));
+    EXPECT_EQ(bits_set({}),
+              HF(0.f).getRoundedNormalizedSignificand<HF>(round, &carry_bit));
     EXPECT_FALSE(carry_bit);
 
     EXPECT_EQ(bits_set({0}),
@@ -719,10 +722,9 @@ TEST(HexFloatOperationTests, NonRounding) {
             .getRoundedNormalizedSignificand<HF>(round, &carry_bit));
     EXPECT_FALSE(carry_bit);
 
-    EXPECT_EQ(
-        bits_set({0, 1, 4, 22}),
-        HF(static_cast<float>(float_fractions({0, 1, 2, 5, 23})))
-            .getRoundedNormalizedSignificand<HF>(round, &carry_bit));
+    EXPECT_EQ(bits_set({0, 1, 4, 22}),
+              HF(static_cast<float>(float_fractions({0, 1, 2, 5, 23})))
+                  .getRoundedNormalizedSignificand<HF>(round, &carry_bit));
     EXPECT_FALSE(carry_bit);
   }
 }
@@ -734,8 +736,7 @@ struct RoundSignificandCase {
   spvutils::round_direction round;
 };
 
-using HexFloatRoundTest =
-    ::testing::TestWithParam<RoundSignificandCase>;
+using HexFloatRoundTest = ::testing::TestWithParam<RoundSignificandCase>;
 
 TEST_P(HexFloatRoundTest, RoundDownToFP16) {
   using HF = spvutils::HexFloat<spvutils::FloatProxy<float>>;
@@ -744,8 +745,8 @@ TEST_P(HexFloatRoundTest, RoundDownToFP16) {
   HF input_value(GetParam().source_float);
   bool carry_bit = false;
   EXPECT_EQ(GetParam().expected_results.first,
-            input_value.getRoundedNormalizedSignificand<HF16>(
-                GetParam().round, &carry_bit));
+            input_value.getRoundedNormalizedSignificand<HF16>(GetParam().round,
+                                                              &carry_bit));
   EXPECT_EQ(carry_bit, GetParam().expected_results.second);
 }
 
@@ -831,16 +832,16 @@ TEST_P(HexFloatRoundUpSignificandTest, Widening) {
   }
 }
 
-INSTANTIATE_TEST_CASE_P(F16toF32, HexFloatRoundUpSignificandTest,
-  // 0xFC00 of the source 16-bit hex value cover the sign and the exponent.
-  // They are ignored for this test.
-  ::testing::ValuesIn(std::vector<UpCastSignificandCase>(
-  {
-    {0x3F00, 0x600000},
-    {0x0F00, 0x600000},
-    {0x0F01, 0x602000},
-    {0x0FFF, 0x7FE000},
-  })),);
+INSTANTIATE_TEST_CASE_P(
+    F16toF32, HexFloatRoundUpSignificandTest,
+    // 0xFC00 of the source 16-bit hex value cover the sign and the exponent.
+    // They are ignored for this test.
+    ::testing::ValuesIn(std::vector<UpCastSignificandCase>({
+        {0x3F00, 0x600000},
+        {0x0F00, 0x600000},
+        {0x0F01, 0x602000},
+        {0x0FFF, 0x7FE000},
+    })), );
 
 struct DownCastTest {
   float source_float;
@@ -850,7 +851,7 @@ struct DownCastTest {
 
 std::string get_round_text(spvutils::round_direction direction) {
 #define CASE(round_direction) \
-  case round_direction:      \
+  case round_direction:       \
     return #round_direction
 
   switch (direction) {
@@ -882,44 +883,100 @@ TEST_P(HexFloatFP32To16Tests, NarrowingCasts) {
 const uint16_t positive_infinity = 0x7C00;
 const uint16_t negative_infinity = 0xFC00;
 
-INSTANTIATE_TEST_CASE_P(F32ToF16, HexFloatFP32To16Tests,
-  ::testing::ValuesIn(std::vector<DownCastTest>(
-  {
-    // Exactly representable as half.
-    {0.f, 0x0, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {-0.f, 0x8000, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {1.0f, 0x3C00, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {-1.0f, 0xBC00, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-
-    {float_fractions({0, 1, 10}) , 0x3E01, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {-float_fractions({0, 1, 10}) , 0xBE01, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(ldexp(float_fractions({0, 1, 10}), 3)), 0x4A01, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(-ldexp(float_fractions({0, 1, 10}), 3)), 0xCA01, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-
-
-    // Underflow
-    {static_cast<float>(ldexp(1.0f, -25)), 0x0, {RD::kToZero, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(ldexp(1.0f, -25)), 0x1, {RD::kToPositiveInfinity}},
-    {static_cast<float>(-ldexp(1.0f, -25)), 0x8000, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNearestEven}},
-    {static_cast<float>(-ldexp(1.0f, -25)), 0x8001, {RD::kToNegativeInfinity}},
-    {static_cast<float>(ldexp(1.0f, -24)), 0x1, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-
-    // Overflow
-    {static_cast<float>(ldexp(1.0f, 16)), positive_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(ldexp(1.0f, 18)), positive_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(ldexp(1.3f, 16)), positive_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(-ldexp(1.0f, 16)), negative_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(-ldexp(1.0f, 18)), negative_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {static_cast<float>(-ldexp(1.3f, 16)), negative_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-
-    // Transfer of Infinities
-    {std::numeric_limits<float>::infinity(), positive_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-    {-std::numeric_limits<float>::infinity(), negative_infinity, {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity, RD::kToNearestEven}},
-
-    // Nans are below because we cannot test for equality.
-  })),);
-
-struct UpCastCase{
+INSTANTIATE_TEST_CASE_P(
+    F32ToF16, HexFloatFP32To16Tests,
+    ::testing::ValuesIn(std::vector<DownCastTest>({
+        // Exactly representable as half.
+        {0.f,
+         0x0,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {-0.f,
+         0x8000,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {1.0f,
+         0x3C00,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {-1.0f,
+         0xBC00,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+
+        {float_fractions({0, 1, 10}),
+         0x3E01,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {-float_fractions({0, 1, 10}),
+         0xBE01,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(ldexp(float_fractions({0, 1, 10}), 3)),
+         0x4A01,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(-ldexp(float_fractions({0, 1, 10}), 3)),
+         0xCA01,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+
+        // Underflow
+        {static_cast<float>(ldexp(1.0f, -25)),
+         0x0,
+         {RD::kToZero, RD::kToNegativeInfinity, RD::kToNearestEven}},
+        {static_cast<float>(ldexp(1.0f, -25)), 0x1, {RD::kToPositiveInfinity}},
+        {static_cast<float>(-ldexp(1.0f, -25)),
+         0x8000,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNearestEven}},
+        {static_cast<float>(-ldexp(1.0f, -25)),
+         0x8001,
+         {RD::kToNegativeInfinity}},
+        {static_cast<float>(ldexp(1.0f, -24)),
+         0x1,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+
+        // Overflow
+        {static_cast<float>(ldexp(1.0f, 16)),
+         positive_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(ldexp(1.0f, 18)),
+         positive_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(ldexp(1.3f, 16)),
+         positive_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(-ldexp(1.0f, 16)),
+         negative_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(-ldexp(1.0f, 18)),
+         negative_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {static_cast<float>(-ldexp(1.3f, 16)),
+         negative_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+
+        // Transfer of Infinities
+        {std::numeric_limits<float>::infinity(),
+         positive_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+        {-std::numeric_limits<float>::infinity(),
+         negative_infinity,
+         {RD::kToZero, RD::kToPositiveInfinity, RD::kToNegativeInfinity,
+          RD::kToNearestEven}},
+
+        // Nans are below because we cannot test for equality.
+    })), );
+
+struct UpCastCase {
   uint16_t source_half;
   float expected_float;
 };
@@ -947,28 +1004,28 @@ TEST_P(HexFloatFP16To32Tests, WideningCasts) {
   }
 }
 
-INSTANTIATE_TEST_CASE_P(F16ToF32, HexFloatFP16To32Tests,
-  ::testing::ValuesIn(std::vector<UpCastCase>(
-  {
-    {0x0000, 0.f},
-    {0x8000, -0.f},
-    {0x3C00, 1.0f},
-    {0xBC00, -1.0f},
-    {0x3F00, float_fractions({0, 1, 2})},
-    {0xBF00, -float_fractions({0, 1, 2})},
-    {0x3F01, float_fractions({0, 1, 2, 10})},
-    {0xBF01, -float_fractions({0, 1, 2, 10})},
-
-    // denorm
-    {0x0001, static_cast<float>(ldexp(1.0, -24))},
-    {0x0002, static_cast<float>(ldexp(1.0, -23))},
-    {0x8001, static_cast<float>(-ldexp(1.0, -24))},
-    {0x8011, static_cast<float>(-ldexp(1.0, -20) + -ldexp(1.0, -24))},
-
-    // inf
-    {0x7C00, std::numeric_limits<float>::infinity()},
-    {0xFC00, -std::numeric_limits<float>::infinity()},
-  })),);
+INSTANTIATE_TEST_CASE_P(
+    F16ToF32, HexFloatFP16To32Tests,
+    ::testing::ValuesIn(std::vector<UpCastCase>({
+        {0x0000, 0.f},
+        {0x8000, -0.f},
+        {0x3C00, 1.0f},
+        {0xBC00, -1.0f},
+        {0x3F00, float_fractions({0, 1, 2})},
+        {0xBF00, -float_fractions({0, 1, 2})},
+        {0x3F01, float_fractions({0, 1, 2, 10})},
+        {0xBF01, -float_fractions({0, 1, 2, 10})},
+
+        // denorm
+        {0x0001, static_cast<float>(ldexp(1.0, -24))},
+        {0x0002, static_cast<float>(ldexp(1.0, -23))},
+        {0x8001, static_cast<float>(-ldexp(1.0, -24))},
+        {0x8011, static_cast<float>(-ldexp(1.0, -20) + -ldexp(1.0, -24))},
+
+        // inf
+        {0x7C00, std::numeric_limits<float>::infinity()},
+        {0xFC00, -std::numeric_limits<float>::infinity()},
+    })), );
 
 TEST(HexFloatOperationTests, NanTests) {
   using HF = spvutils::HexFloat<spvutils::FloatProxy<float>>;
@@ -1074,7 +1131,7 @@ INSTANTIATE_TEST_CASE_P(
         // We can't have -1e40 and negate_value == true since
         // that represents an original case of "--1e40" which
         // is invalid.
-  }),);
+    }), );
 
 using ParseNormalFloat16Test =
     ::testing::TestWithParam<FloatParseCase<Float16>>;
@@ -1117,7 +1174,7 @@ INSTANTIATE_TEST_CASE_P(
         BadFloatParseCase<Float16>("-2.0", true, uint16_t{0}),
         BadFloatParseCase<Float16>("+0.0", true, uint16_t{0}),
         BadFloatParseCase<Float16>("+2.0", true, uint16_t{0}),
-    }),);
+    }), );
 
 // A test case for detecting infinities.
 template <typename T>
@@ -1152,7 +1209,7 @@ INSTANTIATE_TEST_CASE_P(
         {"-1e40", false, -FLT_MAX},
         {"1e400", false, FLT_MAX},
         {"-1e400", false, -FLT_MAX},
-    })),);
+    })), );
 
 using FloatProxyParseOverflowDoubleTest =
     ::testing::TestWithParam<OverflowParseCase<double>>;
@@ -1179,7 +1236,7 @@ INSTANTIATE_TEST_CASE_P(
         {"-1e40", true, -1e40},
         {"1e400", false, DBL_MAX},
         {"-1e400", false, -DBL_MAX},
-    })),);
+    })), );
 
 using FloatProxyParseOverflowFloat16Test =
     ::testing::TestWithParam<OverflowParseCase<uint16_t>>;
@@ -1188,8 +1245,8 @@ TEST_P(FloatProxyParseOverflowFloat16Test, Sample) {
   std::istringstream input(GetParam().input);
   HexFloat<FloatProxy<Float16>> value(0);
   input >> value;
-  EXPECT_NE(GetParam().expect_success, input.fail()) << " literal: "
-                                                     << GetParam().input;
+  EXPECT_NE(GetParam().expect_success, input.fail())
+      << " literal: " << GetParam().input;
   if (GetParam().expect_success) {
     EXPECT_THAT(value.value().data(), Eq(GetParam().expected_value))
         << " literal: " << GetParam().input;
@@ -1210,7 +1267,7 @@ INSTANTIATE_TEST_CASE_P(
         {"-1e38", false, uint16_t{0xfbff}},
         {"-1e40", false, uint16_t{0xfbff}},
         {"-1e400", false, uint16_t{0xfbff}},
-    })),);
+    })), );
 
 TEST(FloatProxy, Max) {
   EXPECT_THAT(FloatProxy<Float16>::max().getAsFloat().get_value(),
index abad1c0..3d5d293 100644 (file)
 #include <string>
 #include <unordered_map>
 
-#include "util/huffman_codec.h"
-#include "util/bit_stream.h"
 #include "gmock/gmock.h"
+#include "util/bit_stream.h"
+#include "util/huffman_codec.h"
 
 namespace {
 
-using spvutils::HuffmanCodec;
 using spvutils::BitsToStream;
+using spvutils::HuffmanCodec;
 
 const std::map<std::string, uint32_t>& GetTestSet() {
   static const std::map<std::string, uint32_t> hist = {
-    {"a", 4},
-    {"e", 7},
-    {"f", 3},
-    {"h", 2},
-    {"i", 3},
-    {"m", 2},
-    {"n", 2},
-    {"s", 2},
-    {"t", 2},
-    {"l", 1},
-    {"o", 2},
-    {"p", 1},
-    {"r", 1},
-    {"u", 1},
-    {"x", 1},
+      {"a", 4}, {"e", 7}, {"f", 3}, {"h", 2}, {"i", 3},
+      {"m", 2}, {"n", 2}, {"s", 2}, {"t", 2}, {"l", 1},
+      {"o", 2}, {"p", 1}, {"r", 1}, {"u", 1}, {"x", 1},
   };
 
   return hist;
@@ -72,6 +60,7 @@ TEST(Huffman, PrintTree) {
   std::stringstream ss;
   huffman.PrintTree(ss);
 
+  // clang-format off
   const std::string expected = std::string(R"(
 15-----7------e
        8------4------a
@@ -89,6 +78,7 @@ TEST(Huffman, PrintTree) {
                      3------1------x
                             2------h
 )").substr(1);
+  // clang-format on
 
   EXPECT_EQ(expected, ss.str());
 }
@@ -114,7 +104,8 @@ u 1 00110
 r 1 00111
 p 1 01000
 l 1 01001
-)").substr(1);
+)")
+                                   .substr(1);
 
   EXPECT_EQ(expected, ss.str());
 }
@@ -162,10 +153,14 @@ TEST(Huffman, TestEncode) {
 
 TEST(Huffman, TestDecode) {
   HuffmanCodec<std::string> huffman(GetTestSet());
-  TestBitReader bit_reader("01001""0001""1000""00110""00001""00");
-  auto read_bit = [&bit_reader](bool* bit) {
-    return bit_reader.ReadBit(bit);
-  };
+  TestBitReader bit_reader(
+      "01001"
+      "0001"
+      "1000"
+      "00110"
+      "00001"
+      "00");
+  auto read_bit = [&bit_reader](bool* bit) { return bit_reader.ReadBit(bit); };
 
   std::string decoded;
 
@@ -188,13 +183,17 @@ TEST(Huffman, TestDecode) {
 }
 
 TEST(Huffman, TestDecodeNumbers) {
-  const std::map<uint32_t, uint32_t> hist = { {1, 10}, {2, 5}, {3, 15} };
+  const std::map<uint32_t, uint32_t> hist = {{1, 10}, {2, 5}, {3, 15}};
   HuffmanCodec<uint32_t> huffman(hist);
 
-  TestBitReader bit_reader("1""1""01""00""01""1");
-  auto read_bit = [&bit_reader](bool* bit) {
-    return bit_reader.ReadBit(bit);
-  };
+  TestBitReader bit_reader(
+      "1"
+      "1"
+      "01"
+      "00"
+      "01"
+      "1");
+  auto read_bit = [&bit_reader](bool* bit) { return bit_reader.ReadBit(bit); };
 
   uint32_t decoded;
 
@@ -218,8 +217,7 @@ TEST(Huffman, TestDecodeNumbers) {
 }
 
 TEST(Huffman, SerializeToTextU64) {
-  const std::map<uint64_t, uint32_t> hist =
-  { {1001, 10}, {1002, 5}, {1003, 15} };
+  const std::map<uint64_t, uint32_t> hist = {{1001, 10}, {1002, 5}, {1003, 15}};
   HuffmanCodec<uint64_t> huffman(hist);
 
   const std::string code = huffman.SerializeToText(2);
@@ -233,13 +231,12 @@ TEST(Huffman, SerializeToTextU64) {
     {0, 4, 3},
   }))";
 
-
   ASSERT_EQ(expected, code);
 }
 
 TEST(Huffman, SerializeToTextString) {
-  const std::map<std::string, uint32_t> hist =
-  { {"aaa", 10}, {"bbb", 20}, {"ccc", 15} };
+  const std::map<std::string, uint32_t> hist = {
+      {"aaa", 10}, {"bbb", 20}, {"ccc", 15}};
   HuffmanCodec<std::string> huffman(hist);
 
   const std::string code = huffman.SerializeToText(4);
@@ -258,10 +255,10 @@ TEST(Huffman, SerializeToTextString) {
 
 TEST(Huffman, CreateFromTextString) {
   std::vector<HuffmanCodec<std::string>::Node> nodes = {
-    {},
-    {"root", 2, 3},
-    {"left", 0, 0},
-    {"right", 0, 0},
+      {},
+      {"root", 2, 3},
+      {"left", 0, 0},
+      {"right", 0, 0},
   };
 
   HuffmanCodec<std::string> huffman(1, std::move(nodes));
@@ -272,20 +269,21 @@ TEST(Huffman, CreateFromTextString) {
   const std::string expected = std::string(R"(
 0------right
 0------left
-)").substr(1);
+)")
+                                   .substr(1);
 
   EXPECT_EQ(expected, ss.str());
 }
 
 TEST(Huffman, CreateFromTextU64) {
   HuffmanCodec<uint64_t> huffman(5, {
-        {0, 0, 0},
-        {1001, 0, 0},
-        {1002, 0, 0},
-        {1003, 0, 0},
-        {0, 1, 2},
-        {0, 4, 3},
-      });
+                                        {0, 0, 0},
+                                        {1001, 0, 0},
+                                        {1002, 0, 0},
+                                        {1003, 0, 0},
+                                        {0, 1, 2},
+                                        {0, 4, 3},
+                                    });
 
   std::stringstream ss;
   huffman.PrintTree(ss);
@@ -294,14 +292,13 @@ TEST(Huffman, CreateFromTextU64) {
 0------1003
 0------0------1002
        0------1001
-)").substr(1);
+)")
+                                   .substr(1);
 
   EXPECT_EQ(expected, ss.str());
 
   TestBitReader bit_reader("01");
-  auto read_bit = [&bit_reader](bool* bit) {
-    return bit_reader.ReadBit(bit);
-  };
+  auto read_bit = [&bit_reader](bool* bit) { return bit_reader.ReadBit(bit); };
 
   uint64_t decoded = 0;
   ASSERT_TRUE(huffman.DecodeFromStream(read_bit, &decoded));
index 30a8fb0..3e95d0c 100644 (file)
@@ -18,8 +18,8 @@
 
 #include <gmock/gmock.h>
 
-#include "test_fixture.h"
 #include "source/util/bitutils.h"
+#include "test_fixture.h"
 
 namespace {
 
index b78440d..bde786a 100644 (file)
@@ -20,6 +20,7 @@ namespace {
 using BinaryVersion = spvtest::LinkerTest;
 
 TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) {
+  // clang-format off
   spvtest::Binaries binaries = {
       {
           SpvMagicNumber,
@@ -43,6 +44,7 @@ TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) {
           0u   // NOTE: Schema; reserved
       }
   };
+  // clang-format on
   spvtest::Binary linked_binary;
 
   ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary));
index 0d1bf21..c242f4b 100644 (file)
@@ -24,20 +24,15 @@ using IdsLimit = spvtest::LinkerTest;
 TEST_F(IdsLimit, UnderLimit) {
   spvtest::Binaries binaries = {
       {
-          SpvMagicNumber,
-          SpvVersion,
-          SPV_GENERATOR_CODEPLAY,
-          0x2FFFFFu, // NOTE: Bound
-          0u,        // NOTE: Schema; reserved
+          SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY,
+          0x2FFFFFu,  // NOTE: Bound
+          0u,         // NOTE: Schema; reserved
       },
       {
-          SpvMagicNumber,
-          SpvVersion,
-          SPV_GENERATOR_CODEPLAY,
-          0x100000u, // NOTE: Bound
-          0u,        // NOTE: Schema; reserved
-      }
-  };
+          SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY,
+          0x100000u,  // NOTE: Bound
+          0u,         // NOTE: Schema; reserved
+      }};
   spvtest::Binary linked_binary;
 
   ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary));
@@ -48,27 +43,20 @@ TEST_F(IdsLimit, UnderLimit) {
 TEST_F(IdsLimit, OverLimit) {
   spvtest::Binaries binaries = {
       {
-          SpvMagicNumber,
-          SpvVersion,
-          SPV_GENERATOR_CODEPLAY,
-          0x2FFFFFu, // NOTE: Bound
-          0u,        // NOTE: Schema; reserved
+          SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY,
+          0x2FFFFFu,  // NOTE: Bound
+          0u,         // NOTE: Schema; reserved
       },
       {
-          SpvMagicNumber,
-          SpvVersion,
-          SPV_GENERATOR_CODEPLAY,
-          0x100000u, // NOTE: Bound
-          0u,        // NOTE: Schema; reserved
+          SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY,
+          0x100000u,  // NOTE: Bound
+          0u,         // NOTE: Schema; reserved
       },
       {
-          SpvMagicNumber,
-          SpvVersion,
-          SPV_GENERATOR_CODEPLAY,
+          SpvMagicNumber, SpvVersion, SPV_GENERATOR_CODEPLAY,
           3u,  // NOTE: Bound
           0u,  // NOTE: Schema; reserved
-      }
-  };
+      }};
 
   spvtest::Binary linked_binary;
 
index 8b67d34..c926f0e 100644 (file)
@@ -134,4 +134,4 @@ TEST_F(UniqueIds, UniquelyMerged) {
   EXPECT_EQ(SPV_SUCCESS, res);
 }
 
-} // anonymous namespace
+}  // anonymous namespace
index 95f2b08..08c2921 100644 (file)
@@ -28,9 +28,7 @@ using spvutils::MultiMoveToFront;
 class MoveToFrontTester : public MoveToFront<uint32_t> {
  public:
   // Inserts the value in the internal tree data structure. For testing only.
-  void TestInsert(uint32_t val) {
-    InsertNode(CreateNode(val, val));
-  }
+  void TestInsert(uint32_t val) { InsertNode(CreateNode(val, val)); }
 
   // Removes the value from the internal tree data structure. For testing only.
   void TestRemove(uint32_t val) {
@@ -41,15 +39,14 @@ class MoveToFrontTester : public MoveToFront<uint32_t> {
 
   // Prints the internal tree data structure to |out|. For testing only.
   void PrintTree(std::ostream& out, bool print_timestamp = false) const {
-    if (root_)
-      PrintTreeInternal(out, root_, 1, print_timestamp);
+    if (root_) PrintTreeInternal(out, root_, 1, print_timestamp);
   }
 
-  // Returns node handle corresponding to the value. The value may not be in the tree.
+  // Returns node handle corresponding to the value. The value may not be in the
+  // tree.
   uint32_t GetNodeHandle(uint32_t value) const {
     const auto it = value_to_node_.find(value);
-    if (it == value_to_node_.end())
-      return 0;
+    if (it == value_to_node_.end()) return 0;
 
     return it->second;
   }
@@ -61,9 +58,7 @@ class MoveToFrontTester : public MoveToFront<uint32_t> {
     return nodes_.size() - 1;
   }
 
-  uint32_t GetLastAccessedValue() const {
-    return last_accessed_value_;
-  }
+  uint32_t GetLastAccessedValue() const { return last_accessed_value_; }
 
  private:
   // Prints the internal tree data structure for debug purposes in the following
@@ -77,9 +72,9 @@ class MoveToFrontTester : public MoveToFront<uint32_t> {
                          bool print_timestamp) const;
 };
 
-void MoveToFrontTester::PrintTreeInternal(
-    std::ostream& out, uint32_t node,
-    size_t depth, bool print_timestamp) const {
+void MoveToFrontTester::PrintTreeInternal(std::ostream& out, uint32_t node,
+                                          size_t depth,
+                                          bool print_timestamp) const {
   if (!node) {
     out << "D" << depth - 1 << std::endl;
     return;
@@ -87,13 +82,13 @@ void MoveToFrontTester::PrintTreeInternal(
 
   const size_t kTextFieldWvaluethWithoutTimestamp = 10;
   const size_t kTextFieldWvaluethWithTimestamp = 14;
-  const size_t text_field_wvalueth = print_timestamp ?
-      kTextFieldWvaluethWithTimestamp : kTextFieldWvaluethWithoutTimestamp;
+  const size_t text_field_wvalueth = print_timestamp
+                                         ? kTextFieldWvaluethWithTimestamp
+                                         : kTextFieldWvaluethWithoutTimestamp;
 
   std::stringstream label;
   label << ValueOf(node) << "H" << HeightOf(node) << "S" << SizeOf(node);
-  if (print_timestamp)
-    label << "T" << TimestampOf(node);
+  if (print_timestamp) label << "T" << TimestampOf(node);
   const size_t label_length = label.str().length();
   if (label_length < text_field_wvalueth)
     label << std::string(text_field_wvalueth - label_length, '-');
@@ -128,13 +123,15 @@ TEST(MoveToFront, InsertLeftRotation) {
 
   CheckTree(mtf, std::string(R"(
 30H2S2----20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(10);
   CheckTree(mtf, std::string(R"(
 20H2S3----10H1S1----D2
           30H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, InsertRightRotation) {
@@ -146,13 +143,15 @@ TEST(MoveToFront, InsertRightRotation) {
   CheckTree(mtf, std::string(R"(
 10H2S2----D1
           20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(30);
   CheckTree(mtf, std::string(R"(
 20H2S3----10H1S1----D2
           30H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, InsertRightLeftRotation) {
@@ -163,13 +162,15 @@ TEST(MoveToFront, InsertRightLeftRotation) {
 
   CheckTree(mtf, std::string(R"(
 30H2S2----20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(25);
   CheckTree(mtf, std::string(R"(
 25H2S3----20H1S1----D2
           30H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, InsertLeftRightRotation) {
@@ -181,13 +182,15 @@ TEST(MoveToFront, InsertLeftRightRotation) {
   CheckTree(mtf, std::string(R"(
 10H2S2----D1
           20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(15);
   CheckTree(mtf, std::string(R"(
 15H2S3----10H1S1----D2
           20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RemoveSingleton) {
@@ -196,7 +199,8 @@ TEST(MoveToFront, RemoveSingleton) {
   mtf.TestInsert(10);
   CheckTree(mtf, std::string(R"(
 10H1S1----D1
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(10);
   CheckTree(mtf, "");
@@ -211,12 +215,14 @@ TEST(MoveToFront, RemoveRootWithScapegoat) {
   CheckTree(mtf, std::string(R"(
 10H2S3----5H1S1-----D2
           15H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(10);
   CheckTree(mtf, std::string(R"(
 15H2S2----5H1S1-----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RemoveRightRotation) {
@@ -230,14 +236,16 @@ TEST(MoveToFront, RemoveRightRotation) {
 10H3S4----5H1S1-----D2
           15H2S2----D2
                     20H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(5);
 
   CheckTree(mtf, std::string(R"(
 15H2S3----10H1S1----D2
           20H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RemoveLeftRotation) {
@@ -250,14 +258,16 @@ TEST(MoveToFront, RemoveLeftRotation) {
   CheckTree(mtf, std::string(R"(
 10H3S4----5H2S2-----1H1S1-----D3
           15H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(15);
 
   CheckTree(mtf, std::string(R"(
 5H2S3-----1H1S1-----D2
           10H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RemoveLeftRightRotation) {
@@ -270,14 +280,16 @@ TEST(MoveToFront, RemoveLeftRightRotation) {
   CheckTree(mtf, std::string(R"(
 10H3S4----5H1S1-----D2
           15H2S2----12H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(5);
 
   CheckTree(mtf, std::string(R"(
 12H2S3----10H1S1----D2
           15H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RemoveRightLeftRotation) {
@@ -291,20 +303,22 @@ TEST(MoveToFront, RemoveRightLeftRotation) {
 10H3S4----5H2S2-----D2
                     8H1S1-----D3
           15H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(15);
 
   CheckTree(mtf, std::string(R"(
 8H2S3-----5H1S1-----D2
           10H1S1----D2
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, MultipleOperations) {
   MoveToFrontTester mtf;
-  std::vector<uint32_t> vals =
-      { 5, 11, 12, 16, 15, 6, 14, 2, 7, 10, 4, 8, 9, 3, 1, 13 };
+  std::vector<uint32_t> vals = {5, 11, 12, 16, 15, 6, 14, 2,
+                                7, 10, 4,  8,  9,  3, 1,  13};
 
   for (uint32_t i : vals) {
     mtf.TestInsert(i);
@@ -319,7 +333,8 @@ TEST(MoveToFront, MultipleOperations) {
           15H3S5----13H2S3----12H1S1----D4
                               14H1S1----D4
                     16H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(11);
 
@@ -331,7 +346,8 @@ TEST(MoveToFront, MultipleOperations) {
           15H3S5----13H2S3----12H1S1----D4
                               14H1S1----D4
                     16H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(11);
 
@@ -343,7 +359,8 @@ TEST(MoveToFront, MultipleOperations) {
           13H3S6----12H2S2----11H1S1----D4
                     15H2S3----14H1S1----D4
                               16H1S1----D4
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(5);
 
@@ -355,7 +372,8 @@ TEST(MoveToFront, MultipleOperations) {
           13H3S6----12H2S2----11H1S1----D4
                     15H2S3----14H1S1----D4
                               16H1S1----D4
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestInsert(5);
 
@@ -368,7 +386,8 @@ TEST(MoveToFront, MultipleOperations) {
           13H3S6----12H2S2----11H1S1----D4
                     15H2S3----14H1S1----D4
                               16H1S1----D4
-)").substr(1));
+)")
+                     .substr(1));
 
   mtf.TestRemove(2);
   mtf.TestRemove(1);
@@ -384,7 +403,8 @@ TEST(MoveToFront, MultipleOperations) {
                     12H2S2----11H1S1----D4
           15H2S3----14H1S1----D3
                     16H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, BiggerScaleTreeTest) {
@@ -435,7 +455,8 @@ TEST(MoveToFront, BiggerScaleTreeTest) {
                               24H1S1----D4
           37H2S3----35H1S1----D3
                     46H1S1----D3
-)").substr(1));
+)")
+                     .substr(1));
 }
 
 TEST(MoveToFront, RankFromValue) {
@@ -448,20 +469,26 @@ TEST(MoveToFront, RankFromValue) {
   EXPECT_TRUE(mtf.Insert(2));
   EXPECT_TRUE(mtf.Insert(3));
   EXPECT_FALSE(mtf.Insert(2));
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 2H2S3T2-------1H1S1T1-------D2
               3H1S1T3-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_FALSE(mtf.RankFromValue(4, &rank));
 
   EXPECT_TRUE(mtf.RankFromValue(1, &rank));
   EXPECT_EQ(3u, rank);
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 3H2S3T3-------2H1S1T2-------D2
               1H1S1T4-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.RankFromValue(1, &rank));
   EXPECT_EQ(1u, rank);
@@ -482,21 +509,27 @@ TEST(MoveToFront, RankFromValue) {
   EXPECT_TRUE(mtf.RankFromValue(1, &rank));
   EXPECT_EQ(2u, rank);
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 2H3S5T6-------3H1S1T5-------D2
               50H2S3T9------40H1S1T7------D3
                             1H1S1T10------D3
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.RankFromValue(50, &rank));
   EXPECT_EQ(2u, rank);
 
   EXPECT_EQ(5u, mtf.GetSize());
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 2H3S5T6-------3H1S1T5-------D2
               1H2S3T10------40H1S1T7------D3
                             50H1S1T11-----D3
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_FALSE(mtf.RankFromValue(0, &rank));
   EXPECT_FALSE(mtf.RankFromValue(20, &rank));
@@ -524,35 +557,47 @@ TEST(MoveToFront, ValueFromRank) {
   EXPECT_EQ(1u, value);
   EXPECT_EQ(1u, mtf.GetLastAccessedValue());
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 3H2S3T3-------2H1S1T2-------D2
               1H1S1T4-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.ValueFromRank(2, &value));
   EXPECT_EQ(3u, value);
 
   EXPECT_EQ(3u, mtf.GetSize());
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 1H2S3T4-------2H1S1T2-------D2
               3H1S1T5-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.ValueFromRank(3, &value));
   EXPECT_EQ(2u, value);
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 3H2S3T5-------1H1S1T4-------D2
               2H1S1T6-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.Insert(10));
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 3H3S4T5-------1H1S1T4-------D2
               2H2S2T6-------D2
                             10H1S1T7------D3
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.ValueFromRank(1, &value));
   EXPECT_EQ(10u, value);
@@ -568,29 +613,38 @@ TEST(MoveToFront, Remove) {
   EXPECT_TRUE(mtf.Insert(2));
   EXPECT_TRUE(mtf.Insert(3));
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 2H2S3T2-------1H1S1T1-------D2
               3H1S1T3-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_EQ(1u, mtf.GetNodeHandle(1));
   EXPECT_EQ(3u, mtf.GetTotalNodeCount());
   EXPECT_TRUE(mtf.Remove(1));
   EXPECT_EQ(3u, mtf.GetTotalNodeCount());
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 2H2S2T2-------D1
               3H1S1T3-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   uint32_t value = 0;
   EXPECT_TRUE(mtf.ValueFromRank(2, &value));
   EXPECT_EQ(2u, value);
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 3H2S2T3-------D1
               2H1S1T4-------D2
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   EXPECT_TRUE(mtf.Insert(1));
   EXPECT_EQ(1u, mtf.GetNodeHandle(1));
@@ -752,13 +806,16 @@ TEST(MoveToFront, LargerScale) {
     }
   }
 
-  CheckTree(mtf, std::string(R"(
+  CheckTree(mtf,
+            std::string(R"(
 6H4S9T1029----8H2S3T8-------7H1S1T7-------D3
                             9H1S1T9-------D3
               2H3S5T1033----4H2S3T1031----5H1S1T1030----D4
                                           3H1S1T1032----D4
                             1H1S1T1034----D3
-)").substr(1), /* print_timestamp = */ true);
+)")
+                .substr(1),
+            /* print_timestamp = */ true);
 
   ASSERT_TRUE(mtf.Insert(1000));
   ASSERT_TRUE(mtf.ValueFromRank(1, &value));
@@ -817,7 +874,6 @@ TEST(MultiMoveToFront, Empty) {
   EXPECT_FALSE(multi_mtf.Remove(1001, "AAA"));
 }
 
-
 TEST(MultiMoveToFront, TwoSequences) {
   MultiMoveToFront<std::string> multi_mtf;
 
index 61b6ca8..c868e72 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "source/name_mapper.h"
 
-using libspirv::NameMapper;
 using libspirv::FriendlyNameMapper;
+using libspirv::NameMapper;
 using spvtest::ScopedContext;
 using ::testing::Eq;
 
@@ -197,7 +197,8 @@ INSTANTIATE_TEST_CASE_P(ExoticTypes, FriendlyNameTest,
                             {"%1 = OpTypeDeviceEvent", 1, "DeviceEvent"},
                             {"%1 = OpTypeReserveId", 1, "ReserveId"},
                             {"%1 = OpTypeQueue", 1, "Queue"},
-                            {"%1 = OpTypeOpaque \"hello world!\"", 1, "Opaque_hello_world_"},
+                            {"%1 = OpTypeOpaque \"hello world!\"", 1,
+                             "Opaque_hello_world_"},
                             {"%1 = OpTypePipe ReadOnly", 1, "PipeReadOnly"},
                             {"%1 = OpTypePipe WriteOnly", 1, "PipeWriteOnly"},
                             {"%1 = OpTypePipe ReadWrite", 1, "PipeReadWrite"},
index 68946bb..f83f5e8 100644 (file)
@@ -65,38 +65,20 @@ TEST_P(IdValidityTest, IdTypes) {
 
 INSTANTIATE_TEST_CASE_P(
     ValidAndInvalidIds, IdValidityTest,
-    ::testing::ValuesIn(std::vector<IdCheckCase>({{"%1", true},
-                                                  {"%2abc", true},
-                                                  {"%3Def", true},
-                                                  {"%4GHI", true},
-                                                  {"%5_j_k", true},
-                                                  {"%6J_M", true},
-                                                  {"%n", true},
-                                                  {"%O", true},
-                                                  {"%p7", true},
-                                                  {"%Q8", true},
-                                                  {"%R_S", true},
-                                                  {"%T_10_U", true},
-                                                  {"%V_11", true},
-                                                  {"%W_X_13", true},
-                                                  {"%_A", true},
-                                                  {"%_", true},
-                                                  {"%__", true},
-                                                  {"%A_", true},
-                                                  {"%_A_", true},
+    ::testing::ValuesIn(std::vector<IdCheckCase>(
+        {{"%1", true},          {"%2abc", true},   {"%3Def", true},
+         {"%4GHI", true},       {"%5_j_k", true},  {"%6J_M", true},
+         {"%n", true},          {"%O", true},      {"%p7", true},
+         {"%Q8", true},         {"%R_S", true},    {"%T_10_U", true},
+         {"%V_11", true},       {"%W_X_13", true}, {"%_A", true},
+         {"%_", true},          {"%__", true},     {"%A_", true},
+         {"%_A_", true},
 
-                                                  {"%@", false},
-                                                  {"%!", false},
-                                                  {"%ABC!", false},
-                                                  {"%__A__@", false},
-                                                  {"%%", false},
-                                                  {"%-", false},
-                                                  {"%foo_@_bar", false},
-                                                  {"%", false},
+         {"%@", false},         {"%!", false},     {"%ABC!", false},
+         {"%__A__@", false},    {"%%", false},     {"%-", false},
+         {"%foo_@_bar", false}, {"%", false},
 
-                                                  {"5", false},
-                                                  {"32", false},
-                                                  {"foo", false},
-                                                  {"a%bar", false}})),);
+         {"5", false},          {"32", false},     {"foo", false},
+         {"a%bar", false}})), );
 
 }  // anonymous namespace
index 850a5ef..80d805e 100644 (file)
@@ -197,7 +197,8 @@ INSTANTIATE_TEST_CASE_P(
     Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
             ValuesIn(std::vector<EnumCapabilityCase>{
                 CASE1(DIMENSIONALITY, Dim1D, Sampled1D),
-                CASE0(DIMENSIONALITY, Dim2D), CASE0(DIMENSIONALITY, Dim3D),
+                CASE0(DIMENSIONALITY, Dim2D),
+                CASE0(DIMENSIONALITY, Dim3D),
                 CASE1(DIMENSIONALITY, DimCube, Shader),
                 CASE1(DIMENSIONALITY, DimRect, SampledRect),
                 CASE1(DIMENSIONALITY, DimBuffer, SampledBuffer),
@@ -616,14 +617,16 @@ INSTANTIATE_TEST_CASE_P(
             })), );
 
 // See SPIR-V Section 3.27 Scope <id>
-INSTANTIATE_TEST_CASE_P(
-    Scope, EnumCapabilityTest,
-    Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1),
-            ValuesIn(std::vector<EnumCapabilityCase>{
-                CASE0(SCOPE_ID, ScopeCrossDevice), CASE0(SCOPE_ID, ScopeDevice),
-                CASE0(SCOPE_ID, ScopeWorkgroup), CASE0(SCOPE_ID, ScopeSubgroup),
-                CASE0(SCOPE_ID, ScopeInvocation),
-            })), );
+INSTANTIATE_TEST_CASE_P(Scope, EnumCapabilityTest,
+                        Combine(Values(SPV_ENV_UNIVERSAL_1_0,
+                                       SPV_ENV_UNIVERSAL_1_1),
+                                ValuesIn(std::vector<EnumCapabilityCase>{
+                                    CASE0(SCOPE_ID, ScopeCrossDevice),
+                                    CASE0(SCOPE_ID, ScopeDevice),
+                                    CASE0(SCOPE_ID, ScopeWorkgroup),
+                                    CASE0(SCOPE_ID, ScopeSubgroup),
+                                    CASE0(SCOPE_ID, ScopeInvocation),
+                                })), );
 
 // See SPIR-V Section 3.28 Group Operation
 INSTANTIATE_TEST_CASE_P(
index 358671c..95acc9a 100644 (file)
@@ -73,13 +73,13 @@ TEST_P(MaskExpansionTest, Sample) {
 
   spv_operand_pattern_t pattern(GetParam().initial);
   spvPushOperandTypesForMask(operandTable, GetParam().type, GetParam().mask,
-                                &pattern);
+                             &pattern);
   EXPECT_THAT(pattern, Eq(GetParam().expected));
 }
 
 // These macros let us write non-trivial examples without too much text.
 #define PREFIX0 SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_NONE
-#define PREFIX1                                              \
+#define PREFIX1                                                         \
   SPV_OPERAND_TYPE_STORAGE_CLASS, SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE, \
       SPV_OPERAND_TYPE_ID
 INSTANTIATE_TEST_CASE_P(
@@ -202,27 +202,25 @@ TEST(AlternatePatternFollowingImmediate, ResultIdFront) {
               Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV,
                                        SPV_OPERAND_TYPE_RESULT_ID,
                                        SPV_OPERAND_TYPE_OPTIONAL_CIV}));
-  EXPECT_THAT(spvAlternatePatternFollowingImmediate(
-                  {SPV_OPERAND_TYPE_RESULT_ID,
-                   SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID}),
-              Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_RESULT_ID,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV}));
-  EXPECT_THAT(spvAlternatePatternFollowingImmediate(
-                  {SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_DIMENSIONALITY,
-                   SPV_OPERAND_TYPE_LINKAGE_TYPE,
-                   SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE,
-                   SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID,
-                   SPV_OPERAND_TYPE_VARIABLE_ID}),
-              Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_RESULT_ID,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV,
-                                       SPV_OPERAND_TYPE_OPTIONAL_CIV}));
+  EXPECT_THAT(
+      spvAlternatePatternFollowingImmediate({SPV_OPERAND_TYPE_RESULT_ID,
+                                             SPV_OPERAND_TYPE_FP_ROUNDING_MODE,
+                                             SPV_OPERAND_TYPE_ID}),
+      Eq(spv_operand_pattern_t{
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID,
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV}));
+  EXPECT_THAT(
+      spvAlternatePatternFollowingImmediate(
+          {SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_DIMENSIONALITY,
+           SPV_OPERAND_TYPE_LINKAGE_TYPE,
+           SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE,
+           SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID,
+           SPV_OPERAND_TYPE_VARIABLE_ID}),
+      Eq(spv_operand_pattern_t{
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID,
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV,
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV,
+          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_OPTIONAL_CIV}));
 }
 
 TEST(AlternatePatternFollowingImmediate, ResultIdMiddle) {
@@ -252,16 +250,16 @@ TEST(AlternatePatternFollowingImmediate, ResultIdBack) {
   EXPECT_THAT(spvAlternatePatternFollowingImmediate(
                   {SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID,
                    SPV_OPERAND_TYPE_RESULT_ID}),
-              Eq(spv_operand_pattern_t{
-                  SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID}));
+              Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV,
+                                       SPV_OPERAND_TYPE_RESULT_ID}));
   EXPECT_THAT(
       spvAlternatePatternFollowingImmediate(
           {SPV_OPERAND_TYPE_DIMENSIONALITY, SPV_OPERAND_TYPE_LINKAGE_TYPE,
            SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE,
            SPV_OPERAND_TYPE_FP_ROUNDING_MODE, SPV_OPERAND_TYPE_ID,
            SPV_OPERAND_TYPE_VARIABLE_ID, SPV_OPERAND_TYPE_RESULT_ID}),
-      Eq(spv_operand_pattern_t{
-          SPV_OPERAND_TYPE_OPTIONAL_CIV, SPV_OPERAND_TYPE_RESULT_ID}));
+      Eq(spv_operand_pattern_t{SPV_OPERAND_TYPE_OPTIONAL_CIV,
+                               SPV_OPERAND_TYPE_RESULT_ID}));
 }
 
 }  // anonymous namespace
index a9056a2..464d38f 100644 (file)
@@ -17,8 +17,8 @@
 namespace {
 
 using GetTargetTest = ::testing::TestWithParam<spv_target_env>;
-using ::testing::ValuesIn;
 using std::vector;
+using ::testing::ValuesIn;
 
 TEST_P(GetTargetTest, Default) {
   spv_operand_table table;
index a16eb47..6982e51 100644 (file)
@@ -24,10 +24,10 @@ using AggressiveDCETest = PassTest<::testing::Test>;
 
 TEST_F(AggressiveDCETest, EliminateExtendedInst) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
   //  in vec4 Dead;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -103,21 +103,20 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoEliminateFrexp) {
   // Note: SPIR-V hand-edited to utilize Frexp
   //
   // #version 450
-  // 
+  //
   // in vec4 BaseColor;
   // in vec4 Dead;
   // out vec4 Color;
   // out ivec4 iv2;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -204,19 +203,18 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, EliminateDecorate) {
   // Note: The SPIR-V was hand-edited to add the OpDecorate
   //
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
   // in vec4 Dead;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -294,17 +292,16 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, Simple) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
   //  in vec4 Dead;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -379,20 +376,19 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, DeadCycle) {
   // #version 140
   // in vec4 BaseColor;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     int g_I ;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -534,17 +530,16 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, OptWhitelistExtension) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
   //  in vec4 Dead;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -620,17 +615,16 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs1 + names_before + predefs2 + func_before, 
-      predefs1 + names_after + predefs2 + func_after, 
-      true, true);
+      predefs1 + names_before + predefs2 + func_before,
+      predefs1 + names_after + predefs2 + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoOptBlacklistExtension) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
   //  in vec4 Dead;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -676,8 +670,7 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, ElimWithCall) {
@@ -686,11 +679,11 @@ TEST_F(AggressiveDCETest, ElimWithCall) {
   // #version 140
   // in vec4 i1;
   // in vec4 i2;
-  // 
+  //
   // void nothing(vec4 v)
   // {
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 v1 = i1;
@@ -811,15 +804,15 @@ TEST_F(AggressiveDCETest, NoParamElim) {
   // This demonstrates that unused parameters are not eliminated, but
   // dead uses of them are.
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // vec4 foo(vec4 v1, vec4 v2)
   // {
   //     vec4 t = -v1;
   //     return v2;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 dead;
@@ -1037,7 +1030,7 @@ OpFunctionEnd
 )";
 
   const std::string func_after =
-        R"(%main = OpFunction %void None %9
+      R"(%main = OpFunction %void None %9
 %25 = OpLabel
 %26 = OpLoad %v2float %texCoords
 %29 = OpLoad %15 %sampler15
@@ -1055,15 +1048,15 @@ TEST_F(AggressiveDCETest, NoParamStoreElim) {
   // Should not eliminate stores to params
   //
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void foo(in vec4 v1, out vec4 v2)
   // {
   //     v2 = -v1;
   // }
-  // 
+  //
   // void main()
   // {
   //     foo(BaseColor, OutColor);
@@ -1118,8 +1111,7 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, PrivateStoreElimInEntryNoCalls) {
@@ -1131,7 +1123,7 @@ TEST_F(AggressiveDCETest, PrivateStoreElimInEntryNoCalls) {
   // layout(location = 0) out vec4 OutColor;
   //
   // private vec4 dv;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -1206,12 +1198,12 @@ TEST_F(AggressiveDCETest, NoPrivateStoreElimIfLoad) {
   // Note: Not legal GLSL
   //
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
   //
   // private vec4 pv;
-  // 
+  //
   // void main()
   // {
   //     pv = BaseColor;
@@ -1252,8 +1244,7 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoPrivateStoreElimWithCall) {
@@ -1261,17 +1252,17 @@ TEST_F(AggressiveDCETest, NoPrivateStoreElimWithCall) {
   // Note: Not legal GLSL
   //
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
   //
   // private vec4 v1;
-  // 
+  //
   // void foo()
   // {
   //     OutColor = -v1;
   // }
-  // 
+  //
   // void main()
   // {
   //     v1 = BaseColor;
@@ -1318,8 +1309,7 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoPrivateStoreElimInNonEntry) {
@@ -1327,17 +1317,17 @@ TEST_F(AggressiveDCETest, NoPrivateStoreElimInNonEntry) {
   // Note: Not legal GLSL
   //
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
   //
   // private vec4 v1;
-  // 
+  //
   // void foo()
   // {
   //     v1 = BaseColor;
   // }
-  // 
+  //
   // void main()
   // {
   //     foo();
@@ -1384,16 +1374,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, EliminateDeadIfThenElse) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float d;
@@ -1505,17 +1494,15 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs_before + func_before, 
-      predefs_after + func_after, 
-      true, true);
+      predefs_before + func_before, predefs_after + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, EliminateDeadIfThen) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float d;
@@ -1618,17 +1605,15 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs_before + func_before, 
-      predefs_after + func_after, 
-      true, true);
+      predefs_before + func_before, predefs_after + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, EliminateDeadIfThenElseNested) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float d;
@@ -1768,17 +1753,15 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs_before + func_before, 
-      predefs_after + func_after, 
-      true, true);
+      predefs_before + func_before, predefs_after + func_after, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoEliminateLiveIfThenElse) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float t;
@@ -1844,16 +1827,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoEliminateLiveIfThenElseNested) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float t;
@@ -1945,18 +1927,17 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, NoEliminateIfWithPhi) {
   // Note: Assembly hand-optimized from GLSL
   //
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float t;
@@ -2013,16 +1994,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
 }
 
 TEST_F(AggressiveDCETest, EliminateEntireFunctionBody) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     float d;
@@ -2127,12 +2107,9 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::AggressiveDCEPass>(
-      predefs_before + func_before, 
-      predefs_after + func_after, 
-      true, true);
+      predefs_before + func_before, predefs_after + func_after, true, true);
 }
 
-
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
 //
 //    Check that logical addressing required
index ffed4ac..e1e87e1 100644 (file)
@@ -88,10 +88,12 @@ class AssemblyBuilder {
         types_consts_globals_(),
         main_func_(),
         main_func_postamble_({
-            "OpReturn", "OpFunctionEnd",
+            "OpReturn",
+            "OpFunctionEnd",
         }) {
     AppendTypesConstantsGlobals({
-        "%void = OpTypeVoid", "%main_func_type = OpTypeFunction %void",
+        "%void = OpTypeVoid",
+        "%main_func_type = OpTypeFunction %void",
     });
     AppendInMain({
         "%main = OpFunction %void None %main_func_type",
index 50bb46c..1d6084d 100644 (file)
@@ -166,8 +166,11 @@ TEST_F(AssemblyBuilderTest, ShaderWithConstants) {
 TEST_F(AssemblyBuilderTest, SpecConstants) {
   AssemblyBuilder builder;
   builder.AppendTypesConstantsGlobals({
-      "%bool = OpTypeBool", "%uint = OpTypeInt 32 0", "%int = OpTypeInt 32 1",
-      "%float = OpTypeFloat 32", "%double = OpTypeFloat 64",
+      "%bool = OpTypeBool",
+      "%uint = OpTypeInt 32 0",
+      "%int = OpTypeInt 32 1",
+      "%float = OpTypeFloat 32",
+      "%double = OpTypeFloat 64",
       "%v2int = OpTypeVector %int 2",
 
       "%spec_true = OpSpecConstantTrue %bool",
index 2133fee..de5e260 100644 (file)
@@ -27,9 +27,9 @@ TEST_F(BlockMergeTest, Simple) {
   // between two statements in main.
   //
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -84,8 +84,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::BlockMergePass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
+                                             true, true);
 }
 
 TEST_F(BlockMergeTest, EmptyBlock) {
@@ -93,9 +93,9 @@ TEST_F(BlockMergeTest, EmptyBlock) {
   // after two statements in main.
   //
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  void main()
   //  {
   //      vec4 v = BaseColor;
@@ -154,8 +154,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::BlockMergePass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
+                                             true, true);
 }
 
 TEST_F(BlockMergeTest, NoOptOfMergeOrContinueBlock) {
@@ -164,7 +164,7 @@ TEST_F(BlockMergeTest, NoOptOfMergeOrContinueBlock) {
   //
   // #version 140
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     while (true) {
@@ -212,8 +212,7 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::BlockMergePass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::BlockMergePass>(assembly, assembly, true, true);
 }
 
 TEST_F(BlockMergeTest, NestedInControlFlow) {
@@ -222,16 +221,16 @@ TEST_F(BlockMergeTest, NestedInControlFlow) {
   //
   // #version 140
   // in vec4 BaseColor;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     bool g_B ;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
-  //     if (g_B) 
+  //     if (g_B)
   //       vec4 v = v * 0.25;
   //     gl_FragColor = v;
   // }
@@ -325,8 +324,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::BlockMergePass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
+                                             true, true);
 }
 
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
index 9699ee4..aa6ac77 100644 (file)
@@ -149,7 +149,6 @@ OpFunctionEnd
   SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
 }
 
-
 TEST_F(CFGCleanupTest, UpdatePhis) {
   const std::string before = R"(
                OpCapability Shader
@@ -252,7 +251,7 @@ TEST_F(CFGCleanupTest, RemoveNamedLabels) {
                OpReturn
                OpFunctionEnd)";
 
-    const std::string after = R"(OpCapability Shader
+  const std::string after = R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Vertex %main "main"
@@ -270,7 +269,7 @@ OpFunctionEnd
 }
 
 TEST_F(CFGCleanupTest, RemovePhiArgsFromFarBlocks) {
-    const std::string before = R"(
+  const std::string before = R"(
                OpCapability Shader
           %1 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
@@ -318,7 +317,7 @@ TEST_F(CFGCleanupTest, RemovePhiArgsFromFarBlocks) {
                OpReturn
                OpFunctionEnd)";
 
-    const std::string after = R"(OpCapability Shader
+  const std::string after = R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main" %y %outparm
@@ -368,7 +367,7 @@ OpFunctionEnd
 }
 
 TEST_F(CFGCleanupTest, RemovePhiConstantArgs) {
-    const std::string before = R"(
+  const std::string before = R"(
                OpCapability Shader
           %1 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
@@ -409,7 +408,7 @@ TEST_F(CFGCleanupTest, RemovePhiConstantArgs) {
                OpReturn
                OpFunctionEnd)";
 
-    const std::string after = R"(OpCapability Shader
+  const std::string after = R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main" %y %outparm
index bc642f3..b2b9409 100644 (file)
@@ -30,13 +30,13 @@ TEST_F(CommonUniformElimTest, Basic1) {
   // #version 140
   // in vec4 BaseColor;
   // in float fi;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     float g_F;
   //     float g_F2;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -179,13 +179,13 @@ TEST_F(CommonUniformElimTest, Basic2) {
   // in vec4 BaseColor;
   // in float fi;
   // in float fi2;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     float g_F;
   //     float g_F2;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     float f = fi;
@@ -340,13 +340,13 @@ TEST_F(CommonUniformElimTest, Basic3) {
   // #version 140
   // in vec4 BaseColor;
   // in float fi;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     bool g_B;
   //     float g_F;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -458,12 +458,12 @@ TEST_F(CommonUniformElimTest, Loop) {
   // #version 140
   // in vec4 BC;
   // in vec4 BC2;
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     float g_F;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BC;
@@ -663,7 +663,7 @@ OpFunctionEnd
       predefs + before, predefs + after, true, true);
 }
 
-  TEST_F(CommonUniformElimTest, Volatile1) {
+TEST_F(CommonUniformElimTest, Volatile1) {
   // Note: This test exemplifies the following:
   // - Same test as Basic1 with the exception that
   //   the Load of g_F in else-branch is volatile
@@ -810,7 +810,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::CommonUniformElimPass>(
-  predefs + before, predefs + after, true, true);
+      predefs + before, predefs + after, true, true);
 }
 
 TEST_F(CommonUniformElimTest, Volatile2) {
@@ -918,7 +918,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  opt::Pass::Status res = std::get<1>(SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(text, true));
+  opt::Pass::Status res = std::get<1>(
+      SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(text, true));
   EXPECT_EQ(res, opt::Pass::Status::SuccessWithoutChange);
 }
 
@@ -955,7 +956,7 @@ TEST_F(CommonUniformElimTest, Volatile3) {
   // }
 
   const std::string text =
-  R"(OpCapability Shader
+      R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main" %BaseColor %fi
@@ -1034,7 +1035,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  opt::Pass::Status res = std::get<1>(SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(text, true));
+  opt::Pass::Status res = std::get<1>(
+      SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(text, true));
   EXPECT_EQ(res, opt::Pass::Status::SuccessWithoutChange);
 }
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
index ac95d4a..d5fcfb9 100644 (file)
@@ -28,7 +28,7 @@ using CompactIdsTest = PassTest<::testing::Test>;
 
 TEST_F(CompactIdsTest, PassOff) {
   const std::string before =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
@@ -48,7 +48,7 @@ OpMemoryModel Physical32 OpenCL
 
 TEST_F(CompactIdsTest, PassOn) {
   const std::string before =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
@@ -67,7 +67,7 @@ OpFunctionEnd
 )";
 
   const std::string after =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
index 661f9c7..148c546 100644 (file)
@@ -24,9 +24,9 @@ using DeadBranchElimTest = PassTest<::testing::Test>;
 
 TEST_F(DeadBranchElimTest, IfThenElseTrue) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -99,15 +99,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, IfThenElseFalse) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -180,15 +180,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, IfThenTrue) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -262,15 +262,15 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, IfThenFalse) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -339,8 +339,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, IfThenElsePhiTrue) {
@@ -348,7 +348,7 @@ TEST_F(DeadBranchElimTest, IfThenElsePhiTrue) {
   // Note: The SPIR-V has had store/load elimination and phi insertion
   //
   // #version 140
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -412,8 +412,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, IfThenElsePhiFalse) {
@@ -421,7 +421,7 @@ TEST_F(DeadBranchElimTest, IfThenElsePhiFalse) {
   // Note: The SPIR-V has had store/load elimination and phi insertion
   //
   // #version 140
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -485,18 +485,18 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, CompoundIfThenElseFalse) {
   // #version 140
-  // 
+  //
   // layout(std140) uniform U_t
   // {
   //     bool g_B ;
   // } ;
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -620,12 +620,11 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, PreventOrphanMerge) {
-
   const std::string predefs =
       R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
@@ -685,12 +684,11 @@ OpKill
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, HandleOrphanMerge) {
-
   const std::string predefs =
       R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
@@ -747,8 +745,8 @@ OpReturnValue %13
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, KeepContinueTargetWhenKillAfterMerge) {
@@ -845,16 +843,16 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, DecorateDeleted) {
   // Note: SPIR-V hand-edited to add decoration
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -956,10 +954,10 @@ OpFunctionEnd
 
 TEST_F(DeadBranchElimTest, LoopInDeadBranch) {
   // #version 450
-  // 
+  //
   // layout(location = 0) in vec4 BaseColor;
   // layout(location = 0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -1055,16 +1053,16 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, SwitchLiveCase) {
   // #version 450
-  // 
+  //
   // layout (location=0) in vec4 BaseColor;
   // layout (location=0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     switch (1) {
@@ -1148,16 +1146,16 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, SwitchLiveDefault) {
   // #version 450
-  // 
+  //
   // layout (location=0) in vec4 BaseColor;
   // layout (location=0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     switch (7) {
@@ -1241,8 +1239,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 TEST_F(DeadBranchElimTest, SwitchLiveCaseBreakFromLoop) {
@@ -1251,7 +1249,7 @@ TEST_F(DeadBranchElimTest, SwitchLiveCaseBreakFromLoop) {
   // This construct is currently formed by inlining a function
   // containing early returns from the cases of a switch. The
   // function is wrapped in a one-trip loop and returns are
-  // translated to branches to the loop's merge block. 
+  // translated to branches to the loop's merge block.
 
   const std::string predefs =
       R"(OpCapability Shader
@@ -1344,8 +1342,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::DeadBranchElimPass>(
-      predefs + before, predefs + after, true, true);
+  SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
+                                                 predefs + after, true, true);
 }
 
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
index b51f489..3533de1 100644 (file)
@@ -34,11 +34,10 @@ using namespace spvtools;
 using spvtools::opt::analysis::DefUseManager;
 
 // Returns the number of uses of |id|.
-uint32_t NumUses(const std::unique_ptr<ir::IRContext> &context, uint32_t id) {
+uint32_t NumUses(const std::unique_ptr<ir::IRContext>context, uint32_t id) {
   uint32_t count = 0;
-  context->get_def_use_mgr()->ForEachUse(id, [&count](ir::Instruction*, uint32_t) {
-    ++count;
-  });
+  context->get_def_use_mgr()->ForEachUse(
+      id, [&count](ir::Instruction*, uint32_t) { ++count; });
   return count;
 }
 
@@ -46,11 +45,13 @@ uint32_t NumUses(const std::unique_ptr<ir::IRContext> &context, uint32_t id) {
 //
 // If |id| is used multiple times in a single instruction, that instruction's
 // opcode will appear a corresponding number of times.
-std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<ir::IRContext> &context, uint32_t id) {
+std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<ir::IRContext>& context,
+                                 uint32_t id) {
   std::vector<SpvOp> opcodes;
-  context->get_def_use_mgr()->ForEachUse(id, [&opcodes](ir::Instruction* user, uint32_t) {
-    opcodes.push_back(user->opcode());
-  });
+  context->get_def_use_mgr()->ForEachUse(
+      id, [&opcodes](ir::Instruction* user, uint32_t) {
+        opcodes.push_back(user->opcode());
+      });
   return opcodes;
 }
 
@@ -109,7 +110,7 @@ UserMap BuildAllUsers(const DefUseManager* mgr, uint32_t idBound) {
   UserMap userMap;
   for (uint32_t id = 0; id != idBound; ++id) {
     if (mgr->GetDef(id)) {
-      mgr->ForEachUser(id, [id,&userMap](ir::Instruction* user) {
+      mgr->ForEachUser(id, [id, &userMap](ir::Instruction* user) {
         if (user->opcode() != SpvOpConstant) {
           userMap[id].push_back(user);
         }
@@ -121,8 +122,7 @@ UserMap BuildAllUsers(const DefUseManager* mgr, uint32_t idBound) {
 
 // Constants don't disassemble properly without a full context, so skip them as
 // checks.
-void CheckUse(const InstDefUse& expected_defs_uses,
-              const DefUseManager* mgr,
+void CheckUse(const InstDefUse& expected_defs_uses, const DefUseManager* mgr,
               uint32_t idBound) {
   UserMap actual_uses = BuildAllUsers(mgr, idBound);
   // Check uses.
@@ -1252,9 +1252,9 @@ TEST(DefUseTest, OpSwitch) {
   (void)context->get_def_use_mgr();
 
   // Do a bunch replacements.
-  context->ReplaceAllUsesWith(11, 7);     // to existing id
+  context->ReplaceAllUsesWith(11, 7);   // to existing id
   context->ReplaceAllUsesWith(10, 11);  // to existing id
-  context->ReplaceAllUsesWith(9, 10);    // to existing id
+  context->ReplaceAllUsesWith(9, 10);   // to existing id
 
   // clang-format off
   const char modified_text[] =
@@ -1340,7 +1340,7 @@ TEST_P(AnalyzeInstDefUseTest, Case) {
 
   CheckDef(tc.expected_define_use, manager.id_to_defs());
   CheckUse(tc.expected_define_use, &manager, context->module()->IdBound());
-  //CheckUse(tc.expected_define_use, manager.id_to_uses());
+  // CheckUse(tc.expected_define_use, manager.id_to_uses());
 }
 
 // clang-format off
@@ -1387,14 +1387,13 @@ TEST(AnalyzeInstDefUse, UseWithNoResultId) {
   manager.AnalyzeInstDefUse(&branch);
   context.module()->SetIdBound(3);
 
-  InstDefUse expected =
-  {
-    // defs
-    {
-      {2, "%2 = OpLabel"},
-    },
-    // uses
-    {{2, {"OpBranch %2"}}},
+  InstDefUse expected = {
+      // defs
+      {
+          {2, "%2 = OpLabel"},
+      },
+      // uses
+      {{2, {"OpBranch %2"}}},
   };
 
   CheckDef(expected, manager.id_to_defs());
@@ -1415,15 +1414,16 @@ TEST(AnalyzeInstDefUse, AddNewInstruction) {
   ir::Instruction newInst(context.get(), SpvOpConstantTrue, 1, 2, {});
   manager.AnalyzeInstDefUse(&newInst);
 
-  InstDefUse expected =
-  {
-    { // defs
-      {1, "%1 = OpTypeBool"},
-      {2, "%2 = OpConstantTrue %1"},
-    },
-    { // uses
-      {1, {"%2 = OpConstantTrue %1"}},
-    },
+  InstDefUse expected = {
+      {
+          // defs
+          {1, "%1 = OpTypeBool"},
+          {2, "%2 = OpConstantTrue %1"},
+      },
+      {
+          // uses
+          {1, {"%2 = OpConstantTrue %1"}},
+      },
   };
 
   CheckDef(expected, manager.id_to_defs());
@@ -1461,7 +1461,8 @@ TEST_P(KillInstTest, Case) {
 
   EXPECT_EQ(tc.after, DisassembleModule(context->module()));
   CheckDef(tc.expected_define_use, context->get_def_use_mgr()->id_to_defs());
-  CheckUse(tc.expected_define_use, context->get_def_use_mgr(), context->module()->IdBound());
+  CheckUse(tc.expected_define_use, context->get_def_use_mgr(),
+           context->module()->IdBound());
 }
 
 // clang-format off
index 474a6ea..ebbb233 100644 (file)
@@ -59,7 +59,9 @@ TEST_F(EliminateDeadConstantBasicTest, BasicAllDeadConstants) {
   // None of the above constants is ever used, so all of them should be
   // eliminated.
   const char* const_decl_opcodes[] = {
-      " OpConstantTrue ", " OpConstantFalse ", " OpConstant ",
+      " OpConstantTrue ",
+      " OpConstantFalse ",
+      " OpConstant ",
   };
   // Skip lines that have any one of const_decl_opcodes.
   const std::string expected_disassembly =
index 7678894..d3588f7 100644 (file)
@@ -125,8 +125,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineOpaquePass>(
-      predefs + before + post_defs,
-      predefs + after + post_defs, true, true);
+      predefs + before + post_defs, predefs + after + post_defs, true, true);
 }
 
 TEST_F(InlineOpaqueTest, InlineOpaqueReturn) {
@@ -216,8 +215,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineOpaquePass>(
-      predefs + before + post_defs,
-      predefs + after + post_defs, true, true);
+      predefs + before + post_defs, predefs + after + post_defs, true, true);
 }
 
 TEST_F(InlineOpaqueTest, InlineInNonEntryPointFunction) {
@@ -331,21 +329,20 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineOpaquePass>(
-      predefs + before + post_defs,
-      predefs + after + post_defs, true, true);
+      predefs + before + post_defs, predefs + after + post_defs, true, true);
 }
 
 TEST_F(InlineOpaqueTest, NoInlineNoOpaque) {
   // Function without opaque interface is not inlined.
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     return bar.x + bar.y;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
@@ -405,8 +402,7 @@ OpReturnValue %31
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InlineOpaquePass>(
-      assembly, assembly, true, true);
+  SinglePassRunAndCheck<opt::InlineOpaquePass>(assembly, assembly, true, true);
 }
 
 }  // anonymous namespace
index b18a54e..3eaf4df 100644 (file)
@@ -24,14 +24,14 @@ using InlineTest = PassTest<::testing::Test>;
 
 TEST_F(InlineTest, Simple) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     return bar.x + bar.y;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
@@ -134,23 +134,23 @@ TEST_F(InlineTest, Simple) {
 
 TEST_F(InlineTest, Nested) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo2(float f, float f2)
   // {
   //     return f * f2;
   // }
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     return foo2(bar.x + bar.y, bar.z);
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
-  //     gl_FragColor = color; 
+  //     gl_FragColor = color;
   // }
   const std::vector<const char*> predefs = {
       // clang-format off
@@ -284,20 +284,20 @@ TEST_F(InlineTest, Nested) {
 
 TEST_F(InlineTest, InOutParameter) {
   // #version 400
-  // 
+  //
   // in vec4 Basecolor;
-  // 
+  //
   // void foo(inout vec4 bar)
   // {
   //     bar.z = bar.x + bar.y;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 b = Basecolor;
   //     foo(b);
   //     vec4 color = vec4(b.z);
-  //     gl_FragColor = color; 
+  //     gl_FragColor = color;
   // }
   const std::vector<const char*> predefs = {
       // clang-format off
@@ -413,9 +413,9 @@ TEST_F(InlineTest, InOutParameter) {
 
 TEST_F(InlineTest, BranchInCallee) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     float r = bar.x;
@@ -423,12 +423,12 @@ TEST_F(InlineTest, BranchInCallee) {
   //         r = -r;
   //     return r;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
-  // 
-  //     gl_FragColor = color; 
+  //
+  //     gl_FragColor = color;
   // }
   const std::vector<const char*> predefs = {
       // clang-format off
@@ -549,9 +549,9 @@ TEST_F(InlineTest, BranchInCallee) {
 
 TEST_F(InlineTest, PhiAfterCall) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(float bar)
   // {
   //     float r = bar;
@@ -559,13 +559,13 @@ TEST_F(InlineTest, PhiAfterCall) {
   //         r = -r;
   //     return r;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = BaseColor;
   //     if (foo(color.x) > 2.0 && foo(color.y) > 2.0)
   //         color = vec4(0.0);
-  //     gl_FragColor = color; 
+  //     gl_FragColor = color;
   // }
   const std::vector<const char*> predefs = {
       // clang-format off
@@ -744,12 +744,12 @@ TEST_F(InlineTest, PhiAfterCall) {
 
 TEST_F(InlineTest, OpSampledImageOutOfBlock) {
   // #version 450
-  // 
+  //
   // uniform texture2D t2D;
   // uniform sampler samp;
   // out vec4 FragColor;
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     float r = bar.x;
@@ -757,13 +757,13 @@ TEST_F(InlineTest, OpSampledImageOutOfBlock) {
   //         r = -r;
   //     return r;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color1 = texture(sampler2D(t2D, samp), vec2(1.0));
   //     vec4 color2 = vec4(foo(BaseColor));
   //     vec4 color3 = texture(sampler2D(t2D, samp), vec2(0.5));
-  //     FragColor = (color1 + color2 + color3)/3; 
+  //     FragColor = (color1 + color2 + color3)/3;
   // }
   //
   // Note: the before SPIR-V will need to be edited to create a use of
@@ -941,15 +941,15 @@ TEST_F(InlineTest, OpSampledImageOutOfBlock) {
 
 TEST_F(InlineTest, OpImageOutOfBlock) {
   // #version 450
-  // 
+  //
   // uniform texture2D t2D;
   // uniform sampler samp;
   // uniform sampler samp2;
-  // 
+  //
   // out vec4 FragColor;
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     float r = bar.x;
@@ -957,13 +957,13 @@ TEST_F(InlineTest, OpImageOutOfBlock) {
   //         r = -r;
   //     return r;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color1 = texture(sampler2D(t2D, samp), vec2(1.0));
   //     vec4 color2 = vec4(foo(BaseColor));
   //     vec4 color3 = texture(sampler2D(t2D, samp2), vec2(0.5));
-  //     FragColor = (color1 + color2 + color3)/3; 
+  //     FragColor = (color1 + color2 + color3)/3;
   // }
   // Note: the before SPIR-V will need to be edited to create an OpImage
   // from the first OpSampledImage, place it before the call and use it
@@ -1147,15 +1147,15 @@ TEST_F(InlineTest, OpImageOutOfBlock) {
 
 TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
   // #version 450
-  // 
+  //
   // uniform texture2D t2D;
   // uniform sampler samp;
   // uniform sampler samp2;
-  // 
+  //
   // out vec4 FragColor;
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     float r = bar.x;
@@ -1163,13 +1163,13 @@ TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
   //         r = -r;
   //     return r;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color1 = texture(sampler2D(t2D, samp), vec2(1.0));
   //     vec4 color2 = vec4(foo(BaseColor));
   //     vec4 color3 = texture(sampler2D(t2D, samp2), vec2(0.5));
-  //     FragColor = (color1 + color2 + color3)/3; 
+  //     FragColor = (color1 + color2 + color3)/3;
   // }
   // Note: the before SPIR-V will need to be edited to create an OpImage
   // and subsequent OpSampledImage that is used across the function call.
@@ -1353,20 +1353,20 @@ TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
 
 TEST_F(InlineTest, EarlyReturnFunctionInlined) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     if (bar.x < 0.0)
   //         return 0.0;
   //     return bar.x;
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
-  //     gl_FragColor = color; 
+  //     gl_FragColor = color;
   // }
 
   const std::string predefs =
@@ -1474,8 +1474,8 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-      predefs + before + nonEntryFuncs, 
-      predefs + after + nonEntryFuncs, false, true);
+      predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
+      true);
 }
 
 TEST_F(InlineTest, EarlyReturnNotAppearingLastInFunctionInlined) {
@@ -1530,7 +1530,7 @@ OpFunctionEnd
 )";
 
   const std::string after =
-R"(%main = OpFunction %void None %4
+      R"(%main = OpFunction %void None %4
 %10 = OpLabel
 OpSelectionMerge %12 None
 OpBranchConditional %true %13 %12
@@ -1544,25 +1544,25 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-      predefs + nonEntryFuncs + before,
-      predefs + nonEntryFuncs + after, false, true);
+      predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
+      true);
 }
 
 TEST_F(InlineTest, ForwardReferencesInPhiInlined) {
   // The basic structure of the test case is like this:
-  // 
+  //
   // int foo() {
   //   int result = 1;
   //   if (true) {
   //      result = 1;
-  //   } 
+  //   }
   //   return result;
-  // }   
-  // 
+  // }
+  //
   // void main() {
   //  int x = foo();
   // }
-  // 
+  //
   // but with modifications: Using Phi instead of load/store, and the
   // return block in foo appears before the "then" block.
 
@@ -1611,7 +1611,7 @@ OpFunctionEnd
 )";
 
   const std::string after =
-R"(%main = OpFunction %void None %6
+      R"(%main = OpFunction %void None %6
 %19 = OpLabel
 %21 = OpVariable %_ptr_Function_int Function
 %x = OpVariable %_ptr_Function_int Function
@@ -1633,15 +1633,15 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-      predefs + nonEntryFuncs + before,
-      predefs + nonEntryFuncs + after, false, true);
+      predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
+      true);
 }
 
 TEST_F(InlineTest, EarlyReturnInLoopIsNotInlined) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // float foo(vec4 bar)
   // {
   //     while (true) {
@@ -1650,11 +1650,11 @@ TEST_F(InlineTest, EarlyReturnInLoopIsNotInlined) {
   //         return bar.x;
   //     }
   // }
-  // 
+  //
   // void main()
   // {
   //     vec4 color = vec4(foo(BaseColor));
-  //     gl_FragColor = color; 
+  //     gl_FragColor = color;
   // }
 
   const std::string assembly =
@@ -1729,8 +1729,8 @@ OpReturnValue %41
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-      assembly, assembly, false, true);
+  SinglePassRunAndCheck<opt::InlineExhaustivePass>(assembly, assembly, false,
+                                                   true);
 }
 
 TEST_F(InlineTest, ExternalFunctionIsNotInlined) {
@@ -1754,8 +1754,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-      assembly, assembly, false, true);
+  SinglePassRunAndCheck<opt::InlineExhaustivePass>(assembly, assembly, false,
+                                                   true);
 }
 
 TEST_F(InlineTest, SingleBlockLoopCallsMultiBlockCallee) {
@@ -1997,12 +1997,13 @@ OpFunctionEnd
       true);
 }
 
-TEST_F(InlineTest, MultiBlockLoopHeaderCallsFromToMultiBlockCalleeHavingSelectionMerge) {
+TEST_F(InlineTest,
+       MultiBlockLoopHeaderCallsFromToMultiBlockCalleeHavingSelectionMerge) {
   // This is similar to SingleBlockLoopCallsMultiBlockCalleeHavingSelectionMerge
   // but the call is in the header block of a multi block loop.
 
   const std::string predefs =
-R"(OpCapability Shader
+      R"(OpCapability Shader
 OpMemoryModel Logical GLSL450
 OpEntryPoint GLCompute %1 "main"
 OpSource OpenCL_C 120
@@ -2019,7 +2020,7 @@ OpSource OpenCL_C 120
 )";
 
   const std::string nonEntryFuncs =
-  R"(%12 = OpFunction %void None %11
+      R"(%12 = OpFunction %void None %11
 %13 = OpLabel
 %14 = OpCopyObject %int %int_1
 OpSelectionMerge %15 None
@@ -2077,7 +2078,9 @@ OpFunctionEnd
       true);
 }
 
-TEST_F(InlineTest, SingleBlockLoopCallsMultiBlockCalleeHavingSelectionMergeAndMultiReturns) {
+TEST_F(
+    InlineTest,
+    SingleBlockLoopCallsMultiBlockCalleeHavingSelectionMergeAndMultiReturns) {
   // This is similar to SingleBlockLoopCallsMultiBlockCalleeHavingSelectionMerge
   // except that in addition to starting with a selection header, the
   // callee also has multi returns.
@@ -2271,7 +2274,7 @@ TEST_F(InlineTest, Decorated1) {
   // }
 
   const std::string predefs =
-  R"(OpCapability Shader
+      R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor
@@ -2288,7 +2291,7 @@ OpDecorate %9 RelaxedPrecision
 )";
 
   const std::string before =
-  R"(%void = OpTypeVoid
+      R"(%void = OpTypeVoid
 %11 = OpTypeFunction %void
 %float = OpTypeFloat 32
 %v4float = OpTypeVector %float 4
@@ -2317,9 +2320,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-
   const std::string after =
-  R"(OpDecorate %37 RelaxedPrecision
+      R"(OpDecorate %37 RelaxedPrecision
 %void = OpTypeVoid
 %11 = OpTypeFunction %void
 %float = OpTypeFloat 32
@@ -2357,7 +2359,7 @@ OpFunctionEnd
 )";
 
   const std::string nonEntryFuncs =
-  R"(%foo_vf4_ = OpFunction %float None %15
+      R"(%foo_vf4_ = OpFunction %float None %15
 %bar = OpFunctionParameter %_ptr_Function_v4float
 %27 = OpLabel
 %28 = OpAccessChain %_ptr_Function_float %bar %uint_0
@@ -2369,8 +2371,8 @@ OpReturnValue %9
 OpFunctionEnd
 )";
   SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-  predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
-  true);
+      predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
+      true);
 }
 
 TEST_F(InlineTest, Decorated2) {
@@ -2396,7 +2398,7 @@ TEST_F(InlineTest, Decorated2) {
   // }
 
   const std::string predefs =
-  R"(OpCapability Shader
+      R"(OpCapability Shader
 %1 = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main" %BaseColor %gl_FragColor
@@ -2413,7 +2415,7 @@ OpDecorate %foo_vf4_ RelaxedPrecision
 )";
 
   const std::string before =
-  R"(%void = OpTypeVoid
+      R"(%void = OpTypeVoid
 %10 = OpTypeFunction %void
 %float = OpTypeFloat 32
 %v4float = OpTypeVector %float 4
@@ -2442,9 +2444,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-
   const std::string after =
-  R"(OpDecorate %32 RelaxedPrecision
+      R"(OpDecorate %32 RelaxedPrecision
 %void = OpTypeVoid
 %10 = OpTypeFunction %void
 %float = OpTypeFloat 32
@@ -2482,7 +2483,7 @@ OpFunctionEnd
 )";
 
   const std::string nonEntryFuncs =
-  R"(%foo_vf4_ = OpFunction %float None %14
+      R"(%foo_vf4_ = OpFunction %float None %14
 %bar = OpFunctionParameter %_ptr_Function_v4float
 %26 = OpLabel
 %27 = OpAccessChain %_ptr_Function_float %bar %uint_0
@@ -2494,8 +2495,8 @@ OpReturnValue %31
 OpFunctionEnd
 )";
   SinglePassRunAndCheck<opt::InlineExhaustivePass>(
-  predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
-  true);
+      predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
+      true);
 }
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
 //
index bc90a30..1fd77b0 100644 (file)
@@ -30,12 +30,12 @@ TEST_F(InsertExtractElimTest, Simple) {
   // #version 140
   //
   // in vec4 BaseColor;
-  // 
+  //
   // struct S_t {
   //     vec4 v0;
   //     vec4 v1;
   // };
-  // 
+  //
   // void main()
   // {
   //     S_t s0;
@@ -99,8 +99,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(predefs + before, 
-      predefs + after, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(
+      predefs + before, predefs + after, true, true);
 }
 
 TEST_F(InsertExtractElimTest, OptimizeAcrossNonConflictingInsert) {
@@ -111,12 +111,12 @@ TEST_F(InsertExtractElimTest, OptimizeAcrossNonConflictingInsert) {
   // #version 140
   //
   // in vec4 BaseColor;
-  // 
+  //
   // struct S_t {
   //     vec4 v0;
   //     vec4 v1;
   // };
-  // 
+  //
   // void main()
   // {
   //     S_t s0;
@@ -184,8 +184,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(predefs + before, 
-      predefs + after, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(
+      predefs + before, predefs + after, true, true);
 }
 
 TEST_F(InsertExtractElimTest, OptimizeOpaque) {
@@ -266,8 +266,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(predefs + before, 
-      predefs + after, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(
+      predefs + before, predefs + after, true, true);
 }
 
 TEST_F(InsertExtractElimTest, OptimizeNestedStruct) {
@@ -277,22 +277,22 @@ TEST_F(InsertExtractElimTest, OptimizeNestedStruct) {
   //     int x;
   //     SamplerState ss;
   // };
-  // 
+  //
   // struct S1
   // {
   //     float b;
   //     S0 s0;
   // };
-  // 
+  //
   // struct S2
   // {
   //     int a1;
   //     S1 resources;
   // };
-  // 
+  //
   // SamplerState samp;
   // Texture2D tex;
-  // 
+  //
   // float4 main(float4 vpos : VPOS) : COLOR0
   // {
   //     S1 s1;
@@ -395,8 +395,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(predefs + before, 
-      predefs + after, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(
+      predefs + before, predefs + after, true, true);
 }
 
 TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization) {
@@ -407,12 +407,12 @@ TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization) {
   // #version 140
   //
   // in vec4 BaseColor;
-  // 
+  //
   // struct S_t {
   //     vec4 v0;
   //     vec4 v1;
   // };
-  // 
+  //
   // void main()
   // {
   //     S_t s0;
@@ -463,8 +463,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(assembly, 
-      assembly, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(assembly, assembly, true,
+                                                    true);
 }
 
 TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization2) {
@@ -475,12 +475,12 @@ TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization2) {
   // #version 140
   //
   // in vec4 BaseColor;
-  // 
+  //
   // struct S_t {
   //     vec4 v0;
   //     vec4 v1;
   // };
-  // 
+  //
   // void main()
   // {
   //     S_t s0;
@@ -535,8 +535,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::InsertExtractElimPass>(assembly, 
-      assembly, true, true);
+  SinglePassRunAndCheck<opt::InsertExtractElimPass>(assembly, assembly, true,
+                                                    true);
 }
 
 // TODO(greg-lunarg): Add tests to verify handling of these cases:
index 7adb442..ae4f3a5 100644 (file)
 
 #include "gmock/gmock.h"
 
-#include "spirv-tools/libspirv.h"
-#include "unit_spirv.h"
 #include "pass_fixture.h"
 #include "pass_utils.h"
+#include "spirv-tools/libspirv.h"
+#include "unit_spirv.h"
 
 namespace {
 
 using namespace spvtools;
-using spvtest::MakeInstruction;
 using ir::Instruction;
 using ir::IRContext;
 using ir::Operand;
+using spvtest::MakeInstruction;
 using ::testing::Eq;
 using DescriptorTypeTest = PassTest<::testing::Test>;
 
index ae46df9..87e7e97 100644 (file)
@@ -219,7 +219,8 @@ TEST(IrBuilder, OpUndefOutsideFunction) {
   ASSERT_NE(nullptr, context);
 
   const auto opundef_count = std::count_if(
-      context->module()->types_values_begin(), context->module()->types_values_end(),
+      context->module()->types_values_begin(),
+      context->module()->types_values_end(),
       [](const ir::Instruction& inst) { return inst.opcode() == SpvOpUndef; });
   EXPECT_EQ(3, opundef_count);
 
@@ -302,7 +303,7 @@ TEST(IrBuilder, KeepLineDebugInfoBeforeFunctionEnd) {
 
 TEST(IrBuilder, KeepModuleProcessedInRightPlace) {
   DoRoundTripCheck(
-   // clang-format off
+      // clang-format off
                "OpCapability Shader\n"
                "OpMemoryModel Logical GLSL450\n"
           "%1 = OpString \"minimal.vert\"\n"
index 23221e1..b559a81 100644 (file)
@@ -23,16 +23,15 @@ using namespace spvtools;
 using LocalAccessChainConvertTest = PassTest<::testing::Test>;
 
 TEST_F(LocalAccessChainConvertTest, StructOfVecsOfFloatConverted) {
-
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  struct S_t {
   //      vec4 v0;
   //      vec4 v1;
   //  };
-  //  
+  //
   //  void main()
   //  {
   //      S_t s0;
@@ -131,16 +130,15 @@ OpFunctionEnd
 }
 
 TEST_F(LocalAccessChainConvertTest, InBoundsAccessChainsConverted) {
-
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  struct S_t {
   //      vec4 v0;
   //      vec4 v1;
   //  };
-  //  
+  //
   //  void main()
   //  {
   //      S_t s0;
@@ -239,16 +237,15 @@ OpFunctionEnd
 }
 
 TEST_F(LocalAccessChainConvertTest, TwoUsesofSingleChainConverted) {
-
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  struct S_t {
   //      vec4 v0;
   //      vec4 v1;
   //  };
-  //  
+  //
   //  void main()
   //  {
   //      S_t s0;
@@ -458,22 +455,20 @@ OpFunctionEnd
       predefs + before + remain, predefs + after + remain, true, true);
 }
 
-TEST_F(LocalAccessChainConvertTest, 
-       NestedStructsConverted) {
-
+TEST_F(LocalAccessChainConvertTest, NestedStructsConverted) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
-  //  
+  //
   //  struct S1_t {
   //      vec4 v1;
   //  };
-  //  
+  //
   //  struct S2_t {
   //      vec4 v2;
   //      S1_t s1;
   //  };
-  //  
+  //
   //  void main()
   //  {
   //      S2_t s2;
@@ -575,14 +570,12 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
-      predefs_before + before , predefs_after + after, true, true);
+      predefs_before + before, predefs_after + after, true, true);
 }
 
-TEST_F(LocalAccessChainConvertTest, 
-       DynamicallyIndexedVarNotConverted) {
-
+TEST_F(LocalAccessChainConvertTest, DynamicallyIndexedVarNotConverted) {
   //  #version 140
-  //  
+  //
   //  in vec4 BaseColor;
   //  flat in int Idx;
   //  in float Bi;
@@ -591,7 +584,7 @@ TEST_F(LocalAccessChainConvertTest,
   //      vec4 v0;
   //      vec4 v1;
   //  };
-  //  
+  //
   //  void main()
   //  {
   //      S_t s0;
@@ -652,8 +645,8 @@ OpReturn
 OpFunctionEnd
 )";
 
-  SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
-      assembly, assembly, false, true);
+  SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(assembly, assembly,
+                                                          false, true);
 }
 
 TEST_F(LocalAccessChainConvertTest, SomeAccessChainsHaveNoUse) {
index 6444799..07a8c06 100644 (file)
@@ -54,7 +54,7 @@ TEST_F(LocalRedundancyEliminationTest, RemoveRedundantAdd) {
                OpReturn
                OpFunctionEnd
   )";
-SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text);
+  SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text);
 }
 
 // Make sure we keep instruction that are different, but look similar.
index 7d7559a..218e8e7 100644 (file)
@@ -681,21 +681,21 @@ TEST_F(LocalSingleBlockLoadStoreElimTest, PositiveAndNegativeCallTree) {
   // Note that the call tree function bar is optimized, but foo is not
   //
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
-  // 
+  //
   // vec4 foo(vec4 v1)
   // {
   //     vec4 t = v1;
   //     return t;
   // }
-  // 
+  //
   // vec4 bar(vec4 v1)
   // {
   //     vec4 t = v1;
   //     return t;
   // }
-  // 
+  //
   // void main()
   // {
   //     gl_FragColor = bar(BaseColor);
index cc74dab..126350a 100644 (file)
@@ -147,8 +147,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
-      predefs_before + before, 
-      predefs_after + after, true, true);
+      predefs_before + before, predefs_after + after, true, true);
 }
 
 TEST_F(LocalSingleStoreElimTest, MultipleLoads) {
@@ -278,8 +277,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
-      predefs_before + before, 
-      predefs_after + after, true, true);
+      predefs_before + before, predefs_after + after, true, true);
 }
 
 TEST_F(LocalSingleStoreElimTest, NoStoreElimWithInterveningAccessChainLoad) {
@@ -380,8 +378,7 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
-      predefs_before + before, 
-      predefs_after + after, true, true);
+      predefs_before + before, predefs_after + after, true, true);
 }
 
 TEST_F(LocalSingleStoreElimTest, NoReplaceOfDominatingPartialStore) {
index e53853d..c79ef57 100644 (file)
@@ -24,10 +24,10 @@ using LocalSSAElimTest = PassTest<::testing::Test>;
 
 TEST_F(LocalSSAElimTest, ForLoop) {
   // #version 140
-  // 
+  //
   // in vec4 BC;
   // out float fo;
-  // 
+  //
   // void main()
   // {
   //     float f = 0.0;
@@ -143,16 +143,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, ForLoopWithContinue) {
   // #version 140
-  // 
+  //
   // in vec4 BC;
   // out float fo;
-  // 
+  //
   // void main()
   // {
   //     float f = 0.0;
@@ -291,16 +290,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, ForLoopWithBreak) {
   // #version 140
-  // 
+  //
   // in vec4 BC;
   // out float fo;
-  // 
+  //
   // void main()
   // {
   //     float f = 0.0;
@@ -440,16 +438,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, SwapProblem) {
   // #version 140
-  // 
+  //
   // in float fe;
   // out float fo;
-  // 
+  //
   // void main()
   // {
   //     float f1 = 0.0;
@@ -580,16 +577,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, LostCopyProblem) {
   // #version 140
-  // 
+  //
   // in vec4 BC;
   // out float fo;
-  // 
+  //
   // void main()
   // {
   //     float f = 0.0;
@@ -731,16 +727,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, IfThenElse) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
   // in float f;
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -843,18 +838,17 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, DecoratedVar) {
   // SPIR-V hand edited to decorate v
   // #version 450
-  // 
+  //
   // layout (location=0) in vec4 BaseColor;
   // layout (location=1) in float f;
   // layout (location=0) out vec4 OutColor;
-  // 
+  //
   // void main()
   // {
   //     vec4 v;
@@ -979,17 +973,15 @@ OpFunctionEnd
 )";
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
-      predefs_before + before,
-      predefs_after + after,
-      true, true);
+      predefs_before + before, predefs_after + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, IfThen) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
   // in float f;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -1081,16 +1073,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, Switch) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
   // in float f;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -1220,16 +1211,15 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, SwitchWithFallThrough) {
   // #version 140
-  // 
+  //
   // in vec4 BaseColor;
   // in float f;
-  // 
+  //
   // void main()
   // {
   //     vec4 v = BaseColor;
@@ -1360,8 +1350,7 @@ OpFunctionEnd
 
   SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
       predefs + names_before + predefs2 + before,
-      predefs + names_after + predefs2 + after,
-      true, true);
+      predefs + names_after + predefs2 + after, true, true);
 }
 
 TEST_F(LocalSSAElimTest, DontPatchPhiInLoopHeaderThatIsNotAVar) {
index 4a434ed..43be818 100644 (file)
@@ -26,9 +26,9 @@
 
 namespace {
 
+using spvtest::GetIdBound;
 using spvtools::ir::IRContext;
 using spvtools::ir::Module;
-using spvtest::GetIdBound;
 using ::testing::Eq;
 
 TEST(ModuleTest, SetIdBound) {
@@ -55,19 +55,23 @@ TEST(ModuleTest, ComputeIdBound) {
   // Sensitive to result id
   EXPECT_EQ(2u, BuildModule("%void = OpTypeVoid")->module()->ComputeIdBound());
   // Sensitive to type id
-  EXPECT_EQ(1000u, BuildModule("%a = OpTypeArray !999 3")->module()->ComputeIdBound());
+  EXPECT_EQ(1000u,
+            BuildModule("%a = OpTypeArray !999 3")->module()->ComputeIdBound());
   // Sensitive to a regular Id parameter
-  EXPECT_EQ(2000u, BuildModule("OpDecorate !1999 0")->module()->ComputeIdBound());
+  EXPECT_EQ(2000u,
+            BuildModule("OpDecorate !1999 0")->module()->ComputeIdBound());
   // Sensitive to a scope Id parameter.
   EXPECT_EQ(3000u,
             BuildModule("%f = OpFunction %void None %fntype %a = OpLabel "
                         "OpMemoryBarrier !2999 %b\n")
-                ->module()->ComputeIdBound());
+                ->module()
+                ->ComputeIdBound());
   // Sensitive to a semantics Id parameter
   EXPECT_EQ(4000u,
             BuildModule("%f = OpFunction %void None %fntype %a = OpLabel "
                         "OpMemoryBarrier %b !3999\n")
-                ->module()->ComputeIdBound());
+                ->module()
+                ->ComputeIdBound());
 }
 
 }  // anonymous namespace
index 18cc18b..ad59058 100644 (file)
@@ -31,4 +31,4 @@ inline uint32_t GetIdBound(const spvtools::ir::Module& m) {
 
 }  // namespace spvtest
 
-#endif // LIBSPIRV_TEST_OPT_MODULE_UTILS_H_
+#endif  // LIBSPIRV_TEST_OPT_MODULE_UTILS_H_
index fdc4398..0e87c7b 100644 (file)
@@ -63,7 +63,7 @@ class PassTest : public TestT {
                                   << original << std::endl;
     if (!context()) {
       return std::make_tuple(std::vector<uint32_t>(),
-          opt::Pass::Status::Failure);
+                             opt::Pass::Status::Failure);
     }
 
     const auto status = pass->Run(context());
@@ -95,8 +95,8 @@ class PassTest : public TestT {
     std::tie(optimized_bin, status) = SinglePassRunToBinary<PassT>(
         assembly, skip_nop, std::forward<Args>(args)...);
     std::string optimized_asm;
-    EXPECT_TRUE(tools_.Disassemble(optimized_bin, &optimized_asm,
-                                   disassemble_options_))
+    EXPECT_TRUE(
+        tools_.Disassemble(optimized_bin, &optimized_asm, disassemble_options_))
         << "Disassembling failed for shader:\n"
         << assembly << std::endl;
     return std::make_tuple(optimized_asm, status);
@@ -123,18 +123,16 @@ class PassTest : public TestT {
       spv_target_env target_env = SPV_ENV_UNIVERSAL_1_1;
       spv_context spvContext = spvContextCreate(target_env);
       spv_diagnostic diagnostic = nullptr;
-      spv_const_binary_t binary = {optimized_bin.data(),
-          optimized_bin.size()};
+      spv_const_binary_t binary = {optimized_bin.data(), optimized_bin.size()};
       spv_result_t error = spvValidate(spvContext, &binary, &diagnostic);
       EXPECT_EQ(error, 0);
-      if (error != 0)
-        spvDiagnosticPrint(diagnostic);
+      if (error != 0) spvDiagnosticPrint(diagnostic);
       spvDiagnosticDestroy(diagnostic);
       spvContextDestroy(spvContext);
     }
     std::string optimized_asm;
-    EXPECT_TRUE(tools_.Disassemble(optimized_bin, &optimized_asm,
-                                   disassemble_options_))
+    EXPECT_TRUE(
+        tools_.Disassemble(optimized_bin, &optimized_asm, disassemble_options_))
         << "Disassembling failed for shader:\n"
         << original << std::endl;
     EXPECT_EQ(expected, optimized_asm);
@@ -149,7 +147,7 @@ class PassTest : public TestT {
                              const std::string& expected, bool skip_nop,
                              Args&&... args) {
     SinglePassRunAndCheck<PassT>(original, expected, skip_nop, false,
-      std::forward<Args>(args)...);
+                                 std::forward<Args>(args)...);
   }
 
 #ifdef SPIRV_EFFCEE
@@ -200,8 +198,7 @@ class PassTest : public TestT {
     context()->module()->ToBinary(&binary, /* skip_nop = */ false);
 
     std::string optimized;
-    EXPECT_TRUE(tools_.Disassemble(binary, &optimized,
-                                   disassemble_options_));
+    EXPECT_TRUE(tools_.Disassemble(binary, &optimized, disassemble_options_));
     EXPECT_EQ(expected, optimized);
   }
 
@@ -213,11 +210,12 @@ class PassTest : public TestT {
     disassemble_options_ = disassemble_options;
   }
 
-  MessageConsumer consumer() { return consumer_;}
+  MessageConsumer consumer() { return consumer_; }
   ir::IRContext* context() { return context_.get(); }
+
  private:
-  MessageConsumer consumer_;  // Message consumer.
-  std::unique_ptr<ir::IRContext> context_; // IR context
+  MessageConsumer consumer_;                // Message consumer.
+  std::unique_ptr<ir::IRContext> context_;  // IR context
   SpirvTools tools_;  // An instance for calling SPIRV-Tools functionalities.
   std::unique_ptr<opt::PassManager> manager_;  // The pass manager.
   uint32_t assemble_options_;
index 77ed38b..4d5bcce 100644 (file)
@@ -141,8 +141,8 @@ class AppendTypeVoidInstPass : public opt::Pass {
 
   const char* name() const override { return "AppendTypeVoidInstPass"; }
   Status Process(ir::IRContext* irContext) override {
-    auto inst = MakeUnique<ir::Instruction>(irContext, SpvOpTypeVoid, 0, result_id_,
-                                            std::vector<ir::Operand>{});
+    auto inst = MakeUnique<ir::Instruction>(
+        irContext, SpvOpTypeVoid, 0, result_id_, std::vector<ir::Operand>{});
     irContext->AddType(std::move(inst));
     return Status::SuccessWithChange;
   }
@@ -157,7 +157,6 @@ TEST(PassManager, RecomputeIdBoundAutomatically) {
   ir::IRContext context(std::move(module), manager.consumer());
   EXPECT_THAT(GetIdBound(*context.module()), Eq(0u));
 
-
   manager.Run(&context);
   manager.AddPass<AppendOpNopPass>();
   // With no ID changes, the ID bound does not change.
index 276d314..998327a 100644 (file)
@@ -42,7 +42,9 @@ TEST_P(DefaultValuesStringParsingTest, TestCase) {
           tc.default_values_str);
   if (tc.expect_success) {
     EXPECT_NE(nullptr, actual_map);
-    if (actual_map) { EXPECT_THAT(*actual_map, Eq(tc.expected_map)); }
+    if (actual_map) {
+      EXPECT_THAT(*actual_map, Eq(tc.expected_map));
+    }
   } else {
     EXPECT_EQ(nullptr, actual_map);
   }
@@ -272,7 +274,9 @@ INSTANTIATE_TEST_CASE_P(
             "%3 = OpSpecConstantTrue %bool\n",
             // default values
             SpecIdToValueStrMap{
-                {201, "0x1.fffffffffffffp+1024"}, {202, "2048"}, {203, "false"},
+                {201, "0x1.fffffffffffffp+1024"},
+                {202, "2048"},
+                {203, "false"},
             },
             // expected
             "OpDecorate %1 SpecId 201\n"
index 8e6ee01..8cae51e 100644 (file)
@@ -76,7 +76,9 @@ using StripDebugInfoTest = PassTest<::testing::TestWithParam<const char*>>;
 
 TEST_P(StripDebugInfoTest, Kind) {
   std::vector<const char*> text = {
-      "OpCapability Shader", "OpMemoryModel Logical GLSL450", GetParam(),
+      "OpCapability Shader",
+      "OpMemoryModel Logical GLSL450",
+      GetParam(),
   };
   SinglePassRunAndCheck<opt::StripDebugInfoPass>(JoinAllInsts(text),
                                                  JoinNonDebugInsts(text),
index 5813201..8fc262c 100644 (file)
@@ -156,7 +156,8 @@ TEST_F(UnifyFrontEndConstantSingleTest, Basic) {
 
   expected_builder
       .AppendTypesConstantsGlobals({
-          "%uint = OpTypeInt 32 0", "%_pf_uint = OpTypePointer Function %uint",
+          "%uint = OpTypeInt 32 0",
+          "%_pf_uint = OpTypePointer Function %uint",
           "%unsigned_1 = OpConstant %uint 1",
       })
       .AppendInMain({
@@ -302,7 +303,8 @@ TEST_F(UnifyFrontEndConstantSingleTest, UnifyWithDecorationOnTypes) {
           "OpStore %flat_d_var %flat_d_1",
       })
       .AppendNames({
-          "OpName %flat_1 \"flat_1_dup\"", "OpName %flat_d_1 \"flat_d_1_dup\"",
+          "OpName %flat_1 \"flat_1_dup\"",
+          "OpName %flat_d_1 \"flat_d_1_dup\"",
       });
 
   Check(expected_builder, test_builder);
index 085c5f3..e20e685 100644 (file)
@@ -51,7 +51,7 @@ struct SubstringReplacementTestCase {
   const char* expected_str;
   bool replace_should_succeed;
 };
-}
+}  // namespace
 using FindAndReplaceTest =
     ::testing::TestWithParam<SubstringReplacementTestCase>;
 
index 3215d73..54af641 100644 (file)
@@ -299,7 +299,7 @@ TEST_F(ValueTableTest, SameCall) {
   )";
   auto context = BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
   opt::ValueNumberTable vtable(context.get());
-  ir::Instruction* inst= context->get_def_use_mgr()->GetDef(10);
+  ir::Instruction* inst = context->get_def_use_mgr()->GetDef(10);
   EXPECT_EQ(vtable.GetValueNumber(inst), vtable.GetValueNumber(inst));
 }
 
@@ -332,7 +332,7 @@ TEST_F(ValueTableTest, DifferentCall) {
   )";
   auto context = BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
   opt::ValueNumberTable vtable(context.get());
-  ir::Instruction* inst1= context->get_def_use_mgr()->GetDef(10);
+  ir::Instruction* inst1 = context->get_def_use_mgr()->GetDef(10);
   ir::Instruction* inst2 = context->get_def_use_mgr()->GetDef(12);
   EXPECT_NE(vtable.GetValueNumber(inst1), vtable.GetValueNumber(inst2));
 }
@@ -363,7 +363,7 @@ TEST_F(ValueTableTest, DifferentTypes) {
   )";
   auto context = BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
   opt::ValueNumberTable vtable(context.get());
-  ir::Instruction* inst1= context->get_def_use_mgr()->GetDef(11);
+  ir::Instruction* inst1 = context->get_def_use_mgr()->GetDef(11);
   ir::Instruction* inst2 = context->get_def_use_mgr()->GetDef(12);
   EXPECT_NE(vtable.GetValueNumber(inst1), vtable.GetValueNumber(inst2));
 }
index 9c8850b..9189fbe 100644 (file)
 #include "spirv-tools/libspirv.h"
 
 namespace {
-using spvutils::NumberType;
 using spvutils::EncodeNumberStatus;
-using spvutils::ParseNumber;
-using spvutils::ParseAndEncodeIntegerNumber;
+using spvutils::NumberType;
 using spvutils::ParseAndEncodeFloatingPointNumber;
+using spvutils::ParseAndEncodeIntegerNumber;
 using spvutils::ParseAndEncodeNumber;
+using spvutils::ParseNumber;
 using testing::Eq;
 using testing::IsNull;
 using testing::NotNull;
index b8af964..75d730d 100644 (file)
@@ -34,16 +34,15 @@ spv_result_t ToBinaryAndBack(
   spv_binary binary;
   spv_text text;
 
-  spv_result_t result = spvTextToBinaryWithOptions(
-      ctx.context, before.c_str(), before.size(), text_to_binary_options,
-      &binary, nullptr);
+  spv_result_t result =
+      spvTextToBinaryWithOptions(ctx.context, before.c_str(), before.size(),
+                                 text_to_binary_options, &binary, nullptr);
   if (result != SPV_SUCCESS) {
     return result;
   }
 
-  result = spvBinaryToText(
-      ctx.context, binary->code, binary->wordCount, binary_to_text_options,
-      &text, nullptr);
+  result = spvBinaryToText(ctx.context, binary->code, binary->wordCount,
+                           binary_to_text_options, &text, nullptr);
   if (result != SPV_SUCCESS) {
     return result;
   }
@@ -58,7 +57,7 @@ spv_result_t ToBinaryAndBack(
 
 TEST(ToBinaryAndBack, DontPreserveNumericIds) {
   const std::string before =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
@@ -78,7 +77,7 @@ OpFunctionEnd
 )";
 
   const std::string expected =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
@@ -98,16 +97,16 @@ OpFunctionEnd
 )";
 
   std::string after;
-  EXPECT_EQ(SPV_SUCCESS, ToBinaryAndBack(before, &after,
-                                         SPV_TEXT_TO_BINARY_OPTION_NONE,
-                                         SPV_BINARY_TO_TEXT_OPTION_NO_HEADER));
+  EXPECT_EQ(SPV_SUCCESS,
+            ToBinaryAndBack(before, &after, SPV_TEXT_TO_BINARY_OPTION_NONE,
+                            SPV_BINARY_TO_TEXT_OPTION_NO_HEADER));
 
   EXPECT_EQ(expected, after);
 }
 
 TEST(TextHandler, PreserveNumericIds) {
   const std::string before =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
@@ -127,7 +126,7 @@ OpFunctionEnd
 )";
 
   const std::string expected =
-R"(OpCapability Addresses
+      R"(OpCapability Addresses
 OpCapability Kernel
 OpCapability GenericPointer
 OpCapability Linkage
index 087de8a..11c71aa 100644 (file)
@@ -33,8 +33,7 @@ void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
     case SPV_MSG_FATAL:
     case SPV_MSG_INTERNAL_ERROR:
     case SPV_MSG_ERROR:
-      std::cerr << "error: " << position.index << ": " << message
-                << std::endl;
+      std::cerr << "error: " << position.index << ": " << message << std::endl;
       break;
     case SPV_MSG_WARNING:
       std::cout << "warning: " << position.index << ": " << message
@@ -50,12 +49,12 @@ void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
 
 // Calls libspirv::AggregateStats for binary compiled from |code|.
 void CompileAndAggregateStats(const std::string& code, SpirvStats* stats,
-                    spv_target_env env = SPV_ENV_UNIVERSAL_1_1) {
+                              spv_target_env env = SPV_ENV_UNIVERSAL_1_1) {
   ScopedContext ctx(env);
   SetContextMessageConsumer(ctx.context, DiagnosticsMessageHandler);
   spv_binary binary;
-  ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(
-      ctx.context, code.c_str(), code.size(), &binary, nullptr));
+  ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(ctx.context, code.c_str(), code.size(),
+                                         &binary, nullptr));
 
   ASSERT_EQ(SPV_SUCCESS, AggregateStats(*ctx.context, binary->code,
                                         binary->wordCount, nullptr, stats));
@@ -192,8 +191,8 @@ OpCapability Linkage
 OpMemoryModel Logical GLSL450
 )";
 
-  const uint32_t kGeneratorKhronosAssembler =
-      SPV_GENERATOR_KHRONOS_ASSEMBLER << 16;
+  const uint32_t kGeneratorKhronosAssembler = SPV_GENERATOR_KHRONOS_ASSEMBLER
+                                              << 16;
 
   SpirvStats stats;
 
@@ -288,15 +287,15 @@ OpMemoryModel Physical32 OpenCL
   EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpExtension).size());
   EXPECT_EQ(
       1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpCapability));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension));
   EXPECT_EQ(
       1u, stats.opcode_markov_hist[0].at(SpvOpExtension).at(SpvOpMemoryModel));
 
   EXPECT_EQ(1u, stats.opcode_markov_hist[1].size());
   EXPECT_EQ(2u, stats.opcode_markov_hist[1].at(SpvOpCapability).size());
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension));
   EXPECT_EQ(
       1u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpMemoryModel));
 
@@ -309,18 +308,17 @@ OpMemoryModel Physical32 OpenCL
   EXPECT_EQ(2u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).size());
   EXPECT_EQ(
       4u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpCapability));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpExtension));
   EXPECT_EQ(
       1u, stats.opcode_markov_hist[0].at(SpvOpCapability).at(SpvOpMemoryModel));
   EXPECT_EQ(
       1u, stats.opcode_markov_hist[0].at(SpvOpExtension).at(SpvOpMemoryModel));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[0].at(SpvOpMemoryModel).at(SpvOpTypeInt));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeInt));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeFloat));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[0].at(SpvOpMemoryModel).at(SpvOpTypeInt));
+  EXPECT_EQ(1u, stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeInt));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[0].at(SpvOpTypeInt).at(SpvOpTypeFloat));
 
   EXPECT_EQ(3u, stats.opcode_markov_hist[1].size());
   EXPECT_EQ(4u, stats.opcode_markov_hist[1].at(SpvOpCapability).size());
@@ -328,16 +326,16 @@ OpMemoryModel Physical32 OpenCL
   EXPECT_EQ(1u, stats.opcode_markov_hist[1].at(SpvOpTypeInt).size());
   EXPECT_EQ(
       2u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpCapability));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpExtension));
   EXPECT_EQ(
       2u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpMemoryModel));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpTypeInt));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[1].at(SpvOpMemoryModel).at(SpvOpTypeInt));
-  EXPECT_EQ(
-      1u, stats.opcode_markov_hist[1].at(SpvOpTypeInt).at(SpvOpTypeFloat));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[1].at(SpvOpCapability).at(SpvOpTypeInt));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[1].at(SpvOpMemoryModel).at(SpvOpTypeInt));
+  EXPECT_EQ(1u,
+            stats.opcode_markov_hist[1].at(SpvOpTypeInt).at(SpvOpTypeFloat));
 }
 
 TEST(AggregateStats, ConstantLiteralsHistogram) {
@@ -471,16 +469,14 @@ OpMemoryModel Logical GLSL450
 
   {
     const std::unordered_map<uint32_t, uint32_t> expected = {
-      {kF32, 3}, {kU32, 2}, {kF32_1, 2}, {kU32_32, 1}
-    };
+        {kF32, 3}, {kU32, 2}, {kF32_1, 2}, {kU32_32, 1}};
     EXPECT_EQ(expected, stats.id_descriptor_hist);
   }
 
   CompileAndAggregateStats(code2, &stats);
   {
     const std::unordered_map<uint32_t, uint32_t> expected = {
-      {kF32, 6}, {kU32, 4}, {kF32_1, 3}, {kF32_3, 1}, {kU32_32, 2}
-    };
+        {kF32, 6}, {kU32, 4}, {kF32_1, 3}, {kF32_3, 1}, {kU32_32, 2}};
     EXPECT_EQ(expected, stats.id_descriptor_hist);
   }
 }
index 6dcaac4..6667969 100644 (file)
@@ -14,8 +14,8 @@
 
 // Tests for unique type declaration rules validator.
 
-#include <string>
 #include <sstream>
+#include <string>
 
 #include "spirv/1.1/spirv.h"
 #include "test_fixture.h"
index 0c8389d..f47195b 100644 (file)
@@ -22,15 +22,15 @@ namespace {
 
 using ::testing::AnyOf;
 using ::testing::Eq;
-using ::testing::ValuesIn;
 using ::testing::StartsWith;
+using ::testing::ValuesIn;
 
 using TargetEnvTest = ::testing::TestWithParam<spv_target_env>;
 TEST_P(TargetEnvTest, CreateContext) {
   spv_target_env env = GetParam();
   spv_context context = spvContextCreate(env);
   ASSERT_NE(nullptr, context);
-  spvContextDestroy(context); // Avoid leaking
+  spvContextDestroy(context);  // Avoid leaking
 }
 
 TEST_P(TargetEnvTest, ValidDescription) {
index e41a014..dc75a8e 100644 (file)
@@ -14,9 +14,9 @@
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
 #include "message.h"
+#include "test_fixture.h"
 
 #include <string>
 
index e0fe84e..94cc8f0 100644 (file)
 #include <sstream>
 #include <tuple>
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
-using ::testing::Combine;
-using ::testing::Eq;
-using ::testing::Values;
-using ::testing::ValuesIn;
 using spvtest::EnumCase;
 using spvtest::MakeInstruction;
 using spvtest::MakeVector;
 using spvtest::TextToBinaryTest;
 using std::get;
 using std::tuple;
+using ::testing::Combine;
+using ::testing::Eq;
+using ::testing::Values;
+using ::testing::ValuesIn;
 
 // Test OpDecorate
 
index c086caa..7431042 100644 (file)
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
-using ::testing::ElementsAre;
-using ::testing::Eq;
-using ::testing::_;
 using spvtest::MakeInstruction;
 using spvtest::TextToBinaryTest;
+using ::testing::_;
+using ::testing::ElementsAre;
+using ::testing::Eq;
 
 // Test OpMemoryBarrier
 
index d975f1c..d04aa13 100644 (file)
 #include <cstdint>
 #include <limits>
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
+using spvtest::Concatenate;
 using spvtest::EnumCase;
 using spvtest::MakeInstruction;
-using spvtest::Concatenate;
 using ::testing::Eq;
 
 // Test Sampler Addressing Mode enum values
@@ -233,14 +233,15 @@ INSTANTIATE_TEST_CASE_P(
     }),);
 // clang-format on
 
-// A test case for checking OpConstant with invalid literals with a leading minus.
+// A test case for checking OpConstant with invalid literals with a leading
+// minus.
 struct InvalidLeadingMinusCase {
   std::string type;
   std::string literal;
 };
 
-using OpConstantInvalidLeadingMinusTest =
-    spvtest::TextToBinaryTestBase<::testing::TestWithParam<InvalidLeadingMinusCase>>;
+using OpConstantInvalidLeadingMinusTest = spvtest::TextToBinaryTestBase<
+    ::testing::TestWithParam<InvalidLeadingMinusCase>>;
 
 TEST_P(OpConstantInvalidLeadingMinusTest, InvalidCase) {
   const std::string input = "%1 = " + GetParam().type +
@@ -519,7 +520,7 @@ INSTANTIATE_TEST_CASE_P(
         "%1 = OpTypeFloat 64\n%2 = OpConstant %1 0\n",
         "%1 = OpTypeFloat 64\n%2 = OpConstant %1 1.79769e+308\n",
         "%1 = OpTypeFloat 64\n%2 = OpConstant %1 -1.79769e+308\n",
-    }),);
+    }), );
 
 INSTANTIATE_TEST_CASE_P(
     OpConstantHalfRoundTrip, RoundTripTest,
@@ -537,24 +538,24 @@ INSTANTIATE_TEST_CASE_P(
         "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.8p+1\n",
         "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.ffcp+1\n",
 
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1p-16\n", // some denorms
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1p-16\n",  // some denorms
         "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1p-24\n",
         "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1p-24\n",
 
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1p+16\n", // +inf
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1p+16\n", // -inf
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.01p+16\n", // -inf
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.01p+16\n", // nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.11p+16\n", // nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.ffp+16\n", // nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.ffcp+16\n", // nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.004p+16\n", // nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.01p+16\n", // -nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.11p+16\n", // -nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.ffp+16\n", // -nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.ffcp+16\n", // -nan
-        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.004p+16\n", // -nan
-    }),);
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1p+16\n",       // +inf
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1p+16\n",      // -inf
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.01p+16\n",   // -inf
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.01p+16\n",    // nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.11p+16\n",    // nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.ffp+16\n",    // nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.ffcp+16\n",   // nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 0x1.004p+16\n",   // nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.01p+16\n",   // -nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.11p+16\n",   // -nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.ffp+16\n",   // -nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.ffcp+16\n",  // -nan
+        "%1 = OpTypeFloat 16\n%2 = OpConstant %1 -0x1.004p+16\n",  // -nan
+    }), );
 
 // clang-format off
 // (Clang-format really wants to break up these strings across lines.
@@ -629,7 +630,7 @@ INSTANTIATE_TEST_CASE_P(
         "%1 = OpTypeFloat 64\n%2 = OpSpecConstant %1 0\n",
         "%1 = OpTypeFloat 64\n%2 = OpSpecConstant %1 1.79769e+308\n",
         "%1 = OpTypeFloat 64\n%2 = OpSpecConstant %1 -1.79769e+308\n",
-    }),);
+    }), );
 
 // Test OpSpecConstantOp
 
@@ -780,7 +781,7 @@ INSTANTIATE_TEST_CASE_P(
         // composite, and then literal indices.
         {CASE(CompositeInsert), {0}},
         {CASE(CompositeInsert), {4, 3, 99, 1}},
-    }),);
+    }), );
 
 using OpSpecConstantOpTestWithOneIdThenLiteralNumbers =
     spvtest::TextToBinaryTestBase<::testing::TestWithParam<EnumCase<SpvOp>>>;
@@ -811,7 +812,7 @@ INSTANTIATE_TEST_CASE_P(
         // indices.  Let's only test a few.
         {CASE(CompositeExtract), {0}},
         {CASE(CompositeExtract), {0, 99, 42, 16, 17, 12, 19}},
-    }),);
+    }), );
 
 // TODO(dneto): OpConstantTrue
 // TODO(dneto): OpConstantFalse
index 8152bf2..56bb408 100644 (file)
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
-using ::testing::Combine;
-using ::testing::Eq;
-using ::testing::TestWithParam;
-using ::testing::Values;
-using ::testing::ValuesIn;
 using spvtest::Concatenate;
 using spvtest::EnumCase;
 using spvtest::MakeInstruction;
@@ -38,6 +33,11 @@ using spvtest::TextToBinaryTest;
 using std::get;
 using std::ostringstream;
 using std::tuple;
+using ::testing::Combine;
+using ::testing::Eq;
+using ::testing::TestWithParam;
+using ::testing::Values;
+using ::testing::ValuesIn;
 
 // Test OpSelectionMerge
 
index ec2acab..93b71ee 100644 (file)
@@ -19,8 +19,8 @@
 
 #include <string>
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
index 852eef7..7829611 100644 (file)
@@ -67,7 +67,7 @@ INSTANTIATE_TEST_CASE_P(
          {13, 14, 15, 16, 17, 18, 19, 20, 21}},
         {"%l0 %l1 %l2 %l3 %l4 %l5 %l6 %l7 %l8 %l9",
          {13, 14, 15, 16, 17, 18, 19, 20, 21, 22}},
-    }),);
+    }), );
 
 // Test some bad parses of OpEnqueueKernel.  For other cases, we're relying
 // on the uniformity of the parsing algorithm.  The following two tests, ensure
index 4b7c25c..e2a5101 100644 (file)
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
 #include "spirv/1.0/GLSL.std.450.h"
 #include "spirv/1.0/OpenCL.std.h"
+#include "test_fixture.h"
 
 namespace {
 
@@ -89,7 +89,6 @@ TEST_F(TextToBinaryTest, ExtInstFromTwoDifferentImports) {
   EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
 }
 
-
 // A test case for assembling into words in an instruction.
 struct AssemblyCase {
   std::string input;
@@ -185,19 +184,19 @@ INSTANTIATE_TEST_CASE_P(
     SPV_KHR_subgroup_vote, ExtensionRoundTripTest,
     // We'll get coverage over operand tables by trying the universal
     // environments, and at least one specific environment.
-    Combine(
-        Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-               SPV_ENV_VULKAN_1_0),
-        ValuesIn(std::vector<AssemblyCase>{
-            {"OpCapability SubgroupVoteKHR\n",
-             MakeInstruction(SpvOpCapability, {SpvCapabilitySubgroupVoteKHR})},
-            {"%2 = OpSubgroupAnyKHR %1 %3\n",
-             MakeInstruction(SpvOpSubgroupAnyKHR, {1, 2, 3})},
-            {"%2 = OpSubgroupAllKHR %1 %3\n",
-             MakeInstruction(SpvOpSubgroupAllKHR, {1, 2, 3})},
-            {"%2 = OpSubgroupAllEqualKHR %1 %3\n",
-             MakeInstruction(SpvOpSubgroupAllEqualKHR, {1, 2, 3})},
-        })), );
+    Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+                   SPV_ENV_VULKAN_1_0),
+            ValuesIn(std::vector<AssemblyCase>{
+                {"OpCapability SubgroupVoteKHR\n",
+                 MakeInstruction(SpvOpCapability,
+                                 {SpvCapabilitySubgroupVoteKHR})},
+                {"%2 = OpSubgroupAnyKHR %1 %3\n",
+                 MakeInstruction(SpvOpSubgroupAnyKHR, {1, 2, 3})},
+                {"%2 = OpSubgroupAllKHR %1 %3\n",
+                 MakeInstruction(SpvOpSubgroupAllKHR, {1, 2, 3})},
+                {"%2 = OpSubgroupAllEqualKHR %1 %3\n",
+                 MakeInstruction(SpvOpSubgroupAllEqualKHR, {1, 2, 3})},
+            })), );
 
 // SPV_KHR_16bit_storage
 
@@ -277,25 +276,27 @@ INSTANTIATE_TEST_CASE_P(
                                                  SpvBuiltInViewIndex})},
             })), );
 
-
 // SPV_AMD_shader_explicit_vertex_parameter
 
-#define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_shader_explicit_vertex_parameter\"\n"
+#define PREAMBLE \
+  "%1 = OpExtInstImport \"SPV_AMD_shader_explicit_vertex_parameter\"\n"
 INSTANTIATE_TEST_CASE_P(
     SPV_AMD_shader_explicit_vertex_parameter, ExtensionRoundTripTest,
     // We'll get coverage over operand tables by trying the universal
     // environments, and at least one specific environment.
-    Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                   SPV_ENV_VULKAN_1_0),
-            ValuesIn(std::vector<AssemblyCase>{
-                {PREAMBLE "%3 = OpExtInst %2 %1 InterpolateAtVertexAMD %4 %5\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_explicit_vertex_parameter")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
-            })), );
+    Combine(
+        Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+               SPV_ENV_VULKAN_1_0),
+        ValuesIn(std::vector<AssemblyCase>{
+            {PREAMBLE "%3 = OpExtInst %2 %1 InterpolateAtVertexAMD %4 %5\n",
+             Concatenate(
+                 {MakeInstruction(
+                      SpvOpExtInstImport, {1},
+                      MakeVector("SPV_AMD_shader_explicit_vertex_parameter")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
+        })), );
 #undef PREAMBLE
 
-
 // SPV_AMD_shader_trinary_minmax
 
 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_shader_trinary_minmax\"\n"
@@ -303,49 +304,58 @@ INSTANTIATE_TEST_CASE_P(
     SPV_AMD_shader_trinary_minmax, ExtensionRoundTripTest,
     // We'll get coverage over operand tables by trying the universal
     // environments, and at least one specific environment.
-    Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                   SPV_ENV_VULKAN_1_0),
-            ValuesIn(std::vector<AssemblyCase>{
-                {PREAMBLE "%3 = OpExtInst %2 %1 FMin3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 UMin3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 SMin3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 FMax3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 UMax3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 5, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 SMax3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 6, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 FMid3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 7, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 UMid3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 8, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 SMid3AMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_trinary_minmax")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 9, 4, 5, 6})})},
-            })), );
+    Combine(
+        Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+               SPV_ENV_VULKAN_1_0),
+        ValuesIn(std::vector<AssemblyCase>{
+            {PREAMBLE "%3 = OpExtInst %2 %1 FMin3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 UMin3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 SMin3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 FMax3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 UMax3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 5, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 SMax3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 6, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 FMid3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 7, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 UMid3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 8, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 SMid3AMD %4 %5 %6\n",
+             Concatenate(
+                 {MakeInstruction(SpvOpExtInstImport, {1},
+                                  MakeVector("SPV_AMD_shader_trinary_minmax")),
+                  MakeInstruction(SpvOpExtInst, {2, 3, 1, 9, 4, 5, 6})})},
+        })), );
 #undef PREAMBLE
 
-
 // SPV_AMD_gcn_shader
 
 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_gcn_shader\"\n"
@@ -371,7 +381,6 @@ INSTANTIATE_TEST_CASE_P(
             })), );
 #undef PREAMBLE
 
-
 // SPV_AMD_shader_ballot
 
 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_shader_ballot\"\n"
@@ -379,29 +388,31 @@ INSTANTIATE_TEST_CASE_P(
     SPV_AMD_shader_ballot, ExtensionRoundTripTest,
     // We'll get coverage over operand tables by trying the universal
     // environments, and at least one specific environment.
-    Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
-                   SPV_ENV_VULKAN_1_0),
-            ValuesIn(std::vector<AssemblyCase>{
-                {PREAMBLE "%3 = OpExtInst %2 %1 SwizzleInvocationsAMD %4 %5\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_ballot")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 SwizzleInvocationsMaskedAMD %4 %5\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_ballot")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 WriteInvocationAMD %4 %5 %6\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_ballot")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
-                {PREAMBLE "%3 = OpExtInst %2 %1 MbcntAMD %4\n",
-                 Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
-                                              MakeVector("SPV_AMD_shader_ballot")),
-                              MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4})})},
-            })), );
+    Combine(
+        Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
+               SPV_ENV_VULKAN_1_0),
+        ValuesIn(std::vector<AssemblyCase>{
+            {PREAMBLE "%3 = OpExtInst %2 %1 SwizzleInvocationsAMD %4 %5\n",
+             Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+                                          MakeVector("SPV_AMD_shader_ballot")),
+                          MakeInstruction(SpvOpExtInst, {2, 3, 1, 1, 4, 5})})},
+            {PREAMBLE
+             "%3 = OpExtInst %2 %1 SwizzleInvocationsMaskedAMD %4 %5\n",
+             Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+                                          MakeVector("SPV_AMD_shader_ballot")),
+                          MakeInstruction(SpvOpExtInst, {2, 3, 1, 2, 4, 5})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 WriteInvocationAMD %4 %5 %6\n",
+             Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+                                          MakeVector("SPV_AMD_shader_ballot")),
+                          MakeInstruction(SpvOpExtInst,
+                                          {2, 3, 1, 3, 4, 5, 6})})},
+            {PREAMBLE "%3 = OpExtInst %2 %1 MbcntAMD %4\n",
+             Concatenate({MakeInstruction(SpvOpExtInstImport, {1},
+                                          MakeVector("SPV_AMD_shader_ballot")),
+                          MakeInstruction(SpvOpExtInst, {2, 3, 1, 4, 4})})},
+        })), );
 #undef PREAMBLE
 
-
 // SPV_KHR_variable_pointers
 
 INSTANTIATE_TEST_CASE_P(
@@ -415,9 +426,8 @@ INSTANTIATE_TEST_CASE_P(
                  MakeInstruction(SpvOpCapability,
                                  {SpvCapabilityVariablePointers})},
                 {"OpCapability VariablePointersStorageBuffer\n",
-                 MakeInstruction(
-                     SpvOpCapability,
-                     {SpvCapabilityVariablePointersStorageBuffer})},
+                 MakeInstruction(SpvOpCapability,
+                                 {SpvCapabilityVariablePointersStorageBuffer})},
             })), );
 
 }  // anonymous namespace
index 51dd52e..65f0af3 100644 (file)
@@ -63,7 +63,7 @@ INSTANTIATE_TEST_CASE_P(
         {" ConstOffsets %5", {MASK(ConstOffsets), 5}},
         {" Sample %5", {MASK(Sample), 5}},
         {" MinLod %5", {MASK(MinLod), 5}},
-    }),);
+    }), );
 #undef MASK
 #define MASK(NAME) static_cast<uint32_t>(SpvImageOperands##NAME##Mask)
 INSTANTIATE_TEST_CASE_P(
@@ -76,8 +76,7 @@ INSTANTIATE_TEST_CASE_P(
         {" Lod|Grad %5 %6 %7", {MASK(Lod) | MASK(Grad), 5, 6, 7}},
         {" Grad|ConstOffset %5 %6 %7",
          {MASK(Grad) | MASK(ConstOffset), 5, 6, 7}},
-        {" ConstOffset|Offset %5 %6",
-         {MASK(ConstOffset) | MASK(Offset), 5, 6}},
+        {" ConstOffset|Offset %5 %6", {MASK(ConstOffset) | MASK(Offset), 5, 6}},
         {" Offset|ConstOffsets %5 %6",
          {MASK(Offset) | MASK(ConstOffsets), 5, 6}},
         {" ConstOffsets|Sample %5 %6",
@@ -93,7 +92,7 @@ INSTANTIATE_TEST_CASE_P(
          " %5 %6 %7 %8 %9 %10 %11 %12",
          {MASK(Bias) | MASK(Lod) | MASK(Grad) | MASK(ConstOffset) |
               MASK(Offset) | MASK(ConstOffsets) | MASK(Sample),
-          5, 6, 7, 8, 9, 10, 11, 12}}}),);
+          5, 6, 7, 8, 9, 10, 11, 12}}}), );
 #undef MASK
 
 TEST_F(ImageOperandsTest, WrongOperand) {
@@ -132,7 +131,7 @@ TEST_F(OpImageTest, InvalidSampledImageOperand) {
 TEST_F(OpImageTest, TooManyOperands) {
   // We should improve this message, to say what instruction we're trying to
   // parse.
-  EXPECT_THAT(CompileFailure("%2 = OpImage %1 %3 %4"), // an Id
+  EXPECT_THAT(CompileFailure("%2 = OpImage %1 %3 %4"),  // an Id
               Eq("Expected '=', found end of stream."));
 
   EXPECT_THAT(CompileFailure("%2 = OpImage %1 %3 99"),  // a number
@@ -185,7 +184,7 @@ INSTANTIATE_TEST_CASE_P(ImageSparseReadImageOperandsAny,
                             {" ConstOffsets %5", {MASK(ConstOffsets), 5}},
                             {" Sample %5", {MASK(Sample), 5}},
                             {" MinLod %5", {MASK(MinLod), 5}},
-                        }),);
+                        }), );
 #undef MASK
 #define MASK(NAME) static_cast<uint32_t>(SpvImageOperands##NAME##Mask)
 INSTANTIATE_TEST_CASE_P(
@@ -210,7 +209,7 @@ INSTANTIATE_TEST_CASE_P(
           5, 6, 7, 8, 9, 10, 11, 12}},
         // Don't try the masks reversed, since this is a round trip test,
         // and the disassembler will sort them.
-    }),);
+    }), );
 #undef MASK
 
 TEST_F(OpImageSparseReadTest, InvalidTypeOperand) {
index 2146fce..2267b06 100644 (file)
@@ -50,7 +50,7 @@ INSTANTIATE_TEST_CASE_P(
         {SpvMemoryAccessVolatileMask, "Volatile", {}},
         {SpvMemoryAccessAlignedMask, "Aligned", {16}},
         {SpvMemoryAccessNontemporalMask, "Nontemporal", {}},
-    }),);
+    }), );
 
 TEST_F(TextToBinaryTest, CombinedMemoryAccessMask) {
   const std::string input = "OpStore %ptr %value Volatile|Aligned 16";
index 470bdca..3d21b43 100644 (file)
@@ -17,8 +17,8 @@
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
index 27991b2..972a2f3 100644 (file)
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
-using ::testing::Combine;
-using ::testing::Eq;
-using ::testing::TestWithParam;
-using ::testing::Values;
-using ::testing::ValuesIn;
 using spvtest::EnumCase;
 using spvtest::MakeInstruction;
 using spvtest::MakeVector;
 using std::get;
 using std::tuple;
+using ::testing::Combine;
+using ::testing::Eq;
+using ::testing::TestWithParam;
+using ::testing::Values;
+using ::testing::ValuesIn;
 
 // Test OpMemoryModel
 
index 66d13ea..97dc286 100644 (file)
@@ -12,8 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
index c74f9a6..8cc8896 100644 (file)
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
 using ::spvtest::MakeInstruction;
-using ::testing::Eq;
 using std::vector;
+using ::testing::Eq;
 
 using OpGetKernelLocalSizeForSubgroupCountTest = spvtest::TextToBinaryTest;
 
index 20f3797..be8d691 100644 (file)
@@ -17,8 +17,8 @@
 
 #include "unit_spirv.h"
 
-#include "test_fixture.h"
 #include "gmock/gmock.h"
+#include "test_fixture.h"
 
 namespace {
 
index ff7e04e..e9a709b 100644 (file)
 
 #include "gmock/gmock.h"
 
-#include "test_fixture.h"
-#include "unit_spirv.h"
 #include "source/spirv_constant.h"
 #include "source/util/bitutils.h"
 #include "source/util/hex_float.h"
+#include "test_fixture.h"
+#include "unit_spirv.h"
 
 namespace {
 
index 4744815..416d6e5 100644 (file)
@@ -22,8 +22,8 @@
 
 #include "source/assembly_grammar.h"
 #include "source/binary.h"
-#include "source/enum_set.h"
 #include "source/diagnostic.h"
+#include "source/enum_set.h"
 #include "source/opcode.h"
 #include "source/spirv_endian.h"
 #include "source/text.h"
@@ -42,7 +42,7 @@ std::string to_string(const T& val) {
   os << val;
   return os.str();
 }
-}
+}  // namespace std
 #endif
 
 // Determine endianness & predicate tests on it
index d0edd6f..5f36f39 100644 (file)
@@ -20,9 +20,9 @@
 
 namespace {
 
-using ::testing::ElementsAre;
 using spvtools::utils::IntrusiveList;
 using spvtools::utils::IntrusiveNodeBase;
+using ::testing::ElementsAre;
 using IListTest = ::testing::Test;
 
 class TestNode : public IntrusiveNodeBase<TestNode> {
index 096fbfe..7c3172f 100644 (file)
@@ -31,7 +31,7 @@ using ValidateArithmetics = spvtest::ValidateBase<bool>;
 
 std::string GenerateCode(const std::string& main_body) {
   const std::string prefix =
-R"(
+      R"(
 OpCapability Shader
 OpCapability Int64
 OpCapability Float64
@@ -159,7 +159,7 @@ OpEntryPoint Fragment %main "main"
 %main_entry = OpLabel)";
 
   const std::string suffix =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
@@ -284,8 +284,10 @@ TEST_F(ValidateArithmetics, FNegateTypeIdU32) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected floating scalar or vector type as Result Type: FNegate"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected floating scalar or vector type as Result Type: FNegate"));
 }
 
 TEST_F(ValidateArithmetics, FNegateTypeIdVec2U32) {
@@ -295,8 +297,10 @@ TEST_F(ValidateArithmetics, FNegateTypeIdVec2U32) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected floating scalar or vector type as Result Type: FNegate"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected floating scalar or vector type as Result Type: FNegate"));
 }
 
 TEST_F(ValidateArithmetics, FNegateWrongOperand) {
@@ -306,9 +310,9 @@ TEST_F(ValidateArithmetics, FNegateWrongOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "FNegate operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "FNegate operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, FMulTypeIdU32) {
@@ -318,8 +322,10 @@ TEST_F(ValidateArithmetics, FMulTypeIdU32) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected floating scalar or vector type as Result Type: FMul"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected floating scalar or vector type as Result Type: FMul"));
 }
 
 TEST_F(ValidateArithmetics, FMulTypeIdVec2U32) {
@@ -329,8 +335,10 @@ TEST_F(ValidateArithmetics, FMulTypeIdVec2U32) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected floating scalar or vector type as Result Type: FMul"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected floating scalar or vector type as Result Type: FMul"));
 }
 
 TEST_F(ValidateArithmetics, FMulWrongOperand1) {
@@ -340,9 +348,9 @@ TEST_F(ValidateArithmetics, FMulWrongOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "FMul operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "FMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, FMulWrongOperand2) {
@@ -352,9 +360,9 @@ TEST_F(ValidateArithmetics, FMulWrongOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "FMul operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "FMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, FMulWrongVectorOperand1) {
@@ -364,9 +372,9 @@ TEST_F(ValidateArithmetics, FMulWrongVectorOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "FMul operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "FMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, FMulWrongVectorOperand2) {
@@ -376,9 +384,9 @@ TEST_F(ValidateArithmetics, FMulWrongVectorOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "FMul operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "FMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, IMulFloatTypeId) {
@@ -388,8 +396,9 @@ TEST_F(ValidateArithmetics, IMulFloatTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: IMul"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected int scalar or vector type as Result Type: IMul"));
 }
 
 TEST_F(ValidateArithmetics, IMulFloatOperand1) {
@@ -399,9 +408,9 @@ TEST_F(ValidateArithmetics, IMulFloatOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as operand: "
-      "IMul operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as operand: "
+                        "IMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, IMulFloatOperand2) {
@@ -411,9 +420,9 @@ TEST_F(ValidateArithmetics, IMulFloatOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as operand: "
-      "IMul operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as operand: "
+                        "IMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, IMulWrongBitWidthOperand1) {
@@ -423,9 +432,10 @@ TEST_F(ValidateArithmetics, IMulWrongBitWidthOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same bit width "
-      "as Result Type: IMul operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same bit width "
+                "as Result Type: IMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, IMulWrongBitWidthOperand2) {
@@ -435,9 +445,10 @@ TEST_F(ValidateArithmetics, IMulWrongBitWidthOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same bit width "
-      "as Result Type: IMul operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same bit width "
+                "as Result Type: IMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, IMulWrongBitWidthVector) {
@@ -447,9 +458,10 @@ TEST_F(ValidateArithmetics, IMulWrongBitWidthVector) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same bit width "
-      "as Result Type: IMul operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same bit width "
+                "as Result Type: IMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, IMulVectorScalarOperand1) {
@@ -459,9 +471,10 @@ TEST_F(ValidateArithmetics, IMulVectorScalarOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same dimension "
-      "as Result Type: IMul operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same dimension "
+                "as Result Type: IMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, IMulVectorScalarOperand2) {
@@ -471,9 +484,10 @@ TEST_F(ValidateArithmetics, IMulVectorScalarOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same dimension "
-      "as Result Type: IMul operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same dimension "
+                "as Result Type: IMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, IMulScalarVectorOperand1) {
@@ -483,9 +497,10 @@ TEST_F(ValidateArithmetics, IMulScalarVectorOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same dimension "
-      "as Result Type: IMul operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same dimension "
+                "as Result Type: IMul operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, IMulScalarVectorOperand2) {
@@ -495,9 +510,10 @@ TEST_F(ValidateArithmetics, IMulScalarVectorOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to have the same dimension "
-      "as Result Type: IMul operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected arithmetic operands to have the same dimension "
+                "as Result Type: IMul operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, SNegateFloat) {
@@ -507,9 +523,9 @@ TEST_F(ValidateArithmetics, SNegateFloat) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as operand: "
-      "SNegate operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as operand: "
+                        "SNegate operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, UDivFloatType) {
@@ -519,8 +535,10 @@ TEST_F(ValidateArithmetics, UDivFloatType) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected unsigned int scalar or vector type as Result Type: UDiv"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected unsigned int scalar or vector type as Result Type: UDiv"));
 }
 
 TEST_F(ValidateArithmetics, UDivSignedIntType) {
@@ -530,8 +548,10 @@ TEST_F(ValidateArithmetics, UDivSignedIntType) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected unsigned int scalar or vector type as Result Type: UDiv"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected unsigned int scalar or vector type as Result Type: UDiv"));
 }
 
 TEST_F(ValidateArithmetics, UDivWrongOperand1) {
@@ -541,9 +561,9 @@ TEST_F(ValidateArithmetics, UDivWrongOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "UDiv operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "UDiv operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, UDivWrongOperand2) {
@@ -553,9 +573,9 @@ TEST_F(ValidateArithmetics, UDivWrongOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected arithmetic operands to be of Result Type: "
-      "UDiv operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected arithmetic operands to be of Result Type: "
+                        "UDiv operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, DotSuccess) {
@@ -574,8 +594,8 @@ TEST_F(ValidateArithmetics, DotWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float scalar type as Result Type: Dot"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float scalar type as Result Type: Dot"));
 }
 
 TEST_F(ValidateArithmetics, DotNotVectorTypeOperand1) {
@@ -585,8 +605,9 @@ TEST_F(ValidateArithmetics, DotNotVectorTypeOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector as operand: Dot operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected float vector as operand: Dot operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, DotNotVectorTypeOperand2) {
@@ -596,8 +617,9 @@ TEST_F(ValidateArithmetics, DotNotVectorTypeOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector as operand: Dot operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected float vector as operand: Dot operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, DotWrongComponentOperand1) {
@@ -607,9 +629,9 @@ TEST_F(ValidateArithmetics, DotWrongComponentOperand1) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component type to be equal to Result Type: "
-      "Dot operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected component type to be equal to Result Type: "
+                        "Dot operand index 2"));
 }
 
 TEST_F(ValidateArithmetics, DotWrongComponentOperand2) {
@@ -619,9 +641,9 @@ TEST_F(ValidateArithmetics, DotWrongComponentOperand2) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component type to be equal to Result Type: "
-      "Dot operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected component type to be equal to Result Type: "
+                        "Dot operand index 3"));
 }
 
 TEST_F(ValidateArithmetics, DotDifferentVectorSize) {
@@ -631,8 +653,10 @@ TEST_F(ValidateArithmetics, DotDifferentVectorSize) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to have the same number of componenets: Dot"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected operands to have the same number of componenets: Dot"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesScalarSuccess) {
@@ -651,9 +675,9 @@ TEST_F(ValidateArithmetics, VectorTimesScalarWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as Result Type: "
-      "VectorTimesScalar"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float vector type as Result Type: "
+                        "VectorTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesScalarWrongVector) {
@@ -663,9 +687,10 @@ TEST_F(ValidateArithmetics, VectorTimesScalarWrongVector) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector operand type to be equal to Result Type: "
-      "VectorTimesScalar"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected vector operand type to be equal to Result Type: "
+                "VectorTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesScalarWrongScalar) {
@@ -675,9 +700,10 @@ TEST_F(ValidateArithmetics, VectorTimesScalarWrongScalar) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected scalar operand type to be equal to the component "
-      "type of the vector operand: VectorTimesScalar"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected scalar operand type to be equal to the component "
+                "type of the vector operand: VectorTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesScalarSuccess) {
@@ -696,9 +722,9 @@ TEST_F(ValidateArithmetics, MatrixTimesScalarWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as Result Type: "
-      "MatrixTimesScalar"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float matrix type as Result Type: "
+                        "MatrixTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesScalarWrongMatrix) {
@@ -708,9 +734,10 @@ TEST_F(ValidateArithmetics, MatrixTimesScalarWrongMatrix) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected matrix operand type to be equal to Result Type: "
-      "MatrixTimesScalar"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected matrix operand type to be equal to Result Type: "
+                "MatrixTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesScalarWrongScalar) {
@@ -720,9 +747,10 @@ TEST_F(ValidateArithmetics, MatrixTimesScalarWrongScalar) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected scalar operand type to be equal to the component "
-      "type of the matrix operand: MatrixTimesScalar"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected scalar operand type to be equal to the component "
+                "type of the matrix operand: MatrixTimesScalar"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrix2x22Success) {
@@ -750,9 +778,9 @@ TEST_F(ValidateArithmetics, VectorTimesMatrixWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as Result Type: "
-      "VectorTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float vector type as Result Type: "
+                        "VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrixNotFloatVector) {
@@ -762,9 +790,9 @@ TEST_F(ValidateArithmetics, VectorTimesMatrixNotFloatVector) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as left operand: "
-      "VectorTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float vector type as left operand: "
+                        "VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrixWrongVectorComponent) {
@@ -774,9 +802,11 @@ TEST_F(ValidateArithmetics, VectorTimesMatrixWrongVectorComponent) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component types of Result Type and vector to be equal: "
-      "VectorTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected component types of Result Type and vector to be equal: "
+          "VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrixWrongMatrix) {
@@ -786,9 +816,9 @@ TEST_F(ValidateArithmetics, VectorTimesMatrixWrongMatrix) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as right operand: "
-      "VectorTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float matrix type as right operand: "
+                        "VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrixWrongMatrixComponent) {
@@ -798,9 +828,11 @@ TEST_F(ValidateArithmetics, VectorTimesMatrixWrongMatrixComponent) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component types of Result Type and matrix to be equal: "
-      "VectorTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected component types of Result Type and matrix to be equal: "
+          "VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrix2eq2x23Fail) {
@@ -810,9 +842,11 @@ TEST_F(ValidateArithmetics, VectorTimesMatrix2eq2x23Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of columns of the matrix to be equal to Result Type "
-      "vector size: VectorTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected number of columns of the matrix to be equal to Result Type "
+          "vector size: VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, VectorTimesMatrix2x32Fail) {
@@ -822,9 +856,11 @@ TEST_F(ValidateArithmetics, VectorTimesMatrix2x32Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of rows of the matrix to be equal to the vector "
-      "operand size: VectorTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected number of rows of the matrix to be equal to the vector "
+          "operand size: VectorTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVector22x2Success) {
@@ -852,9 +888,9 @@ TEST_F(ValidateArithmetics, MatrixTimesVectorWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as Result Type: "
-      "MatrixTimesVector"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float vector type as Result Type: "
+                        "MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVectorWrongMatrix) {
@@ -864,9 +900,9 @@ TEST_F(ValidateArithmetics, MatrixTimesVectorWrongMatrix) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as left operand: "
-      "MatrixTimesVector"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float matrix type as left operand: "
+                        "MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVectorWrongMatrixCol) {
@@ -876,9 +912,11 @@ TEST_F(ValidateArithmetics, MatrixTimesVectorWrongMatrixCol) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected column type of the matrix to be equal to Result Type: "
-      "MatrixTimesVector"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected column type of the matrix to be equal to Result Type: "
+          "MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVectorWrongVector) {
@@ -888,9 +926,9 @@ TEST_F(ValidateArithmetics, MatrixTimesVectorWrongVector) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as right operand: "
-      "MatrixTimesVector"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float vector type as right operand: "
+                        "MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVectorDifferentComponents) {
@@ -900,9 +938,9 @@ TEST_F(ValidateArithmetics, MatrixTimesVectorDifferentComponents) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component types of the operands to be equal: "
-      "MatrixTimesVector"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected component types of the operands to be equal: "
+                        "MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesVector22x3Fail) {
@@ -912,9 +950,11 @@ TEST_F(ValidateArithmetics, MatrixTimesVector22x3Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of columns of the matrix to be equal to the vector "
-      "size: MatrixTimesVector"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected number of columns of the matrix to be equal to the vector "
+          "size: MatrixTimesVector"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrix22x22Success) {
@@ -951,8 +991,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrixWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as Result Type: MatrixTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected float matrix type as Result Type: MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrixWrongLeftOperand) {
@@ -962,8 +1004,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrixWrongLeftOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as left operand: MatrixTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected float matrix type as left operand: MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrixWrongRightOperand) {
@@ -973,8 +1017,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrixWrongRightOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as right operand: MatrixTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected float matrix type as right operand: MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrix32x23Fail) {
@@ -984,9 +1030,11 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrix32x23Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected column types of Result Type and left matrix to be equal: "
-      "MatrixTimesMatrix"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected column types of Result Type and left matrix to be equal: "
+          "MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrixDifferentComponents) {
@@ -996,9 +1044,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrixDifferentComponents) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component types of Result Type and right matrix to be equal: "
-      "MatrixTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected component types of Result Type and right "
+                        "matrix to be equal: "
+                        "MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrix23x23Fail) {
@@ -1008,9 +1057,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrix23x23Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of columns of Result Type and right matrix to be equal: "
-      "MatrixTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected number of columns of Result Type and right "
+                        "matrix to be equal: "
+                        "MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, MatrixTimesMatrix23x22Fail) {
@@ -1020,9 +1070,10 @@ TEST_F(ValidateArithmetics, MatrixTimesMatrix23x22Fail) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of columns of left matrix and number of rows of right "
-      "matrix to be equal: MatrixTimesMatrix"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected number of columns of left matrix and number "
+                        "of rows of right "
+                        "matrix to be equal: MatrixTimesMatrix"));
 }
 
 TEST_F(ValidateArithmetics, OuterProduct2x2Success) {
@@ -1059,9 +1110,9 @@ TEST_F(ValidateArithmetics, OuterProductWrongTypeId) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float matrix type as Result Type: "
-      "OuterProduct"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected float matrix type as Result Type: "
+                        "OuterProduct"));
 }
 
 TEST_F(ValidateArithmetics, OuterProductWrongLeftOperand) {
@@ -1071,9 +1122,10 @@ TEST_F(ValidateArithmetics, OuterProductWrongLeftOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected column type of Result Type to be equal to the type "
-      "of the left operand: OuterProduct"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected column type of Result Type to be equal to the type "
+                "of the left operand: OuterProduct"));
 }
 
 TEST_F(ValidateArithmetics, OuterProductRightOperandNotFloatVector) {
@@ -1083,8 +1135,9 @@ TEST_F(ValidateArithmetics, OuterProductRightOperandNotFloatVector) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float vector type as right operand: OuterProduct"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected float vector type as right operand: OuterProduct"));
 }
 
 TEST_F(ValidateArithmetics, OuterProductRightOperandWrongComponent) {
@@ -1094,8 +1147,9 @@ TEST_F(ValidateArithmetics, OuterProductRightOperandWrongComponent) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected component types of the operands to be equal: OuterProduct"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected component types of the operands to be equal: "
+                        "OuterProduct"));
 }
 
 TEST_F(ValidateArithmetics, OuterProductRightOperandWrongDimension) {
@@ -1105,9 +1159,10 @@ TEST_F(ValidateArithmetics, OuterProductRightOperandWrongDimension) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected number of columns of the matrix to be equal to the "
-      "vector size of the right operand: OuterProduct"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected number of columns of the matrix to be equal to the "
+                "vector size of the right operand: OuterProduct"));
 }
 
 TEST_F(ValidateArithmetics, IAddCarrySuccess) {
@@ -1127,8 +1182,8 @@ TEST_F(ValidateArithmetics, IAddCarryResultTypeNotStruct) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected a struct as Result Type: IAddCarry"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected a struct as Result Type: IAddCarry"));
 }
 
 TEST_F(ValidateArithmetics, IAddCarryResultTypeNotTwoMembers) {
@@ -1138,8 +1193,9 @@ TEST_F(ValidateArithmetics, IAddCarryResultTypeNotTwoMembers) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type struct to have two members: IAddCarry"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type struct to have two members: IAddCarry"));
 }
 
 TEST_F(ValidateArithmetics, IAddCarryResultTypeMemberNotUnsignedInt) {
@@ -1149,9 +1205,10 @@ TEST_F(ValidateArithmetics, IAddCarryResultTypeMemberNotUnsignedInt) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type struct member types to be unsigned integer scalar "
-      "or vector: IAddCarry"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type struct member types to be "
+                        "unsigned integer scalar "
+                        "or vector: IAddCarry"));
 }
 
 TEST_F(ValidateArithmetics, IAddCarryWrongLeftOperand) {
@@ -1161,8 +1218,9 @@ TEST_F(ValidateArithmetics, IAddCarryWrongLeftOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to be of Result Type member type: IAddCarry"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both operands to be of Result Type member "
+                        "type: IAddCarry"));
 }
 
 TEST_F(ValidateArithmetics, IAddCarryWrongRightOperand) {
@@ -1172,8 +1230,9 @@ TEST_F(ValidateArithmetics, IAddCarryWrongRightOperand) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to be of Result Type member type: IAddCarry"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both operands to be of Result Type member "
+                        "type: IAddCarry"));
 }
 
 TEST_F(ValidateArithmetics, OpSMulExtendedSuccess) {
@@ -1195,9 +1254,10 @@ TEST_F(ValidateArithmetics, SMulExtendedResultTypeMemberNotInt) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type struct member types to be integer scalar "
-      "or vector: SMulExtended"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type struct member types to be integer scalar "
+                "or vector: SMulExtended"));
 }
 
 TEST_F(ValidateArithmetics, SMulExtendedResultTypeMembersNotIdentical) {
@@ -1207,9 +1267,10 @@ TEST_F(ValidateArithmetics, SMulExtendedResultTypeMembersNotIdentical) {
 
   CompileSuccessfully(GenerateCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type struct member types to be identical: "
-      "SMulExtended"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type struct member types to be identical: "
+                "SMulExtended"));
 }
 
 }  // anonymous namespace
index c302001..65ce0ac 100644 (file)
@@ -31,13 +31,13 @@ std::string GenerateShaderCode(
     const std::string& body,
     const std::string& capabilities_and_extensions = "") {
   const std::string capabilities =
-R"(
+      R"(
 OpCapability Shader
 OpCapability Int64
 OpCapability Float64)";
 
   const std::string after_extension_before_body =
-R"(
+      R"(
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main"
 %void = OpTypeVoid
@@ -131,12 +131,12 @@ OpEntryPoint Fragment %main "main"
 %main_entry = OpLabel)";
 
   const std::string after_body =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
   return capabilities + capabilities_and_extensions +
-      after_extension_before_body + body + after_body;
+         after_extension_before_body + body + after_body;
 }
 
 TEST_F(ValidateBitwise, ShiftAllSuccess) {
@@ -157,8 +157,9 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: ShiftRightLogical"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as Result Type: "
+                        "ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, OpShiftRightLogicalBaseNotInt) {
@@ -168,8 +169,9 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalBaseNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base to be int scalar or vector: ShiftRightLogical"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base to be int scalar or vector: ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, OpShiftRightLogicalBaseWrongDimension) {
@@ -179,9 +181,10 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalBaseWrongDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base to have the same dimension as Result Type: "
-      "ShiftRightLogical"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base to have the same dimension as Result Type: "
+                "ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, OpShiftRightLogicalBaseWrongBitWidth) {
@@ -191,9 +194,10 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalBaseWrongBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base to have the same bit width as Result Type: "
-      "ShiftRightLogical"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base to have the same bit width as Result Type: "
+                "ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, OpShiftRightLogicalShiftNotInt) {
@@ -203,8 +207,10 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalShiftNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Shift to be int scalar or vector: ShiftRightLogical"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Shift to be int scalar or vector: ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, OpShiftRightLogicalShiftWrongDimension) {
@@ -214,9 +220,10 @@ TEST_F(ValidateBitwise, OpShiftRightLogicalShiftWrongDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Shift to have the same dimension as Result Type: "
-      "ShiftRightLogical"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Shift to have the same dimension as Result Type: "
+                "ShiftRightLogical"));
 }
 
 TEST_F(ValidateBitwise, LogicAllSuccess) {
@@ -238,8 +245,10 @@ TEST_F(ValidateBitwise, OpBitwiseAndWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: BitwiseAnd"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected int scalar or vector type as Result Type: BitwiseAnd"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndLeftNotInt) {
@@ -249,9 +258,9 @@ TEST_F(ValidateBitwise, OpBitwiseAndLeftNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector as operand: BitwiseAnd "
-      "operand index 2"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector as operand: BitwiseAnd "
+                        "operand index 2"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndRightNotInt) {
@@ -261,9 +270,9 @@ TEST_F(ValidateBitwise, OpBitwiseAndRightNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector as operand: BitwiseAnd "
-      "operand index 3"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector as operand: BitwiseAnd "
+                        "operand index 3"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndLeftWrongDimension) {
@@ -273,9 +282,10 @@ TEST_F(ValidateBitwise, OpBitwiseAndLeftWrongDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to have the same dimension as Result Type: "
-      "BitwiseAnd operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to have the same dimension as Result Type: "
+                "BitwiseAnd operand index 2"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndRightWrongDimension) {
@@ -285,9 +295,10 @@ TEST_F(ValidateBitwise, OpBitwiseAndRightWrongDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to have the same dimension as Result Type: "
-      "BitwiseAnd operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to have the same dimension as Result Type: "
+                "BitwiseAnd operand index 3"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndLeftWrongBitWidth) {
@@ -297,9 +308,10 @@ TEST_F(ValidateBitwise, OpBitwiseAndLeftWrongBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to have the same bit width as Result Type: "
-      "BitwiseAnd operand index 2"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to have the same bit width as Result Type: "
+                "BitwiseAnd operand index 2"));
 }
 
 TEST_F(ValidateBitwise, OpBitwiseAndRightWrongBitWidth) {
@@ -309,9 +321,10 @@ TEST_F(ValidateBitwise, OpBitwiseAndRightWrongBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to have the same bit width as Result Type: "
-      "BitwiseAnd operand index 3"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to have the same bit width as Result Type: "
+                "BitwiseAnd operand index 3"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldInsertSuccess) {
@@ -331,8 +344,10 @@ TEST_F(ValidateBitwise, OpBitFieldInsertWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: BitFieldInsert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected int scalar or vector type as Result Type: BitFieldInsert"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldInsertWrongBaseType) {
@@ -342,8 +357,10 @@ TEST_F(ValidateBitwise, OpBitFieldInsertWrongBaseType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base Type to be equal to Result Type: BitFieldInsert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Base Type to be equal to Result Type: BitFieldInsert"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldInsertWrongInsertType) {
@@ -353,8 +370,10 @@ TEST_F(ValidateBitwise, OpBitFieldInsertWrongInsertType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Insert Type to be equal to Result Type: BitFieldInsert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Insert Type to be equal to Result Type: BitFieldInsert"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldInsertOffsetNotInt) {
@@ -364,8 +383,9 @@ TEST_F(ValidateBitwise, OpBitFieldInsertOffsetNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Offset Type to be int scalar: BitFieldInsert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Offset Type to be int scalar: BitFieldInsert"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldInsertCountNotInt) {
@@ -375,8 +395,9 @@ TEST_F(ValidateBitwise, OpBitFieldInsertCountNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Count Type to be int scalar: BitFieldInsert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Count Type to be int scalar: BitFieldInsert"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldSExtractSuccess) {
@@ -396,8 +417,9 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: BitFieldSExtract"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as Result Type: "
+                        "BitFieldSExtract"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldSExtractWrongBaseType) {
@@ -407,8 +429,10 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractWrongBaseType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base Type to be equal to Result Type: BitFieldSExtract"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Base Type to be equal to Result Type: BitFieldSExtract"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldSExtractOffsetNotInt) {
@@ -418,8 +442,9 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractOffsetNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Offset Type to be int scalar: BitFieldSExtract"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Offset Type to be int scalar: BitFieldSExtract"));
 }
 
 TEST_F(ValidateBitwise, OpBitFieldSExtractCountNotInt) {
@@ -429,8 +454,9 @@ TEST_F(ValidateBitwise, OpBitFieldSExtractCountNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Count Type to be int scalar: BitFieldSExtract"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Count Type to be int scalar: BitFieldSExtract"));
 }
 
 TEST_F(ValidateBitwise, OpBitReverseSuccess) {
@@ -450,8 +476,10 @@ TEST_F(ValidateBitwise, OpBitReverseWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: BitReverse"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected int scalar or vector type as Result Type: BitReverse"));
 }
 
 TEST_F(ValidateBitwise, OpBitReverseWrongBaseType) {
@@ -461,8 +489,9 @@ TEST_F(ValidateBitwise, OpBitReverseWrongBaseType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base Type to be equal to Result Type: BitReverse"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base Type to be equal to Result Type: BitReverse"));
 }
 
 TEST_F(ValidateBitwise, OpBitCountSuccess) {
@@ -482,8 +511,9 @@ TEST_F(ValidateBitwise, OpBitCountWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: BitCount"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected int scalar or vector type as Result Type: BitCount"));
 }
 
 TEST_F(ValidateBitwise, OpBitCountBaseNotInt) {
@@ -493,8 +523,9 @@ TEST_F(ValidateBitwise, OpBitCountBaseNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base Type to be int scalar or vector: BitCount"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base Type to be int scalar or vector: BitCount"));
 }
 
 TEST_F(ValidateBitwise, OpBitCountBaseWrongDimension) {
@@ -504,9 +535,10 @@ TEST_F(ValidateBitwise, OpBitCountBaseWrongDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Base dimension to be equal to Result Type dimension: "
-      "BitCount"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Base dimension to be equal to Result Type dimension: "
+                "BitCount"));
 }
 
 }  // anonymous namespace
index 26a6ec1..28df365 100644 (file)
@@ -1459,10 +1459,10 @@ INSTANTIATE_TEST_CASE_P(
 // True if capability exists in env.
 bool Exists(const std::string& capability, spv_target_env env) {
   spv_operand_desc dummy;
-  return SPV_SUCCESS ==
-         libspirv::AssemblyGrammar(ScopedContext(env).context)
-             .lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, capability.c_str(),
-                            capability.size(), &dummy);
+  return SPV_SUCCESS == libspirv::AssemblyGrammar(ScopedContext(env).context)
+                            .lookupOperand(SPV_OPERAND_TYPE_CAPABILITY,
+                                           capability.c_str(),
+                                           capability.size(), &dummy);
 }
 
 TEST_P(ValidateCapability, Capability) {
@@ -1626,4 +1626,4 @@ OpDecorate %intt BuiltIn PointSize
               HasSubstr("Capability value 4427 is not allowed by Vulkan 1.0"));
 }
 
-}  // namespace anonymous
+}  // namespace
index c1b5ce2..78cbe09 100644 (file)
@@ -262,8 +262,8 @@ TEST_P(ValidateCFG, LoopUnreachableFromEntryButLeadingToReturn) {
            OpFunctionEnd
   )";
   CompileSuccessfully(str);
-  ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()) << str
-                                                 << getDiagnosticString();
+  ASSERT_EQ(SPV_SUCCESS, ValidateInstructions())
+      << str << getDiagnosticString();
 }
 
 TEST_P(ValidateCFG, Simple) {
@@ -278,9 +278,10 @@ TEST_P(ValidateCFG, Simple) {
     loop.SetBody("OpLoopMerge %merge %cont None\n");
   }
 
-  string str = header(GetParam()) + nameOps("loop", "entry", "cont", "merge",
-                                            make_pair("func", "Main")) +
-               types_consts() + "%func    = OpFunction %voidt None %funct\n";
+  string str =
+      header(GetParam()) +
+      nameOps("loop", "entry", "cont", "merge", make_pair("func", "Main")) +
+      types_consts() + "%func    = OpFunction %voidt None %funct\n";
 
   str += entry >> loop;
   str += loop >> vector<Block>({cont, merge});
@@ -1258,9 +1259,10 @@ TEST_P(ValidateCFG, ContinueTargetCanBeMergeBlockForNestedStructureGood) {
     if_head.SetBody("OpSelectionMerge %if_merge None\n");
   }
 
-  string str = header(GetParam()) + nameOps("entry", "loop", "if_head",
-                                            "if_true", "if_merge", "merge") +
-               types_consts() + "%func    = OpFunction %voidt None %funct\n";
+  string str =
+      header(GetParam()) +
+      nameOps("entry", "loop", "if_head", "if_true", "if_merge", "merge") +
+      types_consts() + "%func    = OpFunction %voidt None %funct\n";
 
   str += entry >> loop;
   str += loop >> if_head;
@@ -1298,8 +1300,8 @@ TEST_P(ValidateCFG, SingleLatchBlockMultipleBranchesToLoopHeader) {
   str += "OpFunctionEnd";
 
   CompileSuccessfully(str);
-  EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << str
-                                                 << getDiagnosticString();
+  EXPECT_EQ(SPV_SUCCESS, ValidateInstructions())
+      << str << getDiagnosticString();
 }
 
 TEST_P(ValidateCFG, SingleLatchBlockHeaderContinueTargetIsItselfGood) {
@@ -1330,8 +1332,8 @@ TEST_P(ValidateCFG, SingleLatchBlockHeaderContinueTargetIsItselfGood) {
   str += "OpFunctionEnd";
 
   CompileSuccessfully(str);
-  EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()) << str
-                                                 << getDiagnosticString();
+  EXPECT_EQ(SPV_SUCCESS, ValidateInstructions())
+      << str << getDiagnosticString();
 }
 
 // Unit test to check the case where a basic block is the entry block of 2
@@ -1399,4 +1401,4 @@ TEST_F(ValidateCFG, OpReturnInNonVoidFunc) {
 
 /// TODO(umar): Switch instructions
 /// TODO(umar): Nested CFG constructs
-}  /// namespace
+}  // namespace
index 391651d..75b101e 100644 (file)
@@ -31,13 +31,13 @@ std::string GenerateShaderCode(
     const std::string& body,
     const std::string& capabilities_and_extensions = "") {
   const std::string capabilities =
-R"(
+      R"(
 OpCapability Shader
 OpCapability Int64
 OpCapability Float64)";
 
   const std::string after_extension_before_body =
-R"(
+      R"(
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main"
 %void = OpTypeVoid
@@ -143,19 +143,19 @@ OpEntryPoint Fragment %main "main"
 %main_entry = OpLabel)";
 
   const std::string after_body =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
   return capabilities + capabilities_and_extensions +
-      after_extension_before_body + body + after_body;
+         after_extension_before_body + body + after_body;
 }
 
 std::string GenerateKernelCode(
     const std::string& body,
     const std::string& capabilities_and_extensions = "") {
   const std::string capabilities =
-R"(
+      R"(
 OpCapability Addresses
 OpCapability Kernel
 OpCapability Linkage
@@ -164,7 +164,7 @@ OpCapability Int64
 OpCapability Float64)";
 
   const std::string after_extension_before_body =
-R"(
+      R"(
 OpMemoryModel Physical32 OpenCL
 %void = OpTypeVoid
 %func = OpTypeFunction %void
@@ -250,12 +250,12 @@ OpMemoryModel Physical32 OpenCL
 %main_entry = OpLabel)";
 
   const std::string after_body =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
   return capabilities + capabilities_and_extensions +
-      after_extension_before_body + body + after_body;
+         after_extension_before_body + body + after_body;
 }
 
 TEST_F(ValidateConversion, ConvertFToUSuccess) {
@@ -276,8 +276,9 @@ TEST_F(ValidateConversion, ConvertFToUWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected unsigned int scalar or vector type as Result Type: ConvertFToU"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected unsigned int scalar or vector type as Result "
+                        "Type: ConvertFToU"));
 }
 
 TEST_F(ValidateConversion, ConvertFToUWrongInputType) {
@@ -287,8 +288,9 @@ TEST_F(ValidateConversion, ConvertFToUWrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be float scalar or vector: ConvertFToU"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be float scalar or vector: ConvertFToU"));
 }
 
 TEST_F(ValidateConversion, ConvertFToUDifferentDimension) {
@@ -298,8 +300,9 @@ TEST_F(ValidateConversion, ConvertFToUDifferentDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: ConvertFToU"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have the same dimension as Result "
+                        "Type: ConvertFToU"));
 }
 
 TEST_F(ValidateConversion, ConvertFToSSuccess) {
@@ -320,8 +323,10 @@ TEST_F(ValidateConversion, ConvertFToSWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: ConvertFToS"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected int scalar or vector type as Result Type: ConvertFToS"));
 }
 
 TEST_F(ValidateConversion, ConvertFToSWrongInputType) {
@@ -331,8 +336,9 @@ TEST_F(ValidateConversion, ConvertFToSWrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be float scalar or vector: ConvertFToS"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be float scalar or vector: ConvertFToS"));
 }
 
 TEST_F(ValidateConversion, ConvertFToSDifferentDimension) {
@@ -342,8 +348,9 @@ TEST_F(ValidateConversion, ConvertFToSDifferentDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: ConvertFToS"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have the same dimension as Result "
+                        "Type: ConvertFToS"));
 }
 
 TEST_F(ValidateConversion, ConvertSToFSuccess) {
@@ -364,8 +371,10 @@ TEST_F(ValidateConversion, ConvertSToFWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float scalar or vector type as Result Type: ConvertSToF"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected float scalar or vector type as Result Type: ConvertSToF"));
 }
 
 TEST_F(ValidateConversion, ConvertSToFWrongInputType) {
@@ -375,8 +384,9 @@ TEST_F(ValidateConversion, ConvertSToFWrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be int scalar or vector: ConvertSToF"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be int scalar or vector: ConvertSToF"));
 }
 
 TEST_F(ValidateConversion, ConvertSToFDifferentDimension) {
@@ -386,8 +396,9 @@ TEST_F(ValidateConversion, ConvertSToFDifferentDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: ConvertSToF"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have the same dimension as Result "
+                        "Type: ConvertSToF"));
 }
 
 TEST_F(ValidateConversion, UConvertSuccess) {
@@ -466,8 +477,9 @@ TEST_F(ValidateConversion, SConvertWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: SConvert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected int scalar or vector type as Result Type: SConvert"));
 }
 
 TEST_F(ValidateConversion, SConvertWrongInputType) {
@@ -477,8 +489,8 @@ TEST_F(ValidateConversion, SConvertWrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be int scalar or vector: SConvert"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to be int scalar or vector: SConvert"));
 }
 
 TEST_F(ValidateConversion, SConvertDifferentDimension) {
@@ -488,8 +500,9 @@ TEST_F(ValidateConversion, SConvertDifferentDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: SConvert"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have the same dimension as Result "
+                        "Type: SConvert"));
 }
 
 TEST_F(ValidateConversion, SConvertSameBitWidth) {
@@ -499,8 +512,9 @@ TEST_F(ValidateConversion, SConvertSameBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have different bit width from Result Type: SConvert"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have different bit width from "
+                        "Result Type: SConvert"));
 }
 
 TEST_F(ValidateConversion, FConvertSuccess) {
@@ -521,8 +535,10 @@ TEST_F(ValidateConversion, FConvertWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected float scalar or vector type as Result Type: FConvert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected float scalar or vector type as Result Type: FConvert"));
 }
 
 TEST_F(ValidateConversion, FConvertWrongInputType) {
@@ -532,8 +548,9 @@ TEST_F(ValidateConversion, FConvertWrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be float scalar or vector: FConvert"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be float scalar or vector: FConvert"));
 }
 
 TEST_F(ValidateConversion, FConvertDifferentDimension) {
@@ -543,8 +560,9 @@ TEST_F(ValidateConversion, FConvertDifferentDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: FConvert"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have the same dimension as Result "
+                        "Type: FConvert"));
 }
 
 TEST_F(ValidateConversion, FConvertSameBitWidth) {
@@ -554,8 +572,9 @@ TEST_F(ValidateConversion, FConvertSameBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have different bit width from Result Type: FConvert"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have different bit width from "
+                        "Result Type: FConvert"));
 }
 
 TEST_F(ValidateConversion, QuantizeToF16Success) {
@@ -576,9 +595,10 @@ TEST_F(ValidateConversion, QuantizeToF16WrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected 32-bit float scalar or vector type as Result Type: "
-      "QuantizeToF16"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected 32-bit float scalar or vector type as Result Type: "
+                "QuantizeToF16"));
 }
 
 TEST_F(ValidateConversion, QuantizeToF16WrongResultTypeBitWidth) {
@@ -588,9 +608,10 @@ TEST_F(ValidateConversion, QuantizeToF16WrongResultTypeBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected 32-bit float scalar or vector type as Result Type: "
-      "QuantizeToF16"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected 32-bit float scalar or vector type as Result Type: "
+                "QuantizeToF16"));
 }
 
 TEST_F(ValidateConversion, QuantizeToF16WrongInputType) {
@@ -600,8 +621,10 @@ TEST_F(ValidateConversion, QuantizeToF16WrongInputType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input type to be equal to Result Type: QuantizeToF16"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected input type to be equal to Result Type: QuantizeToF16"));
 }
 
 TEST_F(ValidateConversion, ConvertPtrToUSuccess) {
@@ -623,9 +646,9 @@ TEST_F(ValidateConversion, ConvertPtrToUWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected unsigned int scalar type as Result Type: "
-      "ConvertPtrToU"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected unsigned int scalar type as Result Type: "
+                        "ConvertPtrToU"));
 }
 
 TEST_F(ValidateConversion, ConvertPtrToUNotPointer) {
@@ -635,8 +658,8 @@ TEST_F(ValidateConversion, ConvertPtrToUNotPointer) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer: ConvertPtrToU"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to be a pointer: ConvertPtrToU"));
 }
 
 TEST_F(ValidateConversion, SatConvertSToUSuccess) {
@@ -657,9 +680,9 @@ TEST_F(ValidateConversion, SatConvertSToUWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector type as Result Type: "
-      "SatConvertSToU"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar or vector type as Result Type: "
+                        "SatConvertSToU"));
 }
 
 TEST_F(ValidateConversion, SatConvertSToUWrongInputType) {
@@ -669,8 +692,9 @@ TEST_F(ValidateConversion, SatConvertSToUWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar or vector as input: SatConvertSToU"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected int scalar or vector as input: SatConvertSToU"));
 }
 
 TEST_F(ValidateConversion, SatConvertSToUDifferentDimension) {
@@ -680,9 +704,10 @@ TEST_F(ValidateConversion, SatConvertSToUDifferentDimension) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same dimension as Result Type: "
-      "SatConvertSToU"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to have the same dimension as Result Type: "
+                "SatConvertSToU"));
 }
 
 TEST_F(ValidateConversion, ConvertUToPtrSuccess) {
@@ -702,8 +727,8 @@ TEST_F(ValidateConversion, ConvertUToPtrWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be a pointer: ConvertUToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be a pointer: ConvertUToPtr"));
 }
 
 TEST_F(ValidateConversion, ConvertUToPtrNotInt) {
@@ -713,8 +738,8 @@ TEST_F(ValidateConversion, ConvertUToPtrNotInt) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar as input: ConvertUToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar as input: ConvertUToPtr"));
 }
 
 TEST_F(ValidateConversion, ConvertUToPtrNotIntScalar) {
@@ -724,8 +749,8 @@ TEST_F(ValidateConversion, ConvertUToPtrNotIntScalar) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected int scalar as input: ConvertUToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected int scalar as input: ConvertUToPtr"));
 }
 
 TEST_F(ValidateConversion, PtrCastToGenericSuccess) {
@@ -746,8 +771,9 @@ TEST_F(ValidateConversion, PtrCastToGenericWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be a pointer: PtrCastToGeneric"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be a pointer: PtrCastToGeneric"));
 }
 
 TEST_F(ValidateConversion, PtrCastToGenericWrongResultStorageClass) {
@@ -758,8 +784,9 @@ TEST_F(ValidateConversion, PtrCastToGenericWrongResultStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have storage class Generic: PtrCastToGeneric"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have storage class Generic: "
+                        "PtrCastToGeneric"));
 }
 
 TEST_F(ValidateConversion, PtrCastToGenericWrongInputType) {
@@ -770,8 +797,8 @@ TEST_F(ValidateConversion, PtrCastToGenericWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer: PtrCastToGeneric"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to be a pointer: PtrCastToGeneric"));
 }
 
 TEST_F(ValidateConversion, PtrCastToGenericWrongInputStorageClass) {
@@ -781,9 +808,9 @@ TEST_F(ValidateConversion, PtrCastToGenericWrongInputStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have storage class Workgroup, "
-      "CrossWorkgroup or Function: PtrCastToGeneric"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have storage class Workgroup, "
+                        "CrossWorkgroup or Function: PtrCastToGeneric"));
 }
 
 TEST_F(ValidateConversion, PtrCastToGenericPointToDifferentType) {
@@ -794,9 +821,10 @@ TEST_F(ValidateConversion, PtrCastToGenericPointToDifferentType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input and Result Type to point to the same type: "
-      "PtrCastToGeneric"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input and Result Type to point to the same type: "
+                "PtrCastToGeneric"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrSuccess) {
@@ -821,8 +849,9 @@ TEST_F(ValidateConversion, GenericCastToPtrWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be a pointer: GenericCastToPtr"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be a pointer: GenericCastToPtr"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrWrongResultStorageClass) {
@@ -834,9 +863,9 @@ TEST_F(ValidateConversion, GenericCastToPtrWrongResultStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have storage class Workgroup, "
-      "CrossWorkgroup or Function: GenericCastToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have storage class Workgroup, "
+                        "CrossWorkgroup or Function: GenericCastToPtr"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrWrongInputType) {
@@ -848,8 +877,8 @@ TEST_F(ValidateConversion, GenericCastToPtrWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer: GenericCastToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to be a pointer: GenericCastToPtr"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrWrongInputStorageClass) {
@@ -860,9 +889,9 @@ TEST_F(ValidateConversion, GenericCastToPtrWrongInputStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have storage class Generic: "
-      "GenericCastToPtr"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have storage class Generic: "
+                        "GenericCastToPtr"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrPointToDifferentType) {
@@ -874,9 +903,10 @@ TEST_F(ValidateConversion, GenericCastToPtrPointToDifferentType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input and Result Type to point to the same type: "
-      "GenericCastToPtr"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input and Result Type to point to the same type: "
+                "GenericCastToPtr"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitSuccess) {
@@ -901,8 +931,10 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be a pointer: GenericCastToPtrExplicit"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Result Type to be a pointer: GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitResultStorageClassDiffers) {
@@ -914,9 +946,9 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitResultStorageClassDiffers) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be of target storage class: "
-      "GenericCastToPtrExplicit"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be of target storage class: "
+                        "GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongResultStorageClass) {
@@ -928,9 +960,10 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongResultStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected target storage class to be Workgroup, "
-      "CrossWorkgroup or Function: GenericCastToPtrExplicit"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected target storage class to be Workgroup, "
+                "CrossWorkgroup or Function: GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongInputType) {
@@ -942,8 +975,9 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer: GenericCastToPtrExplicit"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be a pointer: GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongInputStorageClass) {
@@ -954,9 +988,9 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitWrongInputStorageClass) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have storage class Generic: "
-      "GenericCastToPtrExplicit"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have storage class Generic: "
+                        "GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, GenericCastToPtrExplicitPointToDifferentType) {
@@ -968,9 +1002,10 @@ TEST_F(ValidateConversion, GenericCastToPtrExplicitPointToDifferentType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input and Result Type to point to the same type: "
-      "GenericCastToPtrExplicit"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input and Result Type to point to the same type: "
+                "GenericCastToPtrExplicit"));
 }
 
 TEST_F(ValidateConversion, BitcastSuccess) {
@@ -998,8 +1033,8 @@ TEST_F(ValidateConversion, BitcastInputHasNoType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have a type: Bitcast"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to have a type: Bitcast"));
 }
 
 TEST_F(ValidateConversion, BitcastWrongResultType) {
@@ -1009,9 +1044,10 @@ TEST_F(ValidateConversion, BitcastWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be a pointer or int or float vector "
-      "or scalar type: Bitcast"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be a pointer or int or float vector "
+                "or scalar type: Bitcast"));
 }
 
 TEST_F(ValidateConversion, BitcastWrongInputType) {
@@ -1021,9 +1057,9 @@ TEST_F(ValidateConversion, BitcastWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer or int or float vector "
-      "or scalar: Bitcast"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected input to be a pointer or int or float vector "
+                        "or scalar: Bitcast"));
 }
 
 TEST_F(ValidateConversion, BitcastPtrWrongInputType) {
@@ -1033,9 +1069,10 @@ TEST_F(ValidateConversion, BitcastPtrWrongInputType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to be a pointer or int scalar if Result Type "
-      "is pointer: Bitcast"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected input to be a pointer or int scalar if Result Type "
+                "is pointer: Bitcast"));
 }
 
 TEST_F(ValidateConversion, BitcastPtrWrongResultType) {
@@ -1045,9 +1082,11 @@ TEST_F(ValidateConversion, BitcastPtrWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Pointer can only be converted to another pointer or int scalar: "
-      "Bitcast"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Pointer can only be converted to another pointer or int scalar: "
+          "Bitcast"));
 }
 
 TEST_F(ValidateConversion, BitcastDifferentTotalBitWidth) {
@@ -1057,9 +1096,11 @@ TEST_F(ValidateConversion, BitcastDifferentTotalBitWidth) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected input to have the same total bit width as Result Type: "
-      "Bitcast"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected input to have the same total bit width as Result Type: "
+          "Bitcast"));
 }
 
 }  // anonymous namespace
index 289ed5d..8e66656 100644 (file)
@@ -27,8 +27,8 @@ namespace {
 using ::testing::HasSubstr;
 using ::testing::MatchesRegex;
 
-using std::string;
 using std::pair;
+using std::string;
 using std::stringstream;
 
 using ValidateData = spvtest::ValidateBase<pair<string, bool>>;
@@ -231,9 +231,10 @@ TEST_F(ValidateData, int16_good) {
 }
 
 TEST_F(ValidateData, storage_uniform_buffer_block_16_good) {
-  string str = HeaderWith("StorageUniformBufferBlock16 "
-                          "OpExtension \"SPV_KHR_16bit_storage\"") +
-      "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
+  string str = HeaderWith(
+                   "StorageUniformBufferBlock16 "
+                   "OpExtension \"SPV_KHR_16bit_storage\"") +
+               "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
   CompileSuccessfully(str.c_str());
   ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
 }
@@ -247,17 +248,19 @@ TEST_F(ValidateData, storage_uniform_16_good) {
 }
 
 TEST_F(ValidateData, storage_push_constant_16_good) {
-  string str = HeaderWith("StoragePushConstant16 "
-                          "OpExtension \"SPV_KHR_16bit_storage\"") +
-      "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
+  string str = HeaderWith(
+                   "StoragePushConstant16 "
+                   "OpExtension \"SPV_KHR_16bit_storage\"") +
+               "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
   CompileSuccessfully(str.c_str());
   ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
 }
 
 TEST_F(ValidateData, storage_input_output_16_good) {
-  string str = HeaderWith("StorageInputOutput16 "
-                          "OpExtension \"SPV_KHR_16bit_storage\"") +
-      "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
+  string str = HeaderWith(
+                   "StorageInputOutput16 "
+                   "OpExtension \"SPV_KHR_16bit_storage\"") +
+               "%2 = OpTypeInt 16 1 %3 = OpTypeFloat 16";
   CompileSuccessfully(str.c_str());
   ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
 }
@@ -568,7 +571,7 @@ TEST_F(ValidateData, ext_16bit_storage_caps_allow_free_fp_rounding_mode) {
 }
 
 TEST_F(ValidateData, default_disallow_free_fp_rounding_mode) {
-    string str = R"(
+  string str = R"(
         OpCapability Shader
         OpCapability Linkage
         OpMemoryModel Logical GLSL450
@@ -576,11 +579,11 @@ TEST_F(ValidateData, default_disallow_free_fp_rounding_mode) {
         %1 = OpTypeFloat 32
         %2 = OpConstant %1 1.25
     )";
-    CompileSuccessfully(str.c_str());
-    ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions());
-    EXPECT_THAT(getDiagnosticString(),
-                HasSubstr("Operand 2 of Decorate requires one of these "
-                          "capabilities: Kernel"));
+  CompileSuccessfully(str.c_str());
+  ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions());
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Operand 2 of Decorate requires one of these "
+                        "capabilities: Kernel"));
 }
 
 }  // anonymous namespace
index 03e5535..2feba52 100644 (file)
 // Common validation fixtures for unit tests
 
 #include "gmock/gmock.h"
+#include "source/val/decoration.h"
 #include "unit_spirv.h"
 #include "val_fixtures.h"
-#include "source/val/decoration.h"
 
 namespace {
 
+using libspirv::Decoration;
 using std::string;
 using std::vector;
-using ::testing::HasSubstr;
 using ::testing::Eq;
-using libspirv::Decoration;
+using ::testing::HasSubstr;
 
 using ValidateDecorations = spvtest::ValidateBase<bool>;
 
@@ -449,4 +449,3 @@ TEST_F(ValidateDecorations, FunctionDefinitionWithoutImportLinkageGood) {
 }
 
 }  // anonymous namespace
-
index f8c3c97..864dad0 100644 (file)
@@ -112,9 +112,10 @@ TEST_F(ValidateDerivatives, OpDPdxWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be float scalar or vector type: "
-      "DPdx"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be float scalar or vector type: "
+                "DPdx"));
 }
 
 TEST_F(ValidateDerivatives, OpDPdxWrongPType) {
@@ -125,9 +126,9 @@ TEST_F(ValidateDerivatives, OpDPdxWrongPType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected P type and Result Type to be the same: "
-      "DPdx"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected P type and Result Type to be the same: "
+                        "DPdx"));
 }
 
 TEST_F(ValidateDerivatives, OpDPdxWrongExecutionModel) {
@@ -138,8 +139,10 @@ TEST_F(ValidateDerivatives, OpDPdxWrongExecutionModel) {
 
   CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Derivative instructions require Fragment execution model: DPdx"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Derivative instructions require Fragment execution model: DPdx"));
 }
 
 }  // anonymous namespace
index dad4772..e4993ca 100644 (file)
@@ -42,41 +42,28 @@ string GetErrorString(const std::string& extension) {
   return "Found unrecognized extension " + extension;
 }
 
-INSTANTIATE_TEST_CASE_P(ExpectSuccess, ValidateKnownExtensions, Values(
-    // Match the order as published on the SPIR-V Registry.
-    "SPV_AMD_shader_explicit_vertex_parameter",
-    "SPV_AMD_shader_trinary_minmax",
-    "SPV_AMD_gcn_shader",
-    "SPV_KHR_shader_ballot",
-    "SPV_AMD_shader_ballot",
-    "SPV_AMD_gpu_shader_half_float",
-    "SPV_KHR_shader_draw_parameters",
-    "SPV_KHR_subgroup_vote",
-    "SPV_KHR_16bit_storage",
-    "SPV_KHR_device_group",
-    "SPV_KHR_multiview",
-    "SPV_NVX_multiview_per_view_attributes",
-    "SPV_NV_viewport_array2",
-    "SPV_NV_stereo_view_rendering",
-    "SPV_NV_sample_mask_override_coverage",
-    "SPV_NV_geometry_shader_passthrough",
-    "SPV_AMD_texture_gather_bias_lod",
-    "SPV_KHR_storage_buffer_storage_class",
-    "SPV_KHR_variable_pointers",
-    "SPV_AMD_gpu_shader_int16",
-    "SPV_KHR_post_depth_coverage",
-    "SPV_KHR_shader_atomic_counter_ops",
-    "SPV_EXT_shader_stencil_export",
-    "SPV_EXT_shader_viewport_index_layer",
-    "SPV_AMD_shader_image_load_store_lod",
-    "SPV_AMD_shader_fragment_mask"
-    ));
-
-INSTANTIATE_TEST_CASE_P(FailSilently, ValidateUnknownExtensions, Values(
-    "ERROR_unknown_extension",
-    "SPV_KHR_",
-    "SPV_KHR_shader_ballot_ERROR"
-    ));
+INSTANTIATE_TEST_CASE_P(
+    ExpectSuccess, ValidateKnownExtensions,
+    Values(
+        // Match the order as published on the SPIR-V Registry.
+        "SPV_AMD_shader_explicit_vertex_parameter",
+        "SPV_AMD_shader_trinary_minmax", "SPV_AMD_gcn_shader",
+        "SPV_KHR_shader_ballot", "SPV_AMD_shader_ballot",
+        "SPV_AMD_gpu_shader_half_float", "SPV_KHR_shader_draw_parameters",
+        "SPV_KHR_subgroup_vote", "SPV_KHR_16bit_storage",
+        "SPV_KHR_device_group", "SPV_KHR_multiview",
+        "SPV_NVX_multiview_per_view_attributes", "SPV_NV_viewport_array2",
+        "SPV_NV_stereo_view_rendering", "SPV_NV_sample_mask_override_coverage",
+        "SPV_NV_geometry_shader_passthrough", "SPV_AMD_texture_gather_bias_lod",
+        "SPV_KHR_storage_buffer_storage_class", "SPV_KHR_variable_pointers",
+        "SPV_AMD_gpu_shader_int16", "SPV_KHR_post_depth_coverage",
+        "SPV_KHR_shader_atomic_counter_ops", "SPV_EXT_shader_stencil_export",
+        "SPV_EXT_shader_viewport_index_layer",
+        "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_fragment_mask"));
+
+INSTANTIATE_TEST_CASE_P(FailSilently, ValidateUnknownExtensions,
+                        Values("ERROR_unknown_extension", "SPV_KHR_",
+                               "SPV_KHR_shader_ballot_ERROR"));
 
 TEST_P(ValidateKnownExtensions, ExpectSuccess) {
   const std::string extension = GetParam();
@@ -114,7 +101,8 @@ TEST_F(ValidateExtensionCapabilities, DeclCapabilityFailure) {
   CompileSuccessfully(str.c_str());
   ASSERT_EQ(SPV_ERROR_MISSING_EXTENSION, ValidateInstructions());
   EXPECT_THAT(getDiagnosticString(), HasSubstr("1st operand of Capability"));
-  EXPECT_THAT(getDiagnosticString(), HasSubstr("requires one of these extensions"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("requires one of these extensions"));
   EXPECT_THAT(getDiagnosticString(), HasSubstr("SPV_KHR_device_group"));
 }
 
index c72cbf5..81db158 100644 (file)
@@ -82,8 +82,8 @@ spv_result_t ValidateBase<T>::ValidateAndRetrieveValidationState(
 
 template <typename T>
 std::string ValidateBase<T>::getDiagnosticString() {
-  return diagnostic_ == nullptr ?
-      std::string() : std::string(diagnostic_->error);
+  return diagnostic_ == nullptr ? std::string()
+                                : std::string(diagnostic_->error);
 }
 
 template <typename T>
@@ -107,4 +107,4 @@ template class spvtest::ValidateBase<
                                std::function<spv_result_t(int)>>>>;
 template class spvtest::ValidateBase<SpvCapability>;
 template class spvtest::ValidateBase<std::pair<std::string, std::string>>;
-}
+}  // namespace spvtest
index 0e6114f..5865db2 100644 (file)
@@ -17,8 +17,8 @@
 #ifndef LIBSPIRV_TEST_VALIDATE_FIXTURES_H_
 #define LIBSPIRV_TEST_VALIDATE_FIXTURES_H_
 
-#include "unit_spirv.h"
 #include "source/val/validation_state.h"
+#include "unit_spirv.h"
 
 namespace spvtest {
 
@@ -60,5 +60,5 @@ class ValidateBase : public ::testing::Test,
   spv_validator_options options_;
   std::unique_ptr<libspirv::ValidationState_t> vstate_;
 };
-}
+}  // namespace spvtest
 #endif
index 1cdc267..0727923 100644 (file)
 
 namespace {
 
-using ::testing::HasSubstr;
-using ::testing::ValuesIn;
 using spvtest::ScopedContext;
 using std::ostringstream;
 using std::string;
 using std::vector;
+using ::testing::HasSubstr;
+using ::testing::ValuesIn;
 
 using ValidateIdWithMessage = spvtest::ValidateBase<bool>;
 
@@ -2516,8 +2516,7 @@ TEST_F(ValidateIdWithMessage, OpStoreBuiltin) {
 
   CompileSuccessfully(spirv.c_str());
   EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(),
-              HasSubstr("storage class is read-only"));
+  EXPECT_THAT(getDiagnosticString(), HasSubstr("storage class is read-only"));
 }
 
 TEST_F(ValidateIdWithMessage, OpCopyMemoryGood) {
@@ -2736,8 +2735,8 @@ TEST_P(AccessChainInstructionTest, AccessChainGood) {
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup +
                  "%float_entry = " + instr +
-      R"( %_ptr_Private_float %my_matrix )" + elem +
-      R"(%int_0 %int_1
+                 R"( %_ptr_Private_float %my_matrix )" + elem +
+                 R"(%int_0 %int_1
               OpReturn
               OpFunctionEnd
           )";
@@ -2770,8 +2769,8 @@ TEST_P(AccessChainInstructionTest, AccessChainBaseTypeVoidBad) {
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
 %float_entry = )" +
-      instr + " %_ptr_Private_float %void " + elem +
-      R"(%int_0 %int_1
+                 instr + " %_ptr_Private_float %void " + elem +
+                 R"(%int_0 %int_1
 OpReturn
 OpFunctionEnd
   )";
@@ -2788,8 +2787,7 @@ TEST_P(AccessChainInstructionTest, AccessChainBaseTypeNonPtrVariableBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_float %_ptr_Private_float )" + elem +
                  R"(%int_0 %int_1
 OpReturn
@@ -2809,8 +2807,7 @@ TEST_P(AccessChainInstructionTest,
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Function_float %my_matrix )" + elem +
                  R"(%int_0 %int_1
 OpReturn
@@ -2831,8 +2828,7 @@ TEST_P(AccessChainInstructionTest,
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_float %my_float_var )" + elem + R"(%int_0
 OpReturn
 OpFunctionEnd
@@ -2851,8 +2847,7 @@ TEST_P(AccessChainInstructionTest, AccessChainNoIndexesGood) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_float %my_float_var )" + elem + R"(
 OpReturn
 OpFunctionEnd
@@ -2867,8 +2862,7 @@ TEST_P(AccessChainInstructionTest, AccessChainNoIndexesBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_mat4x3 %my_float_var )" + elem + R"(
 OpReturn
 OpFunctionEnd
@@ -3017,10 +3011,9 @@ TEST_P(AccessChainInstructionTest, CustomizedAccessChainTooManyIndexesBad) {
 TEST_P(AccessChainInstructionTest, AccessChainUndefinedIndexBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
-  string spirv =
-      kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
+  string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
 %entry = )" + instr +
-          R"( %_ptr_Private_float %my_matrix )" + elem + R"(%float %int_1
+                 R"( %_ptr_Private_float %my_matrix )" + elem + R"(%float %int_1
 OpReturn
 OpFunctionEnd
   )";
@@ -3037,9 +3030,9 @@ TEST_P(AccessChainInstructionTest, AccessChainStructIndexNotConstantBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%f = )" +
-      instr + R"( %_ptr_Uniform_float %blockName_var )" + elem +
-      R"(%int_0 %spec_int %int_2
+%f = )" + instr + R"( %_ptr_Uniform_float %blockName_var )" +
+                 elem +
+                 R"(%int_0 %spec_int %int_2
 OpReturn
 OpFunctionEnd
   )";
@@ -3057,8 +3050,7 @@ TEST_P(AccessChainInstructionTest,
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Uniform_float %blockName_var )" + elem +
                  R"(%int_0 %int_1 %int_2
 OpReturn
@@ -3078,8 +3070,7 @@ TEST_P(AccessChainInstructionTest, AccessChainStructTooManyIndexesBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Uniform_float %blockName_var )" + elem +
                  R"(%int_0 %int_2 %int_2
 OpReturn
@@ -3098,8 +3089,7 @@ TEST_P(AccessChainInstructionTest, AccessChainStructIndexOutOfBoundBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Uniform_float %blockName_var )" + elem +
                  R"(%int_3 %int_2 %int_2
 OpReturn
@@ -3186,8 +3176,7 @@ TEST_P(AccessChainInstructionTest, AccessChainMatrixMoreArgsThanNeededBad) {
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_float %my_matrix )" + elem +
                  R"(%int_0 %int_1 %int_0
 OpReturn
@@ -3207,8 +3196,7 @@ TEST_P(AccessChainInstructionTest,
   const std::string instr = GetParam();
   const std::string elem = AccessChainRequiresElemId(instr) ? "%int_0 " : "";
   string spirv = kGLSL450MemoryModel + kDeeplyNestedStructureSetup + R"(
-%entry = )" +
-      instr +
+%entry = )" + instr +
                  R"( %_ptr_Private_mat4x3 %my_matrix )" + elem +
                  R"(%int_0 %int_1
 OpReturn
@@ -4094,10 +4082,9 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector1ComponentType) {
      OpFunctionEnd)";
   CompileSuccessfully(spirv.c_str());
   EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(
-      getDiagnosticString(),
-      HasSubstr("The Component Type of Vector 1 must be the same as "
-                "ResultType."));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("The Component Type of Vector 1 must be the same as "
+                        "ResultType."));
 }
 
 TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2ComponentType) {
@@ -4128,10 +4115,9 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleVector2ComponentType) {
      OpFunctionEnd)";
   CompileSuccessfully(spirv.c_str());
   EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(
-      getDiagnosticString(),
-      HasSubstr("The Component Type of Vector 2 must be the same as "
-                "ResultType."));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("The Component Type of Vector 2 must be the same as "
+                        "ResultType."));
 }
 
 TEST_F(ValidateIdWithMessage, OpVectorShuffleLiterals) {
@@ -4276,7 +4262,8 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_CondIsScalarInt) {
   EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
   EXPECT_THAT(
       getDiagnosticString(),
-      HasSubstr("Condition operand for OpBranchConditional must be of boolean type"));
+      HasSubstr(
+          "Condition operand for OpBranchConditional must be of boolean type"));
 }
 
 TEST_F(ValidateIdWithMessage, OpBranchConditional_TrueTargetIsNotLabel) {
@@ -4288,13 +4275,13 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_TrueTargetIsNotLabel) {
   // EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
   // EXPECT_THAT(
   //     getDiagnosticString(),
-  //     HasSubstr("The 'True Label' operand for OpBranchConditional must be the ID of an OpLabel instruction"));
+  //     HasSubstr("The 'True Label' operand for OpBranchConditional must be the
+  //     ID of an OpLabel instruction"));
 
   // xxxnsubtil: this is actually caught by the ID validation instead
   EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
-  EXPECT_THAT(
-      getDiagnosticString(),
-      HasSubstr("are referenced but not defined in function"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("are referenced but not defined in function"));
 }
 
 TEST_F(ValidateIdWithMessage, OpBranchConditional_FalseTargetIsNotLabel) {
@@ -4306,13 +4293,13 @@ TEST_F(ValidateIdWithMessage, OpBranchConditional_FalseTargetIsNotLabel) {
   // EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
   // EXPECT_THAT(
   //     getDiagnosticString(),
-  //     HasSubstr("The 'False Label' operand for OpBranchConditional must be the ID of an OpLabel instruction"));
+  //     HasSubstr("The 'False Label' operand for OpBranchConditional must be
+  //     the ID of an OpLabel instruction"));
 
   // xxxnsubtil: this is actually caught by the ID validation
   EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
-  EXPECT_THAT(
-      getDiagnosticString(),
-      HasSubstr("are referenced but not defined in function"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("are referenced but not defined in function"));
 }
 
 TEST_F(ValidateIdWithMessage, OpBranchConditional_NotEnoughWeights) {
index 559bc65..9ad74df 100644 (file)
@@ -330,8 +330,9 @@ TEST_F(ValidateImage, SampledImageWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be OpTypeSampledImage: SampledImage"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be OpTypeSampledImage: SampledImage"));
 }
 
 TEST_F(ValidateImage, SampledImageNotImage) {
@@ -344,8 +345,9 @@ TEST_F(ValidateImage, SampledImageNotImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: SampledImage"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: SampledImage"));
 }
 
 TEST_F(ValidateImage, SampledImageImageNotForSampling) {
@@ -357,8 +359,10 @@ TEST_F(ValidateImage, SampledImageImageNotForSampling) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled' parameter to be 0 or 1: SampledImage"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image 'Sampled' parameter to be 0 or 1: SampledImage"));
 }
 
 TEST_F(ValidateImage, SampledImageImageDimSubpassData) {
@@ -370,8 +374,9 @@ TEST_F(ValidateImage, SampledImageImageDimSubpassData) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Dim' parameter to be not SubpassData"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Dim' parameter to be not SubpassData"));
 }
 
 TEST_F(ValidateImage, SampledImageNotSampler) {
@@ -383,8 +388,9 @@ TEST_F(ValidateImage, SampledImageNotSampler) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampler to be of type OpTypeSampler: SampledImage"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampler to be of type OpTypeSampler: SampledImage"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodSuccess) {
@@ -414,9 +420,9 @@ TEST_F(ValidateImage, SampleImplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodWrongNumComponentsResultType) {
@@ -429,9 +435,9 @@ TEST_F(ValidateImage, SampleImplicitLodWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have 4 components: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodNotSampledImage) {
@@ -442,9 +448,10 @@ TEST_F(ValidateImage, SampleImplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodWrongSampledType) {
@@ -457,9 +464,10 @@ TEST_F(ValidateImage, SampleImplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodVoidSampledType) {
@@ -484,9 +492,9 @@ TEST_F(ValidateImage, SampleImplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodCoordinateSizeTooSmall) {
@@ -499,9 +507,10 @@ TEST_F(ValidateImage, SampleImplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodSuccessShader) {
@@ -558,9 +567,9 @@ TEST_F(ValidateImage, SampleExplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodWrongNumComponentsResultType) {
@@ -573,9 +582,9 @@ TEST_F(ValidateImage, SampleExplicitLodWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have 4 components: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodNotSampledImage) {
@@ -586,9 +595,10 @@ TEST_F(ValidateImage, SampleExplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodWrongSampledType) {
@@ -601,9 +611,10 @@ TEST_F(ValidateImage, SampleExplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodVoidSampledType) {
@@ -628,9 +639,9 @@ TEST_F(ValidateImage, SampleExplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodCoordinateSizeTooSmall) {
@@ -643,9 +654,10 @@ TEST_F(ValidateImage, SampleExplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodBias) {
@@ -658,9 +670,10 @@ TEST_F(ValidateImage, SampleExplicitLodBias) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Bias can only be used with ImplicitLod opcodes: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image Operand Bias can only be used with ImplicitLod opcodes: "
+                "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, LodAndGrad) {
@@ -673,9 +686,11 @@ TEST_F(ValidateImage, LodAndGrad) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand bits Lod and Grad cannot be set at the same time: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand bits Lod and Grad cannot be set at the same time: "
+          "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, ImplicitLodWithLod) {
@@ -688,9 +703,10 @@ TEST_F(ValidateImage, ImplicitLodWithLod) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Lod cannot be used with ImplicitLod opcodes: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image Operand Lod cannot be used with ImplicitLod opcodes: "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, LodWrongType) {
@@ -702,9 +718,9 @@ TEST_F(ValidateImage, LodWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Lod to be int or float scalar: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand Lod to be int or float scalar: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, LodWrongDim) {
@@ -716,9 +732,10 @@ TEST_F(ValidateImage, LodWrongDim) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Lod requires 'Dim' parameter to be 1D, 2D, 3D or Cube: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Lod requires 'Dim' parameter to be 1D, "
+                        "2D, 3D or Cube: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, LodMultisampled) {
@@ -730,9 +747,9 @@ TEST_F(ValidateImage, LodMultisampled) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Lod requires 'MS' parameter to be 0: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Lod requires 'MS' parameter to be 0: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, MinLodIncompatible) {
@@ -744,9 +761,11 @@ TEST_F(ValidateImage, MinLodIncompatible) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand MinLod can only be used with ImplicitLod opcodes or "
-      "together with Image Operand Grad: ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand MinLod can only be used with ImplicitLod opcodes or "
+          "together with Image Operand Grad: ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, ImplicitLodWithGrad) {
@@ -759,9 +778,10 @@ TEST_F(ValidateImage, ImplicitLodWithGrad) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Grad can only be used with ExplicitLod opcodes: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image Operand Grad can only be used with ExplicitLod opcodes: "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLod3DArrayedMultisampledSuccess) {
@@ -803,9 +823,9 @@ TEST_F(ValidateImage, SampleImplicitLodBiasWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Bias to be float scalar: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand Bias to be float scalar: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodBiasWrongDim) {
@@ -818,9 +838,10 @@ TEST_F(ValidateImage, SampleImplicitLodBiasWrongDim) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Bias requires 'Dim' parameter to be 1D, 2D, 3D or Cube: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Bias requires 'Dim' parameter to be 1D, "
+                        "2D, 3D or Cube: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodBiasMultisampled) {
@@ -833,9 +854,9 @@ TEST_F(ValidateImage, SampleImplicitLodBiasMultisampled) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Bias requires 'MS' parameter to be 0: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Bias requires 'MS' parameter to be 0: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodGradDxWrongType) {
@@ -848,9 +869,10 @@ TEST_F(ValidateImage, SampleExplicitLodGradDxWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both Image Operand Grad ids to be float scalars or vectors: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both Image Operand Grad ids to be float "
+                        "scalars or vectors: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodGradDyWrongType) {
@@ -863,9 +885,10 @@ TEST_F(ValidateImage, SampleExplicitLodGradDyWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both Image Operand Grad ids to be float scalars or vectors: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both Image Operand Grad ids to be float "
+                        "scalars or vectors: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodGradDxWrongSize) {
@@ -878,9 +901,11 @@ TEST_F(ValidateImage, SampleExplicitLodGradDxWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Grad dx to have 3 components, but given 2: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image Operand Grad dx to have 3 components, but given 2: "
+          "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodGradDyWrongSize) {
@@ -893,9 +918,11 @@ TEST_F(ValidateImage, SampleExplicitLodGradDyWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Grad dy to have 3 components, but given 2: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image Operand Grad dy to have 3 components, but given 2: "
+          "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleExplicitLodGradMultisampled) {
@@ -908,9 +935,9 @@ TEST_F(ValidateImage, SampleExplicitLodGradMultisampled) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Grad requires 'MS' parameter to be 0: "
-      "ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Grad requires 'MS' parameter to be 0: "
+                        "ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodConstOffsetCubeDim) {
@@ -923,9 +950,11 @@ TEST_F(ValidateImage, SampleImplicitLodConstOffsetCubeDim) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand ConstOffset cannot be used with Cube Image 'Dim': "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand ConstOffset cannot be used with Cube Image 'Dim': "
+          "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodConstOffsetWrongType) {
@@ -938,9 +967,11 @@ TEST_F(ValidateImage, SampleImplicitLodConstOffsetWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffset to be int scalar or vector: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image Operand ConstOffset to be int scalar or vector: "
+          "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodConstOffsetWrongSize) {
@@ -953,9 +984,10 @@ TEST_F(ValidateImage, SampleImplicitLodConstOffsetWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffset to have 3 components, but given 2: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand ConstOffset to have 3 "
+                        "components, but given 2: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodConstOffsetNotConst) {
@@ -969,9 +1001,10 @@ TEST_F(ValidateImage, SampleImplicitLodConstOffsetNotConst) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffset to be a const object: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image Operand ConstOffset to be a const object: "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodOffsetCubeDim) {
@@ -984,9 +1017,10 @@ TEST_F(ValidateImage, SampleImplicitLodOffsetCubeDim) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Offset cannot be used with Cube Image 'Dim': "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image Operand Offset cannot be used with Cube Image 'Dim': "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodOffsetWrongType) {
@@ -999,9 +1033,10 @@ TEST_F(ValidateImage, SampleImplicitLodOffsetWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Offset to be int scalar or vector: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image Operand Offset to be int scalar or vector: "
+                "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodOffsetWrongSize) {
@@ -1014,9 +1049,11 @@ TEST_F(ValidateImage, SampleImplicitLodOffsetWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Offset to have 3 components, but given 2: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image Operand Offset to have 3 components, but given 2: "
+          "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodMoreThanOneOffset) {
@@ -1029,9 +1066,10 @@ TEST_F(ValidateImage, SampleImplicitLodMoreThanOneOffset) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operands Offset, ConstOffset, ConstOffsets cannot be used together: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operands Offset, ConstOffset, ConstOffsets "
+                        "cannot be used together: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodMinLodWrongType) {
@@ -1044,9 +1082,9 @@ TEST_F(ValidateImage, SampleImplicitLodMinLodWrongType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand MinLod to be float scalar: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand MinLod to be float scalar: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodMinLodWrongDim) {
@@ -1059,9 +1097,10 @@ TEST_F(ValidateImage, SampleImplicitLodMinLodWrongDim) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand MinLod requires 'Dim' parameter to be 1D, 2D, 3D or Cube: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand MinLod requires 'Dim' parameter to be "
+                        "1D, 2D, 3D or Cube: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImplicitLodMinLodMultisampled) {
@@ -1074,9 +1113,9 @@ TEST_F(ValidateImage, SampleImplicitLodMinLodMultisampled) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand MinLod requires 'MS' parameter to be 0: "
-      "ImageSampleImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand MinLod requires 'MS' parameter to be 0: "
+                        "ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodSuccess2D) {
@@ -1118,9 +1157,9 @@ TEST_F(ValidateImage, SampleProjExplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodWrongNumComponentsResultType) {
@@ -1133,9 +1172,9 @@ TEST_F(ValidateImage, SampleProjExplicitLodWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have 4 components: "
+                        "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodNotSampledImage) {
@@ -1146,9 +1185,10 @@ TEST_F(ValidateImage, SampleProjExplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodWrongSampledType) {
@@ -1161,9 +1201,10 @@ TEST_F(ValidateImage, SampleProjExplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodVoidSampledType) {
@@ -1188,9 +1229,9 @@ TEST_F(ValidateImage, SampleProjExplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjExplicitLodCoordinateSizeTooSmall) {
@@ -1203,9 +1244,10 @@ TEST_F(ValidateImage, SampleProjExplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 3 components, but given only 2: "
-      "ImageSampleProjExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 3 components, "
+                        "but given only 2: "
+                        "ImageSampleProjExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodSuccess) {
@@ -1235,9 +1277,9 @@ TEST_F(ValidateImage, SampleProjImplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodWrongNumComponentsResultType) {
@@ -1250,9 +1292,9 @@ TEST_F(ValidateImage, SampleProjImplicitLodWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have 4 components: "
+                        "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodNotSampledImage) {
@@ -1263,9 +1305,10 @@ TEST_F(ValidateImage, SampleProjImplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodWrongSampledType) {
@@ -1278,9 +1321,10 @@ TEST_F(ValidateImage, SampleProjImplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodVoidSampledType) {
@@ -1305,9 +1349,9 @@ TEST_F(ValidateImage, SampleProjImplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjImplicitLodCoordinateSizeTooSmall) {
@@ -1320,9 +1364,10 @@ TEST_F(ValidateImage, SampleProjImplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 3 components, but given only 2: "
-      "ImageSampleProjImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 3 components, "
+                        "but given only 2: "
+                        "ImageSampleProjImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodSuccess) {
@@ -1352,9 +1397,9 @@ TEST_F(ValidateImage, SampleDrefImplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float scalar type: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float scalar type: "
+                        "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodNotSampledImage) {
@@ -1365,9 +1410,10 @@ TEST_F(ValidateImage, SampleDrefImplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodWrongSampledType) {
@@ -1380,9 +1426,10 @@ TEST_F(ValidateImage, SampleDrefImplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodVoidSampledType) {
@@ -1395,9 +1442,10 @@ TEST_F(ValidateImage, SampleDrefImplicitLodVoidSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodWrongCoordinateType) {
@@ -1410,9 +1458,9 @@ TEST_F(ValidateImage, SampleDrefImplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodCoordinateSizeTooSmall) {
@@ -1425,9 +1473,10 @@ TEST_F(ValidateImage, SampleDrefImplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefImplicitLodWrongDrefType) {
@@ -1440,9 +1489,9 @@ TEST_F(ValidateImage, SampleDrefImplicitLodWrongDrefType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Dref to be of Image 'Sampled Type': "
-      "ImageSampleDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Dref to be of Image 'Sampled Type': "
+                        "ImageSampleDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodSuccess) {
@@ -1471,9 +1520,9 @@ TEST_F(ValidateImage, SampleDrefExplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float scalar type: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float scalar type: "
+                        "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodNotSampledImage) {
@@ -1484,9 +1533,10 @@ TEST_F(ValidateImage, SampleDrefExplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodWrongSampledType) {
@@ -1499,9 +1549,10 @@ TEST_F(ValidateImage, SampleDrefExplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodVoidSampledType) {
@@ -1514,9 +1565,10 @@ TEST_F(ValidateImage, SampleDrefExplicitLodVoidSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodWrongCoordinateType) {
@@ -1529,9 +1581,9 @@ TEST_F(ValidateImage, SampleDrefExplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodCoordinateSizeTooSmall) {
@@ -1544,9 +1596,10 @@ TEST_F(ValidateImage, SampleDrefExplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 3 components, but given only 2: "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 3 components, "
+                        "but given only 2: "
+                        "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleDrefExplicitLodWrongDrefType) {
@@ -1559,9 +1612,9 @@ TEST_F(ValidateImage, SampleDrefExplicitLodWrongDrefType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Dref to be of Image 'Sampled Type': "
-      "ImageSampleDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Dref to be of Image 'Sampled Type': "
+                        "ImageSampleDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodSuccess) {
@@ -1591,9 +1644,9 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float scalar type: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float scalar type: "
+                        "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodNotSampledImage) {
@@ -1604,9 +1657,10 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongSampledType) {
@@ -1619,9 +1673,10 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodVoidSampledType) {
@@ -1634,9 +1689,10 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodVoidSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongCoordinateType) {
@@ -1649,9 +1705,9 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodCoordinateSizeTooSmall) {
@@ -1664,9 +1720,10 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 3 components, but given only 2: "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 3 components, "
+                        "but given only 2: "
+                        "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongDrefType) {
@@ -1679,9 +1736,9 @@ TEST_F(ValidateImage, SampleProjDrefImplicitLodWrongDrefType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Dref to be of Image 'Sampled Type': "
-      "ImageSampleProjDrefImplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Dref to be of Image 'Sampled Type': "
+                        "ImageSampleProjDrefImplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodSuccess) {
@@ -1710,9 +1767,9 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float scalar type: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float scalar type: "
+                        "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodNotSampledImage) {
@@ -1723,9 +1780,10 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodWrongSampledType) {
@@ -1738,9 +1796,10 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodVoidSampledType) {
@@ -1753,9 +1812,10 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodVoidSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled Type' to be the same as Result Type: "
+                "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodWrongCoordinateType) {
@@ -1768,9 +1828,9 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleProjDrefExplicitLodCoordinateSizeTooSmall) {
@@ -1783,9 +1843,10 @@ TEST_F(ValidateImage, SampleProjDrefExplicitLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageSampleProjDrefExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageSampleProjDrefExplicitLod"));
 }
 
 TEST_F(ValidateImage, FetchSuccess) {
@@ -1806,9 +1867,9 @@ TEST_F(ValidateImage, FetchWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageFetch"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchWrongNumComponentsResultType) {
@@ -1819,8 +1880,9 @@ TEST_F(ValidateImage, FetchWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: ImageFetch"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to have 4 components: ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchNotImage) {
@@ -1833,8 +1895,9 @@ TEST_F(ValidateImage, FetchNotImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageFetch"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchNotSampled) {
@@ -1845,8 +1908,9 @@ TEST_F(ValidateImage, FetchNotSampled) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled' parameter to be 1: ImageFetch"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled' parameter to be 1: ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchCube) {
@@ -1857,8 +1921,8 @@ TEST_F(ValidateImage, FetchCube) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' cannot be Cube: ImageFetch"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image 'Dim' cannot be Cube: ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchWrongSampledType) {
@@ -1869,9 +1933,10 @@ TEST_F(ValidateImage, FetchWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageFetch"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchVoidSampledType) {
@@ -1894,9 +1959,9 @@ TEST_F(ValidateImage, FetchWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be int scalar or vector: "
-      "ImageFetch"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be int scalar or vector: "
+                        "ImageFetch"));
 }
 
 TEST_F(ValidateImage, FetchCoordinateSizeTooSmall) {
@@ -1907,9 +1972,10 @@ TEST_F(ValidateImage, FetchCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageFetch"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageFetch"));
 }
 
 TEST_F(ValidateImage, GatherSuccess) {
@@ -1935,9 +2001,9 @@ TEST_F(ValidateImage, GatherWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: "
-      "ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int or float vector type: "
+                        "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherWrongNumComponentsResultType) {
@@ -1950,9 +2016,9 @@ TEST_F(ValidateImage, GatherWrongNumComponentsResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: "
-      "ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to have 4 components: "
+                        "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherNotSampledImage) {
@@ -1963,9 +2029,10 @@ TEST_F(ValidateImage, GatherNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sampled Image to be of type OpTypeSampledImage: "
-      "ImageGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Sampled Image to be of type OpTypeSampledImage: "
+                "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherWrongSampledType) {
@@ -1978,9 +2045,10 @@ TEST_F(ValidateImage, GatherWrongSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherVoidSampledType) {
@@ -2005,9 +2073,9 @@ TEST_F(ValidateImage, GatherWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: "
-      "ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to be float scalar or vector: "
+                        "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherCoordinateSizeTooSmall) {
@@ -2020,9 +2088,10 @@ TEST_F(ValidateImage, GatherCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 4 components, but given only 1: "
-      "ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 4 components, "
+                        "but given only 1: "
+                        "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherWrongComponentType) {
@@ -2035,8 +2104,8 @@ TEST_F(ValidateImage, GatherWrongComponentType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Component to be int scalar: ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Component to be int scalar: ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherDimCube) {
@@ -2049,9 +2118,11 @@ TEST_F(ValidateImage, GatherDimCube) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand ConstOffsets cannot be used with Cube Image 'Dim': "
-      "ImageGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand ConstOffsets cannot be used with Cube Image 'Dim': "
+          "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherConstOffsetsNotArray) {
@@ -2064,9 +2135,10 @@ TEST_F(ValidateImage, GatherConstOffsetsNotArray) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffsets to be an array of size 4: "
-      "ImageGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image Operand ConstOffsets to be an array of size 4: "
+                "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherConstOffsetsArrayWrongSize) {
@@ -2079,9 +2151,10 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffsets to be an array of size 4: "
-      "ImageGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image Operand ConstOffsets to be an array of size 4: "
+                "ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherConstOffsetsArrayNotVector) {
@@ -2094,9 +2167,10 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayNotVector) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffsets array componenets to be int vectors "
-      "of size 2: ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand ConstOffsets array componenets "
+                        "to be int vectors "
+                        "of size 2: ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherConstOffsetsArrayVectorWrongSize) {
@@ -2109,9 +2183,10 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayVectorWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffsets array componenets to be int vectors "
-      "of size 2: ImageGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand ConstOffsets array componenets "
+                        "to be int vectors "
+                        "of size 2: ImageGather"));
 }
 
 TEST_F(ValidateImage, GatherConstOffsetsArrayNotConst) {
@@ -2125,9 +2200,10 @@ TEST_F(ValidateImage, GatherConstOffsetsArrayNotConst) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand ConstOffsets to be a const object: "
-      "ImageGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image Operand ConstOffsets to be a const object: "
+                "ImageGather"));
 }
 
 TEST_F(ValidateImage, NotGatherWithConstOffsets) {
@@ -2140,9 +2216,11 @@ TEST_F(ValidateImage, NotGatherWithConstOffsets) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand ConstOffsets can only be used with OpImageGather "
-      "and OpImageDrefGather: ImageSampleImplicitLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand ConstOffsets can only be used with OpImageGather "
+          "and OpImageDrefGather: ImageSampleImplicitLod"));
 }
 
 TEST_F(ValidateImage, DrefGatherSuccess) {
@@ -2168,9 +2246,10 @@ TEST_F(ValidateImage, DrefGatherVoidSampledType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageDrefGather"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageDrefGather"));
 }
 
 TEST_F(ValidateImage, DrefGatherWrongDrefType) {
@@ -2183,8 +2262,10 @@ TEST_F(ValidateImage, DrefGatherWrongDrefType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Dref to be of Image 'Sampled Type': ImageDrefGather"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Dref to be of Image 'Sampled Type': ImageDrefGather"));
 }
 
 TEST_F(ValidateImage, ReadSuccess1) {
@@ -2238,9 +2319,10 @@ TEST_F(ValidateImage, ReadNeedCapabilityStorageImageReadWithoutFormat) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability StorageImageReadWithoutFormat is required to read storage "
-      "image: ImageRead"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Capability StorageImageReadWithoutFormat is required "
+                        "to read storage "
+                        "image: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadNeedCapabilityImage1D) {
@@ -2251,8 +2333,10 @@ TEST_F(ValidateImage, ReadNeedCapabilityImage1D) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability Image1D is required to access storage image: ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Capability Image1D is required to access storage image: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadNeedCapabilityImageCubeArray) {
@@ -2263,9 +2347,11 @@ TEST_F(ValidateImage, ReadNeedCapabilityImageCubeArray) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability ImageCubeArray is required to access storage image: "
-      "ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Capability ImageCubeArray is required to access storage image: "
+          "ImageRead"));
 }
 
 // TODO(atgoo@github.com) Disabled until the spec is clarified.
@@ -2278,8 +2364,10 @@ TEST_F(ValidateImage, DISABLED_ReadWrongResultType) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int or float vector type: ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Result Type to be int or float vector type: ImageRead"));
 }
 
 // TODO(atgoo@github.com) Disabled until the spec is clarified.
@@ -2292,8 +2380,9 @@ TEST_F(ValidateImage, DISABLED_ReadWrongNumComponentsResultType) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 4 components: ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to have 4 components: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadNotImage) {
@@ -2305,8 +2394,8 @@ TEST_F(ValidateImage, ReadNotImage) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageRead"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image to be of type OpTypeImage: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadImageSampled) {
@@ -2318,8 +2407,9 @@ TEST_F(ValidateImage, ReadImageSampled) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled' parameter to be 0 or 2: ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled' parameter to be 0 or 2: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadWrongSampledType) {
@@ -2331,9 +2421,10 @@ TEST_F(ValidateImage, ReadWrongSampledType) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Result Type components: "
-      "ImageRead"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image 'Sampled Type' to be the same as "
+                        "Result Type components: "
+                        "ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadVoidSampledType) {
@@ -2358,8 +2449,9 @@ TEST_F(ValidateImage, ReadWrongCoordinateType) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be int scalar or vector: ImageRead"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Coordinate to be int scalar or vector: ImageRead"));
 }
 
 TEST_F(ValidateImage, ReadCoordinateSizeTooSmall) {
@@ -2371,9 +2463,10 @@ TEST_F(ValidateImage, ReadCoordinateSizeTooSmall) {
   const std::string extra = "\nOpCapability StorageImageReadWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageRead"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageRead"));
 }
 
 TEST_F(ValidateImage, WriteSuccess1) {
@@ -2430,8 +2523,8 @@ TEST_F(ValidateImage, WriteSubpassData) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' cannot be SubpassData: ImageWrite"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image 'Dim' cannot be SubpassData: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteNeedCapabilityStorageImageWriteWithoutFormat) {
@@ -2442,9 +2535,11 @@ TEST_F(ValidateImage, WriteNeedCapabilityStorageImageWriteWithoutFormat) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability StorageImageWriteWithoutFormat is required to write to "
-      "storage image: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Capability StorageImageWriteWithoutFormat is required to write to "
+          "storage image: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteNeedCapabilityImage1D) {
@@ -2455,8 +2550,9 @@ TEST_F(ValidateImage, WriteNeedCapabilityImage1D) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability Image1D is required to access storage image: ImageWrite"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Capability Image1D is required to access storage "
+                        "image: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteNeedCapabilityImageCubeArray) {
@@ -2467,9 +2563,11 @@ TEST_F(ValidateImage, WriteNeedCapabilityImageCubeArray) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Capability ImageCubeArray is required to access storage image: "
-      "ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Capability ImageCubeArray is required to access storage image: "
+          "ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteNotImage) {
@@ -2480,8 +2578,9 @@ TEST_F(ValidateImage, WriteNotImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteImageSampled) {
@@ -2493,8 +2592,9 @@ TEST_F(ValidateImage, WriteImageSampled) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled' parameter to be 0 or 2: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image 'Sampled' parameter to be 0 or 2: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteWrongCoordinateType) {
@@ -2506,8 +2606,9 @@ TEST_F(ValidateImage, WriteWrongCoordinateType) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be int scalar or vector: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Coordinate to be int scalar or vector: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteCoordinateSizeTooSmall) {
@@ -2519,9 +2620,10 @@ TEST_F(ValidateImage, WriteCoordinateSizeTooSmall) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageWrite"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteTexelWrongType) {
@@ -2533,8 +2635,10 @@ TEST_F(ValidateImage, WriteTexelWrongType) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Texel to be int or float vector or scalar: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Texel to be int or float vector or scalar: ImageWrite"));
 }
 
 TEST_F(ValidateImage, DISABLED_WriteTexelNotVector4) {
@@ -2546,8 +2650,8 @@ TEST_F(ValidateImage, DISABLED_WriteTexelNotVector4) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Texel to have 4 components: ImageWrite"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Texel to have 4 components: ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteTexelWrongComponentType) {
@@ -2559,9 +2663,11 @@ TEST_F(ValidateImage, WriteTexelWrongComponentType) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image 'Sampled Type' to be the same as Texel components: "
-      "ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Image 'Sampled Type' to be the same as Texel components: "
+          "ImageWrite"));
 }
 
 TEST_F(ValidateImage, WriteSampleNotInteger) {
@@ -2573,9 +2679,9 @@ TEST_F(ValidateImage, WriteSampleNotInteger) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image Operand Sample to be int scalar: "
-      "ImageWrite"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Image Operand Sample to be int scalar: "
+                        "ImageWrite"));
 }
 
 TEST_F(ValidateImage, SampleNotMultisampled) {
@@ -2587,8 +2693,10 @@ TEST_F(ValidateImage, SampleNotMultisampled) {
   const std::string extra = "\nOpCapability StorageImageWriteWithoutFormat\n";
   CompileSuccessfully(GenerateShaderCode(body, extra).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Sample requires non-zero 'MS' parameter: ImageWrite"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Image Operand Sample requires non-zero 'MS' parameter: ImageWrite"));
 }
 
 TEST_F(ValidateImage, SampleWrongOpcode) {
@@ -2601,9 +2709,10 @@ TEST_F(ValidateImage, SampleWrongOpcode) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image Operand Sample can only be used with OpImageFetch, OpImageRead "
-      "and OpImageWrite: ImageSampleExplicitLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image Operand Sample can only be used with "
+                        "OpImageFetch, OpImageRead "
+                        "and OpImageWrite: ImageSampleExplicitLod"));
 }
 
 TEST_F(ValidateImage, SampleImageToImageSuccess) {
@@ -2628,8 +2737,8 @@ TEST_F(ValidateImage, SampleImageToImageWrongResultType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be OpTypeImage: Image"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be OpTypeImage: Image"));
 }
 
 TEST_F(ValidateImage, SampleImageToImageNotSampledImage) {
@@ -2640,8 +2749,10 @@ TEST_F(ValidateImage, SampleImageToImageNotSampledImage) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sample Image to be of type OpTypeSampleImage: Image"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Sample Image to be of type OpTypeSampleImage: Image"));
 }
 
 TEST_F(ValidateImage, SampleImageToImageNotTheSameImageType) {
@@ -2654,8 +2765,9 @@ TEST_F(ValidateImage, SampleImageToImageNotTheSameImageType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Sample Image image type to be equal to Result Type: Image"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Sample Image image type to be equal to "
+                        "Result Type: Image"));
 }
 
 TEST_F(ValidateImage, QueryFormatSuccess) {
@@ -2676,8 +2788,10 @@ TEST_F(ValidateImage, QueryFormatWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int scalar type: ImageQueryFormat"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Result Type to be int scalar type: ImageQueryFormat"));
 }
 
 TEST_F(ValidateImage, QueryFormatNotImage) {
@@ -2690,8 +2804,10 @@ TEST_F(ValidateImage, QueryFormatNotImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operand to be of type OpTypeImage: ImageQueryFormat"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected operand to be of type OpTypeImage: ImageQueryFormat"));
 }
 
 TEST_F(ValidateImage, QueryOrderSuccess) {
@@ -2712,8 +2828,9 @@ TEST_F(ValidateImage, QueryOrderWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int scalar type: ImageQueryOrder"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be int scalar type: ImageQueryOrder"));
 }
 
 TEST_F(ValidateImage, QueryOrderNotImage) {
@@ -2726,8 +2843,9 @@ TEST_F(ValidateImage, QueryOrderNotImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operand to be of type OpTypeImage: ImageQueryOrder"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operand to be of type OpTypeImage: ImageQueryOrder"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodSuccess) {
@@ -2748,9 +2866,9 @@ TEST_F(ValidateImage, QuerySizeLodWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int scalar or vector type: "
-      "ImageQuerySizeLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int scalar or vector type: "
+                        "ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodResultTypeWrongSize) {
@@ -2761,8 +2879,10 @@ TEST_F(ValidateImage, QuerySizeLodResultTypeWrongSize) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Result Type has 1 components, but 2 expected: ImageQuerySizeLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Result Type has 1 components, but 2 expected: ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodNotImage) {
@@ -2775,8 +2895,9 @@ TEST_F(ValidateImage, QuerySizeLodNotImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageQuerySizeLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodWrongImageDim) {
@@ -2787,8 +2908,9 @@ TEST_F(ValidateImage, QuerySizeLodWrongImageDim) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQuerySizeLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodMultisampled) {
@@ -2799,8 +2921,8 @@ TEST_F(ValidateImage, QuerySizeLodMultisampled) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'MS' must be 0: ImageQuerySizeLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image 'MS' must be 0: ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeLodWrongLodType) {
@@ -2811,8 +2933,9 @@ TEST_F(ValidateImage, QuerySizeLodWrongLodType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Level of Detail to be int or float scalar: ImageQuerySizeLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Level of Detail to be int or float scalar: "
+                        "ImageQuerySizeLod"));
 }
 
 TEST_F(ValidateImage, QuerySizeSuccess) {
@@ -2833,9 +2956,9 @@ TEST_F(ValidateImage, QuerySizeWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int scalar or vector type: "
-      "ImageQuerySize"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Result Type to be int scalar or vector type: "
+                        "ImageQuerySize"));
 }
 
 TEST_F(ValidateImage, QuerySizeNotImage) {
@@ -2848,8 +2971,9 @@ TEST_F(ValidateImage, QuerySizeNotImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageQuerySize"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: ImageQuerySize"));
 }
 
 // TODO(atgoo@github.com) Add more tests for OpQuerySize.
@@ -2889,8 +3013,9 @@ TEST_F(ValidateImage, QueryLodWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be float vector type: ImageQueryLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to be float vector type: ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLodResultTypeWrongSize) {
@@ -2903,8 +3028,9 @@ TEST_F(ValidateImage, QueryLodResultTypeWrongSize) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to have 2 components: ImageQueryLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Result Type to have 2 components: ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLodNotSampledImage) {
@@ -2915,9 +3041,10 @@ TEST_F(ValidateImage, QueryLodNotSampledImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image operand to be of type OpTypeSampledImage: "
-      "ImageQueryLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image operand to be of type OpTypeSampledImage: "
+                "ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLodWrongDim) {
@@ -2930,8 +3057,9 @@ TEST_F(ValidateImage, QueryLodWrongDim) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQueryLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLodWrongCoordinateType) {
@@ -2944,8 +3072,10 @@ TEST_F(ValidateImage, QueryLodWrongCoordinateType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to be float scalar or vector: ImageQueryLod"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Coordinate to be float scalar or vector: ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLodCoordinateSizeTooSmall) {
@@ -2958,9 +3088,10 @@ TEST_F(ValidateImage, QueryLodCoordinateSizeTooSmall) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Coordinate to have at least 2 components, but given only 1: "
-      "ImageQueryLod"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected Coordinate to have at least 2 components, "
+                        "but given only 1: "
+                        "ImageQueryLod"));
 }
 
 TEST_F(ValidateImage, QueryLevelsSuccess) {
@@ -2981,8 +3112,10 @@ TEST_F(ValidateImage, QueryLevelsWrongResultType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Result Type to be int scalar type: ImageQueryLevels"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected Result Type to be int scalar type: ImageQueryLevels"));
 }
 
 TEST_F(ValidateImage, QueryLevelsNotImage) {
@@ -2995,8 +3128,9 @@ TEST_F(ValidateImage, QueryLevelsNotImage) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected Image to be of type OpTypeImage: ImageQueryLevels"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected Image to be of type OpTypeImage: ImageQueryLevels"));
 }
 
 TEST_F(ValidateImage, QueryLevelsWrongDim) {
@@ -3007,8 +3141,9 @@ TEST_F(ValidateImage, QueryLevelsWrongDim) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQueryLevels"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Image 'Dim' must be 1D, 2D, 3D or Cube: ImageQueryLevels"));
 }
 
 TEST_F(ValidateImage, QuerySamplesSuccess) {
@@ -3029,8 +3164,8 @@ TEST_F(ValidateImage, QuerySamplesNot2D) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'Dim' must be 2D: ImageQuerySamples"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image 'Dim' must be 2D: ImageQuerySamples"));
 }
 
 TEST_F(ValidateImage, QuerySamplesNotMultisampled) {
@@ -3041,8 +3176,8 @@ TEST_F(ValidateImage, QuerySamplesNotMultisampled) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Image 'MS' must be 1: ImageQuerySamples"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Image 'MS' must be 1: ImageQuerySamples"));
 }
 
 TEST_F(ValidateImage, QueryLodWrongExecutionModel) {
@@ -3055,8 +3190,8 @@ TEST_F(ValidateImage, QueryLodWrongExecutionModel) {
 
   CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "OpImageQueryLod requires Fragment execution model"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("OpImageQueryLod requires Fragment execution model"));
 }
 
 TEST_F(ValidateImage, QueryLodWrongExecutionModelWithFunc) {
@@ -3074,8 +3209,8 @@ OpFunctionEnd
 
   CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "OpImageQueryLod requires Fragment execution model"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("OpImageQueryLod requires Fragment execution model"));
 }
 
 TEST_F(ValidateImage, ImplicitLodWrongExecutionModel) {
@@ -3088,8 +3223,9 @@ TEST_F(ValidateImage, ImplicitLodWrongExecutionModel) {
 
   CompileSuccessfully(GenerateShaderCode(body, "", "Vertex").c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "ImplicitLod instructions require Fragment execution model"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("ImplicitLod instructions require Fragment execution model"));
 }
 
 }  // anonymous namespace
index 56c25ba..70f4ae5 100644 (file)
@@ -79,4 +79,4 @@ INSTANTIATE_TEST_CASE_P(
         CASE(DrefExplicitLod, "%float %img %coord %dref Lod %lod"),
     }), );
 #undef CASE
-}
+}  // namespace
index c6750e1..06ecdc7 100644 (file)
@@ -28,16 +28,16 @@ using std::function;
 using std::ostream;
 using std::ostream_iterator;
 using std::pair;
-using std::stringstream;
 using std::string;
+using std::stringstream;
 using std::tie;
 using std::tuple;
 using std::vector;
 
+using libspirv::spvResultToString;
 using ::testing::Eq;
 using ::testing::HasSubstr;
 using ::testing::StrEq;
-using libspirv::spvResultToString;
 
 using pred_type = function<spv_result_t(int)>;
 using ValidateLayout =
@@ -504,7 +504,8 @@ TEST_F(ValidateLayout, ModuleProcessedInvalidIn10) {
 )";
 
   CompileSuccessfully(str, SPV_ENV_UNIVERSAL_1_1);
-  ASSERT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
+  ASSERT_EQ(SPV_ERROR_INVALID_BINARY,
+            ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
   // In a 1.0 environment the binary parse fails before we even get to
   // validation.  This occurs no matter where the OpModuleProcessed is placed.
   EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid opcode: 330"));
@@ -537,7 +538,8 @@ TEST_F(ValidateLayout, ModuleProcessedBeforeLastNameIsTooEarly) {
 )";
 
   CompileSuccessfully(str, SPV_ENV_UNIVERSAL_1_1);
-  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
+  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT,
+            ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
   // By the mechanics of the validator, we assume ModuleProcessed is in the
   // right spot, but then that OpName is in the wrong spot.
   EXPECT_THAT(getDiagnosticString(),
@@ -555,9 +557,11 @@ TEST_F(ValidateLayout, ModuleProcessedInvalidAfterFirstAnnotation) {
 )";
 
   CompileSuccessfully(str, SPV_ENV_UNIVERSAL_1_1);
-  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
-  EXPECT_THAT(getDiagnosticString(),
-              HasSubstr("ModuleProcessed cannot appear in a function declaration"));
+  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT,
+            ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("ModuleProcessed cannot appear in a function declaration"));
 }
 
 TEST_F(ValidateLayout, ModuleProcessedInvalidInFunctionBeforeLabel) {
@@ -575,9 +579,11 @@ TEST_F(ValidateLayout, ModuleProcessedInvalidInFunctionBeforeLabel) {
 )";
 
   CompileSuccessfully(str, SPV_ENV_UNIVERSAL_1_1);
-  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
-  EXPECT_THAT(getDiagnosticString(),
-              HasSubstr("ModuleProcessed cannot appear in a function declaration"));
+  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT,
+            ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("ModuleProcessed cannot appear in a function declaration"));
 }
 
 TEST_F(ValidateLayout, ModuleProcessedInvalidInBasicBlock) {
@@ -595,11 +601,12 @@ TEST_F(ValidateLayout, ModuleProcessedInvalidInBasicBlock) {
 )";
 
   CompileSuccessfully(str, SPV_ENV_UNIVERSAL_1_1);
-  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
-  EXPECT_THAT(getDiagnosticString(),
-              HasSubstr("ModuleProcessed cannot appear in a function declaration"));
+  ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT,
+            ValidateInstructions(SPV_ENV_UNIVERSAL_1_1));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("ModuleProcessed cannot appear in a function declaration"));
 }
 
-
 // TODO(umar): Test optional instructions
-}
+}  // namespace
index c9e07e7..791ffa0 100644 (file)
@@ -24,9 +24,9 @@
 
 namespace {
 
+using std::string;
 using ::testing::HasSubstr;
 using ::testing::MatchesRegex;
-using std::string;
 
 using ValidateLimits = spvtest::ValidateBase<bool>;
 
@@ -302,8 +302,8 @@ TEST_F(ValidateLimits, CustomizedOpTypeFunctionGood) {
   for (int i = 0; i < num_args; ++i) {
     spirv << " %1";
   }
-  spvValidatorOptionsSetUniversalLimit(options_,
-                                       spv_validator_limit_max_function_args, 100u);
+  spvValidatorOptionsSetUniversalLimit(
+      options_, spv_validator_limit_max_function_args, 100u);
   CompileSuccessfully(spirv.str());
   EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
 }
@@ -318,8 +318,8 @@ TEST_F(ValidateLimits, CustomizedOpTypeFunctionBad) {
   for (int i = 0; i < num_args; ++i) {
     spirv << " %1";
   }
-  spvValidatorOptionsSetUniversalLimit(options_,
-                                       spv_validator_limit_max_function_args, 100u);
+  spvValidatorOptionsSetUniversalLimit(
+      options_, spv_validator_limit_max_function_args, 100u);
   CompileSuccessfully(spirv.str());
   EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
   EXPECT_THAT(getDiagnosticString(),
@@ -526,8 +526,8 @@ TEST_F(ValidateLimits, StructNestingDepthGood) {
     %int = OpTypeInt 32 0
     %s_depth_1  = OpTypeStruct %int
   )";
-  for(auto i=2; i<=255; ++i) {
-    spirv << "%s_depth_" << i << " = OpTypeStruct %int %s_depth_" << i-1;
+  for (auto i = 2; i <= 255; ++i) {
+    spirv << "%s_depth_" << i << " = OpTypeStruct %int %s_depth_" << i - 1;
     spirv << "\n";
   }
   CompileSuccessfully(spirv.str());
@@ -541,8 +541,8 @@ TEST_F(ValidateLimits, StructNestingDepthBad) {
     %int = OpTypeInt 32 0
     %s_depth_1  = OpTypeStruct %int
   )";
-  for(auto i=2; i<=256; ++i) {
-    spirv << "%s_depth_" << i << " = OpTypeStruct %int %s_depth_" << i-1;
+  for (auto i = 2; i <= 256; ++i) {
+    spirv << "%s_depth_" << i << " = OpTypeStruct %int %s_depth_" << i - 1;
     spirv << "\n";
   }
   CompileSuccessfully(spirv.str());
index 348b6f2..8464a21 100644 (file)
@@ -31,13 +31,13 @@ std::string GenerateShaderCode(
     const std::string& body,
     const std::string& capabilities_and_extensions = "") {
   const std::string capabilities =
-R"(
+      R"(
 OpCapability Shader
 OpCapability Int64
 OpCapability Float64)";
 
   const std::string after_extension_before_body =
-R"(
+      R"(
 %ext_inst = OpExtInstImport "GLSL.std.450"
 OpMemoryModel Logical GLSL450
 OpEntryPoint Fragment %main "main"
@@ -147,19 +147,19 @@ OpEntryPoint Fragment %main "main"
 %main_entry = OpLabel)";
 
   const std::string after_body =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
   return capabilities + capabilities_and_extensions +
-      after_extension_before_body + body + after_body;
+         after_extension_before_body + body + after_body;
 }
 
 std::string GenerateKernelCode(
     const std::string& body,
     const std::string& capabilities_and_extensions = "") {
   const std::string capabilities =
-R"(
+      R"(
 OpCapability Addresses
 OpCapability Kernel
 OpCapability Linkage
@@ -167,7 +167,7 @@ OpCapability Int64
 OpCapability Float64)";
 
   const std::string after_extension_before_body =
-R"(
+      R"(
 OpMemoryModel Physical32 OpenCL
 %void = OpTypeVoid
 %func = OpTypeFunction %void
@@ -249,12 +249,12 @@ OpMemoryModel Physical32 OpenCL
 %main_entry = OpLabel)";
 
   const std::string after_body =
-R"(
+      R"(
 OpReturn
 OpFunctionEnd)";
 
   return capabilities + capabilities_and_extensions +
-      after_extension_before_body + body + after_body;
+         after_extension_before_body + body + after_body;
 }
 
 TEST_F(ValidateLogicals, OpAnySuccess) {
@@ -275,8 +275,8 @@ TEST_F(ValidateLogicals, OpAnyWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar type as Result Type: Any"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected bool scalar type as Result Type: Any"));
 }
 
 TEST_F(ValidateLogicals, OpAnyWrongOperand) {
@@ -286,8 +286,8 @@ TEST_F(ValidateLogicals, OpAnyWrongOperand) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operand to be vector bool: Any"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected operand to be vector bool: Any"));
 }
 
 TEST_F(ValidateLogicals, OpIsNanSuccess) {
@@ -310,8 +310,9 @@ TEST_F(ValidateLogicals, OpIsNanWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: IsNan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected bool scalar or vector type as Result Type: IsNan"));
 }
 
 TEST_F(ValidateLogicals, OpIsNanOperandNotFloat) {
@@ -321,8 +322,9 @@ TEST_F(ValidateLogicals, OpIsNanOperandNotFloat) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operand to be scalar or vector float: IsNan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operand to be scalar or vector float: IsNan"));
 }
 
 TEST_F(ValidateLogicals, OpIsNanOperandWrongSize) {
@@ -332,9 +334,11 @@ TEST_F(ValidateLogicals, OpIsNanOperandWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operand to be equal: "
-      "IsNan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operand to be equal: "
+          "IsNan"));
 }
 
 TEST_F(ValidateLogicals, OpLessOrGreaterSuccess) {
@@ -357,8 +361,10 @@ TEST_F(ValidateLogicals, OpLessOrGreaterWrongTypeId) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: LessOrGreater"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: LessOrGreater"));
 }
 
 TEST_F(ValidateLogicals, OpLessOrGreaterLeftOperandNotFloat) {
@@ -368,8 +374,10 @@ TEST_F(ValidateLogicals, OpLessOrGreaterLeftOperandNotFloat) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector float: LessOrGreater"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected operands to be scalar or vector float: LessOrGreater"));
 }
 
 TEST_F(ValidateLogicals, OpLessOrGreaterLeftOperandWrongSize) {
@@ -379,9 +387,11 @@ TEST_F(ValidateLogicals, OpLessOrGreaterLeftOperandWrongSize) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operands to be equal: "
-      "LessOrGreater"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operands to be equal: "
+          "LessOrGreater"));
 }
 
 TEST_F(ValidateLogicals, OpLessOrGreaterOperandsDifferentType) {
@@ -391,9 +401,10 @@ TEST_F(ValidateLogicals, OpLessOrGreaterOperandsDifferentType) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected left and right operands to have the same type: "
-      "LessOrGreater"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected left and right operands to have the same type: "
+                "LessOrGreater"));
 }
 
 TEST_F(ValidateLogicals, OpFOrdEqualSuccess) {
@@ -416,8 +427,10 @@ TEST_F(ValidateLogicals, OpFOrdEqualWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: FOrdEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: FOrdEqual"));
 }
 
 TEST_F(ValidateLogicals, OpFOrdEqualLeftOperandNotFloat) {
@@ -427,8 +440,9 @@ TEST_F(ValidateLogicals, OpFOrdEqualLeftOperandNotFloat) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector float: FOrdEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector float: FOrdEqual"));
 }
 
 TEST_F(ValidateLogicals, OpFOrdEqualLeftOperandWrongSize) {
@@ -438,9 +452,11 @@ TEST_F(ValidateLogicals, OpFOrdEqualLeftOperandWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operands to be equal: "
-      "FOrdEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operands to be equal: "
+          "FOrdEqual"));
 }
 
 TEST_F(ValidateLogicals, OpFOrdEqualOperandsDifferentType) {
@@ -450,9 +466,10 @@ TEST_F(ValidateLogicals, OpFOrdEqualOperandsDifferentType) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected left and right operands to have the same type: "
-      "FOrdEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected left and right operands to have the same type: "
+                "FOrdEqual"));
 }
 
 TEST_F(ValidateLogicals, OpLogicalEqualSuccess) {
@@ -474,8 +491,10 @@ TEST_F(ValidateLogicals, OpLogicalEqualWrongTypeId) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: LogicalEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: LogicalEqual"));
 }
 
 TEST_F(ValidateLogicals, OpLogicalEqualWrongLeftOperand) {
@@ -485,8 +504,9 @@ TEST_F(ValidateLogicals, OpLogicalEqualWrongLeftOperand) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to be of Result Type: LogicalEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected both operands to be of Result Type: LogicalEqual"));
 }
 
 TEST_F(ValidateLogicals, OpLogicalEqualWrongRightOperand) {
@@ -496,8 +516,9 @@ TEST_F(ValidateLogicals, OpLogicalEqualWrongRightOperand) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to be of Result Type: LogicalEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected both operands to be of Result Type: LogicalEqual"));
 }
 
 TEST_F(ValidateLogicals, OpLogicalNotSuccess) {
@@ -519,8 +540,10 @@ TEST_F(ValidateLogicals, OpLogicalNotWrongTypeId) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: LogicalNot"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: LogicalNot"));
 }
 
 TEST_F(ValidateLogicals, OpLogicalNotWrongOperand) {
@@ -530,8 +553,8 @@ TEST_F(ValidateLogicals, OpLogicalNotWrongOperand) {
 
   CompileSuccessfully(GenerateKernelCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operand to be of Result Type: LogicalNot"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected operand to be of Result Type: LogicalNot"));
 }
 
 TEST_F(ValidateLogicals, OpSelectSuccess) {
@@ -554,8 +577,9 @@ TEST_F(ValidateLogicals, OpSelectWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected scalar or vector type as Result Type: Select"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected scalar or vector type as Result Type: Select"));
 }
 
 TEST_F(ValidateLogicals, OpSelectPointerNoCapability) {
@@ -569,9 +593,11 @@ OpStore %y %f32vec4_1234
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Using pointers with OpSelect requires capability VariablePointers "
-      "or VariablePointersStorageBuffer"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Using pointers with OpSelect requires capability VariablePointers "
+          "or VariablePointersStorageBuffer"));
 }
 
 TEST_F(ValidateLogicals, OpSelectPointerWithCapability1) {
@@ -617,8 +643,9 @@ TEST_F(ValidateLogicals, OpSelectWrongCondition) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as condition: Select"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected bool scalar or vector type as condition: Select"));
 }
 
 TEST_F(ValidateLogicals, OpSelectWrongConditionDimension) {
@@ -628,9 +655,11 @@ TEST_F(ValidateLogicals, OpSelectWrongConditionDimension) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the condition to be equal: "
-      "Select"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the condition to be equal: "
+          "Select"));
 }
 
 TEST_F(ValidateLogicals, OpSelectWrongLeftObject) {
@@ -640,8 +669,8 @@ TEST_F(ValidateLogicals, OpSelectWrongLeftObject) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both objects to be of Result Type: Select"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both objects to be of Result Type: Select"));
 }
 
 TEST_F(ValidateLogicals, OpSelectWrongRightObject) {
@@ -651,8 +680,8 @@ TEST_F(ValidateLogicals, OpSelectWrongRightObject) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both objects to be of Result Type: Select"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both objects to be of Result Type: Select"));
 }
 
 TEST_F(ValidateLogicals, OpIEqualSuccess) {
@@ -675,8 +704,9 @@ TEST_F(ValidateLogicals, OpIEqualWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: IEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected bool scalar or vector type as Result Type: IEqual"));
 }
 
 TEST_F(ValidateLogicals, OpIEqualLeftOperandNotInt) {
@@ -686,8 +716,9 @@ TEST_F(ValidateLogicals, OpIEqualLeftOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: IEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: IEqual"));
 }
 
 TEST_F(ValidateLogicals, OpIEqualLeftOperandWrongSize) {
@@ -697,9 +728,11 @@ TEST_F(ValidateLogicals, OpIEqualLeftOperandWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operands to be equal: "
-      "IEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operands to be equal: "
+          "IEqual"));
 }
 
 TEST_F(ValidateLogicals, OpIEqualRightOperandNotInt) {
@@ -709,8 +742,9 @@ TEST_F(ValidateLogicals, OpIEqualRightOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: IEqual"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: IEqual"));
 }
 
 TEST_F(ValidateLogicals, OpIEqualDifferentBitWidth) {
@@ -720,8 +754,9 @@ TEST_F(ValidateLogicals, OpIEqualDifferentBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to have the same component bit width: IEqual"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both operands to have the same component bit "
+                        "width: IEqual"));
 }
 
 TEST_F(ValidateLogicals, OpUGreaterThanSuccess) {
@@ -746,8 +781,10 @@ TEST_F(ValidateLogicals, OpUGreaterThanWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: UGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: UGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpUGreaterThanLeftOperandNotInt) {
@@ -757,8 +794,9 @@ TEST_F(ValidateLogicals, OpUGreaterThanLeftOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: UGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: UGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpUGreaterThanLeftOperandWrongSize) {
@@ -768,9 +806,11 @@ TEST_F(ValidateLogicals, OpUGreaterThanLeftOperandWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operands to be equal: "
-      "UGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operands to be equal: "
+          "UGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpUGreaterThanRightOperandNotInt) {
@@ -780,8 +820,9 @@ TEST_F(ValidateLogicals, OpUGreaterThanRightOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: UGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: UGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpUGreaterThanDifferentBitWidth) {
@@ -791,9 +832,10 @@ TEST_F(ValidateLogicals, OpUGreaterThanDifferentBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to have the same component bit width: "
-      "UGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected both operands to have the same component bit width: "
+                "UGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpSGreaterThanSuccess) {
@@ -818,8 +860,10 @@ TEST_F(ValidateLogicals, OpSGreaterThanWrongTypeId) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected bool scalar or vector type as Result Type: SGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected bool scalar or vector type as Result Type: SGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpSGreaterThanLeftOperandNotInt) {
@@ -829,8 +873,9 @@ TEST_F(ValidateLogicals, OpSGreaterThanLeftOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: SGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: SGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpSGreaterThanLeftOperandWrongSize) {
@@ -840,9 +885,11 @@ TEST_F(ValidateLogicals, OpSGreaterThanLeftOperandWrongSize) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected vector sizes of Result Type and the operands to be equal: "
-      "SGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr(
+          "Expected vector sizes of Result Type and the operands to be equal: "
+          "SGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpSGreaterThanRightOperandNotInt) {
@@ -852,8 +899,9 @@ TEST_F(ValidateLogicals, OpSGreaterThanRightOperandNotInt) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected operands to be scalar or vector int: SGreaterThan"));
+  EXPECT_THAT(
+      getDiagnosticString(),
+      HasSubstr("Expected operands to be scalar or vector int: SGreaterThan"));
 }
 
 TEST_F(ValidateLogicals, OpSGreaterThanDifferentBitWidth) {
@@ -863,8 +911,9 @@ TEST_F(ValidateLogicals, OpSGreaterThanDifferentBitWidth) {
 
   CompileSuccessfully(GenerateShaderCode(body).c_str());
   ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
-  EXPECT_THAT(getDiagnosticString(), HasSubstr(
-      "Expected both operands to have the same component bit width: SGreaterThan"));
+  EXPECT_THAT(getDiagnosticString(),
+              HasSubstr("Expected both operands to have the same component bit "
+                        "width: SGreaterThan"));
 }
 
 }  // anonymous namespace
index 22e94f2..973d4b8 100644 (file)
@@ -25,8 +25,8 @@
 using ::testing::HasSubstr;
 using ::testing::MatchesRegex;
 
-using std::string;
 using std::pair;
+using std::string;
 using std::stringstream;
 
 namespace {
index 2fed565..ea09cf9 100644 (file)
@@ -47,6 +47,7 @@ class ValidationStateTest : public testing::Test {
     spvContextDestroy(context_);
     spvValidatorOptionsDestroy(options_);
   }
+
  protected:
   spv_context context_;
   spv_validator_options options_;
@@ -121,20 +122,15 @@ TEST_F(ValidationState_HasAnyOfExtensions, SingleCapMask) {
 }
 
 TEST_F(ValidationState_HasAnyOfExtensions, MultiCapMask) {
-  const auto set1 = ExtensionSet {
-    Extension::kSPV_KHR_multiview,
-    Extension::kSPV_KHR_16bit_storage
-  };
-  const auto set2 = ExtensionSet {
-    Extension::kSPV_KHR_shader_draw_parameters,
-    Extension::kSPV_NV_stereo_view_rendering,
-    Extension::kSPV_KHR_shader_ballot
-  };
+  const auto set1 = ExtensionSet{Extension::kSPV_KHR_multiview,
+                                 Extension::kSPV_KHR_16bit_storage};
+  const auto set2 = ExtensionSet{Extension::kSPV_KHR_shader_draw_parameters,
+                                 Extension::kSPV_NV_stereo_view_rendering,
+                                 Extension::kSPV_KHR_shader_ballot};
   EXPECT_FALSE(state_.HasAnyOfExtensions(set1));
   EXPECT_FALSE(state_.HasAnyOfExtensions(set2));
   state_.RegisterExtension(Extension::kSPV_KHR_multiview);
   EXPECT_TRUE(state_.HasAnyOfExtensions(set1));
   EXPECT_FALSE(state_.HasAnyOfExtensions(set2));
 }
-
-}
+}  // namespace
index 579c381..02ef6f5 100644 (file)
@@ -175,4 +175,4 @@ TEST_F(ValidateStorage, GenericVariableInsideFunction) {
   EXPECT_THAT(getDiagnosticString(),
               HasSubstr("OpVariable storage class cannot be Generic"));
 }
-}
+}  // namespace
index 8bca1f0..ad16f24 100644 (file)
@@ -91,8 +91,8 @@ OpFunctionEnd
 // Returns expected error string if |opcode| produces a duplicate type
 // declaration.
 string GetErrorString(SpvOp opcode) {
-  return "Duplicate non-aggregate type declarations are not allowed. Opcode: "
-      + std::string(spvOpcodeString(opcode));
+  return "Duplicate non-aggregate type declarations are not allowed. Opcode: " +
+         std::string(spvOpcodeString(opcode));
 }
 
 TEST_F(ValidateTypeUnique, success) {