[PATCH] Exhaustively test all permutations of triple parts in TripleTest.

Douglas Katzman dougk at google.com
Thu Apr 16 12:55:53 PDT 2015


On account of evolution of the enum types, iteration over "everything" didn't really work.

http://reviews.llvm.org/D9057

Files:
  include/llvm/ADT/Triple.h
  unittests/ADT/TripleTest.cpp

Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h
+++ include/llvm/ADT/Triple.h
@@ -83,6 +83,8 @@
     spir64,     // SPIR: standard portable IR for OpenCL 64-bit version
     kalimba     // Kalimba: generic kalimba
   };
+  // Keep this in sync with the preceding list.
+  static constexpr ArchType ArchTypeMax = kalimba;
   enum SubArchType {
     NoSubArch,
 
@@ -119,6 +121,8 @@
     NVIDIA,
     CSR
   };
+  // Keep this in sync with the preceding list.
+  static constexpr VendorType VendorTypeMax = CSR;
   enum OSType {
     UnknownOS,
 
@@ -147,6 +151,8 @@
     AMDHSA,     // AMD HSA Runtime
     PS4
   };
+  // Keep this in sync with the preceding list.
+  static constexpr OSType OSTypeMax = PS4;
   enum EnvironmentType {
     UnknownEnvironment,
 
@@ -163,6 +169,8 @@
     Itanium,
     Cygnus,
   };
+  // Keep this in sync with the preceding list.
+  static constexpr EnvironmentType EnvironmentTypeMax = Cygnus;
   enum ObjectFormatType {
     UnknownObjectFormat,
 
Index: unittests/ADT/TripleTest.cpp
===================================================================
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -220,12 +220,12 @@
   // Check that normalizing a permutated set of valid components returns a
   // triple with the unpermuted components.
   StringRef C[4];
-  for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::amdil; ++Arch) {
+  for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::ArchTypeMax; ++Arch) {
     C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
-    for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::PC;
+    for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::VendorTypeMax;
          ++Vendor) {
       C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
-      for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) {
+      for (int OS = 1+Triple::UnknownOS; OS <= Triple::OSTypeMax; ++OS) {
         if (OS == Triple::Win32)
           continue;
 
@@ -240,7 +240,7 @@
         EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1])));
         EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0])));
 
-        for (int Env = 1 + Triple::UnknownEnvironment; Env <= Triple::Android;
+        for (int Env = 1 + Triple::UnknownEnvironment; Env <= Triple::EnvironmentTypeMax;
              ++Env) {
           C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9057.23871.patch
Type: text/x-patch
Size: 2491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150416/c44e9947/attachment.bin>


More information about the llvm-commits mailing list