[llvm] r299066 - Revert "Make naming in Host.h in line with coding standards."

Kristof Beyls via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 04:06:26 PDT 2017


Author: kbeyls
Date: Thu Mar 30 06:06:25 2017
New Revision: 299066

URL: http://llvm.org/viewvc/llvm-project?rev=299066&view=rev
Log:
Revert "Make naming in Host.h in line with coding standards."

This reverts r299062, which caused build failures on Windows.
It also reverts the attempts to fix the windows builds in r299064 and r299065.
The introduction of namespace llvm::sys::detail makes MSVC, and seemingly also
mingw, complain about ambiguity with the existing namespace llvm::detail.
E.g.:
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/MathExtras.h(184): error C2872: 'detail': ambiguous symbol
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/PointerLikeTypeTraits.h(31): note: could be 'llvm::detail'
C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/Host.h(80): note: or       'llvm::sys::detail'

In r299064 and r299065 I tried to fix these ambiguities, based on the errors
reported in the log files. It seems however that the build stops early when
this kind of error is encountered, and many build-then-fix-iterations on
Windows may be needed to fix this. Therefore reverting r299062 for now to
get the build working again on Windows.


Modified:
    llvm/trunk/include/llvm/ADT/DenseSet.h
    llvm/trunk/include/llvm/ADT/StringExtras.h
    llvm/trunk/include/llvm/Support/Host.h
    llvm/trunk/include/llvm/Support/MathExtras.h
    llvm/trunk/lib/Support/Chrono.cpp
    llvm/trunk/lib/Support/Host.cpp
    llvm/trunk/unittests/Support/Host.cpp

Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Thu Mar 30 06:06:25 2017
@@ -179,12 +179,12 @@ public:
   void erase(ConstIterator CI) { return TheMap.erase(CI.I); }
 
   std::pair<iterator, bool> insert(const ValueT &V) {
-    llvm::detail::DenseSetEmpty Empty;
+    detail::DenseSetEmpty Empty;
     return TheMap.try_emplace(V, Empty);
   }
 
   std::pair<iterator, bool> insert(ValueT &&V) {
-    llvm::detail::DenseSetEmpty Empty;
+    detail::DenseSetEmpty Empty;
     return TheMap.try_emplace(std::move(V), Empty);
   }
 
@@ -193,12 +193,11 @@ public:
   template <typename LookupKeyT>
   std::pair<iterator, bool> insert_as(const ValueT &V,
                                       const LookupKeyT &LookupKey) {
-    return TheMap.insert_as({V, llvm::detail::DenseSetEmpty()}, LookupKey);
+    return TheMap.insert_as({V, detail::DenseSetEmpty()}, LookupKey);
   }
   template <typename LookupKeyT>
   std::pair<iterator, bool> insert_as(ValueT &&V, const LookupKeyT &LookupKey) {
-    return TheMap.insert_as({std::move(V), llvm::detail::DenseSetEmpty()},
-                            LookupKey);
+    return TheMap.insert_as({std::move(V), detail::DenseSetEmpty()}, LookupKey);
   }
 
   // Range insertion of values.
@@ -213,15 +212,15 @@ public:
 
 /// Implements a dense probed hash-table based set.
 template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>>
-class DenseSet
-    : public llvm::detail::DenseSetImpl<
-          ValueT, DenseMap<ValueT, llvm::detail::DenseSetEmpty, ValueInfoT,
-                           llvm::detail::DenseSetPair<ValueT>>,
-          ValueInfoT> {
-  using BaseT = llvm::detail::DenseSetImpl<
-      ValueT, DenseMap<ValueT, llvm::detail::DenseSetEmpty, ValueInfoT,
-                       llvm::detail::DenseSetPair<ValueT>>,
-      ValueInfoT>;
+class DenseSet : public detail::DenseSetImpl<
+                     ValueT, DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
+                                      detail::DenseSetPair<ValueT>>,
+                     ValueInfoT> {
+  using BaseT =
+      detail::DenseSetImpl<ValueT,
+                           DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
+                                    detail::DenseSetPair<ValueT>>,
+                           ValueInfoT>;
 
 public:
   using BaseT::BaseT;
@@ -232,14 +231,13 @@ public:
 template <typename ValueT, unsigned InlineBuckets = 4,
           typename ValueInfoT = DenseMapInfo<ValueT>>
 class SmallDenseSet
-    : public llvm::detail::DenseSetImpl<
-          ValueT,
-          SmallDenseMap<ValueT, llvm::detail::DenseSetEmpty, InlineBuckets,
-                        ValueInfoT, llvm::detail::DenseSetPair<ValueT>>,
+    : public detail::DenseSetImpl<
+          ValueT, SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
+                                ValueInfoT, detail::DenseSetPair<ValueT>>,
           ValueInfoT> {
-  using BaseT = llvm::detail::DenseSetImpl<
-      ValueT, SmallDenseMap<ValueT, llvm::detail::DenseSetEmpty, InlineBuckets,
-                            ValueInfoT, llvm::detail::DenseSetPair<ValueT>>,
+  using BaseT = detail::DenseSetImpl<
+      ValueT, SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
+                            ValueInfoT, detail::DenseSetPair<ValueT>>,
       ValueInfoT>;
 
 public:

Modified: llvm/trunk/include/llvm/ADT/StringExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/StringExtras.h Thu Mar 30 06:06:25 2017
@@ -231,7 +231,7 @@ inline size_t join_items_size(const A1 &
 template <typename IteratorT>
 inline std::string join(IteratorT Begin, IteratorT End, StringRef Separator) {
   typedef typename std::iterator_traits<IteratorT>::iterator_category tag;
-  return llvm::detail::join_impl(Begin, End, Separator, tag());
+  return detail::join_impl(Begin, End, Separator, tag());
 }
 
 /// Joins the strings in the range [R.begin(), R.end()), adding Separator
@@ -251,11 +251,10 @@ inline std::string join_items(Sep Separa
   if (sizeof...(Items) == 0)
     return Result;
 
-  size_t NS = llvm::detail::join_one_item_size(Separator);
-  size_t NI = llvm::detail::join_items_size(std::forward<Args>(Items)...);
+  size_t NS = detail::join_one_item_size(Separator);
+  size_t NI = detail::join_items_size(std::forward<Args>(Items)...);
   Result.reserve(NI + (sizeof...(Items) - 1) * NS + 1);
-  llvm::detail::join_items_impl(Result, Separator,
-                                std::forward<Args>(Items)...);
+  detail::join_items_impl(Result, Separator, std::forward<Args>(Items)...);
   return Result;
 }
 

Modified: llvm/trunk/include/llvm/Support/Host.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Host.h?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Host.h (original)
+++ llvm/trunk/include/llvm/Support/Host.h Thu Mar 30 06:06:25 2017
@@ -77,11 +77,11 @@ constexpr bool IsBigEndianHost = false;
   /// Returns -1 if unknown for the current host system.
   int getHostNumPhysicalCores();
 
-  namespace detail {
-  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
-  StringRef getHostCPUNameForPowerPC(const StringRef &ProcCpuinfoContent);
-  StringRef getHostCPUNameForARM(const StringRef &ProcCpuinfoContent);
-  StringRef getHostCPUNameForS390x(const StringRef &ProcCpuinfoContent);
+  /// helper functions to extract HostCPUName from /proc/cpuinfo on linux.
+  namespace LinuxReadCpuInfo {
+  StringRef getHostCPUName_powerpc(const StringRef &ProcCpuinfoContent);
+  StringRef getHostCPUName_arm(const StringRef &ProcCpuinfoContent);
+  StringRef getHostCPUName_s390x(const StringRef &ProcCpuinfoContent);
   }
 }
 }

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Thu Mar 30 06:06:25 2017
@@ -112,7 +112,7 @@ std::size_t countTrailingZeros(T Val, Ze
   static_assert(std::numeric_limits<T>::is_integer &&
                     !std::numeric_limits<T>::is_signed,
                 "Only unsigned integral types are allowed.");
-  return llvm::detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+  return detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
 }
 
 namespace detail {
@@ -181,7 +181,7 @@ std::size_t countLeadingZeros(T Val, Zer
   static_assert(std::numeric_limits<T>::is_integer &&
                     !std::numeric_limits<T>::is_signed,
                 "Only unsigned integral types are allowed.");
-  return llvm::detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+  return detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
 }
 
 /// \brief Get the index of the first set bit starting from the least
@@ -495,7 +495,7 @@ inline unsigned countPopulation(T Value)
   static_assert(std::numeric_limits<T>::is_integer &&
                     !std::numeric_limits<T>::is_signed,
                 "Only unsigned integral types are allowed.");
-  return llvm::detail::PopulationCounter<T, sizeof(T)>::count(Value);
+  return detail::PopulationCounter<T, sizeof(T)>::count(Value);
 }
 
 /// Log2 - This function returns the log base 2 of the specified value

Modified: llvm/trunk/lib/Support/Chrono.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Chrono.cpp?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Chrono.cpp (original)
+++ llvm/trunk/lib/Support/Chrono.cpp Thu Mar 30 06:06:25 2017
@@ -16,12 +16,12 @@ namespace llvm {
 
 using namespace sys;
 
-const char llvm::detail::unit<std::ratio<3600>>::value[] = "h";
-const char llvm::detail::unit<std::ratio<60>>::value[] = "m";
-const char llvm::detail::unit<std::ratio<1>>::value[] = "s";
-const char llvm::detail::unit<std::milli>::value[] = "ms";
-const char llvm::detail::unit<std::micro>::value[] = "us";
-const char llvm::detail::unit<std::nano>::value[] = "ns";
+const char detail::unit<std::ratio<3600>>::value[] = "h";
+const char detail::unit<std::ratio<60>>::value[] = "m";
+const char detail::unit<std::ratio<1>>::value[] = "s";
+const char detail::unit<std::milli>::value[] = "ms";
+const char detail::unit<std::micro>::value[] = "us";
+const char detail::unit<std::nano>::value[] = "ns";
 
 static inline struct tm getStructTM(TimePoint<> TP) {
   struct tm Storage;

Modified: llvm/trunk/lib/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Host.cpp (original)
+++ llvm/trunk/lib/Support/Host.cpp Thu Mar 30 06:06:25 2017
@@ -64,7 +64,7 @@ static std::unique_ptr<llvm::MemoryBuffe
   return std::move(*Text);
 }
 
-StringRef sys::detail::getHostCPUNameForPowerPC(
+StringRef sys::LinuxReadCpuInfo::getHostCPUName_powerpc(
     const StringRef &ProcCpuinfoContent) {
   // Access to the Processor Version Register (PVR) on PowerPC is privileged,
   // and so we must use an operating-system interface to determine the current
@@ -144,7 +144,7 @@ StringRef sys::detail::getHostCPUNameFor
       .Default(generic);
 }
 
-StringRef sys::detail::getHostCPUNameForARM(
+StringRef sys::LinuxReadCpuInfo::getHostCPUName_arm(
     const StringRef &ProcCpuinfoContent) {
   // The cpuid register on arm is not accessible from user space. On Linux,
   // it is exposed through the /proc/cpuinfo file.
@@ -195,7 +195,7 @@ StringRef sys::detail::getHostCPUNameFor
   return "generic";
 }
 
-StringRef sys::detail::getHostCPUNameForS390x(
+StringRef sys::LinuxReadCpuInfo::getHostCPUName_s390x(
     const StringRef &ProcCpuinfoContent) {
   // STIDP is a privileged operation, so use /proc/cpuinfo instead.
 
@@ -1197,19 +1197,19 @@ StringRef sys::getHostCPUName() {
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return detail::getHostCPUNameForPowerPC(Content);
+  return LinuxReadCpuInfo::getHostCPUName_powerpc(Content);
 }
 #elif defined(__linux__) && defined(__arm__)
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return detail::getHostCPUNameForARM(Content);
+  return LinuxReadCpuInfo::getHostCPUName_arm(Content);
 }
 #elif defined(__linux__) && defined(__s390x__)
 StringRef sys::getHostCPUName() {
   std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
   const StringRef& Content = P ? P->getBuffer() : "";
-  return detail::getHostCPUNameForS390x(Content);
+  return LinuxReadCpuInfo::getHostCPUName_s390x(Content);
 }
 #else
 StringRef sys::getHostCPUName() { return "generic"; }

Modified: llvm/trunk/unittests/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Host.cpp?rev=299066&r1=299065&r2=299066&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Host.cpp (original)
+++ llvm/trunk/unittests/Support/Host.cpp Thu Mar 30 06:06:25 2017
@@ -66,16 +66,19 @@ Revision        : 0000
 Serial          : 0000000000000000
 )";
 
-  EXPECT_EQ(sys::detail::getHostCPUNameForARM(CortexA9ProcCpuinfo),
+  EXPECT_EQ(sys::LinuxReadCpuInfo::getHostCPUName_arm(CortexA9ProcCpuinfo),
             "cortex-a9");
-  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x41\n"
-                                              "CPU part        : 0xc0f"),
-            "cortex-a15");
+  EXPECT_EQ(
+      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x41\n"
+                                                "CPU part        : 0xc0f"),
+      "cortex-a15");
   // Verify that both CPU implementer and CPU part are checked:
-  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x40\n"
-                                              "CPU part        : 0xc0f"),
-            "generic");
-  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x51\n"
-                                              "CPU part        : 0x06f"),
-            "krait");
+  EXPECT_EQ(
+      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x40\n"
+                                                "CPU part        : 0xc0f"),
+      "generic");
+  EXPECT_EQ(
+      sys::LinuxReadCpuInfo::getHostCPUName_arm("CPU implementer : 0x51\n"
+                                                "CPU part        : 0x06f"),
+      "krait");
 }




More information about the llvm-commits mailing list