[PATCH] D56503: [libcxx] Portability fix: add missing includes.

Andrey Maksimov via Phabricator reviews at reviews.llvm.org
Tue Jan 22 07:41:26 PST 2019


amakc11 updated this revision to Diff 182913.
amakc11 added a comment.

For complete consistency with this request, two more tests were patched. Calls to `strcmp()` replaced with `std::strcmp()` and `<cstring>` header added according to the requirement of the standard. The test `std/depr/depr.c.headers/string_h.pass.cpp` remains untouched since it checks the requirements to `<string.h>` header.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56503/new/

https://reviews.llvm.org/D56503

Files:
  test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
  test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
  test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
  test/std/language.support/support.rtti/type.info/type_info.pass.cpp


Index: test/std/language.support/support.rtti/type.info/type_info.pass.cpp
===================================================================
--- test/std/language.support/support.rtti/type.info/type_info.pass.cpp
+++ test/std/language.support/support.rtti/type.info/type_info.pass.cpp
@@ -26,8 +26,8 @@
     const std::type_info& t3 = typeid(short);
     assert(t1 != t3);
     assert(!t1.before(t2));
-    assert(strcmp(t1.name(), t2.name()) == 0);
-    assert(strcmp(t1.name(), t3.name()) != 0);
+    assert(std::strcmp(t1.name(), t2.name()) == 0);
+    assert(std::strcmp(t1.name(), t3.name()) != 0);
   }
   {
     // type_info has a protected constructor taking a string literal. This
Index: test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
===================================================================
--- test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
+++ test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <streambuf>
 #include <cassert>
+#include <cstring>
 
 struct test
     : public std::basic_streambuf<char>
@@ -39,6 +40,6 @@
         char out[sizeof(in)] = {0};
         t.setp(out, out+sizeof(out));
         assert(t.sputn(in, sizeof(in)) == sizeof(in));
-        assert(strcmp(in, out) == 0);
+        assert(std::strcmp(in, out) == 0);
     }
 }
Index: test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
===================================================================
--- test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
+++ test/std/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <streambuf>
 #include <cassert>
+#include <cstring>
 
 struct test
     : public std::basic_streambuf<char>
@@ -37,5 +38,5 @@
     t.setg(input, input, input+7);
     char output[sizeof(input)] = {0};
     assert(t.sgetn(output, 10) == 7);
-    assert(strcmp(input, output) == 0);
+    assert(std::strcmp(input, output) == 0);
 }
Index: test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
===================================================================
--- test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
+++ test/std/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -15,6 +15,7 @@
 
 #include <strstream>
 #include <cassert>
+#include <cstring>
 #include <string>
 
 int main()
@@ -31,6 +32,6 @@
     inout >> i >> d >> s;
     assert(i == 123);
     assert(d == 4.5);
-    assert(strcmp(s.c_str(), "dog") == 0);
+    assert(std::strcmp(s.c_str(), "dog") == 0);
     inout.freeze(false);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56503.182913.patch
Type: text/x-patch
Size: 2874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190122/3245ab8c/attachment-0001.bin>


More information about the libcxx-commits mailing list