6 Commits 7225154f49 ... be587b8cd2

Author SHA1 Message Date
  __vic be587b8cd2 Merge branch 'iso' into generic 4 years ago
  __vic 37aaa23d57 notabug.org mirror added 4 years ago
  __vic 13513053a2 sift_if(): redundant past the end predicate check 4 years ago
  __vic 8d648aa796 __has_cpp_attribute(nodiscard) workaround for Clang 4 years ago
  __vic ac088026eb Tests with __VIC_NO_BUILTINS added 4 years ago
  __vic d70fd971cf fix: typo '__VIC_NO_BUITLINS' 4 years ago

+ 12 - 0
ChangeLog

@@ -4,6 +4,18 @@ Legend:
     * Changes
     ! Important
 
+2019-07-02  __vic
+    - string_utils.h: sift_if(): redundant past the end predicate check
+
+2019-06-26  __vic
+    + Workaround for Clang 3.9+ issue - __has_cpp_attribute(nodiscard) returns
+      1 even when used mode is C++14 or less
+
+2019-06-21  __vic
+    - "__VIC_NO_BUITLINS" was used instead of __VIC_NO_BUILTINS
+    + test/bits_no_biltins.cpp
+    + test/endian_no_builtins.cpp
+
 2019-05-31  __vic
     + bits.h: ceil_log2(), floor_log2()
 

+ 1 - 0
README

@@ -22,6 +22,7 @@ https://github.com/2underscores-vic/__vic-doc
 SOURCES
 
 https://github.com/2underscores-vic/__vic
+https://notabug.org/__vic/__vic
 
 
 LICENSING

+ 3 - 1
include/__vic/_cfg.h

@@ -282,7 +282,9 @@
 #   define __has_cpp_attribute(a) 0
 #endif
 
-#if __cpp_attributes && __has_cpp_attribute(nodiscard)
+#if __cpp_attributes && __has_cpp_attribute(nodiscard) && \
+    !defined(__clang__)
+// Clang 3.9+ issue - https://bugs.llvm.org/show_bug.cgi?id=33518
 #   define __VIC_NODISCARD [[nodiscard]]
 #else
 #   define __VIC_NODISCARD

+ 15 - 13
include/__vic/bits.h

@@ -11,7 +11,7 @@
 #include<__vic/defs.h>
 #include<__vic/stdint.h>
 #include<climits>
-#if defined(_MSC_VER) && !defined(__VIC_NO_BUITLINS)
+#if defined(_MSC_VER) && !defined(__VIC_NO_BUILTINS)
 #include<intrin.h>
 #endif
 
@@ -87,9 +87,9 @@ __VIC_CONSTEXPR14 unsigned popcount_uint(UInt v)
 //----------------------------------------------------------------------------
 inline unsigned popcount(unsigned v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_popcount(v);
-#elif defined(_MSC_VER) && !defined(__VIC_NO_BUITLINS)
+#elif defined(_MSC_VER) && !defined(__VIC_NO_BUILTINS)
     return __popcnt(v);
 #else
     return popcount_uint(v);
@@ -98,7 +98,7 @@ inline unsigned popcount(unsigned v)
 //----------------------------------------------------------------------------
 inline unsigned popcount(unsigned long v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_popcountl(v);
 #else
     return popcount_uint(v);
@@ -108,9 +108,9 @@ inline unsigned popcount(unsigned long v)
 #ifdef __VIC_LONGLONG
 inline unsigned popcount(unsigned __VIC_LONGLONG v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_popcountll(v);
-#elif defined(_MSC_VER) && !defined(__VIC_NO_BUITLINS)
+#elif defined(_MSC_VER) && !defined(__VIC_NO_BUILTINS)
     return static_cast<unsigned>(__popcnt64(v));
 #else
     return popcount_uint(v);
@@ -120,7 +120,7 @@ inline unsigned popcount(unsigned __VIC_LONGLONG v)
 //----------------------------------------------------------------------------
 inline unsigned popcount(unsigned short v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_popcount(v);
 #else
     return popcount_uint(v);
@@ -129,7 +129,7 @@ inline unsigned popcount(unsigned short v)
 //----------------------------------------------------------------------------
 inline unsigned popcount(unsigned char v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_popcount(v);
 #else
     return popcount_uint(v);
@@ -151,7 +151,7 @@ inline unsigned msb_position_uint(UInt v)
 //----------------------------------------------------------------------------
 inline unsigned msb_position(unsigned v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return sizeof(v) * CHAR_BIT - __builtin_clz(v) - 1U;
 #else
     return msb_position_uint(v);
@@ -160,7 +160,7 @@ inline unsigned msb_position(unsigned v)
 //----------------------------------------------------------------------------
 inline unsigned msb_position(unsigned long v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return sizeof(v) * CHAR_BIT - __builtin_clzl(v) - 1U;
 #else
     return msb_position_uint(v);
@@ -170,7 +170,7 @@ inline unsigned msb_position(unsigned long v)
 #ifdef __VIC_LONGLONG
 inline unsigned msb_position(unsigned __VIC_LONGLONG v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return sizeof(v) * CHAR_BIT - __builtin_clzll(v) - 1U;
 #else
     return msb_position_uint(v);
@@ -180,7 +180,7 @@ inline unsigned msb_position(unsigned __VIC_LONGLONG v)
 //----------------------------------------------------------------------------
 inline unsigned msb_position(unsigned short v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return msb_position(static_cast<unsigned>(v));
 #else
     return msb_position_uint(v);
@@ -189,7 +189,7 @@ inline unsigned msb_position(unsigned short v)
 //----------------------------------------------------------------------------
 inline unsigned msb_position(unsigned char v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return msb_position(static_cast<unsigned>(v));
 #else
     return msb_position_uint(v);
@@ -277,6 +277,8 @@ inline UInt floor2(UInt n)
 }
 //----------------------------------------------------------------------------
 
+#undef __VIC_ASSERT_UINT
+
 } // namespace
 
 #endif // header guard

+ 3 - 3
include/__vic/endian.h

@@ -16,7 +16,7 @@ namespace __vic {
 //----------------------------------------------------------------------------
 __VIC_NODISCARD __VIC_CONSTEXPR_FUNC uint16_t swab16(uint16_t v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS) && \
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS) && \
         (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)
     return __builtin_bswap16(v);
 #else
@@ -26,7 +26,7 @@ __VIC_NODISCARD __VIC_CONSTEXPR_FUNC uint16_t swab16(uint16_t v)
 //----------------------------------------------------------------------------
 __VIC_NODISCARD __VIC_CONSTEXPR_FUNC uint32_t swab32(uint32_t v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_bswap32(v);
 #else
     return (v >> 24) | ((v & uint32_t(0x00FF0000)) >> 8) |
@@ -36,7 +36,7 @@ __VIC_NODISCARD __VIC_CONSTEXPR_FUNC uint32_t swab32(uint32_t v)
 //----------------------------------------------------------------------------
 __VIC_NODISCARD __VIC_CONSTEXPR_FUNC uint64_t swab64(uint64_t v)
 {
-#if defined(__GNUC__) && !defined(__VIC_NO_BUITLINS)
+#if defined(__GNUC__) && !defined(__VIC_NO_BUILTINS)
     return __builtin_bswap64(v);
 #else
     return (v >> 56) |

+ 2 - 1
include/__vic/memory.h

@@ -26,7 +26,8 @@ inline T load_unaligned(const void *p)
 #else // unaligned access is OK
     return *static_cast<const T *>(p);
 #endif
-}//----------------------------------------------------------------------------
+}
+//----------------------------------------------------------------------------
 
 } // namespace
 

+ 3 - 7
include/__vic/string_utils.h

@@ -57,10 +57,8 @@ inline char *sift_if(char *st, Pred pred)
     while(*in && !pred(*in)) in++;
     if(!*in) return st; // no trash chars
     char *out = in;
-    do {
-        in++;
-        if(!pred(*in)) *out++ = *in;
-    } while(*in);
+    while(char ch = *++in)
+        if(!pred(ch)) *out++ = ch;
     *out = '\0';
     return st;
 }
@@ -72,10 +70,8 @@ std::string &sift_if(std::string &st, Pred pred)
     while(in != st.end() && !pred(*in)) ++in;
     if(in == st.end()) return st; // no trash chars
     std::string::iterator out = in;
-    do {
-        ++in;
+    while(++in != st.end())
         if(!pred(*in)) *out++ = *in;
-    } while(in != st.end());
     st.erase(out, st.end());
     return st;
 }

+ 2 - 0
test/bits_no_biltins.cpp

@@ -0,0 +1,2 @@
+#define __VIC_NO_BUILTINS 1
+#include"bits.cpp"

+ 2 - 0
test/endian_no_builtins.cpp

@@ -0,0 +1,2 @@
+#define __VIC_NO_BUILTINS 1
+#include"endian.cpp"