Page MenuHomePhabricator

[libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11.
ClosedPublic

Authored by curdeius on Dec 10 2020, 4:47 AM.

Details

Summary

The relevant part of __config is:

#ifndef _LIBCPP_STD_VER
#  if  __cplusplus <= 201103L
#    define _LIBCPP_STD_VER 11

Diff Detail

Unit TestsFailed

TimeTest
2,009 mslibcxx CI -fno-exceptions > libc++.libcxx/modules::stds_include.sh.cpp
Script: -- : 'RUN: at line 28'; /usr/bin/clang++ -v --target=x86_64-unknown-linux-gnu -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/__config_site -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/include -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -std=c++2a -fno-exceptions -Werror -Wall -Wextra -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -fmodules-cache-path=/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/test/libcxx/modules/Output/stds_include.sh.cpp.dir/t.tmp/ModuleCache -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1 -fmodules -fcxx-modules -fsyntax-only -std=c++03 -DINVALIDATE_CACHE_CXX03 /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules/stds_include.sh.cpp
2,009 mslibcxx CI -fno-exceptions > libc++.libcxx/modules::stds_include.sh.cpp
Script: -- : 'RUN: at line 28'; /usr/bin/clang++ -v --target=x86_64-unknown-linux-gnu -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/__config_site -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/include -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -std=c++2a -fno-exceptions -Werror -Wall -Wextra -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -fmodules-cache-path=/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/test/libcxx/modules/Output/stds_include.sh.cpp.dir/t.tmp/ModuleCache -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1 -fmodules -fcxx-modules -fsyntax-only -std=c++03 -DINVALIDATE_CACHE_CXX03 /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules/stds_include.sh.cpp
2,009 mslibcxx CI -fno-exceptions > libc++.libcxx/modules::stds_include.sh.cpp
Script: -- : 'RUN: at line 28'; /usr/bin/clang++ -v --target=x86_64-unknown-linux-gnu -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/__config_site -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/include -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -std=c++2a -fno-exceptions -Werror -Wall -Wextra -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -fmodules-cache-path=/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/test/libcxx/modules/Output/stds_include.sh.cpp.dir/t.tmp/ModuleCache -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1 -fmodules -fcxx-modules -fsyntax-only -std=c++03 -DINVALIDATE_CACHE_CXX03 /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules/stds_include.sh.cpp
2,009 mslibcxx CI -fno-exceptions > libc++.libcxx/modules::stds_include.sh.cpp
Script: -- : 'RUN: at line 28'; /usr/bin/clang++ -v --target=x86_64-unknown-linux-gnu -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/__config_site -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/include -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -std=c++2a -fno-exceptions -Werror -Wall -Wextra -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -fmodules-cache-path=/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/test/libcxx/modules/Output/stds_include.sh.cpp.dir/t.tmp/ModuleCache -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1 -fmodules -fcxx-modules -fsyntax-only -std=c++03 -DINVALIDATE_CACHE_CXX03 /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules/stds_include.sh.cpp
2,009 mslibcxx CI -fno-exceptions > libc++.libcxx/modules::stds_include.sh.cpp
Script: -- : 'RUN: at line 28'; /usr/bin/clang++ -v --target=x86_64-unknown-linux-gnu -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/__config_site -include /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support/nasty_macros.h -nostdinc++ -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/include -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/include/c++build -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/support -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -std=c++2a -fno-exceptions -Werror -Wall -Wextra -Wshadow -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -fmodules-cache-path=/home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/build/generic-noexceptions/projects/libcxx/test/libcxx/modules/Output/stds_include.sh.cpp.dir/t.tmp/ModuleCache -Wno-macro-redefined -D_LIBCPP_HAS_THREAD_API_PTHREAD -Wno-macro-redefined -D_LIBCPP_ABI_VERSION=1 -fmodules -fcxx-modules -fsyntax-only -std=c++03 -DINVALIDATE_CACHE_CXX03 /home/libcxx-builder/.buildkite-agent/builds/a7186d4e9294-1/llvm-project/libcxx-ci/libcxx/test/libcxx/modules/stds_include.sh.cpp
View Full Test Results (16,960 Failed)

Event Timeline

curdeius requested review of this revision.Dec 10 2020, 4:47 AM
curdeius created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2020, 4:47 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
curdeius edited the summary of this revision. (Show Details)Dec 10 2020, 4:58 AM
curdeius updated this revision to Diff 310874.Dec 10 2020, 6:37 AM

Remove unnecessary #if altogether.

if you need to remove something for C++03, then the test would be:
#ifndef _LIBCPP_CXX03_LANG

curdeius retitled this revision from [libc++] Fix invalid use of `_LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11. to [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11..Dec 10 2020, 6:42 AM
curdeius planned changes to this revision.Dec 10 2020, 6:46 AM

if you need to remove something for C++03, then the test would be:
#ifndef _LIBCPP_CXX03_LANG

That's exactly what I did in the first try. Please see diff https://reviews.llvm.org/D93025?id=310846.
But as one might have expected, there were tests already that depended on this (incorrect #if).
I'm still thinking what the best course of action should be.

Actually, the choices are:

  1. keep the status quo, it means that there will be an #if that is equivalent to #if 1 and is very misleading
  2. remove this #if altogether (diff no. 2)
  3. change to #ifndef _LIBCPP_CXX03_LANG and fix the tests that fail (that's what I'm trying to do)

This has been introduced in D68480. @__simt__, what was the idea behind this #if _LIBCPP_STD_VER >= 11?
There are other parts that use __cxx_atomic_wait but are not guarded on pre-C++11. Cf. lines 1668, 1670 and 2524, 2527.

I'm drawing a blank. Proceed.

ldionne accepted this revision.Dec 10 2020, 10:15 AM
This revision was not accepted when it landed; it landed in state Changes Planned.Dec 10 2020, 11:32 PM
This revision was automatically updated to reflect the committed changes.