Re: [PATCH] D23719: [libc++] Use C11 for atomics check
bcraig added a subscriber: bcraig. bcraig added a comment. I like the rationale here, but can we avoid pulling in headers at all? You could test _ _STDC_NO_ATOMICS_ _. You could also have some code like this... _Atomic int x; int main() { x += 1; return x; } https://reviews.llvm.org/D23719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23719: [libc++] Use C11 for atomics check
bcraig added a comment. In https://reviews.llvm.org/D23719#520952, @rsmith wrote: > Are we really guaranteed that the C and C++ compiler behave the same way > here? I don't see why that would necessarily be the case. For libc++, std::atomic is implemented in terms of _Atomic. So as long as the C++ compiler doesn't butcher _Atomic, it seems that the behavior would be the same. https://reviews.llvm.org/D23719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23719: [libc++] Use C11 for atomics check
bcraig added a comment. In https://reviews.llvm.org/D23719#520953, @smeenai wrote: > @bcraig: `__STDC_NO_ATOMICS__` wouldn't be defined for pre-C11 compilers > either, right? > > From what I understand of the original code sample, one of the purposes was > to check for 64-bit atomic support on 32-bit systems (hence the use of > `uintmax_t` and the check for `__atomic_fetch_add_8`). I don't really know of > a portable way of accomplishing that without at least including ``. Given the choice of including stdatomic.h or stdint.h, I'll gladly take stdint.h. libc++ shouldn't require a C11 enabled C library. C++14 only requires C99. https://reviews.llvm.org/D23719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23719: [libc++] Use C11 for atomics check
bcraig added a comment. In https://reviews.llvm.org/D23719#520969, @rsmith wrote: > In https://reviews.llvm.org/D23719#520954, @bcraig wrote: > > > In https://reviews.llvm.org/D23719#520952, @rsmith wrote: > > > > > Are we really guaranteed that the C and C++ compiler behave the same way > > > here? I don't see why that would necessarily be the case. > > > > > > For libc++, std::atomic is implemented in terms of _Atomic. So as long as > > the C++ compiler doesn't butcher _Atomic, it seems that the behavior would > > be the same. > > > I don't see any good reason to assume that's the case. GCC, for instance, > does not define _Atomic *at all* in C++ mode; the implementation used by > libc++ in that case is completely different. Also, as far as I know, libc++ > did not previously require the host to have a C11 compiler. And there's no > reason to assume that the C compiler picked up by cmake is in any way related > to the C++ compiler. > > Bottom line: if you want to know how the C++ compiler behaves, you need to > test the C++ compiler not the C compiler. I managed to completely miss "#define _Atomic(x) __gcc_atomic::__gcc_atomic_t" in the atomic header. On a different note, the general class of checks that LLVM and LIBCXX have in place to detect atomics generally don't work for cross-compilation. The set(CMAKE_REQUIRED_FLAGS ...) calls overwrite important settings. I end up setting HAVE_CXX_ATOMICS_WITHOUT_LIB=ON, HAVE_CXX_ATOMICS64_WITHOUT_LIB=ON, and LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB=ON explicitly, because the automatic check just doesn't work. So I look forward to the day when updates to these checks stop breaking my build. Given Richard's comments, I don't think this check is the one. https://reviews.llvm.org/D23719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. I will note that I'm only really looking at the tests, mostly from the perspective of a potential user. Thanks for getting C++ initializer lists in. The tests in general look fine. The omission of cross visibility reordering is fine as an initial step. Once multi-TU support is in, you'll definitely want a test for that. Comment at: test/clang-reorder-fields/ClassMixedInitialization.cpp:1-3 @@ +1,4 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,v,s %t.cpp -i -- -std=c++11 +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + Nit: This general pattern seems suspicious to me. It really seems like it should be some variation of "clang-reorder-fields [...] | FileCheck %s", without the cat and sed stuff. Is there a clang-reorder-fields mode where changes are output into a new file / stdout instead of modifying the file in place? Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. In https://reviews.llvm.org/D23279#522504, @djasper wrote: > In the meantime, I don't know whether we should check this in as a > standalone-tool and then merge into clang-refactor once ready. Ben, what do > you think? Well, I don't know how much you should count my opinion, but my preference is to check it in as a standalone tool first, then merge it into clang-rector once it is available. Maybe the build gets turned off by default if we aren't comfortable shipping an interim tool. I'd rather this not linger as a very long-term review though. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. In https://reviews.llvm.org/D23279#523449, @alexshap wrote: > @djasper, @bcraig, @aaron.ballman - many thanks for the comments and > suggestions, > please, let me know if you are waiting for any other changes on my side (for > v0) or if there is anything else i can do to make reviewing easier. I'm not waiting on anything for a v0. Again, just looking at the tests here. I would like to see in a future revision (or this one) a test for the multi-TU support. I would like the test to have one header with a struct definition, and two .c / .cpp files that use the struct definition in a way that would need to be modified. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation
bcraig added a comment. In https://reviews.llvm.org/D21803#530678, @tavianator wrote: > Ping? Well, I still think it's fine. Maybe a direct message to @mclow.lists or @EricWF? https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation
bcraig added a comment. The "@" will do a ping through phabricator, but a direct email is probably going to be your best bet at this point. https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24159: Fix PR30202 - notify_all_at_thread_exit seg faults if run from a raw pthread context.
bcraig added inline comments. Comment at: src/condition_variable.cpp:86 @@ +85,3 @@ +if (tl_ptr.get() == nullptr) { +tl_ptr.set_pointer(new __thread_struct); +} The standard synopsis of notify_all_at_thread_exit in the standard doesn't have a "Throws:" clause. I think that means that this is non-conformant. There is some phrasing in 30.2.2 [thread.req.exception]: Failure to allocate storage shall be reported as described in 17.6.5.12 [res.on.exception.handling]. But I don't see wording in that section that gives permission to throw from functions without Throws clauses. From a user perspective, I generally expect my synchronization primitives to be no-throw. I don't know if it is really possible to provide that guarantee with notify_all_at_thread_exit though, especially if we want it to work outside of a std::thread. https://reviews.llvm.org/D24159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24159: Fix PR30202 - notify_all_at_thread_exit seg faults if run from a raw pthread context.
bcraig added a comment. LGTM Comment at: src/condition_variable.cpp:86 @@ +85,3 @@ +if (tl_ptr.get() == nullptr) { +tl_ptr.set_pointer(new __thread_struct); +} EricWF wrote: > bcraig wrote: > > The standard synopsis of notify_all_at_thread_exit in the standard doesn't > > have a "Throws:" clause. I think that means that this is non-conformant. > > > > There is some phrasing in 30.2.2 [thread.req.exception]: > >Failure to allocate storage shall be reported as described in 17.6.5.12 > > [res.on.exception.handling]. > > But I don't see wording in that section that gives permission to throw from > > functions without Throws clauses. > > > > From a user perspective, I generally expect my synchronization primitives > > to be no-throw. I don't know if it is really possible to provide that > > guarantee with notify_all_at_thread_exit though, especially if we want it > > to work outside of a std::thread. > [res.on.exception.handling]/p4 > > > > Destructor operations defined in the C ++ standard library shall not throw > > exceptions. Every destructor > > in the C ++ standard library shall behave as if it had a non-throwing > > exception specification. Any other > > functions defined in the C ++ standard library that do not have an > > exception-specification may throw > > implementation-defined exceptions unless otherwise specified. [188] An > > implementation may strengthen this > > implicit exception-specification by adding an explicit one. > > And the relevant note: > > > 188) In particular, they can report a failure to allocate storage by > > throwing an exception of type bad_alloc, or a class derived > > from bad_alloc (18.6.3.1). Library implementations should report errors by > > throwing exceptions of or derived from the standard > > exception classes (18.6.3.1, 18.8, 19.2). > > So throwing `std::bad_alloc` is allowed, as it is almost everywhere in the > STL. Also the function already [allocates memory to store the new > entry](https://github.com/llvm-mirror/libcxx/blob/master/src/thread.cpp#L202). > > > > > > > > Yet again, I find that reading comprehension with regards to the standard isn't my strong suit :). I got to "Destructor operations" in p4 and stopped reading. I will still wish for a noexcept version of this function, but it's a pretty impractical wish. The implementation you have here is fine. https://reviews.llvm.org/D24159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h
bcraig added a subscriber: bcraig. bcraig added a comment. This seems related: https://reviews.llvm.org/D20596 In that (stale) review, I switch away from unique_ptr in general for locale related operations. https://reviews.llvm.org/D24374 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24374: [libc++] Avoid include in locale_win32.h
bcraig added a comment. In https://reviews.llvm.org/D24374#538521, @smeenai wrote: > @bcraig thanks for pointing me to that diff; there's a lot of nice cleanup > going on there. Were you planning on updating and following up on it? > > I also realized I forgot to adjust `locale_win32.cpp` for this diff. Will > re-upload with that fixed. I'm still in favor of that change, but I don't expect to have the time, resources, or permission to submit or test that change in the near future. I'm about to change jobs, and the new position doesn't involve working on the llvm projects. https://reviews.llvm.org/D24374 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24278: [analyzer] Extend bug reports with extra notes.
bcraig added a subscriber: bcraig. bcraig added a comment. Neat! I would have liked to have had this for the Excess Padding Checker. Currently, the padding checker has a very long diagnostic that recommends a new order for data members. I think a note (or fixit) would be more appropriate, but that support didn't exist previously. https://reviews.llvm.org/D24278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r299942 - [libc++] Fix unknown pragma warning on MSVC
Author: bcraig Date: Tue Apr 11 09:06:39 2017 New Revision: 299942 URL: http://llvm.org/viewvc/llvm-project?rev=299942&view=rev Log: [libc++] Fix unknown pragma warning on MSVC Modified: libcxx/trunk/include/limits Modified: libcxx/trunk/include/limits URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits?rev=299942&r1=299941&r2=299942&view=diff == --- libcxx/trunk/include/limits (original) +++ libcxx/trunk/include/limits Tue Apr 11 09:06:39 2017 @@ -101,12 +101,12 @@ template<> class numeric_limits #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -#include <__config> #include #include <__undef_min_max> ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r307751 - Fix unrepresentable enum for clang-cl unstable ABI
Author: bcraig Date: Tue Jul 11 18:45:13 2017 New Revision: 307751 URL: http://llvm.org/viewvc/llvm-project?rev=307751&view=rev Log: Fix unrepresentable enum for clang-cl unstable ABI When using LIBCXX_ABI_UNSTABLE=YES, clang-cl gave the following warning: P:\llvm_master\src\llvm\projects\libcxx\include\string(683,51): warning: enumerator value is not representable in the underlying type 'int' [-Wmicrosoft-enum-value] Fixed by switching from enums to static const size_type. https://reviews.llvm.org/D35174 Modified: libcxx/trunk/include/string Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307751&r1=307750&r2=307751&view=diff == --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Tue Jul 11 18:45:13 2017 @@ -676,11 +676,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? @@ -706,11 +706,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r302421 - Fix Windows tests when __config_site is present.
Author: bcraig Date: Mon May 8 08:15:22 2017 New Revision: 302421 URL: http://llvm.org/viewvc/llvm-project?rev=302421&view=rev Log: Fix Windows tests when __config_site is present. Previously, the force includes would complain about a missing _DEBUG symbol. Now we dump macros before adding the force includes to the command line. Modified: libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/utils/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302421&r1=302420&r2=302421&view=diff == --- libcxx/trunk/utils/libcxx/test/config.py (original) +++ libcxx/trunk/utils/libcxx/test/config.py Mon May 8 08:15:22 2017 @@ -1,1113 +1,1113 @@ -#===--===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===--===## - -import locale -import os -import platform -import pkgutil -import pipes -import re -import shlex -import shutil -import sys - -from libcxx.compiler import CXXCompiler -from libcxx.test.target_info import make_target_info -from libcxx.test.executor import * -from libcxx.test.tracing import * -import libcxx.util - -def loadSiteConfig(lit_config, config, param_name, env_name): -# We haven't loaded the site specific configuration (the user is -# probably trying to run on a test file directly, and either the site -# configuration hasn't been created by the build system, or we are in an -# out-of-tree build situation). -site_cfg = lit_config.params.get(param_name, - os.environ.get(env_name)) -if not site_cfg: -lit_config.warning('No site specific configuration file found!' - ' Running the tests in the default configuration.') -elif not os.path.isfile(site_cfg): -lit_config.fatal( -"Specified site configuration file does not exist: '%s'" % -site_cfg) -else: -lit_config.note('using site specific configuration at %s' % site_cfg) -ld_fn = lit_config.load_config - -# Null out the load_config function so that lit.site.cfg doesn't -# recursively load a config even if it tries. -# TODO: This is one hell of a hack. Fix it. -def prevent_reload_fn(*args, **kwargs): -pass -lit_config.load_config = prevent_reload_fn -ld_fn(config, site_cfg) -lit_config.load_config = ld_fn - -class Configuration(object): -# pylint: disable=redefined-outer-name -def __init__(self, lit_config, config): -self.lit_config = lit_config -self.config = config -self.is_windows = platform.system() == 'Windows' -self.cxx = None -self.cxx_is_clang_cl = None -self.cxx_stdlib_under_test = None -self.project_obj_root = None -self.libcxx_src_root = None -self.libcxx_obj_root = None -self.cxx_library_root = None -self.cxx_runtime_root = None -self.abi_library_root = None -self.link_shared = self.get_lit_bool('enable_shared', default=True) -self.debug_build = self.get_lit_bool('debug_build', default=False) -self.exec_env = {} -self.use_target = False -self.use_system_cxx_lib = False -self.use_clang_verify = False -self.long_tests = None -self.execute_external = False - -def get_lit_conf(self, name, default=None): -val = self.lit_config.params.get(name, None) -if val is None: -val = getattr(self.config, name, None) -if val is None: -val = default -return val - -def get_lit_bool(self, name, default=None, env_var=None): -def check_value(value, var_name): -if value is None: -return default -if isinstance(value, bool): -return value -if not isinstance(value, str): -raise TypeError('expected bool or string') -if value.lower() in ('1', 'true'): -return True -if value.lower() in ('', '0', 'false'): -return False -self.lit_config.fatal( -"parameter '{}' should be true or false".format(var_name)) - -conf_val = self.get_lit_conf(name) -if env_var is not None and env_var in os.environ and \ -os.environ[env_var] is not None: -val = os.environ[env_var] -if conf_val is not None: -self.lit_config.warning( -'Environment variable %s=%s is overriding explicit ' -'--param=%s=%s' % (env_var, val, name, conf_val)) -
[libcxx] r302496 - Revert "Fix Windows tests when __config_site is present."
Author: bcraig Date: Mon May 8 20:26:39 2017 New Revision: 302496 URL: http://llvm.org/viewvc/llvm-project?rev=302496&view=rev Log: Revert "Fix Windows tests when __config_site is present." It's 2017, and line endings are still an issue. Modified: libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/utils/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302496&r1=302495&r2=302496&view=diff == --- libcxx/trunk/utils/libcxx/test/config.py (original) +++ libcxx/trunk/utils/libcxx/test/config.py Mon May 8 20:26:39 2017 @@ -1,1113 +1,1113 @@ -#===--===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.TXT for details. -# -#===--===## - -import locale -import os -import platform -import pkgutil -import pipes -import re -import shlex -import shutil -import sys - -from libcxx.compiler import CXXCompiler -from libcxx.test.target_info import make_target_info -from libcxx.test.executor import * -from libcxx.test.tracing import * -import libcxx.util - -def loadSiteConfig(lit_config, config, param_name, env_name): -# We haven't loaded the site specific configuration (the user is -# probably trying to run on a test file directly, and either the site -# configuration hasn't been created by the build system, or we are in an -# out-of-tree build situation). -site_cfg = lit_config.params.get(param_name, - os.environ.get(env_name)) -if not site_cfg: -lit_config.warning('No site specific configuration file found!' - ' Running the tests in the default configuration.') -elif not os.path.isfile(site_cfg): -lit_config.fatal( -"Specified site configuration file does not exist: '%s'" % -site_cfg) -else: -lit_config.note('using site specific configuration at %s' % site_cfg) -ld_fn = lit_config.load_config - -# Null out the load_config function so that lit.site.cfg doesn't -# recursively load a config even if it tries. -# TODO: This is one hell of a hack. Fix it. -def prevent_reload_fn(*args, **kwargs): -pass -lit_config.load_config = prevent_reload_fn -ld_fn(config, site_cfg) -lit_config.load_config = ld_fn - -class Configuration(object): -# pylint: disable=redefined-outer-name -def __init__(self, lit_config, config): -self.lit_config = lit_config -self.config = config -self.is_windows = platform.system() == 'Windows' -self.cxx = None -self.cxx_is_clang_cl = None -self.cxx_stdlib_under_test = None -self.project_obj_root = None -self.libcxx_src_root = None -self.libcxx_obj_root = None -self.cxx_library_root = None -self.cxx_runtime_root = None -self.abi_library_root = None -self.link_shared = self.get_lit_bool('enable_shared', default=True) -self.debug_build = self.get_lit_bool('debug_build', default=False) -self.exec_env = {} -self.use_target = False -self.use_system_cxx_lib = False -self.use_clang_verify = False -self.long_tests = None -self.execute_external = False - -def get_lit_conf(self, name, default=None): -val = self.lit_config.params.get(name, None) -if val is None: -val = getattr(self.config, name, None) -if val is None: -val = default -return val - -def get_lit_bool(self, name, default=None, env_var=None): -def check_value(value, var_name): -if value is None: -return default -if isinstance(value, bool): -return value -if not isinstance(value, str): -raise TypeError('expected bool or string') -if value.lower() in ('1', 'true'): -return True -if value.lower() in ('', '0', 'false'): -return False -self.lit_config.fatal( -"parameter '{}' should be true or false".format(var_name)) - -conf_val = self.get_lit_conf(name) -if env_var is not None and env_var in os.environ and \ -os.environ[env_var] is not None: -val = os.environ[env_var] -if conf_val is not None: -self.lit_config.warning( -'Environment variable %s=%s is overriding explicit ' -'--param=%s=%s' % (env_var, val, name, conf_val)) -return check_value(val, env_var) -return check_value(conf_val, name) - -d
[libcxx] r302497 - Fix Windows tests when __config_site is present.
Author: bcraig Date: Mon May 8 20:34:12 2017 New Revision: 302497 URL: http://llvm.org/viewvc/llvm-project?rev=302497&view=rev Log: Fix Windows tests when __config_site is present. Previously, the force includes would complain about a missing _DEBUG symbol. Now we dump macros before adding the force includes to the command line. Now with proper newlines. Modified: libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/utils/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302497&r1=302496&r2=302497&view=diff == --- libcxx/trunk/utils/libcxx/test/config.py (original) +++ libcxx/trunk/utils/libcxx/test/config.py Mon May 8 20:34:12 2017 @@ -546,6 +546,7 @@ class Configuration(object): def configure_compile_flags_header_includes(self): support_path = os.path.join(self.libcxx_src_root, 'test', 'support') +self.configure_config_site_header() if self.cxx_stdlib_under_test != 'libstdc++' and \ not self.is_windows: self.cxx.compile_flags += [ @@ -561,7 +562,6 @@ class Configuration(object): '-include', os.path.join(support_path, 'set_windows_crt_report_mode.h') ] -self.configure_config_site_header() cxx_headers = self.get_lit_conf('cxx_headers') if cxx_headers == '' or (cxx_headers is None and self.cxx_stdlib_under_test != 'libc++'): ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14403: Create install targets for scan-build and scan-view
bcraig added a subscriber: bcraig. bcraig added a comment. For what it's worth, our internal branch installs these by default, and I was unpleasantly surprised when I found that upstream didn't. http://reviews.llvm.org/D14403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14502: [PATCH] Do not create a clang-install target for MSVC solutions
bcraig added a subscriber: bcraig. bcraig added a comment. Does this affect the presence or functionality of the "INSTALL" project? http://reviews.llvm.org/D14502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14506: Porting shouldVisitImplicitCode to DataRecursiveASTVisitor.
bcraig created this revision. bcraig added reviewers: zaks.anna, rsmith. bcraig added a subscriber: cfe-commits. Herald added a subscriber: klimek. RecursiveASTVisitor allows visitors to specify whether they wish to visit implicitly created code or not. I have ported that code over to DataRecursiveASTVisitor. DataRecursiveASTVisitor didn't have any tests before this change, so I forked RecursiveASTVisitorTestExprVisitor. This test exercised some defaultArgumentWasInherited() cases, so I got those working as well. I plan on using this new feature in a checker that searches for excess padding. http://reviews.llvm.org/D14506 Files: include/clang/AST/DataRecursiveASTVisitor.h unittests/Tooling/CMakeLists.txt unittests/Tooling/DataRecursiveASTVisitorTestExprVisitor.cpp unittests/Tooling/LookupTest.cpp unittests/Tooling/TestVisitor.h Index: unittests/Tooling/TestVisitor.h === --- unittests/Tooling/TestVisitor.h +++ unittests/Tooling/TestVisitor.h @@ -17,6 +17,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/DataRecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendAction.h" @@ -33,11 +34,11 @@ /// /// Visits template instantiations and implicit code by default. template -class TestVisitor : public RecursiveASTVisitor { +class TestVisitorImpl : public T { public: - TestVisitor() { } + TestVisitorImpl() { } - virtual ~TestVisitor() { } + virtual ~TestVisitorImpl() { } enum Language { Lang_C, @@ -80,7 +81,7 @@ class FindConsumer : public ASTConsumer { public: -FindConsumer(TestVisitor *Visitor) : Visitor(Visitor) {} +FindConsumer(TestVisitorImpl *Visitor) : Visitor(Visitor) {} void HandleTranslationUnit(clang::ASTContext &Context) override { Visitor->Context = &Context; @@ -88,12 +89,12 @@ } private: -TestVisitor *Visitor; +TestVisitorImpl *Visitor; }; class TestAction : public ASTFrontendAction { public: -TestAction(TestVisitor *Visitor) : Visitor(Visitor) {} +TestAction(TestVisitorImpl *Visitor) : Visitor(Visitor) {} std::unique_ptr CreateASTConsumer(CompilerInstance &, llvm::StringRef dummy) override { @@ -102,12 +103,17 @@ } protected: -TestVisitor *Visitor; +TestVisitorImpl *Visitor; }; ASTContext *Context; }; +template +using TestVisitor = TestVisitorImpl>; +template +using TestDataVisitor = TestVisitorImpl>; + /// \brief A RecursiveASTVisitor to check that certain matches are (or are /// not) observed during visitation. /// @@ -229,6 +235,10 @@ std::vector DisallowedMatches; std::vector ExpectedMatches; }; + +template +using ExpectedLocationDataVisitor = ExpectedLocationVisitor; + } #endif Index: unittests/Tooling/LookupTest.cpp === --- unittests/Tooling/LookupTest.cpp +++ unittests/Tooling/LookupTest.cpp @@ -23,7 +23,7 @@ bool TraverseDecl(Decl *D) { DeclStack.push_back(D); -bool Ret = TestVisitor::TraverseDecl(D); +bool Ret = TestVisitor::TraverseDecl(D); DeclStack.pop_back(); return Ret; } Index: unittests/Tooling/DataRecursiveASTVisitorTestExprVisitor.cpp === --- /dev/null +++ unittests/Tooling/DataRecursiveASTVisitorTestExprVisitor.cpp @@ -0,0 +1,224 @@ +//===- unittest/Tooling/DataRecursiveASTVisitorTestExprVisitor.cpp ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "TestVisitor.h" +#include + +using namespace clang; + +namespace { + +class ParenExprVisitor : public ExpectedLocationDataVisitor { +public: + bool VisitParenExpr(ParenExpr *Parens) { +Match("", Parens->getExprLoc()); +return true; + } +}; + +TEST(DataRecursiveASTVisitor, VisitsParensDuringDataRecursion) { + ParenExprVisitor Visitor; + Visitor.ExpectMatch("", 1, 9); + EXPECT_TRUE(Visitor.runOver("int k = (4) + 9;\n")); +} + +class TemplateArgumentLocTraverser + : public ExpectedLocationDataVisitor { +public: + bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) { +std::string ArgStr; +llvm::raw_string_ostream Stream(ArgStr); +const TemplateArgument &Arg = ArgLoc.getArgument(); + +Arg.print(Context->getPrintingPolicy(), Stream); +Match(Stream.str(), ArgLoc.getLocation()); +return ExpectedLocationDataVisitor:: + TraverseTemplateArgumentLoc(ArgLoc); + } +}; + +TEST(DataRecursiveASTVisitor, VisitsClassTemplateTemplateParmDefaultArgument) { + TemplateArgumentLocTraverser Visitor; + Visitor.ExpectMatch("X", 2, 40); + E
Re: [PATCH] D14502: [PATCH] Do not create a clang-install target for MSVC solutions
bcraig added a comment. In a text file, I have a big long cmake invocation. Part of that invocation is the following: -DCMAKE_INSTALL_PREFIX=c:/install/Tools The VC "INSTALL" project copies files there, in a very unix-y hierarchy (i.e. c:\install\Tools\bin, c:\install\Tools\include, c:\install\Tools\etc, and so on). http://reviews.llvm.org/D14502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14583: Report Windows error code in a fatal error after a system call
bcraig added a subscriber: bcraig. bcraig added a comment. Looks good to me, but since this is in the LLVMSupport library, you should probably add llvm-commits to the subscriber list. http://reviews.llvm.org/D14583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22470: [libcxx] Improve shared_ptr dtor performance
bcraig created this revision. bcraig added reviewers: jfb, mclow.lists, EricWF. bcraig added a subscriber: cfe-commits. If the last destruction is uncontended, skip the atomic store on __shared_weak_owners_. For x86_64, this results in an 8% improvement in shared_ptr ctor+dtor performance. Old benchmarks/shared_ptr_create_destroy.cpp: 26.8638 seconds New benchmarks/shared_ptr_create_destroy.cpp: 24.6019 seconds The increment / decrement code path did not degrade on X86_64. Old benchmarks/shared_ptr_inc_dec_ref.cpp: 13.0896 seconds New benchmarks/shared_ptr_inc_dec_ref.cpp: 13.0463 seconds https://reviews.llvm.org/D22470 Files: benchmarks/shared_ptr_create_destroy.cpp benchmarks/shared_ptr_inc_dec_ref.cpp src/memory.cpp Index: src/memory.cpp === --- src/memory.cpp +++ src/memory.cpp @@ -96,7 +96,35 @@ void __shared_weak_count::__release_weak() _NOEXCEPT { -if (decrement(__shared_weak_owners_) == -1) +// NOTE: The acquire load here is an optimization of the very +// common case where a shared pointer is being destructed while +// having no other contended references. +// +// BENEFIT: We avoid expensive atomic stores like XADD and STREX +// in a common case. Those instructions are slow and do nasty +// things to caches. +// +// IS THIS SAFE? Yes. During weak destruction, if we see that we +// are the last reference, we know that no-one else is accessing +// us. If someone were accessing us, then they would be doing so +// while the last shared / weak_ptr was being destructed, and +// that's undefined anyway. +// +// If we see anything other than a 0, then we have possible +// contention, and need to use an atomicrmw primitive. +// The same arguments don't apply for increment, where it is legal +// (though inadvisable) to share shared_ptr references between +// threads, and have them all get copied at once. The argument +// also doesn't apply for __release_shared, because an outstanding +// weak_ptr::lock() could read / modify the shared count. +if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0) +{ +// no need to do this store, because we are about +// to destroy everything. +//__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release); +__on_zero_shared_weak(); +} +else if (decrement(__shared_weak_owners_) == -1) __on_zero_shared_weak(); } Index: benchmarks/shared_ptr_inc_dec_ref.cpp === --- /dev/null +++ benchmarks/shared_ptr_inc_dec_ref.cpp @@ -0,0 +1,38 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include +#include +#include +#include + +void clobber() +{ +asm volatile("" : : : "memory"); +} + +std::atomic g_int; +std::atomic g_other; + +int main() { + auto a = std::chrono::high_resolution_clock::now(); + auto sp = std::make_shared(g_int.load(std::memory_order_relaxed)); + { +clobber(); +for (int i = 0; i < 10; ++i) +{ + std::shared_ptr sp2(sp); + g_other.store(*sp2, std::memory_order_relaxed); +} +clobber(); + } + auto b = std::chrono::high_resolution_clock::now(); + std::cout<(b - a).count()/10.0<<" seconds"< +#include +#include +#include + +void clobber() +{ +asm volatile("" : : : "memory"); +} + +std::atomic g_int; +std::atomic g_other; + +int main() { + auto a = std::chrono::high_resolution_clock::now(); + { +clobber(); +for (int i = 0; i < 10; ++i) +{ + auto sp = std::make_shared(g_int.load(std::memory_order_relaxed)); + g_other.store(*sp, std::memory_order_relaxed); +} +clobber(); + } + auto b = std::chrono::high_resolution_clock::now(); + std::cout<(b - a).count()/10.0<<" seconds"<___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22292: [libunwind] Fix unw_getcontext for ARMv6-m
bcraig added a subscriber: bcraig. Comment at: src/UnwindRegistersRestore.S:325 @@ -324,4 +324,3 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv) -#if !defined(__ARM_ARCH_ISA_ARM) - ldr r2, [r0, #52] - ldr r3, [r0, #60] +#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1 + @ r8-r12: ldr into r1-r5, then mov to r8-r12 weimingz wrote: > originally, r8-r12 were not restored. Was that some existing bug? I'm not sure why r12 is getting messed with here. It is intended as a GOT/PLT scratch register. r8+ isn't ubiquitously available in Thumb state according to the ATPCS. The AAPCS says that r4-r8, r10, r11, and SP must be preserved. r9 can optionally be preserved. https://reviews.llvm.org/D22292 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22470: [libcxx] Improve shared_ptr dtor performance
bcraig updated the summary for this revision. bcraig updated this revision to Diff 64504. bcraig added a comment. Added weak_ptr benchmark, as that's where the cost shifted. https://reviews.llvm.org/D22470 Files: benchmarks/shared_ptr_create_destroy.cpp benchmarks/shared_ptr_inc_dec_ref.cpp benchmarks/weak_ptr_inc_dec_ref.cpp src/memory.cpp Index: src/memory.cpp === --- src/memory.cpp +++ src/memory.cpp @@ -96,7 +96,35 @@ void __shared_weak_count::__release_weak() _NOEXCEPT { -if (decrement(__shared_weak_owners_) == -1) +// NOTE: The acquire load here is an optimization of the very +// common case where a shared pointer is being destructed while +// having no other contended references. +// +// BENEFIT: We avoid expensive atomic stores like XADD and STREX +// in a common case. Those instructions are slow and do nasty +// things to caches. +// +// IS THIS SAFE? Yes. During weak destruction, if we see that we +// are the last reference, we know that no-one else is accessing +// us. If someone were accessing us, then they would be doing so +// while the last shared / weak_ptr was being destructed, and +// that's undefined anyway. +// +// If we see anything other than a 0, then we have possible +// contention, and need to use an atomicrmw primitive. +// The same arguments don't apply for increment, where it is legal +// (though inadvisable) to share shared_ptr references between +// threads, and have them all get copied at once. The argument +// also doesn't apply for __release_shared, because an outstanding +// weak_ptr::lock() could read / modify the shared count. +if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0) +{ +// no need to do this store, because we are about +// to destroy everything. +//__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release); +__on_zero_shared_weak(); +} +else if (decrement(__shared_weak_owners_) == -1) __on_zero_shared_weak(); } Index: benchmarks/weak_ptr_inc_dec_ref.cpp === --- /dev/null +++ benchmarks/weak_ptr_inc_dec_ref.cpp @@ -0,0 +1,37 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include +#include +#include +#include + +void clobber() +{ +asm volatile("" : : : "memory"); +} + +std::atomic g_int; +std::atomic g_other; + +int main() { + auto a = std::chrono::high_resolution_clock::now(); + auto sp = std::make_shared(g_int.load(std::memory_order_relaxed)); + { +clobber(); +for (int i = 0; i < 10; ++i) +{ + std::weak_ptr wp(sp); +} +clobber(); + } + auto b = std::chrono::high_resolution_clock::now(); + std::cout<(b - a).count()/10.0<<" seconds"< +#include +#include +#include + +void clobber() +{ +asm volatile("" : : : "memory"); +} + +std::atomic g_int; +std::atomic g_other; + +int main() { + auto a = std::chrono::high_resolution_clock::now(); + auto sp = std::make_shared(g_int.load(std::memory_order_relaxed)); + { +clobber(); +for (int i = 0; i < 10; ++i) +{ + std::shared_ptr sp2(sp); + g_other.store(*sp2, std::memory_order_relaxed); +} +clobber(); + } + auto b = std::chrono::high_resolution_clock::now(); + std::cout<(b - a).count()/10.0<<" seconds"< +#include +#include +#include + +void clobber() +{ +asm volatile("" : : : "memory"); +} + +std::atomic g_int; +std::atomic g_other; + +int main() { + auto a = std::chrono::high_resolution_clock::now(); + { +clobber(); +for (int i = 0; i < 10; ++i) +{ + auto sp = std::make_shared(g_int.load(std::memory_order_relaxed)); + g_other.store(*sp, std::memory_order_relaxed); +} +clobber(); + } + auto b = std::chrono::high_resolution_clock::now(); + std::cout<(b - a).count()/10.0<<" seconds"<___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22557: [libcxx] Diagnose invalid memory order arguments in . Fixes PR21179.
bcraig added a subscriber: bcraig. Comment at: include/atomic:569 @@ +568,3 @@ +__attribute__ ((__enable_if__(__m == memory_order_release \ + || __m == memory_order_acq_rel, ""))) \ +__attribute__ ((__unavailable__("memory order argument to atomic operation is invalid"))) what about relaxed? https://reviews.llvm.org/D22557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22557: [libcxx] Diagnose invalid memory order arguments in . Fixes PR21179.
bcraig added inline comments. Comment at: include/atomic:569 @@ +568,3 @@ +__attribute__ ((__enable_if__(__m == memory_order_release \ + || __m == memory_order_acq_rel, ""))) \ +__attribute__ ((__unavailable__("memory order argument to atomic operation is invalid"))) Gah, read the logic backwards... and even backwards my comments are incomplete. https://reviews.llvm.org/D22557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22470: [libcxx] Improve shared_ptr dtor performance
bcraig added a comment. I am going to submit the code changes and the tests independently. I'm having trouble getting cmake to use the right compiler for the libcxx-benchmarks target. https://reviews.llvm.org/D22470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r277357 - Improve shared_ptr dtor performance
Author: bcraig Date: Mon Aug 1 12:51:26 2016 New Revision: 277357 URL: http://llvm.org/viewvc/llvm-project?rev=277357&view=rev Log: Improve shared_ptr dtor performance If the last destruction is uncontended, skip the atomic store on __shared_weak_owners_. This shifts some costs from normal shared_ptr usage to weak_ptr uses. https://reviews.llvm.org/D22470 Modified: libcxx/trunk/src/memory.cpp Modified: libcxx/trunk/src/memory.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=277357&r1=277356&r2=277357&view=diff == --- libcxx/trunk/src/memory.cpp (original) +++ libcxx/trunk/src/memory.cpp Mon Aug 1 12:51:26 2016 @@ -96,7 +96,35 @@ __shared_weak_count::__release_shared() void __shared_weak_count::__release_weak() _NOEXCEPT { -if (decrement(__shared_weak_owners_) == -1) +// NOTE: The acquire load here is an optimization of the very +// common case where a shared pointer is being destructed while +// having no other contended references. +// +// BENEFIT: We avoid expensive atomic stores like XADD and STREX +// in a common case. Those instructions are slow and do nasty +// things to caches. +// +// IS THIS SAFE? Yes. During weak destruction, if we see that we +// are the last reference, we know that no-one else is accessing +// us. If someone were accessing us, then they would be doing so +// while the last shared / weak_ptr was being destructed, and +// that's undefined anyway. +// +// If we see anything other than a 0, then we have possible +// contention, and need to use an atomicrmw primitive. +// The same arguments don't apply for increment, where it is legal +// (though inadvisable) to share shared_ptr references between +// threads, and have them all get copied at once. The argument +// also doesn't apply for __release_shared, because an outstanding +// weak_ptr::lock() could read / modify the shared count. +if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0) +{ +// no need to do this store, because we are about +// to destroy everything. +//__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release); +__on_zero_shared_weak(); +} +else if (decrement(__shared_weak_owners_) == -1) __on_zero_shared_weak(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22470: [libcxx] Improve shared_ptr dtor performance
bcraig closed this revision. bcraig added a comment. committed https://reviews.llvm.org/rL277357: Improve shared_ptr dtor performance. https://reviews.llvm.org/D22470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r277373 - Adding smart_ptr benchmark
Author: bcraig Date: Mon Aug 1 14:56:39 2016 New Revision: 277373 URL: http://llvm.org/viewvc/llvm-project?rev=277373&view=rev Log: Adding smart_ptr benchmark Initial draft here: https://reviews.llvm.org/D22470 ... though this is Eric Fiselier's rewrite to fit in with Google Benchmark. Added: libcxx/trunk/benchmarks/util_smartptr.bench.cpp Added: libcxx/trunk/benchmarks/util_smartptr.bench.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/util_smartptr.bench.cpp?rev=277373&view=auto == --- libcxx/trunk/benchmarks/util_smartptr.bench.cpp (added) +++ libcxx/trunk/benchmarks/util_smartptr.bench.cpp Mon Aug 1 14:56:39 2016 @@ -0,0 +1,42 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include + +#include "benchmark/benchmark_api.h" + +static void BM_SharedPtrCreateDestroy(benchmark::State& st) { + while (st.KeepRunning()) { +auto sp = std::make_shared(42); +benchmark::DoNotOptimize(sp.get()); + } +} +BENCHMARK(BM_SharedPtrCreateDestroy); + +static void BM_SharedPtrIncDecRef(benchmark::State& st) { + auto sp = std::make_shared(42); + benchmark::DoNotOptimize(sp.get()); + while (st.KeepRunning()) { +std::shared_ptr sp2(sp); +benchmark::ClobberMemory(); + } +} +BENCHMARK(BM_SharedPtrIncDecRef); + +static void BM_WeakPtrIncDecRef(benchmark::State& st) { + auto sp = std::make_shared(42); + benchmark::DoNotOptimize(sp.get()); + while (st.KeepRunning()) { +std::weak_ptr wp(sp); +benchmark::ClobberMemory(); + } +} +BENCHMARK(BM_WeakPtrIncDecRef); + +BENCHMARK_MAIN() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r277456 - Fixing 'Aquire' typo and libcxx build.
Author: bcraig Date: Tue Aug 2 08:43:48 2016 New Revision: 277456 URL: http://llvm.org/viewvc/llvm-project?rev=277456&view=rev Log: Fixing 'Aquire' typo and libcxx build. Modified: libcxx/trunk/src/include/atomic_support.h libcxx/trunk/src/memory.cpp Modified: libcxx/trunk/src/include/atomic_support.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/atomic_support.h?rev=277456&r1=277455&r2=277456&view=diff == --- libcxx/trunk/src/include/atomic_support.h (original) +++ libcxx/trunk/src/include/atomic_support.h Tue Aug 2 08:43:48 2016 @@ -45,7 +45,7 @@ namespace { enum __libcpp_atomic_order { _AO_Relaxed = __ATOMIC_RELAXED, _AO_Consume = __ATOMIC_CONSUME, -_AO_Aquire = __ATOMIC_ACQUIRE, +_AO_Acquire = __ATOMIC_ACQUIRE, _AO_Release = __ATOMIC_RELEASE, _AO_Acq_Rel = __ATOMIC_ACQ_REL, _AO_Seq = __ATOMIC_SEQ_CST Modified: libcxx/trunk/src/memory.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=277456&r1=277455&r2=277456&view=diff == --- libcxx/trunk/src/memory.cpp (original) +++ libcxx/trunk/src/memory.cpp Tue Aug 2 08:43:48 2016 @@ -117,7 +117,7 @@ __shared_weak_count::__release_weak() _N // threads, and have them all get copied at once. The argument // also doesn't apply for __release_shared, because an outstanding // weak_ptr::lock() could read / modify the shared count. -if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Aquire) == 0) +if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0) { // no need to do this store, because we are about // to destroy everything. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a subscriber: bcraig. bcraig added a comment. In https://reviews.llvm.org/D23279#509017, @Eugene.Zelenko wrote: > Do we really need standalone tool for this purpose? If I'm not mistaken, > Static Analyzer already has clang-analyzer-optin.performance.Padding check, > which is also available through Clang-tidy. The excess padding checker doesn't provide a fix-it. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. It is very common for developers to put comments near a field. If this tool doesn't move the "anchored" comments, then its utility will be severely limited. Does this tool also reorder C++ member initializer lists? If it doesn't, then running this tool will introduce warnings in code. The static analyzer does have code to find a less padded ordering for a structure (lib/StaticAnalyzer/Checkers/PaddingChecker.cpp, calculateOptimalPad()). You may want to consider using / factoring out that code for this tool. It does have substantial limitations on which kinds of records it can look at though. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. In https://reviews.llvm.org/D23279#510178, @omtcyfz wrote: > In https://reviews.llvm.org/D23279#510167, @alexshap wrote: > > > my point is the following: this tool helps perform some operation (changing > > the order of fields), > > if smb decides to do it manually - the result will have exactly the same > > issue. > > > While creating tools for automated refactoring our goal is essentially to > perform a refactoring action **without** breaking codebases. For clang-tidy changes, I think that is reasonable. For refactoring, I don't think it is reasonably to have that same expectation. Refactoring an un-inlined method from a .cpp file to an inlined method in a .h can break code. Changing a method signature can definitely break code. Even adding a method (during an "extract") can break code that uses C++ template SFINAE to detect the existence of members. Those are all useful refactorings though, despite the possibility of breakage. I would like there to be some heuristic for how much breakage is too much breakage though. I don't have a good recommendation for what that heuristic should be. I do think that an automated tool will do a better job of changing field orderings in a non-breaking way than most people would, mostly due to initializer lists. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. In https://reviews.llvm.org/D23279#511187, @omtcyfz wrote: > In https://reviews.llvm.org/D23279#510234, @alexshap wrote: > > > > I do think that an automated tool will do a better job of changing field > > > orderings in a non-breaking way than most people would, mostly due to > > > initializer lists. > > > > > > yeah, that was the original motivation > > > How does that justify its current state, in which it does breaks codebases > with more than 1 TU? Yeah, that aspect probably needs work :). Accepting a compilation database seems like a good way to correct that. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23279: clang-reorder-fields
bcraig added a comment. In https://reviews.llvm.org/D23279#511266, @omtcyfz wrote: > In https://reviews.llvm.org/D23279#511202, @bcraig wrote: > > > In https://reviews.llvm.org/D23279#511187, @omtcyfz wrote: > > > > > In https://reviews.llvm.org/D23279#510234, @alexshap wrote: > > > > > > > > I do think that an automated tool will do a better job of changing > > > > > field orderings in a non-breaking way than most people would, mostly > > > > > due to initializer lists. > > > > > > > > > > > > yeah, that was the original motivation > > > > > > > > > How does that justify its current state, in which it does breaks > > > codebases with more than 1 TU? > > > > > > Yeah, that aspect probably needs work :). Accepting a compilation database > > seems like a good way to correct that. > > > Accepting compilation database doesn't solve the problem completely. Most of > the existing Clang-based tools accept compilation database, but they do not > pass information between translation units, which is the most important part. I will agree that compilation databases are a (mostly) necessary, but not sufficient part of the solution. The refactoring tool will need to be careful about changing the structure definition. It needs to remember (across TUs) what the old definition was and what the desired definition is, so that it can correctly fix up the uses and initializer lists. If it saves the files too aggressively, then there will be some serious problems. So lots of things for @alexshap to work on. Repository: rL LLVM https://reviews.llvm.org/D23279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.
bcraig added a comment. Note: In the future, try to provide more context lines in the patch. http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface I'm mostly fine with the algorithmic changes. I'm not thrilled with the formatting of the error message, but I'm not sure if much can be done about it without causing tons of work. Here's my wishlist items... 1. List each field on an individual line, preferably with the type mentioned as well. 2. Get the field ordering information into a note or fixit. 3. Provide a more stable ("stable" as in stable sort) field ordering. I've got an inline comment describing what I mean with that. I'm not sure if my first two items are possible without large overhauls. The third isn't a big deal either. So to recap, I'm strongly in favor of the idea. I'm weakly in favor of the implementation. I'll give you a shot to polish things a bit if you have the inclination. If you don't, then I won't let my idea of a perfect (and expensive) implementation stand in the way of this good implementation. https://reviews.llvm.org/D23387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.
bcraig added a comment. I am kind of interested in what the warning message for clang::Sema in clang/include/clang/Sema/Sema.h looks like. When I last analyzed that file, there was a bunch of padding. It's a very long class though, so it can stress the usability of your messages. https://reviews.llvm.org/D23387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.
bcraig added a comment. LGTM. Thanks for the patch! Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217 @@ +216,3 @@ +// then large field indices to small field indices +return std::make_tuple(Align, -Size, + Field ? -static_cast(Field->getFieldIndex()) Nit: I think std::tie is the more idiomatic way to do this (not that I had it right before either). You get less copying of values, though that doesn't matter much for the types we are using here. https://reviews.llvm.org/D23387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23387: [Analyzer] Report found fields order in PaddingChecker.
bcraig added a comment. LGTM Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217 @@ +216,3 @@ +// then large field indices to small field indices +return std::make_tuple(Align, -Size, + Field ? -static_cast(Field->getFieldIndex()) alexshap wrote: > bcraig wrote: > > Nit: > > I think std::tie is the more idiomatic way to do this (not that I had it > > right before either). You get less copying of values, though that doesn't > > matter much for the types we are using here. > std::tie expects an l-value for 2nd argument, > so it doesn't compile (if i switch to std::tie): > > /Users/alexshap/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:217:16: > error: > no matching function for call to 'tie' > return std::tie(Align, -Size, >^~~~ > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:814:1: > note: > candidate function [with _Tp = clang::CharUnits, > int>] not viable: expects an l-value for 2nd argument > tie(_Tp&... __t) _NOEXCEPT > Fair enough. std::make_tuple it is. https://reviews.llvm.org/D23387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test
bcraig added a comment. @mclow.lists ping http://reviews.llvm.org/D15539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test
bcraig added a comment. Any objections to using the original sizes, but constructing the objects at global scope? That fixes the stack usage without significantly changing the layout characteristics of the test? http://reviews.llvm.org/D15539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test
bcraig updated the summary for this revision. bcraig updated this revision to Diff 47327. http://reviews.llvm.org/D15539 Files: test/dynamic_cast14.pass.cpp Index: test/dynamic_cast14.pass.cpp === --- test/dynamic_cast14.pass.cpp +++ test/dynamic_cast14.pass.cpp @@ -213,20 +213,20 @@ A13* getA13() {return this;} }; +A3 a3; +A4 a4; +A5 a5; +A6 a6; +A7 a7; +A8 a8; +A9 a9; +A10 a10; +A11 a11; +A12 a12; +A13 a13; + void test() { -A3 a3; -A4 a4; -A5 a5; -A6 a6; -A7 a7; -A8 a8; -A9 a9; -A10 a10; -A11 a11; -A12 a12; -A13 a13; - assert(dynamic_cast(a3.getA1_3()) == a3.getA3()); assert(dynamic_cast(a3.getA2()) == a3.getA3()); @@ -934,20 +934,20 @@ A13* getA13() {return this;} }; +A3 a3; +A4 a4; +A5 a5; +A6 a6; +A7 a7; +A8 a8; +A9 a9; +A10 a10; +A11 a11; +A12 a12; +A13 a13; + void test() { -A3 a3; -A4 a4; -A5 a5; -A6 a6; -A7 a7; -A8 a8; -A9 a9; -A10 a10; -A11 a11; -A12 a12; -A13 a13; - assert(dynamic_cast(a3.getA1_3()) == 0); assert(dynamic_cast(a3.getA2()) == a3.getA3()); @@ -1655,20 +1655,20 @@ A13* getA13() {return this;} }; +A3 a3; +A4 a4; +A5 a5; +A6 a6; +A7 a7; +A8 a8; +A9 a9; +A10 a10; +A11 a11; +A12 a12; +A13 a13; + void test() { -A3 a3; -A4 a4; -A5 a5; -A6 a6; -A7 a7; -A8 a8; -A9 a9; -A10 a10; -A11 a11; -A12 a12; -A13 a13; - assert(dynamic_cast(a3.getA1_3()) == a3.getA3()); assert(dynamic_cast(a3.getA2()) == 0); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16639: [libcxx] Limit catopen usage to unix-like OSes
bcraig updated the summary for this revision. bcraig updated this revision to Diff 47328. bcraig added a comment. Moved the CATOPEN config check back to __config. Saving a larger locale refactor for later (but oh boy is it coming). http://reviews.llvm.org/D16639 Files: include/__config Index: include/__config === --- include/__config +++ include/__config @@ -714,10 +714,12 @@ #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif -#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \ -!defined(__CloudABI__) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +// Most unix variants have catopen. These are the specific ones that don't. +#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_CATOPEN 1 #endif +#endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 Index: include/__config === --- include/__config +++ include/__config @@ -714,10 +714,12 @@ #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif -#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \ -!defined(__CloudABI__) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +// Most unix variants have catopen. These are the specific ones that don't. +#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_CATOPEN 1 #endif +#endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r260381 - Limit catopen usage to unix-like OSes
Author: bcraig Date: Wed Feb 10 07:47:25 2016 New Revision: 260381 URL: http://llvm.org/viewvc/llvm-project?rev=260381&view=rev Log: Limit catopen usage to unix-like OSes Operating systems that are not unix-like are unlikely to have access to catopen. Instead of black-listing each one, we now filter out all non-unix operating systems first. We then exclude the unix-like operating systems that don't have catopen. _WIN32 counts as a unix-like operating system because of cygwin. http://reviews.llvm.org/D16639 Modified: libcxx/trunk/include/__config Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=260381&r1=260380&r2=260381&view=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Wed Feb 10 07:47:25 2016 @@ -719,10 +719,12 @@ template struct __static_asse #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif -#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \ -!defined(__CloudABI__) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +// Most unix variants have catopen. These are the specific ones that don't. +#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_CATOPEN 1 #endif +#endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added inline comments. Comment at: test/libcxx/test/config.py:469 @@ +468,3 @@ +if cxx_library_root: +abs_path = cxx_library_root + "/libc++.a" +self.cxx.link_flags += [abs_path] EricWF wrote: > Why not just wrap it in '-B,-static'? I know exactly which binary I want to link against. Running through the linker search path can't make this work better, but it can make it work worse. Comment at: test/libcxx/test/target_info.py:173 @@ -164,2 +172,3 @@ llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) +shared_libcxx = self.full_config.get_lit_bool('enable_shared', False) flags += ['-lm'] EricWF wrote: > Hmm... this would have a different default compared to elsewhere after my > suggested edits. When testing libcxx, it's going to be difficult to get an unset enable_shared, so the default doesn't matter that much in that situation. It might matter more with libcxxabi. I will investigate. Regardless, I'm pretty sure "False" is the default here due to copy / paste rather than long, careful consideration. http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17146: [libcxx] locale portability refactor
bcraig added a comment. In http://reviews.llvm.org/D17146#350382, @mclow.lists wrote: > > I'm open to recommendations on ways to test this that are better than > > "Submit, watch build bots, revert as necessary". > > > My suggestion is to do this incrementally. > Implement the infrastructure bits, then move (say) Linux over to use the new > bits. > Then (say) Mac OS X. Then FreeBSD. Then IBM. Then Windows. > Repeat until everyone's moved over; watching the testbots (and getting the > people who committed support for each of these systems involved). > Then, when they're all moved, delete the old stuff. I can see some places where I can improve the reviewability of the code by doing things incrementally. Basically, I can shuffle code around in a few batches of changes first without substantially modifying the code in a few sets of changes. Then I can do the big _CXX_ transformation after that. I will see about opening different reviews for those smaller renames / shuffles, and link back to this review as justification. I am hesitant to take the approach that you've described (port one platform at a time). I think that would make locale.cpp and have lots of code that looks like the following... #if _USE_THE_NEW_STUFF return _CXX_btowc_l(c, __l); #elif _LIBCPP_LOCALE__L_EXTENSIONS return btowc_l(c, __l); #else return __btowc_l(c, __l); #endif With this approach, I'd still be doing a lot of blind submissions, and in the short term, the code would get worse. If, for whatever reason, I'm unable to complete the port and delete all the old stuff, then the refactor turns into a net negative. http://reviews.llvm.org/D17146 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig updated this revision to Diff 48112. bcraig added a comment. Addressed EricWF's feedback. http://reviews.llvm.org/D16545 Files: CMakeLists.txt test/CMakeLists.txt test/libcxxabi/test/config.py test/lit.site.cfg.in Index: test/lit.site.cfg.in === --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -13,6 +13,8 @@ config.enable_32bit = "@LLVM_BUILD_32_BITS@" config.target_info = "@LIBCXXABI_TARGET_INFO@" config.executor = "@LIBCXXABI_EXECUTOR@" +config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" +config.enable_shared= "@LIBCXX_ENABLE_SHARED@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg") Index: test/libcxxabi/test/config.py === --- test/libcxxabi/test/config.py +++ test/libcxxabi/test/config.py @@ -63,13 +63,3 @@ def configure_compile_flags_rtti(self): pass - -# TODO(ericwf): Remove this. This is a hack for OS X. -# libc++ *should* export all of the symbols found in libc++abi on OS X. -# For this reason LibcxxConfiguration will not link libc++abi in OS X. -# However __cxa_throw_bad_new_array_length doesn't get exported into libc++ -# yet so we still need to explicitly link libc++abi. -# See PR22654. -def configure_link_flags_abi_library(self): -self.cxx.link_flags += ['-lc++abi'] - Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -6,7 +6,12 @@ endif() endmacro() +if (NOT DEFINED LIBCXX_ENABLE_SHARED) + set(LIBCXX_ENABLE_SHARED ON) +endif() + pythonize_bool(LLVM_BUILD_32_BITS) +pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_SHARED) pythonize_bool(LIBCXXABI_ENABLE_THREADS) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) @@ -21,7 +26,12 @@ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg @ONLY) -set(LIBCXXABI_TEST_DEPS cxxabi_shared) +if (LIBCXXABI_ENABLE_SHARED) + set(LIBCXXABI_TEST_DEPS cxxabi_shared) +else() + set(LIBCXXABI_TEST_DEPS cxxabi_static) +endif() + if (NOT LIBCXXABI_BUILT_STANDALONE) list(APPEND LIBCXXABI_TEST_DEPS cxx) endif() Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -116,9 +116,8 @@ option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON) -set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.") -set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.") -set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ library.") +set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") +set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") # Default to building a shared library so that the default options still test # the libc++abi that is being built. There are two problems with testing a @@ -182,6 +181,13 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +# By default, for non-standalone builds, libcxx and libcxxabi share a library +# directory. +if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) + set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH + "The path to libc++ library.") +endif () + #=== # Setup Compiler Flags #=== @@ -338,14 +344,16 @@ # soname, etc... add_subdirectory(src) -if(NOT LIBCXXABI_ENABLE_SHARED) - # TODO: Fix the libc++ cmake files so that libc++abi can be statically linked. - # As it is now, libc++ will prefer linking against a dynamic libc++abi in the - # system library paths over a static libc++abi in the out directory. This - # would test the system library rather than the one we just built, which isn't - # very helpful. - message(WARNING "The libc++abi tests are currently only valid when " - "LIBCXXABI_ENABLE_SHARED is on, no check target will be " +if (LIBCXXABI_BUILT_STANDALONE AND NOT LIBCXXABI_ENABLE_SHARED) + # We can't reasonably test the system C++ library with a static libc++abi. + # We either need to be able to replace libc++abi at run time (with a shared + # libc++abi), or we need to be able to replace the C++ runtime (with a non- + # standalone build). + message(WARNING "The libc++abi tests aren't valid when libc++abi is built " + "standalone (i.e. outside of llvm/projects/libcxxabi ) and " + "is built without a shared library. Either build a sha
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig updated this revision to Diff 48113. bcraig added a comment. Addressed EricWF's feedback (hopefully). http://reviews.llvm.org/D16544 Files: test/CMakeLists.txt test/libcxx/test/config.py test/libcxx/test/target_info.py test/lit.site.cfg.in Index: test/lit.site.cfg.in === --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -21,6 +21,7 @@ config.executor = "@LIBCXX_EXECUTOR@" config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@" config.use_libatomic= "@LIBCXX_HAS_ATOMIC_LIB@" +config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg") Index: test/libcxx/test/target_info.py === --- test/libcxx/test/target_info.py +++ test/libcxx/test/target_info.py @@ -104,6 +104,14 @@ env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) def allow_cxxabi_link(self): +# libc++ *should* export all of the symbols found in libc++abi on OS X. +# For this reason LibcxxConfiguration will not link libc++abi in OS X. +# However __cxa_throw_bad_new_array_length doesn't get exported into +# libc++ yet so we still need to explicitly link libc++abi when testing +# libc++abi +# See PR22654. +if(self.full_config.get_lit_conf('name', '') == 'libc++abi'): +return True # Don't link libc++abi explicitly on OS X because the symbols # should be available in libc++ directly. return False @@ -162,11 +170,14 @@ enable_threads = ('libcpp-has-no-threads' not in self.full_config.config.available_features) llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) +shared_libcxx = self.full_config.get_lit_bool('enable_shared', True) flags += ['-lm'] if not llvm_unwinder: flags += ['-lgcc_s', '-lgcc'] if enable_threads: flags += ['-lpthread'] +if not shared_libcxx: + flags += ['-lrt'] flags += ['-lc'] if llvm_unwinder: flags += ['-lunwind', '-ldl'] Index: test/libcxx/test/config.py === --- test/libcxx/test/config.py +++ test/libcxx/test/config.py @@ -460,7 +460,16 @@ if libcxx_library: self.cxx.link_flags += [libcxx_library] else: -self.cxx.link_flags += ['-lc++'] +libcxx_shared = self.get_lit_bool('enable_shared', default=True) +if libcxx_shared: +self.cxx.link_flags += ['-lc++'] +else: +cxx_library_root = self.get_lit_conf('cxx_library_root') +if cxx_library_root: +abs_path = cxx_library_root + "/libc++.a" +self.cxx.link_flags += [abs_path] +else: +self.cxx.link_flags += ['-lc++'] def configure_link_flags_abi_library(self): cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') @@ -470,7 +479,16 @@ self.cxx.link_flags += ['-lsupc++'] elif cxx_abi == 'libcxxabi': if self.target_info.allow_cxxabi_link(): -self.cxx.link_flags += ['-lc++abi'] +libcxxabi_shared = self.get_lit_bool('libcxxabi_shared', default=True) +if libcxxabi_shared: +self.cxx.link_flags += ['-lc++abi'] +else: +cxxabi_library_root = self.get_lit_conf('abi_library_path') +if cxxabi_library_root: +abs_path = cxxabi_library_root + "/libc++abi.a" +self.cxx.link_flags += [abs_path] +else: +self.cxx.link_flags += ['-lc++abi'] elif cxx_abi == 'libcxxrt': self.cxx.link_flags += ['-lcxxrt'] elif cxx_abi == 'none': Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -14,6 +14,7 @@ pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXX_BUILD_32_BITS) pythonize_bool(LIBCXX_GENERATE_COVERAGE) +pythonize_bool(LIBCXXABI_ENABLE_SHARED) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) @@ -23,6 +24,13 @@ set(LIBCXX_CXX_ABI_LIBNAME "none") endif() +# By default, for non-standalone builds, libcxx and libcxxabi share a library +# directory. +if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH) + set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH + "The path to libc++abi library.") +endif() + set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING "TargetInfo to use when setting up test environment.") set(LIBCX
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig marked 6 inline comments as done. bcraig added a comment. http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig marked an inline comment as done. bcraig added a comment. http://reviews.llvm.org/D16545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test
bcraig added a comment. So does this latest revision get the check-mark of approval? http://reviews.llvm.org/D15539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17380: [libcxx] Split locale management out of ibm/xlocale.h. NFCI
bcraig created this revision. bcraig added reviewers: howard.hinnant, mclow.lists. bcraig added a subscriber: cfe-commits. This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. Unfortunately, I have no access to an AIX machine to build with, so this change has been made blind. Also, the original author (Xing Xue) does not appear to have a Phabricator account. http://reviews.llvm.org/D17380 Files: include/support/ibm/locale_mgmt_aix.h include/support/ibm/xlocale.h Index: include/support/ibm/xlocale.h === --- include/support/ibm/xlocale.h +++ include/support/ibm/xlocale.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H #define _LIBCPP_SUPPORT_IBM_XLOCALE_H +#include #if defined(_AIX) #include "cstdlib" @@ -21,62 +22,6 @@ #if !defined(_AIX71) // AIX 7.1 and higher has these definitions. Definitions and stubs // are provied here as a temporary workaround on AIX 6.1. - -#define LC_COLLATE_MASK 1 -#define LC_CTYPE_MASK 2 -#define LC_MESSAGES_MASK4 -#define LC_MONETARY_MASK8 -#define LC_NUMERIC_MASK 16 -#define LC_TIME_MASK32 -#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ - LC_MESSAGES_MASK | LC_MONETARY_MASK |\ - LC_NUMERIC_MASK | LC_TIME_MASK) - -typedef void* locale_t; - -// The following are stubs. They are not supported on AIX 6.1. -static inline -locale_t newlocale(int category_mask, const char *locale, locale_t base) -{ - _LC_locale_t *newloc, *loc; - if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) - { -errno = EINVAL; -return (locale_t)0; - } - if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) - { -errno = ENOMEM; -return (locale_t)0; - } - if (!base) -base = (_LC_locale_t *)__xopen_locale("C"); - memcpy(newloc, base, sizeof (_LC_locale_t)); - if (category_mask & LC_COLLATE_MASK) -newloc->lc_collate = loc->lc_collate; - if (category_mask & LC_CTYPE_MASK) -newloc->lc_ctype = loc->lc_ctype; - //if (category_mask & LC_MESSAGES_MASK) - // newloc->lc_messages = loc->lc_messages; - if (category_mask & LC_MONETARY_MASK) -newloc->lc_monetary = loc->lc_monetary; - if (category_mask & LC_TIME_MASK) -newloc->lc_time = loc->lc_time; - if (category_mask & LC_NUMERIC_MASK) -newloc->lc_numeric = loc->lc_numeric; - return (locale_t)newloc; -} -static inline -void freelocale(locale_t locobj) -{ - free(locobj); -} -static inline -locale_t uselocale(locale_t newloc) -{ - return (locale_t)0; -} - static inline int isalnum_l(int c, locale_t locale) { Index: include/support/ibm/locale_mgmt_aix.h === --- /dev/null +++ include/support/ibm/locale_mgmt_aix.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +//===--- support/ibm/locale_mgmt_aix.h ===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H +#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK4 +#define LC_MONETARY_MASK8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { +errno = EINVAL; +return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { +errno = ENOME
[PATCH] D17382: [libcxx] Split locale management out of newlib/xlocale.h. NFCI
bcraig created this revision. bcraig added reviewers: jroelofs, mclow.lists. bcraig added a subscriber: cfe-commits. Herald added a subscriber: jfb. This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. The "do-nothing" / "nop" locale functions are also useful on their own for other lightweight platforms. Putting these nop implementations in support/xlocale should enable code sharing. Unfortunately, I have no access to a newlib system to build and test with, so this change has been made blind. http://reviews.llvm.org/D17382 Files: include/support/newlib/xlocale.h include/support/xlocale/__nop_locale_mgmt.h Index: include/support/xlocale/__nop_locale_mgmt.h === --- /dev/null +++ include/support/xlocale/__nop_locale_mgmt.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +//=== support/xlocale/__nop_locale_mgmt.h -===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H +#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +// Patch over lack of extended locale support +typedef void *locale_t; +static inline locale_t duplocale(locale_t) { + return NULL; +} + +static inline void freelocale(locale_t) { +} + +static inline locale_t newlocale(int, const char *, locale_t) { + return NULL; +} + +static inline locale_t uselocale(locale_t) { + return NULL; +} + +#define LC_COLLATE_MASK (1 << LC_COLLATE) +#define LC_CTYPE_MASK(1 << LC_CTYPE) +#define LC_MESSAGES_MASK (1 << LC_MESSAGES) +#define LC_MONETARY_MASK (1 << LC_MONETARY) +#define LC_NUMERIC_MASK (1 << LC_NUMERIC) +#define LC_TIME_MASK (1 << LC_TIME) +#define LC_ALL_MASK (LC_COLLATE_MASK|\ + LC_CTYPE_MASK|\ + LC_MONETARY_MASK|\ + LC_NUMERIC_MASK|\ + LC_TIME_MASK|\ + LC_MESSAGES_MASK) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H Index: include/support/newlib/xlocale.h === --- include/support/newlib/xlocale.h +++ include/support/newlib/xlocale.h @@ -16,41 +16,12 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { #endif -// Patch over newlib's lack of extended locale support -typedef void *locale_t; -static inline locale_t duplocale(locale_t) { - return NULL; -} - -static inline void freelocale(locale_t) { -} - -static inline locale_t newlocale(int, const char *, locale_t) { - return NULL; -} - -static inline locale_t uselocale(locale_t) { - return NULL; -} - -#define LC_COLLATE_MASK (1 << LC_COLLATE) -#define LC_CTYPE_MASK(1 << LC_CTYPE) -#define LC_MESSAGES_MASK (1 << LC_MESSAGES) -#define LC_MONETARY_MASK (1 << LC_MONETARY) -#define LC_NUMERIC_MASK (1 << LC_NUMERIC) -#define LC_TIME_MASK (1 << LC_TIME) -#define LC_ALL_MASK (LC_COLLATE_MASK|\ - LC_CTYPE_MASK|\ - LC_MONETARY_MASK|\ - LC_NUMERIC_MASK|\ - LC_TIME_MASK|\ - LC_MESSAGES_MASK) - // Share implementation with Android's Bionic #include ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261231 - Split locale management out of newlib/xlocale.h. NFCI
Author: bcraig Date: Thu Feb 18 11:40:16 2016 New Revision: 261231 URL: http://llvm.org/viewvc/llvm-project?rev=261231&view=rev Log: Split locale management out of newlib/xlocale.h. NFCI This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. The "do-nothing" / "nop" locale functions are also useful on their own for other lightweight platforms. Putting these nop implementations in support/xlocale should enable code sharing. Unfortunately, I have no access to a newlib system to build and test with, so this change has been made blind. Reviewed: http://reviews.llvm.org/D17382 Added: libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h Modified: libcxx/trunk/include/support/newlib/xlocale.h Modified: libcxx/trunk/include/support/newlib/xlocale.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=261231&r1=261230&r2=261231&view=diff == --- libcxx/trunk/include/support/newlib/xlocale.h (original) +++ libcxx/trunk/include/support/newlib/xlocale.h Thu Feb 18 11:40:16 2016 @@ -16,41 +16,12 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { #endif -// Patch over newlib's lack of extended locale support -typedef void *locale_t; -static inline locale_t duplocale(locale_t) { - return NULL; -} - -static inline void freelocale(locale_t) { -} - -static inline locale_t newlocale(int, const char *, locale_t) { - return NULL; -} - -static inline locale_t uselocale(locale_t) { - return NULL; -} - -#define LC_COLLATE_MASK (1 << LC_COLLATE) -#define LC_CTYPE_MASK(1 << LC_CTYPE) -#define LC_MESSAGES_MASK (1 << LC_MESSAGES) -#define LC_MONETARY_MASK (1 << LC_MONETARY) -#define LC_NUMERIC_MASK (1 << LC_NUMERIC) -#define LC_TIME_MASK (1 << LC_TIME) -#define LC_ALL_MASK (LC_COLLATE_MASK|\ - LC_CTYPE_MASK|\ - LC_MONETARY_MASK|\ - LC_NUMERIC_MASK|\ - LC_TIME_MASK|\ - LC_MESSAGES_MASK) - // Share implementation with Android's Bionic #include Added: libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h?rev=261231&view=auto == --- libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h (added) +++ libcxx/trunk/include/support/xlocale/__nop_locale_mgmt.h Thu Feb 18 11:40:16 2016 @@ -0,0 +1,52 @@ +// -*- C++ -*- +//=== support/xlocale/__nop_locale_mgmt.h -===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H +#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +// Patch over lack of extended locale support +typedef void *locale_t; +static inline locale_t duplocale(locale_t) { + return NULL; +} + +static inline void freelocale(locale_t) { +} + +static inline locale_t newlocale(int, const char *, locale_t) { + return NULL; +} + +static inline locale_t uselocale(locale_t) { + return NULL; +} + +#define LC_COLLATE_MASK (1 << LC_COLLATE) +#define LC_CTYPE_MASK(1 << LC_CTYPE) +#define LC_MESSAGES_MASK (1 << LC_MESSAGES) +#define LC_MONETARY_MASK (1 << LC_MONETARY) +#define LC_NUMERIC_MASK (1 << LC_NUMERIC) +#define LC_TIME_MASK (1 << LC_TIME) +#define LC_ALL_MASK (LC_COLLATE_MASK|\ + LC_CTYPE_MASK|\ + LC_MONETARY_MASK|\ + LC_NUMERIC_MASK|\ + LC_TIME_MASK|\ + LC_MESSAGES_MASK) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261230 - Split locale management out of ibm/xlocale.h. NFCI
Author: bcraig Date: Thu Feb 18 11:37:33 2016 New Revision: 261230 URL: http://llvm.org/viewvc/llvm-project?rev=261230&view=rev Log: Split locale management out of ibm/xlocale.h. NFCI This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. Unfortunately, I have no access to an AIX machine to build with, so this change has been made blind. Also, the original author (Xing Xue) does not appear to have a Phabricator account. Reviewed: http://reviews.llvm.org/D17380 Added: libcxx/trunk/include/support/ibm/locale_mgmt_aix.h Modified: libcxx/trunk/include/support/ibm/xlocale.h Added: libcxx/trunk/include/support/ibm/locale_mgmt_aix.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/ibm/locale_mgmt_aix.h?rev=261230&view=auto == --- libcxx/trunk/include/support/ibm/locale_mgmt_aix.h (added) +++ libcxx/trunk/include/support/ibm/locale_mgmt_aix.h Thu Feb 18 11:37:33 2016 @@ -0,0 +1,85 @@ +// -*- C++ -*- +//===--- support/ibm/locale_mgmt_aix.h ===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H +#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK4 +#define LC_MONETARY_MASK8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { +errno = EINVAL; +return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { +errno = ENOMEM; +return (locale_t)0; + } + if (!base) +base = (_LC_locale_t *)__xopen_locale("C"); + memcpy(newloc, base, sizeof (_LC_locale_t)); + if (category_mask & LC_COLLATE_MASK) +newloc->lc_collate = loc->lc_collate; + if (category_mask & LC_CTYPE_MASK) +newloc->lc_ctype = loc->lc_ctype; + //if (category_mask & LC_MESSAGES_MASK) + // newloc->lc_messages = loc->lc_messages; + if (category_mask & LC_MONETARY_MASK) +newloc->lc_monetary = loc->lc_monetary; + if (category_mask & LC_TIME_MASK) +newloc->lc_time = loc->lc_time; + if (category_mask & LC_NUMERIC_MASK) +newloc->lc_numeric = loc->lc_numeric; + return (locale_t)newloc; +} +static inline +void freelocale(locale_t locobj) +{ + free(locobj); +} +static inline +locale_t uselocale(locale_t newloc) +{ + return (locale_t)0; +} +#endif // !defined(_AIX71) + +#ifdef __cplusplus +} +#endif +#endif // defined(_AIX) +#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H Modified: libcxx/trunk/include/support/ibm/xlocale.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/ibm/xlocale.h?rev=261230&r1=261229&r2=261230&view=diff == --- libcxx/trunk/include/support/ibm/xlocale.h (original) +++ libcxx/trunk/include/support/ibm/xlocale.h Thu Feb 18 11:37:33 2016 @@ -10,6 +10,7 @@ #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H #define _LIBCPP_SUPPORT_IBM_XLOCALE_H +#include #if defined(_AIX) #include "cstdlib" @@ -21,62 +22,6 @@ extern "C" { #if !defined(_AIX71) // AIX 7.1 and higher has these definitions. Definitions and stubs // are provied here as a temporary workaround on AIX 6.1. - -#define LC_COLLATE_MASK 1 -#define LC_CTYPE_MASK 2 -#define LC_MESSAGES_MASK4 -#define LC_MONETARY_MASK8 -#define LC_NUMERIC_MASK 16 -#define LC_TIME_MASK32 -#define LC_AL
[PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install
bcraig created this revision. bcraig added reviewers: mclow.lists, EricWF, danalbert, jroelofs. bcraig added a subscriber: cfe-commits. Prior to this patch, setting LIBCXXABI_LIBDIR_SUFFIX would confuse the check-libcxxabi target. libc++abi.* would get output to lib instead of lib${LIBCXXABI_LIBDIR_SUFFIX}, but the tests would look in the suffixed directory. Now, we match what libcxx does, and set the CMAKE_*_OUTPUT_DIRECTORY to the LIBRARY_DIR. This is also being done in the "standalone" branch, but now it is being performed in the in-tree branch as well. http://reviews.llvm.org/D17410 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -181,6 +181,9 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) + # By default, for non-standalone builds, libcxx and libcxxabi share a library # directory. if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -181,6 +181,9 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) + # By default, for non-standalone builds, libcxx and libcxxabi share a library # directory. if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install
bcraig updated this revision to Diff 48396. bcraig added a comment. Prior version doesn't apply to master. The context was dirty from some unsubmitted patches. http://reviews.llvm.org/D17410 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -182,6 +182,9 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) + #=== # Setup Compiler Flags #=== Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -182,6 +182,9 @@ set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) + #=== # Setup Compiler Flags #=== ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17416: [libcxx] Reorganize locale extension fallbacks
bcraig created this revision. bcraig added reviewers: jroelofs, danalbert, mclow.lists. bcraig added a subscriber: cfe-commits. Herald added subscribers: srhines, danalbert, tberghammer, jfb. This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. The various _l locale extension functions originate from very different places. Some come from POSIX, some are BSD extensions, and some are shared BSD and GLIBC extensions. This patch tries to group the local extension reimplementations by source. This should make it easier to make libcxx work with POSIX compliant C libraries that lack these extensions. The fallback locale functions are also useful on their own for other lightweight platforms. Putting these fallback implementations in support/xlocale should enable code sharing. I have no access to a newlib system or an android system to build and test with. I _do_ have access to a system without any of the _l locale extensions though, and I was able to ensure that the new __posix_l_fallback.h and __strtonum_fallback.h didn't have any massive problems. http://reviews.llvm.org/D17416 Files: include/support/android/locale_bionic.h include/support/newlib/xlocale.h include/support/xlocale/__posix_l_fallback.h include/support/xlocale/__strtonum_fallback.h include/support/xlocale/xlocale.h Index: include/support/xlocale/xlocale.h === --- include/support/xlocale/xlocale.h +++ /dev/null @@ -1,194 +0,0 @@ -// -*- C++ -*- -//===--- support/xlocale/xlocale.h ===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// -// This is a shared implementation of a shim to provide extended locale support -// on top of libc's that don't support it (like Android's bionic, and Newlib). -// -// The 'illusion' only works when the specified locale is "C" or "POSIX", but -// that's about as good as we can do without implementing full xlocale support -// in the underlying libc. -//===--===// - -#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H -#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H - -#ifdef __cplusplus -extern "C" { -#endif - -static inline int isalnum_l(int c, locale_t) { - return isalnum(c); -} - -static inline int isalpha_l(int c, locale_t) { - return isalpha(c); -} - -static inline int isblank_l(int c, locale_t) { - return isblank(c); -} - -static inline int iscntrl_l(int c, locale_t) { - return iscntrl(c); -} - -static inline int isdigit_l(int c, locale_t) { - return isdigit(c); -} - -static inline int isgraph_l(int c, locale_t) { - return isgraph(c); -} - -static inline int islower_l(int c, locale_t) { - return islower(c); -} - -static inline int isprint_l(int c, locale_t) { - return isprint(c); -} - -static inline int ispunct_l(int c, locale_t) { - return ispunct(c); -} - -static inline int isspace_l(int c, locale_t) { - return isspace(c); -} - -static inline int isupper_l(int c, locale_t) { - return isupper(c); -} - -static inline int isxdigit_l(int c, locale_t) { - return isxdigit(c); -} - -static inline int iswalnum_l(wint_t c, locale_t) { - return iswalnum(c); -} - -static inline int iswalpha_l(wint_t c, locale_t) { - return iswalpha(c); -} - -static inline int iswblank_l(wint_t c, locale_t) { - return iswblank(c); -} - -static inline int iswcntrl_l(wint_t c, locale_t) { - return iswcntrl(c); -} - -static inline int iswdigit_l(wint_t c, locale_t) { - return iswdigit(c); -} - -static inline int iswgraph_l(wint_t c, locale_t) { - return iswgraph(c); -} - -static inline int iswlower_l(wint_t c, locale_t) { - return iswlower(c); -} - -static inline int iswprint_l(wint_t c, locale_t) { - return iswprint(c); -} - -static inline int iswpunct_l(wint_t c, locale_t) { - return iswpunct(c); -} - -static inline int iswspace_l(wint_t c, locale_t) { - return iswspace(c); -} - -static inline int iswupper_l(wint_t c, locale_t) { - return iswupper(c); -} - -static inline int iswxdigit_l(wint_t c, locale_t) { - return iswxdigit(c); -} - -static inline int toupper_l(int c, locale_t) { - return toupper(c); -} - -static inline int tolower_l(int c, locale_t) { - return tolower(c); -} - -static inline int towupper_l(int c, locale_t) { - return towupper(c); -} - -static inline int towlower_l(int c, locale_t) { - return towlower(c); -} - -static inline int strcoll_l(const char *s1, const char *s2, locale_t) { - return strcoll(s1, s2); -} - -static inline size_t strxfrm_l(char *dest, const char *src, size_t n, - locale_t) { - return strxfrm(dest, src, n); -} - -static inline size_t strftime_l(char *s, size_t max, c
[PATCH] D17419: [libcxx] Split locale management out of locale_win32. NFCI
bcraig created this revision. bcraig added reviewers: rubenvb, yaron.keren, jroelofs, howard.hinnant, mclow.lists. bcraig added a subscriber: cfe-commits. This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. Unfortunately, the Windows, Cygwin, and MinGW builds seemed to have bit-rotted, so I wasn't able to test this completely. I don't think I made things any worse than they already are though. http://reviews.llvm.org/D17419 Files: include/support/win32/locale_mgmt_win32.h include/support/win32/locale_win32.h Index: include/support/win32/locale_win32.h === --- include/support/win32/locale_win32.h +++ include/support/win32/locale_win32.h @@ -15,26 +15,10 @@ extern "C" unsigned short __declspec(dllimport) _ctype[]; #include "support/win32/support.h" +#include "support/win32/locale_mgmt_win32.h" #include #include -#include // _locale_t -#define locale_t _locale_t -#define LC_COLLATE_MASK _M_COLLATE -#define LC_CTYPE_MASK _M_CTYPE -#define LC_MONETARY_MASK _M_MONETARY -#define LC_NUMERIC_MASK _M_NUMERIC -#define LC_TIME_MASK _M_TIME -#define LC_MESSAGES_MASK _M_MESSAGES -#define LC_ALL_MASK ( LC_COLLATE_MASK \ - | LC_CTYPE_MASK \ - | LC_MESSAGES_MASK \ - | LC_MONETARY_MASK \ - | LC_NUMERIC_MASK \ - | LC_TIME_MASK ) -#define freelocale _free_locale -// FIXME: base currently unused. Needs manual work to construct the new locale -locale_t newlocale( int mask, const char * locale, locale_t base ); -locale_t uselocale( locale_t newloc ); + lconv *localeconv_l( locale_t loc ); size_t mbrlen_l( const char *__restrict s, size_t n, mbstate_t *__restrict ps, locale_t loc); Index: include/support/win32/locale_mgmt_win32.h === --- /dev/null +++ include/support/win32/locale_mgmt_win32.h @@ -0,0 +1,33 @@ +// -*- C++ -*- +//===- support/win32/locale_mgmt_win32.h --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H +#define _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H + +#include // _locale_t +#define locale_t _locale_t +#define LC_COLLATE_MASK _M_COLLATE +#define LC_CTYPE_MASK _M_CTYPE +#define LC_MONETARY_MASK _M_MONETARY +#define LC_NUMERIC_MASK _M_NUMERIC +#define LC_TIME_MASK _M_TIME +#define LC_MESSAGES_MASK _M_MESSAGES +#define LC_ALL_MASK ( LC_COLLATE_MASK \ + | LC_CTYPE_MASK \ + | LC_MESSAGES_MASK \ + | LC_MONETARY_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK ) +#define freelocale _free_locale +// FIXME: base currently unused. Needs manual work to construct the new locale +locale_t newlocale( int mask, const char * locale, locale_t base ); +locale_t uselocale( locale_t newloc ); + +#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H Index: include/support/win32/locale_win32.h === --- include/support/win32/locale_win32.h +++ include/support/win32/locale_win32.h @@ -15,26 +15,10 @@ extern "C" unsigned short __declspec(dllimport) _ctype[]; #include "support/win32/support.h" +#include "support/win32/locale_mgmt_win32.h" #include #include -#include // _locale_t -#define locale_t _locale_t -#define LC_COLLATE_MASK _M_COLLATE -#define LC_CTYPE_MASK _M_CTYPE -#define LC_MONETARY_MASK _M_MONETARY -#define LC_NUMERIC_MASK _M_NUMERIC -#define LC_TIME_MASK _M_TIME -#define LC_MESSAGES_MASK _M_MESSAGES -#define LC_ALL_MASK ( LC_COLLATE_MASK \ - | LC_CTYPE_MASK \ - | LC_MESSAGES_MASK \ - | LC_MONETARY_MASK \ - | LC_NUMERIC_MASK \ - | LC_TIME_MASK ) -#define freelocale _free_locale -// FIXME: base currently unused. Needs manual work to construct the new locale -locale_t newlocale( int mask, const char * locale, locale_t base ); -locale_t uselocale( locale_t newloc ); + lconv *localeconv_l( locale_t loc ); size_t mbrlen_l( const char *__restrict s, size_t n,
[PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS
bcraig created this revision. bcraig added reviewers: scshunt, howard.hinnant, jroelofs, mclow.lists. bcraig added a subscriber: cfe-commits. Herald added a subscriber: jfb. This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. Instead of checking _LIBCPP_LOCALE__L_EXTENSIONS all over, instead check it once, and define the various *_l symbols once. The private redirector symbol names are all prefixed with _CXX_* so that they won't conflict with user symbols, and so they won't conflict with future C library symbols. In particular, glibc likes providing private symbols such as __locale_t, so we should follow a different naming pattern (like _CXX_*) to avoid problems on that front. Tested on Linux with glibc. Hoping for the best on OSX and the various BSDs. http://reviews.llvm.org/D17456 Files: include/__bsd_locale_defaults.h include/__bsd_locale_fallbacks.h include/locale src/locale.cpp Index: src/locale.cpp === --- src/locale.cpp +++ src/locale.cpp @@ -1400,33 +1400,21 @@ wchar_t ctype_byname::do_widen(char c) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -return btowc_l(c, __l); -#else -return __btowc_l(c, __l); -#endif +return _CXX_btowc_l(c, __l); } const char* ctype_byname::do_widen(const char* low, const char* high, char_type* dest) const { for (; low != high; ++low, ++dest) -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -*dest = btowc_l(*low, __l); -#else -*dest = __btowc_l(*low, __l); -#endif +*dest = _CXX_btowc_l(*low, __l); return low; } char ctype_byname::do_narrow(char_type c, char dfault) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(c, __l); -#else -int r = __wctob_l(c, __l); -#endif +int r = _CXX_wctob_l(c, __l); return r != static_cast(WEOF) ? static_cast(r) : dfault; } @@ -1435,11 +1423,7 @@ { for (; low != high; ++low, ++dest) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(*low, __l); -#else -int r = __wctob_l(*low, __l); -#endif +int r = _CXX_wctob_l(*low, __l); *dest = r != static_cast(WEOF) ? static_cast(r) : dfault; } return low; @@ -1549,22 +1533,14 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = _CXX_wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++frm) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(to_nxt, *frm, &save_state, __l); -#else -n = __wcrtomb_l(to_nxt, *frm, &save_state, __l); -#endif +n = _CXX_wcrtomb_l(to_nxt, *frm, &save_state, __l); if (n == size_t(-1)) break; to_nxt += n; @@ -1581,11 +1557,7 @@ { // Try to write the terminating null extern_type tmp[MB_LEN_MAX]; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(tmp, intern_type(), &st, __l); -#else -n = __wcrtomb_l(tmp, intern_type(), &st, __l); -#endif +n = _CXX_wcrtomb_l(tmp, intern_type(), &st, __l); if (n == size_t(-1)) // on error return error; if (n > static_cast(to_end-to_nxt)) // is there room? @@ -1618,23 +1590,15 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = _CXX_mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++to_nxt) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = mbrtowc_l(to_nxt, frm, static_cast(fend-frm), - &save_state, __l); -#else -n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l); -#endif +n = _CXX_mbrtowc_l(to_nxt, frm, static_cast(fend-frm), + &save_state, __l); switch (n) { case 0: @@ -
Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS
bcraig added a comment. In http://reviews.llvm.org/D17456#357232, @jroelofs wrote: > > The private redirector symbol names are all prefixed with _CXX_* so that > > they won't conflict with user symbols, > > > This is more @mclow.lists/@ericwf's domain, but I think __libcxx_ prefixes > would be safer (so that there's no chance of clashing with libstdc++, if they > decide to do something similar, or already have). Do we need our headers to coexist with the headers from other C++ implementations? That seems fraught with peril. I've tried to do something like that in the past with STLPort in combination with various compilers' STLs, and ADL basically made the results unusable. http://reviews.llvm.org/D17456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS
bcraig updated the summary for this revision. bcraig removed a reviewer: scshunt. bcraig updated this revision to Diff 48520. bcraig added a comment. Switched from _CXX_* prefix to _libcxx_* prefix to avoid link time conflicts with other C++ library implementations. Removed Sean Hunt from the reviewers list. http://reviews.llvm.org/D17456 Files: include/__bsd_locale_defaults.h include/__bsd_locale_fallbacks.h include/locale src/locale.cpp Index: src/locale.cpp === --- src/locale.cpp +++ src/locale.cpp @@ -1400,33 +1400,21 @@ wchar_t ctype_byname::do_widen(char c) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -return btowc_l(c, __l); -#else -return __btowc_l(c, __l); -#endif +return __libcxx_btowc_l(c, __l); } const char* ctype_byname::do_widen(const char* low, const char* high, char_type* dest) const { for (; low != high; ++low, ++dest) -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -*dest = btowc_l(*low, __l); -#else -*dest = __btowc_l(*low, __l); -#endif +*dest = __libcxx_btowc_l(*low, __l); return low; } char ctype_byname::do_narrow(char_type c, char dfault) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(c, __l); -#else -int r = __wctob_l(c, __l); -#endif +int r = __libcxx_wctob_l(c, __l); return r != static_cast(WEOF) ? static_cast(r) : dfault; } @@ -1435,11 +1423,7 @@ { for (; low != high; ++low, ++dest) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(*low, __l); -#else -int r = __wctob_l(*low, __l); -#endif +int r = __libcxx_wctob_l(*low, __l); *dest = r != static_cast(WEOF) ? static_cast(r) : dfault; } return low; @@ -1549,22 +1533,14 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = __libcxx_wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++frm) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(to_nxt, *frm, &save_state, __l); -#else -n = __wcrtomb_l(to_nxt, *frm, &save_state, __l); -#endif +n = __libcxx_wcrtomb_l(to_nxt, *frm, &save_state, __l); if (n == size_t(-1)) break; to_nxt += n; @@ -1581,11 +1557,7 @@ { // Try to write the terminating null extern_type tmp[MB_LEN_MAX]; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(tmp, intern_type(), &st, __l); -#else -n = __wcrtomb_l(tmp, intern_type(), &st, __l); -#endif +n = __libcxx_wcrtomb_l(tmp, intern_type(), &st, __l); if (n == size_t(-1)) // on error return error; if (n > static_cast(to_end-to_nxt)) // is there room? @@ -1618,23 +1590,15 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = __libcxx_mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++to_nxt) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = mbrtowc_l(to_nxt, frm, static_cast(fend-frm), - &save_state, __l); -#else -n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l); -#endif +n = __libcxx_mbrtowc_l(to_nxt, frm, static_cast(fend-frm), + &save_state, __l); switch (n) { case 0: @@ -1662,11 +1626,7 @@ if (fend != frm_end) // set up next null terminated sequence { // Try to write the terminating null -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); -#else -n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); -#endif +n = __libcxx_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); if (n != 0) // on error return error; ++to_nxt; @@ -1686,11
Re: [PATCH] D17146: [libcxx] locale portability refactor
bcraig abandoned this revision. bcraig added a comment. Breaking this up into smaller chunks. http://reviews.llvm.org/D17146 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS
bcraig updated the summary for this revision. bcraig added a reviewer: joerg. bcraig updated this revision to Diff 48687. bcraig added a comment. Changed libcxx prefix to libcpp. Changed BSD forwarding macros to macro functions. http://reviews.llvm.org/D17456 Files: include/__bsd_locale_defaults.h include/__bsd_locale_fallbacks.h include/locale src/locale.cpp Index: src/locale.cpp === --- src/locale.cpp +++ src/locale.cpp @@ -1400,33 +1400,21 @@ wchar_t ctype_byname::do_widen(char c) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -return btowc_l(c, __l); -#else -return __btowc_l(c, __l); -#endif +return __libcpp_btowc_l(c, __l); } const char* ctype_byname::do_widen(const char* low, const char* high, char_type* dest) const { for (; low != high; ++low, ++dest) -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -*dest = btowc_l(*low, __l); -#else -*dest = __btowc_l(*low, __l); -#endif +*dest = __libcpp_btowc_l(*low, __l); return low; } char ctype_byname::do_narrow(char_type c, char dfault) const { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(c, __l); -#else -int r = __wctob_l(c, __l); -#endif +int r = __libcpp_wctob_l(c, __l); return r != static_cast(WEOF) ? static_cast(r) : dfault; } @@ -1435,11 +1423,7 @@ { for (; low != high; ++low, ++dest) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -int r = wctob_l(*low, __l); -#else -int r = __wctob_l(*low, __l); -#endif +int r = __libcpp_wctob_l(*low, __l); *dest = r != static_cast(WEOF) ? static_cast(r) : dfault; } return low; @@ -1549,22 +1533,14 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++frm) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(to_nxt, *frm, &save_state, __l); -#else -n = __wcrtomb_l(to_nxt, *frm, &save_state, __l); -#endif +n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l); if (n == size_t(-1)) break; to_nxt += n; @@ -1581,11 +1557,7 @@ { // Try to write the terminating null extern_type tmp[MB_LEN_MAX]; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = wcrtomb_l(tmp, intern_type(), &st, __l); -#else -n = __wcrtomb_l(tmp, intern_type(), &st, __l); -#endif +n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l); if (n == size_t(-1)) // on error return error; if (n > static_cast(to_end-to_nxt)) // is there room? @@ -1618,23 +1590,15 @@ { // save state in case it is needed to recover to_nxt on error mbstate_t save_state = st; -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), -static_cast(to_end-to), &st, __l); -#else -size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l); -#endif +size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm), + static_cast(to_end-to), &st, __l); if (n == size_t(-1)) { // need to recover to_nxt for (to_nxt = to; frm != frm_nxt; ++to_nxt) { -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = mbrtowc_l(to_nxt, frm, static_cast(fend-frm), - &save_state, __l); -#else -n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l); -#endif +n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast(fend-frm), + &save_state, __l); switch (n) { case 0: @@ -1662,11 +1626,7 @@ if (fend != frm_end) // set up next null terminated sequence { // Try to write the terminating null -#ifdef _LIBCPP_LOCALE__L_EXTENSIONS -n = mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); -#else -n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); -#endif +n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l); if (n != 0) // on error return error; ++to_nxt; @@ -1686,11 +1646,7 @@ { to_nxt = to; extern_type tmp[MB_LEN_MAX]; -#ifdef _LIBCPP_L
Re: [PATCH] D15539: [libcxxabi] Reducing stack usage of test
bcraig added a comment. @mclow.lists ping http://reviews.llvm.org/D15539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support
bcraig added a comment. LGTM. You will still need to get approval from one of your original reviewers though. http://reviews.llvm.org/D19415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II
bcraig added a comment. LGTM. You will still need to get approval from one of your original reviewers though. http://reviews.llvm.org/D19412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II
bcraig added inline comments. Comment at: src/algorithm.cpp:51 @@ -50,3 +50,3 @@ #ifndef _LIBCPP_HAS_NO_THREADS -static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER; +static mutex __rs_mut; #endif rmaprath wrote: > mclow.lists wrote: > > What happened to the initializer here? > I'm expecting the constructor of `mutex` to be run here at load time (before > `main`). Note that this a libc++ mutex rather than a pthreads mutex (which > does not required a constructor call like this). Would that be too much of an > overhead? std::mutex's default ctor is constexpr. As long as the compiler supports constexpr, this initialization shouldn't require runtime code. http://reviews.llvm.org/D19412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19667: [ubsan] Minimize size of data for type_mismatch
bcraig added a subscriber: bcraig. bcraig added a comment. Is there an associated patch on the consuming side for this data? http://reviews.llvm.org/D19667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II
bcraig added a comment. In http://reviews.llvm.org/D19412#414374, @rmaprath wrote: > > On a bikeshed note: is `<__os_support>` the right name? Or should it be > > something like `<__thread>` or `<__threading_support>`? > > > I went with `__os_support` in case if we'd want to group further external > dependencies (like, for example, if some non-c POSIX calls are used in the > upcoming `filesystem` library). I can revert back to `__threading_support` if > that's preferred. > > Thanks. > > / Asiri I don't particularly care for <__os_support> either. Either of <__thread> or <__threading_support> are fine with me. Note that there are already other OS specific calls that libcxx has to handle. A lot of the locale code wants to use BSD style foo_l functions that are present on Linux. I prefer to keep the locale code independent of the threading code, as the two don't overlap much. For filesystem related items, I would expect those to go under <__filesystem> or <__filesystem_support>, or something similar. http://reviews.llvm.org/D19412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II
bcraig added a comment. LGTM. You'll still need to wait for one of the other reviewers though (probably @mclow.lists ) http://reviews.llvm.org/D19412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19856: Create new library 'libc++experimental.a' for packaging TS symbols.
bcraig added a comment. LGTM http://reviews.llvm.org/D19856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1
bcraig added a subscriber: bcraig. bcraig added a comment. > We could, on the other hand, do this tightening for all the supported > architectures (for the new, native-only libunwind build suggested by > @jroelofs) with appropriate asserts in place so that we maintain these tight > bounds as we move forward. Not sure if that effort would be worth though, > given that for most non-ARM targets, unwinder stack usage is not a huge > concern. libunwind doesn't currently support Hexagon, but it has been investigated some there. Hexagon would care about stack usage as well. I wouldn't be surprised if some embedded MIPS and Power targets also cared. I don't think any of those targets come close to using 1K for their unwind context. http://reviews.llvm.org/D19920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19936: Adding omitted column to invalid loc diagnostic.
bcraig created this revision. bcraig added reviewers: olista01, t.p.northover. bcraig added a subscriber: cfe-commits. note_fe_backend_invalid_loc expects three arguments (file, line, column), and will assert when only given two. The other two places in this file that use note_fe_backend_invalid_loc already supply the Column for the third parameter. http://reviews.llvm.org/D19936 Files: lib/CodeGen/CodeGenAction.cpp Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -454,7 +454,7 @@ // we could not translate this location. This can happen in the // case of #line directives. Diags.Report(Loc, diag::note_fe_backend_invalid_loc) -<< Filename << Line; +<< Filename << Line << Column; return Loc; } Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -454,7 +454,7 @@ // we could not translate this location. This can happen in the // case of #line directives. Diags.Report(Loc, diag::note_fe_backend_invalid_loc) -<< Filename << Line; +<< Filename << Line << Column; return Loc; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r268732 - Adding omitted column to invalid loc diagnostic.
Author: bcraig Date: Fri May 6 08:29:46 2016 New Revision: 268732 URL: http://llvm.org/viewvc/llvm-project?rev=268732&view=rev Log: Adding omitted column to invalid loc diagnostic. note_fe_backend_invalid_loc expects three arguments (file, line, column), and will assert when only given two. The other two places in this file that use note_fe_backend_invalid_loc already supply the Column for the third parameter. http://reviews.llvm.org/D19936 Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=268732&r1=268731&r2=268732&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri May 6 08:29:46 2016 @@ -454,7 +454,7 @@ const FullSourceLoc BackendConsumer::get // we could not translate this location. This can happen in the // case of #line directives. Diags.Report(Loc, diag::note_fe_backend_invalid_loc) -<< Filename << Line; +<< Filename << Line << Column; return Loc; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19936: Adding omitted column to invalid loc diagnostic.
bcraig added a comment. r268732 http://reviews.llvm.org/D19936 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI
bcraig updated this revision to Diff 57520. http://reviews.llvm.org/D17416 Files: include/support/android/locale_bionic.h include/support/newlib/xlocale.h include/support/xlocale/__posix_l_fallback.h include/support/xlocale/__strtonum_fallback.h include/support/xlocale/xlocale.h Index: include/support/xlocale/xlocale.h === --- include/support/xlocale/xlocale.h +++ /dev/null @@ -1,194 +0,0 @@ -// -*- C++ -*- -//===--- support/xlocale/xlocale.h ===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// -// This is a shared implementation of a shim to provide extended locale support -// on top of libc's that don't support it (like Android's bionic, and Newlib). -// -// The 'illusion' only works when the specified locale is "C" or "POSIX", but -// that's about as good as we can do without implementing full xlocale support -// in the underlying libc. -//===--===// - -#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H -#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H - -#ifdef __cplusplus -extern "C" { -#endif - -static inline int isalnum_l(int c, locale_t) { - return isalnum(c); -} - -static inline int isalpha_l(int c, locale_t) { - return isalpha(c); -} - -static inline int isblank_l(int c, locale_t) { - return isblank(c); -} - -static inline int iscntrl_l(int c, locale_t) { - return iscntrl(c); -} - -static inline int isdigit_l(int c, locale_t) { - return isdigit(c); -} - -static inline int isgraph_l(int c, locale_t) { - return isgraph(c); -} - -static inline int islower_l(int c, locale_t) { - return islower(c); -} - -static inline int isprint_l(int c, locale_t) { - return isprint(c); -} - -static inline int ispunct_l(int c, locale_t) { - return ispunct(c); -} - -static inline int isspace_l(int c, locale_t) { - return isspace(c); -} - -static inline int isupper_l(int c, locale_t) { - return isupper(c); -} - -static inline int isxdigit_l(int c, locale_t) { - return isxdigit(c); -} - -static inline int iswalnum_l(wint_t c, locale_t) { - return iswalnum(c); -} - -static inline int iswalpha_l(wint_t c, locale_t) { - return iswalpha(c); -} - -static inline int iswblank_l(wint_t c, locale_t) { - return iswblank(c); -} - -static inline int iswcntrl_l(wint_t c, locale_t) { - return iswcntrl(c); -} - -static inline int iswdigit_l(wint_t c, locale_t) { - return iswdigit(c); -} - -static inline int iswgraph_l(wint_t c, locale_t) { - return iswgraph(c); -} - -static inline int iswlower_l(wint_t c, locale_t) { - return iswlower(c); -} - -static inline int iswprint_l(wint_t c, locale_t) { - return iswprint(c); -} - -static inline int iswpunct_l(wint_t c, locale_t) { - return iswpunct(c); -} - -static inline int iswspace_l(wint_t c, locale_t) { - return iswspace(c); -} - -static inline int iswupper_l(wint_t c, locale_t) { - return iswupper(c); -} - -static inline int iswxdigit_l(wint_t c, locale_t) { - return iswxdigit(c); -} - -static inline int toupper_l(int c, locale_t) { - return toupper(c); -} - -static inline int tolower_l(int c, locale_t) { - return tolower(c); -} - -static inline int towupper_l(int c, locale_t) { - return towupper(c); -} - -static inline int towlower_l(int c, locale_t) { - return towlower(c); -} - -static inline int strcoll_l(const char *s1, const char *s2, locale_t) { - return strcoll(s1, s2); -} - -static inline size_t strxfrm_l(char *dest, const char *src, size_t n, - locale_t) { - return strxfrm(dest, src, n); -} - -static inline size_t strftime_l(char *s, size_t max, const char *format, -const struct tm *tm, locale_t) { - return strftime(s, max, format, tm); -} - -static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) { - return wcscoll(ws1, ws2); -} - -static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, - locale_t) { - return wcsxfrm(dest, src, n); -} - -static inline long double strtold_l(const char *nptr, char **endptr, locale_t) { - return strtold(nptr, endptr); -} - -static inline long long strtoll_l(const char *nptr, char **endptr, int base, - locale_t) { - return strtoll(nptr, endptr, base); -} - -static inline unsigned long long strtoull_l(const char *nptr, char **endptr, -int base, locale_t) { - return strtoull(nptr, endptr, base); -} - -static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t) { - return wcstoll(nptr, endptr, base); -} - -static inline unsigned long long wcstou
Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI
bcraig updated this revision to Diff 57521. bcraig marked 2 inline comments as done. http://reviews.llvm.org/D17416 Files: include/support/android/locale_bionic.h include/support/newlib/xlocale.h include/support/xlocale/__posix_l_fallback.h include/support/xlocale/__strtonum_fallback.h include/support/xlocale/xlocale.h Index: include/support/xlocale/xlocale.h === --- include/support/xlocale/xlocale.h +++ /dev/null @@ -1,194 +0,0 @@ -// -*- C++ -*- -//===--- support/xlocale/xlocale.h ===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// -// This is a shared implementation of a shim to provide extended locale support -// on top of libc's that don't support it (like Android's bionic, and Newlib). -// -// The 'illusion' only works when the specified locale is "C" or "POSIX", but -// that's about as good as we can do without implementing full xlocale support -// in the underlying libc. -//===--===// - -#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H -#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H - -#ifdef __cplusplus -extern "C" { -#endif - -static inline int isalnum_l(int c, locale_t) { - return isalnum(c); -} - -static inline int isalpha_l(int c, locale_t) { - return isalpha(c); -} - -static inline int isblank_l(int c, locale_t) { - return isblank(c); -} - -static inline int iscntrl_l(int c, locale_t) { - return iscntrl(c); -} - -static inline int isdigit_l(int c, locale_t) { - return isdigit(c); -} - -static inline int isgraph_l(int c, locale_t) { - return isgraph(c); -} - -static inline int islower_l(int c, locale_t) { - return islower(c); -} - -static inline int isprint_l(int c, locale_t) { - return isprint(c); -} - -static inline int ispunct_l(int c, locale_t) { - return ispunct(c); -} - -static inline int isspace_l(int c, locale_t) { - return isspace(c); -} - -static inline int isupper_l(int c, locale_t) { - return isupper(c); -} - -static inline int isxdigit_l(int c, locale_t) { - return isxdigit(c); -} - -static inline int iswalnum_l(wint_t c, locale_t) { - return iswalnum(c); -} - -static inline int iswalpha_l(wint_t c, locale_t) { - return iswalpha(c); -} - -static inline int iswblank_l(wint_t c, locale_t) { - return iswblank(c); -} - -static inline int iswcntrl_l(wint_t c, locale_t) { - return iswcntrl(c); -} - -static inline int iswdigit_l(wint_t c, locale_t) { - return iswdigit(c); -} - -static inline int iswgraph_l(wint_t c, locale_t) { - return iswgraph(c); -} - -static inline int iswlower_l(wint_t c, locale_t) { - return iswlower(c); -} - -static inline int iswprint_l(wint_t c, locale_t) { - return iswprint(c); -} - -static inline int iswpunct_l(wint_t c, locale_t) { - return iswpunct(c); -} - -static inline int iswspace_l(wint_t c, locale_t) { - return iswspace(c); -} - -static inline int iswupper_l(wint_t c, locale_t) { - return iswupper(c); -} - -static inline int iswxdigit_l(wint_t c, locale_t) { - return iswxdigit(c); -} - -static inline int toupper_l(int c, locale_t) { - return toupper(c); -} - -static inline int tolower_l(int c, locale_t) { - return tolower(c); -} - -static inline int towupper_l(int c, locale_t) { - return towupper(c); -} - -static inline int towlower_l(int c, locale_t) { - return towlower(c); -} - -static inline int strcoll_l(const char *s1, const char *s2, locale_t) { - return strcoll(s1, s2); -} - -static inline size_t strxfrm_l(char *dest, const char *src, size_t n, - locale_t) { - return strxfrm(dest, src, n); -} - -static inline size_t strftime_l(char *s, size_t max, const char *format, -const struct tm *tm, locale_t) { - return strftime(s, max, format, tm); -} - -static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) { - return wcscoll(ws1, ws2); -} - -static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, - locale_t) { - return wcsxfrm(dest, src, n); -} - -static inline long double strtold_l(const char *nptr, char **endptr, locale_t) { - return strtold(nptr, endptr); -} - -static inline long long strtoll_l(const char *nptr, char **endptr, int base, - locale_t) { - return strtoll(nptr, endptr, base); -} - -static inline unsigned long long strtoull_l(const char *nptr, char **endptr, -int base, locale_t) { - return strtoull(nptr, endptr, base); -} - -static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t) { - return wcstoll(nptr, endptr, base); -} -
Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI
bcraig added a comment. I'll be submitting this Friday morning, barring any objections (I'm out of the office the next couple of days). http://reviews.llvm.org/D17416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r270213 - Reorganize locale extension fallbacks. NFCI
Author: bcraig Date: Fri May 20 07:58:41 2016 New Revision: 270213 URL: http://llvm.org/viewvc/llvm-project?rev=270213&view=rev Log: Reorganize locale extension fallbacks. NFCI The various _l locale extension functions originate from very different places. Some come from POSIX, some are BSD extensions, and some are shared BSD and GLIBC extensions. This patch tries to group the local extension reimplementations by source. This should make it easier to make libcxx work with POSIX compliant C libraries that lack these extensions. The fallback locale functions are also useful on their own for other lightweight platforms. Putting these fallback implementations in support/xlocale should enable code sharing. I have no access to a newlib system or an android system to build and test with. I _do_ have access to a system without any of the _l locale extensions though, and I was able to ensure that the new __posix_l_fallback.h and __strtonum_fallback.h didn't have any massive problems. http://reviews.llvm.org/D17416 Added: libcxx/trunk/include/support/xlocale/__posix_l_fallback.h libcxx/trunk/include/support/xlocale/__strtonum_fallback.h libcxx/trunk/include/support/xlocale/xlocale.h Modified: libcxx/trunk/include/support/android/locale_bionic.h libcxx/trunk/include/support/newlib/xlocale.h Modified: libcxx/trunk/include/support/android/locale_bionic.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=270213&r1=270212&r2=270213&view=diff == --- libcxx/trunk/include/support/android/locale_bionic.h (original) +++ libcxx/trunk/include/support/android/locale_bionic.h Fri May 20 07:58:41 2016 @@ -24,8 +24,8 @@ extern "C" { } #endif -// Share implementation with Newlib -#include +#include +#include #endif // defined(__ANDROID__) #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H Modified: libcxx/trunk/include/support/newlib/xlocale.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=270213&r1=270212&r2=270213&view=diff == --- libcxx/trunk/include/support/newlib/xlocale.h (original) +++ libcxx/trunk/include/support/newlib/xlocale.h Fri May 20 07:58:41 2016 @@ -17,17 +17,8 @@ #include #include #include - -#ifdef __cplusplus -extern "C" { -#endif - -// Share implementation with Android's Bionic -#include - -#ifdef __cplusplus -} // extern "C" -#endif +#include +#include #endif // _NEWLIB_VERSION Added: libcxx/trunk/include/support/xlocale/__posix_l_fallback.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/xlocale/__posix_l_fallback.h?rev=270213&view=auto == --- libcxx/trunk/include/support/xlocale/__posix_l_fallback.h (added) +++ libcxx/trunk/include/support/xlocale/__posix_l_fallback.h Fri May 20 07:58:41 2016 @@ -0,0 +1,165 @@ +// -*- C++ -*- +//===--- support/xlocale/__posix_l_fallback.h -===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// +// These are reimplementations of some extended locale functions ( *_l ) that +// are normally part of POSIX. This shared implementation provides parts of the +// extended locale support for libc's that normally don't have any (like +// Android's bionic and Newlib). +//===--===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H +#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +inline _LIBCPP_ALWAYS_INLINE int isalnum_l(int c, locale_t) { + return ::isalnum(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isalpha_l(int c, locale_t) { + return ::isalpha(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isblank_l(int c, locale_t) { + return ::isblank(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iscntrl_l(int c, locale_t) { + return ::iscntrl(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isdigit_l(int c, locale_t) { + return ::isdigit(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isgraph_l(int c, locale_t) { + return ::isgraph(c); +} + +inline _LIBCPP_ALWAYS_INLINE int islower_l(int c, locale_t) { + return ::islower(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isprint_l(int c, locale_t) { + return ::isprint(c); +} + +inline _LIBCPP_ALWAYS_INLINE int ispunct_l(int c, locale_t) { + return ::ispunct(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isspace_l(int c, locale_t) { + return ::isspace(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isupper_l(int c, locale_t) { + return ::isupper(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isxdigit_l(i
Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI
bcraig closed this revision. bcraig added a comment. r270213 http://reviews.llvm.org/D17416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi
bcraig added a comment. ping http://reviews.llvm.org/D16545 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install
bcraig added a comment. ping http://reviews.llvm.org/D17410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI
bcraig added a comment. ping @danalbert, @mclow.lists http://reviews.llvm.org/D17416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.
bcraig added a subscriber: bcraig. bcraig added a comment. Is this checker able to connect a std::string with a pre-declared string literal (i.e. constant propagation)? For example... const char *bad_chars = "\0\1\2\3"; std::string bad_str = bad_chars; I've had real code make that mistake before. http://reviews.llvm.org/D18783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install
bcraig added a comment. In http://reviews.llvm.org/D17410#403263, @EricWF wrote: > So we already do this for the standalone builds but not for in-tree builds. > Before committing please make sure to remove the code on CMakeLists.txt line > 99 that does this same thing. Done > I'm assuming changing these CMake variables doesn't propagate upwards to > other in-tree projects? libcxx has an almost identical line in its top level CMakeLists.txt at the same scope. Seems that if it's ok there, it should be fine here. http://reviews.llvm.org/D17410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r266611 - Respect LIBCXXABI_LIBDIR_SUFFIX before an install
Author: bcraig Date: Mon Apr 18 08:30:38 2016 New Revision: 266611 URL: http://llvm.org/viewvc/llvm-project?rev=266611&view=rev Log: Respect LIBCXXABI_LIBDIR_SUFFIX before an install Prior to this patch, setting LIBCXXABI_LIBDIR_SUFFIX would confuse the check-libcxxabi target. libc++abi.* would get output to lib instead of lib${LIBCXXABI_LIBDIR_SUFFIX}, but the tests would look in the suffixed directory. Now, we match what libcxx does, and set the CMAKE_*_OUTPUT_DIRECTORY to the LIBRARY_DIR. http://reviews.llvm.org/D17410 Modified: libcxxabi/trunk/CMakeLists.txt Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=266611&r1=266610&r2=266611&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Mon Apr 18 08:30:38 2016 @@ -96,9 +96,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR set(LIBCXXABI_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) - set(LIBCXXABI_BUILT_STANDALONE 1) else() set(LLVM_MAIN_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Path to LLVM source tree") @@ -182,6 +179,9 @@ set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURREN set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) + #=== # Setup Compiler Flags #=== ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install
bcraig closed this revision. bcraig added a comment. r266611 http://reviews.llvm.org/D17410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi
bcraig added a comment. In http://reviews.llvm.org/D16544#403273, @EricWF wrote: > Just spitballing but have you considered simply passing the full path, > including the library name, to LIT? Instead of needing `enable_shared` > variables we would simply use the named library, be it DSO or archive. I agree that this would be nice. I don't really like the nest of if / else statements that I currently have in place. However, I have now attempted to do this, and failed. My cmake-fu just isn't strong enough. My approach was to populate variables like so... get_target_property(LIBCXXABI_FULL_LIB_PATH cxxabi_static LOCATION) get_target_property(LIBCXXABI_FULL_LIB_PATH cxxabi_shared LOCATION) get_target_property(LIBCXX_FULL_LIB_PATH cxx LOCATION) ... and then to plumb that through lit.site.cfg.in. This would work great if the core of cxxabi and cxx were processed first, followed by their respective tests. Unfortunately, cxxabi and it's tests get processed before cxx gets processed. This means that I can't rely on cxx's CMakeLists.txt to populate a path on behalf of cxxabi. I could attempt to rebuild the path from the pieces of information that I do have access to, but that seems really hacky. Note that getting a full path in doesn't remove all the if / elif complexity in getting cxx[abi] to the link line. If no desired path exists in the config, then something like -lc++ or -lc++abi still needs to be passed in. This is to handle the case where someone is building one of libcxx[abi] without the counterpart being available. We don't know the absolute path to the respective library, but it is (presumably) in the library path. http://reviews.llvm.org/D16544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits