[libcxx-commits] [libcxx] a562853 - [libc++] NFC: Fix return-by-const-value and pass-by-const-value typos

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 29 10:57:11 PDT 2021


Author: Louis Dionne
Date: 2021-06-29T13:57:04-04:00
New Revision: a562853a511b078912f3a9fccb4a27220ce75e9e

URL: https://github.com/llvm/llvm-project/commit/a562853a511b078912f3a9fccb4a27220ce75e9e
DIFF: https://github.com/llvm/llvm-project/commit/a562853a511b078912f3a9fccb4a27220ce75e9e.diff

LOG: [libc++] NFC: Fix return-by-const-value and pass-by-const-value typos

While we can debate on the value of passing by const value, there is no
arguing that it's confusing to do so in some circumstances, such as when
marking a pointer parameter as being const (did you mean a pointer-to-const?).
This commit fixes a few issues along those lines.

Added: 
    

Modified: 
    libcxx/include/vector
    libcxx/src/string.cpp
    libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
    libcxx/test/std/strings/string.view/string.view.find/find_last_not_of_char_size.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 69babd04f7e6c..52ddd45ffa86b 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -144,7 +144,7 @@ public:
     public:
         reference(const reference&) noexcept;
         operator bool() const noexcept;
-        reference& operator=(const bool x) noexcept;
+        reference& operator=(bool x) noexcept;
         reference& operator=(const reference& x) noexcept;
         iterator operator&() const noexcept;
         void flip() noexcept;

diff  --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp
index 63b81d67049d4..97a773f79a3be 100644
--- a/libcxx/src/string.cpp
+++ b/libcxx/src/string.cpp
@@ -423,7 +423,7 @@ get_swprintf()
 }
 
 template <typename S, typename V>
-S i_to_string(const V v)
+S i_to_string(V v)
 {
 //  numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
 //  For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),

diff  --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
index 50b44446d117a..bcae4b462a3cb 100644
--- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -40,12 +40,12 @@ class counting_allocatorT {
     template <class U> bool operator==(const counting_allocatorT<U>& other) const noexcept { return foo == other.foo; }
     template <class U> bool operator!=(const counting_allocatorT<U>& other) const noexcept { return foo != other.foo; }
 
-    T * allocate(const size_t n) const {
+    T* allocate(size_t n) const {
         ca_allocs.push_back(foo);
         void * const pv = ::malloc(n * sizeof(T));
         return static_cast<T *>(pv);
     }
-    void deallocate(T * const p, size_t) const noexcept {
+    void deallocate(T* p, size_t) const noexcept {
         ca_deallocs.push_back(foo);
         free(p);
     }
@@ -63,12 +63,12 @@ class counting_allocatorF {
     template <class U> bool operator==(const counting_allocatorF<U>& other) const noexcept { return foo == other.foo; }
     template <class U> bool operator!=(const counting_allocatorF<U>& other) const noexcept { return foo != other.foo; }
 
-    T * allocate(const size_t n) const {
+    T* allocate(size_t n) const {
         ca_allocs.push_back(foo);
         void * const pv = ::malloc(n * sizeof(T));
         return static_cast<T *>(pv);
     }
-    void deallocate(T * const p, size_t) const noexcept {
+    void deallocate(T* p, size_t) const noexcept {
         ca_deallocs.push_back(foo);
         free(p);
     }

diff  --git a/libcxx/test/std/strings/string.view/string.view.find/find_last_not_of_char_size.pass.cpp b/libcxx/test/std/strings/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
index d2cf8d5d94f9b..798c899e80f28 100644
--- a/libcxx/test/std/strings/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
+++ b/libcxx/test/std/strings/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
@@ -8,7 +8,7 @@
 
 // <string_view>
 
-// const size_type find_last_not_of(charT c, size_type pos = npos) const;
+// size_type find_last_not_of(charT c, size_type pos = npos) const;
 
 #include <string_view>
 #include <cassert>


        


More information about the libcxx-commits mailing list