From a94701db39775a54cbfef2fa49cc5b176bcd681c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 14 Sep 2015 10:05:37 -0400 Subject: [PATCH] Run clang-format. --- source/opcode.cpp | 22 ++++++++++++++-------- source/opcode.h | 6 ++++-- source/text.h | 4 ++-- source/validate_id.cpp | 16 ++++++++-------- test/BinaryToText.cpp | 8 ++++---- test/OpcodeRequiresCapabilities.cpp | 9 +++++++-- test/TextWordGet.cpp | 6 +++--- test/UnitSPIRV.h | 14 +++++++------- test/Validate.cpp | 5 +++-- 9 files changed, 52 insertions(+), 38 deletions(-) diff --git a/source/opcode.cpp b/source/opcode.cpp index d155033..4507da6 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -154,12 +154,12 @@ spv_operand_type_t convertOperandClassToType(spv::Op opcode, return SPV_OPERAND_TYPE_NONE; } -} // anonymous namespace +} // anonymous namespace // Finish populating the opcodeTableEntries array. void spvOpcodeTableInitialize() { // Compute the operandTypes field for each entry. - for (auto& opcode : opcodeTableEntries) { + for (auto &opcode : opcodeTableEntries) { opcode.numTypes = 0; // Type ID always comes first, if present. if (opcode.hasType) @@ -167,11 +167,16 @@ void spvOpcodeTableInitialize() { // Result ID always comes next, if present if (opcode.hasResult) opcode.operandTypes[opcode.numTypes++] = SPV_OPERAND_TYPE_RESULT_ID; - const uint16_t maxNumOperands = sizeof(opcode.operandTypes)/sizeof(opcode.operandTypes[0]); - const uint16_t maxNumClasses = sizeof(opcode.operandClass)/sizeof(opcode.operandClass[0]); - for (uint16_t classIndex = 0; opcode.numTypes < maxNumOperands && classIndex < maxNumClasses ; classIndex++ ) { + const uint16_t maxNumOperands = + sizeof(opcode.operandTypes) / sizeof(opcode.operandTypes[0]); + const uint16_t maxNumClasses = + sizeof(opcode.operandClass) / sizeof(opcode.operandClass[0]); + for (uint16_t classIndex = 0; + opcode.numTypes < maxNumOperands && classIndex < maxNumClasses; + classIndex++) { const OperandClass operandClass = opcode.operandClass[classIndex]; - opcode.operandTypes[opcode.numTypes++] = convertOperandClassToType(opcode.opcode, operandClass); + opcode.operandTypes[opcode.numTypes++] = + convertOperandClassToType(opcode.opcode, operandClass); // The OperandNone value is not explicitly represented in the .inc file. // However, it is the zero value, and is created via implicit value // initialization. @@ -182,8 +187,9 @@ void spvOpcodeTableInitialize() { } // We should have written the terminating SPV_OPERAND_TYPE_NONE entry, but // also without overflowing. - assert((opcode.numTypes < maxNumOperands) - && "Operand class list is too long. Expand spv_opcode_desc_t.operandClass"); + assert((opcode.numTypes < maxNumOperands) && + "Operand class list is too long. Expand " + "spv_opcode_desc_t.operandClass"); } opcodeTableInitialized = true; } diff --git a/source/opcode.h b/source/opcode.h index 4bfe903..2727333 100644 --- a/source/opcode.h +++ b/source/opcode.h @@ -61,7 +61,8 @@ void spvOpcodeSplit(const uint32_t word, uint16_t *wordCount, Op *opcode); /// /// @return result code spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table, - const char *name, spv_opcode_desc *pEntry); + const char *name, + spv_opcode_desc *pEntry); /// @brief Find the opcode ID in the table /// @@ -71,7 +72,8 @@ spv_result_t spvOpcodeTableNameLookup(const spv_opcode_table table, /// /// @return result code spv_result_t spvOpcodeTableValueLookup(const spv_opcode_table table, - const Op opcode, spv_opcode_desc *pEntry); + const Op opcode, + spv_opcode_desc *pEntry); /// @brief Get the argument index for the operand, if any. /// diff --git a/source/text.h b/source/text.h index 72d96d5..f7b9240 100644 --- a/source/text.h +++ b/source/text.h @@ -74,7 +74,7 @@ typedef spv_named_id_table_t *spv_named_id_table; /// @param[in] str the source string /// /// @return word as a string -std::string spvGetWord(const char* str); +std::string spvGetWord(const char *str); /// @brief Advance text to the start of the next line /// @@ -195,7 +195,7 @@ spv_result_t spvTextEncodeOperand( const spv_operand_type_t type, const char *textValue, const spv_operand_table operandTable, const spv_ext_inst_table extInstTable, spv_named_id_table namedIdTable, spv_instruction_t *pInst, - spv_operand_pattern_t* pExpectedOperands, uint32_t *pBound, + spv_operand_pattern_t *pExpectedOperands, uint32_t *pBound, const spv_position_t *pPosition, spv_diagnostic *pDiagnostic); /// @brief Translate single Opcode and operands to binary form diff --git a/source/validate_id.cpp b/source/validate_id.cpp index 3b51e73..2df673f 100644 --- a/source/validate_id.cpp +++ b/source/validate_id.cpp @@ -100,7 +100,7 @@ class idUsage { return idUses.end() != item; } bool foundUses(std::unordered_map< - uint32_t, std::vector>::const_iterator item) { + uint32_t, std::vector>::const_iterator item) { return idUses.end() != item; } @@ -620,8 +620,8 @@ bool idUsage::isValid(const spv_instruction_t *inst, // TODO: Output ID's on diagnostic DIAG(inst->wordCount - 1) << "OpConstantComposite Constituent count does not match " - "Result Type '" << resultType->second.id - << "'s vector component count."; + "Result Type '" + << resultType->second.id << "'s vector component count."; return false); auto componentType = find(resultType->second.inst->words[2]); spvCheck(!found(componentType), assert(0 && "Unreachable!")); @@ -653,8 +653,8 @@ bool idUsage::isValid(const spv_instruction_t *inst, // TODO: Output ID's on diagnostic DIAG(inst->wordCount - 1) << "OpConstantComposite Constituent count does not match " - "Result Type '" << resultType->second.id - << "'s matrix column count."; + "Result Type '" + << resultType->second.id << "'s matrix column count."; return false); auto columnType = find(resultType->second.inst->words[2]); @@ -715,8 +715,8 @@ bool idUsage::isValid(const spv_instruction_t *inst, spvCheck(length->second.inst->words[3] != constituentCount, DIAG(inst->wordCount - 1) << "OpConstantComposite Constituent count does not match " - "Result Type '" << resultType->second.id - << "'s array length."; + "Result Type '" + << resultType->second.id << "'s array length."; return false); for (uint64_t constituentIndex = 3; constituentIndex < inst->wordCount; constituentIndex++) { @@ -2603,7 +2603,7 @@ bool idUsage::isValid(const spv_instruction_t *inst) { #undef FAIL #undef CASE } -}//anonymous namespace +} // anonymous namespace spv_result_t spvValidateInstructionIDs( const spv_instruction_t *pInsts, const uint64_t instCount, diff --git a/test/BinaryToText.cpp b/test/BinaryToText.cpp index 50a05ed..9779c4a 100644 --- a/test/BinaryToText.cpp +++ b/test/BinaryToText.cpp @@ -94,10 +94,10 @@ TEST_F(BinaryToText, InvalidCode) { spv_binary_t binary = {nullptr, 42}; spv_text text; spv_diagnostic diagnostic = nullptr; - ASSERT_EQ(SPV_ERROR_INVALID_BINARY, - spvBinaryToText(nullptr, 42, - SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable, - operandTable, extInstTable, &text, &diagnostic)); + ASSERT_EQ( + SPV_ERROR_INVALID_BINARY, + spvBinaryToText(nullptr, 42, SPV_BINARY_TO_TEXT_OPTION_NONE, opcodeTable, + operandTable, extInstTable, &text, &diagnostic)); if (diagnostic) { spvDiagnosticPrint(diagnostic); spvDiagnosticDestroy(diagnostic); diff --git a/test/OpcodeRequiresCapabilities.cpp b/test/OpcodeRequiresCapabilities.cpp index 447a6b5..aebbb90 100644 --- a/test/OpcodeRequiresCapabilities.cpp +++ b/test/OpcodeRequiresCapabilities.cpp @@ -35,7 +35,11 @@ class Requires : public ::testing::TestWithParam { (Op)0, SPV_OPCODE_FLAGS_CAPABILITIES, GetParam(), - 0, {}, false, false, {}}) {} + 0, + {}, + false, + false, + {}}) {} virtual void SetUp() {} @@ -56,7 +60,8 @@ INSTANTIATE_TEST_CASE_P(Op, Requires, CapabilityLinkage, CapabilityKernel)); TEST(OpcodeRequiresCapability, None) { - spv_opcode_desc_t entry = {nullptr, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, 0, {}, false, false, {}}; + spv_opcode_desc_t entry = { + nullptr, (Op)0, SPV_OPCODE_FLAGS_NONE, 0, 0, {}, false, false, {}}; ASSERT_EQ(0, spvOpcodeRequiresCapabilities(&entry)); } diff --git a/test/TextWordGet.cpp b/test/TextWordGet.cpp index b8ea483..5b6ed70 100644 --- a/test/TextWordGet.cpp +++ b/test/TextWordGet.cpp @@ -28,10 +28,10 @@ namespace { -#define TAB "\t" -#define NEWLINE "\n" +#define TAB "\t" +#define NEWLINE "\n" #define BACKSLASH R"(\)" -#define QUOTE R"(")" +#define QUOTE R"(")" TEST(TextWordGet, NullTerminator) { char textStr[] = "Word"; diff --git a/test/UnitSPIRV.h b/test/UnitSPIRV.h index 370cce9..674d26e 100644 --- a/test/UnitSPIRV.h +++ b/test/UnitSPIRV.h @@ -39,7 +39,7 @@ #ifdef __ANDROID__ #include namespace std { -template +template std::string to_string(const T& val) { std::ostringstream os; os << val; @@ -63,7 +63,6 @@ static const union { uint32_t value; } o32_host_order = {{0, 1, 2, 3}}; - // A namespace for utilities used in SPIR-V Tools unit tests. // TODO(dneto): Move other type declarations into this namespace. namespace spvtest { @@ -98,7 +97,8 @@ class WordVector { inline void PrintTo(const WordVector& words, ::std::ostream* os) { size_t count = 0; for (uint32_t value : words.value()) { - *os << "0x" << std::setw(8) << std::setfill('0') << std::hex << value << " "; + *os << "0x" << std::setw(8) << std::setfill('0') << std::hex << value + << " "; if (count++ % 8 == 7) { *os << std::endl; } @@ -108,8 +108,8 @@ inline void PrintTo(const WordVector& words, ::std::ostream* os) { // Returns a vector of words representing a single instruction with the // given opcode and operand words as a vector. -inline std::vector MakeInstruction( - spv::Op opcode, std::vector args) { +inline std::vector MakeInstruction(spv::Op opcode, + std::vector args) { std::vector result{ spvOpcodeMake(uint16_t(args.size() + 1), opcode)}; result.insert(result.end(), args.begin(), args.end()); @@ -133,13 +133,13 @@ inline std::vector MakeVector(std::string input) { } } // Emit a trailing partial word. - if ((num_bytes+1) % sizeof(uint32_t)) { + if ((num_bytes + 1) % sizeof(uint32_t)) { result.push_back(word); } return result; } -} // namespace spvtest +} // namespace spvtest // A type for easily creating spv_text_t values, with an implicit conversion to // spv_text. diff --git a/test/Validate.cpp b/test/Validate.cpp index 949f336..2072ffe 100644 --- a/test/Validate.cpp +++ b/test/Validate.cpp @@ -84,8 +84,9 @@ OpReturn OpFunctionEnd )"; spv_diagnostic diagnostic = nullptr; - ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(str, strlen(str), opcodeTable, operandTable, - extInstTable, &binary, &diagnostic)); + ASSERT_EQ(SPV_SUCCESS, + spvTextToBinary(str, strlen(str), opcodeTable, operandTable, + extInstTable, &binary, &diagnostic)); ASSERT_EQ(SPV_ERROR_INVALID_ID, spvValidate(binary, opcodeTable, operandTable, extInstTable, SPV_VALIDATE_ALL, &diagnostic)); -- 2.7.4