[libcxx] [test] Fix valarray UB and MSVC warnings.[libcxx] [test] Calling min and max on an empty valarray is UB.libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
[libcxx] [test] Fix valarray UB and MSVC warnings.[libcxx] [test] Calling min and max on an empty valarray is UB.libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpplibcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cppThe calls `v1.min();` and `v1.max();` were emitting nodiscard warningswith MSVC's STL. Upon closer inspection, these calls were triggeringundefined behavior. N4842 [valarray.members] says:"T min() const;8 Preconditions: size() > 0 is true.T max() const;10 Preconditions: size() > 0 is true."As these tests already provide coverage for non-empty valarrays(immediately above), I've simply deleted the code for empty valarrays.[libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC).libcxx/test/support/msvc_stdlib_force_include.hThese macros are being used by:libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cppDefining them to nothing allows that test to pass.[libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC).libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cppThis test is intentionally writing code that MSVC intentionally warnsabout, so the warning should be silenced.Additionally, comment an endif for clarity.[libcxx] [test] Silence MSVC warning C4127 (NFC).libcxx/test/support/charconv_test_helpers.hMSVC avoids emitting this warning when it sees a single constexpr valuebeing tested, but this condition is a mix of compile-time and run-time.Using push-disable-pop is the least intrusive way to silence this.[libcxx] [test] Silence MSVC truncation warning (NFC).libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cppThis test is intentionally truncating float to int, which MSVCintentionally warns about, so push-disable-pop is necessary.[libcxx] [test] Avoid truncation warnings in erase_if tests (NFC).libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpplibcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpplibcxx/test/std/containers/unord/unord.map/erase_if.pass.cpplibcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cppThese tests use maps with `short` keys and values, emitting MSVCtruncation warnings from `int`. Adding `static_cast` to `key_type`and `mapped_type` avoids these warnings.As these tests require C++20 mode (or newer), for brevity I've changedthe multimap tests to use emplace to initialize the test data.This has no effect on the erase_if testing.
show more ...
Add include for 'test_macros.h' to all the tests that were missing them. Thanks to Zoe for the (big, but simple) patch. NFC intended.llvm-svn: 362252
Support tests in freestandingSummary:Freestanding is *weird*. The standard allows it to differ in a bunch of oddmanners from regular C++, and the committee would like to improve thatsituation. I
Support tests in freestandingSummary:Freestanding is *weird*. The standard allows it to differ in a bunch of oddmanners from regular C++, and the committee would like to improve thatsituation. I'd like to make libc++ behave better with what freestanding shouldbe, so that it can be a tool we use in improving the standard. To do that weneed to try stuff out, both with "freestanding the language mode" and"freestanding the library subset".Let's start with the super basic: run the libc++ tests in freestanding, usingclang as the compiler, and see what works. The easiest hack to do this:In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding']Run the tests and they all fail.Why? Because in freestanding `main` isn't special. This "not special" propertyhas two effects: main doesn't get mangled, and main isn't allowed to omit its`return` statement. The first means main gets mangled and the linker can'tcreate a valid executable for us to test. The second means we spew out warnings(ew) and the compiler doesn't insert the `return` we omitted, and main justfalls of the end and does whatever undefined behavior (if you're luck, ud2leading to non-zero return code).Let's start my work with the basics. This patch changes all libc++ tests todeclare `main` as `int main(int, char**` so it mangles consistently (enabling usto declare another `extern "C"` main for freestanding which calls the mangledone), and adds `return 0;` to all places where it was missing. This touches 6124files, and I apologize.The former was done with The Magic Of Sed.The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feedThis works for most tests, though I did have to adjust a few places when e.g.the test runs with `-x c`, macros are used for main (such as for the filesystemtests), etc.Once this is in we can create a freestanding bot which will prevent furtherregressions. After that, we can start the real work of supporting C++freestanding fairly well in libc++.<rdar://problem/47754795>Reviewers: ldionne, mclow.lists, EricWFSubscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commitsDifferential Revision: https://reviews.llvm.org/D57624llvm-svn: 353086
Update more file headers across all of the LLVM projects in the monorepoto reflect the new license. These used slightly different spellings thatdefeated my regular expressions.We understand that
Update more file headers across all of the LLVM projects in the monorepoto reflect the new license. These used slightly different spellings thatdefeated my regular expressions.We understand that people may be surprised that we're moving the headerentirely to discuss the new license. We checked this carefully with theFoundation's lawyer and we believe this is the correct approach.Essentially, all code in the project is now made available by the LLVMproject under our new license, so you will see that the license headersinclude that license only. Some of our contributors have contributedcode under our old license, and accordingly, we have retained a copy ofour old license notice in the top-level files in each project andrepository.llvm-svn: 351648
Fix unused parameters and variablesllvm-svn: 290459
[libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", part 1/12.Change loop indices from int to std::size_t.Also, include <cstddef> when it wasn't already being included.ll
[libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", part 1/12.Change loop indices from int to std::size_t.Also, include <cstddef> when it wasn't already being included.llvm-svn: 287820
Move test into test/std subdirectory.llvm-svn: 224658