Run clang-format.
authorLei Zhang <antiagainst@google.com>
Mon, 14 Sep 2015 14:05:37 +0000 (10:05 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
source/opcode.cpp
source/opcode.h
source/text.h
source/validate_id.cpp
test/BinaryToText.cpp
test/OpcodeRequiresCapabilities.cpp
test/TextWordGet.cpp
test/UnitSPIRV.h
test/Validate.cpp

index d155033..4507da6 100644 (file)
@@ -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 (autoopcode : 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;
 }
index 4bfe903..2727333 100644 (file)
@@ -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 <result-id> operand, if any.
 ///
index 72d96d5..f7b9240 100644 (file)
@@ -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 charstr);
+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_tpExpectedOperands, 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
index 3b51e73..2df673f 100644 (file)
@@ -100,7 +100,7 @@ class idUsage {
     return idUses.end() != item;
   }
   bool foundUses(std::unordered_map<
-      uint32_t, std::vector<spv_id_info_t>>::const_iterator item) {
+                 uint32_t, std::vector<spv_id_info_t>>::const_iterator item) {
     return idUses.end() != item;
   }
 
@@ -620,8 +620,8 @@ bool idUsage::isValid<OpConstantComposite>(const spv_instruction_t *inst,
           // TODO: Output ID's on diagnostic
           DIAG(inst->wordCount - 1)
               << "OpConstantComposite Constituent <id> count does not match "
-                 "Result Type <id> '" << resultType->second.id
-              << "'s vector component count.";
+                 "Result Type <id> '"
+              << 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<OpConstantComposite>(const spv_instruction_t *inst,
           // TODO: Output ID's on diagnostic
           DIAG(inst->wordCount - 1)
               << "OpConstantComposite Constituent <id> count does not match "
-                 "Result Type <id> '" << resultType->second.id
-              << "'s matrix column count.";
+                 "Result Type <id> '"
+              << resultType->second.id << "'s matrix column count.";
           return false);
 
       auto columnType = find(resultType->second.inst->words[2]);
@@ -715,8 +715,8 @@ bool idUsage::isValid<OpConstantComposite>(const spv_instruction_t *inst,
       spvCheck(length->second.inst->words[3] != constituentCount,
                DIAG(inst->wordCount - 1)
                    << "OpConstantComposite Constituent count does not match "
-                      "Result Type <id> '" << resultType->second.id
-                   << "'s array length.";
+                      "Result Type <id> '"
+                   << 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,
index 50a05ed..9779c4a 100644 (file)
@@ -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);
index 447a6b5..aebbb90 100644 (file)
@@ -35,7 +35,11 @@ class Requires : public ::testing::TestWithParam<Capability> {
                (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));
 }
 
index b8ea483..5b6ed70 100644 (file)
 
 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";
index 370cce9..674d26e 100644 (file)
@@ -39,7 +39,7 @@
 #ifdef __ANDROID__
 #include <sstream>
 namespace std {
-template<typename T>
+template <typename T>
 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<uint32_t> MakeInstruction(
-    spv::Op opcode, std::vector<uint32_t> args) {
+inline std::vector<uint32_t> MakeInstruction(spv::Op opcode,
+                                             std::vector<uint32_t> args) {
   std::vector<uint32_t> result{
       spvOpcodeMake(uint16_t(args.size() + 1), opcode)};
   result.insert(result.end(), args.begin(), args.end());
@@ -133,13 +133,13 @@ inline std::vector<uint32_t> 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.
index 949f336..2072ffe 100644 (file)
@@ -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));