diff --git a/Android.bp b/Android.bp index 5a38bbbea90d4874cb2a57896bb10e297b2cb5b2..d752d002877795169322fd5070211d1314797fae 100644 --- a/Android.bp +++ b/Android.bp @@ -413,6 +413,94 @@ libclang_rt_prebuilt_library_shared { }, } +/////////////////////////////////////////////////////////////////////////////// +cc_defaults { + name: "libclang_rt.ubsan_standalone-android.static-default", + defaults: ["libclang_rt-prebuilt-default"], + sdk_version: "minimum", + enabled: false, + vendor_available: true, + product_available: true, + recovery_available: true, + double_loadable: true, + stl: "c++_static", +} + +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-arm-android.static", + defaults: ["libclang_rt.ubsan_standalone-android.static-default"], + sdk_version: "24", + check_elf_files: false, // Bypass circular dependency between libc++ + arch: { + arm: { + enabled: true, + }, + }, +} + +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-aarch64-android.static", + defaults: ["libclang_rt.ubsan_standalone-android.static-default"], + check_elf_files: false, // Bypass circular dependency between libc++ + host_supported: true, + arch: { + arm64: { + enabled: true, + }, + }, +} + +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-i686-android.static", + defaults: [ + "linux_bionic_supported", + "libclang_rt.ubsan_standalone-android.static-default", + ], + check_elf_files: false, // Bypass circular dependency between libc++ + arch: { + x86: { + enabled: true, + }, + }, +} + +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-x86_64-android.static", + defaults: [ + "linux_bionic_supported", + "libclang_rt.ubsan_standalone-android.static-default", + ], + check_elf_files: false, // Bypass circular dependency between libc++ + arch: { + x86_64: { + enabled: true, + }, + }, +} + +/////////////////////////////////////////////////////////////////////////////// +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-i386.static", + enabled: false, + host_supported: true, + target: { + linux_glibc_x86: { + enabled: true, + }, + }, +} + +libclang_rt_prebuilt_library_static { + name: "libclang_rt.ubsan_standalone-x86_64.static", + enabled: false, + host_supported: true, + target: { + linux_glibc_x86_64: { + enabled: true, + }, + }, +} + /////////////////////////////////////////////////////////////////////////////// cc_defaults { name: "libclang_rt.ubsan_minimal-android-default", diff --git a/clang-r353983c/AndroidVersion.txt b/clang-r353983c/AndroidVersion.txt deleted file mode 100644 index 86273868990349c11372fd7a603670f0a4240f97..0000000000000000000000000000000000000000 --- a/clang-r353983c/AndroidVersion.txt +++ /dev/null @@ -1,2 +0,0 @@ -9.0.3 -based on r353983c diff --git a/clang-r353983c/MODULE_LICENSE_APACHE2 b/clang-r353983c/MODULE_LICENSE_APACHE2 deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/clang-r353983c/MODULE_LICENSE_BSD_LIKE b/clang-r353983c/MODULE_LICENSE_BSD_LIKE deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/clang-r353983c/MODULE_LICENSE_MIT b/clang-r353983c/MODULE_LICENSE_MIT deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/clang-r353983c/NOTICE b/clang-r353983c/NOTICE deleted file mode 100644 index b051002f8a69f553700ee907ccd3c56d9a2c6c8e..0000000000000000000000000000000000000000 --- a/clang-r353983c/NOTICE +++ /dev/null @@ -1,2414 +0,0 @@ -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== -University of Illinois/NCSA -Open Source License - -Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== - -The compiler_rt library is dual licensed under both the University of Illinois -"BSD-Like" license and the MIT license. As a user of this code you may choose -to use it under either license. As a contributor, you agree to allow your code -to be used under both. - -Full text of the relevant licenses is included below. - -============================================================================== - -University of Illinois/NCSA -Open Source License - -Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT - -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== - -Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== - -The libc++ library is dual licensed under both the University of Illinois -"BSD-Like" license and the MIT license. As a user of this code you may choose -to use it under either license. As a contributor, you agree to allow your code -to be used under both. - -Full text of the relevant licenses is included below. - -============================================================================== - -University of Illinois/NCSA -Open Source License - -Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT - -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== - -Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== - -The libc++abi library is dual licensed under both the University of Illinois -"BSD-Like" license and the MIT license. As a user of this code you may choose -to use it under either license. As a contributor, you agree to allow your code -to be used under both. - -Full text of the relevant licenses is included below. - -============================================================================== - -University of Illinois/NCSA -Open Source License - -Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT - -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== - -Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== - -The software contained in this directory tree is dual licensed under both the -University of Illinois "BSD-Like" license and the MIT license. As a user of -this code you may choose to use it under either license. As a contributor, -you agree to allow your code to be used under both. The full text of the -relevant licenses is included below. - -In addition, a license agreement from the copyright/patent holders of the -software contained in this directory tree is included below. - -============================================================================== - -University of Illinois/NCSA -Open Source License - -Copyright (c) 1997-2019 Intel Corporation - -All rights reserved. - -Developed by: - OpenMP Runtime Team - Intel Corporation - http://www.openmprtl.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of Intel Corporation OpenMP Runtime Team nor the - names of its contributors may be used to endorse or promote products - derived from this Software without specific prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== - -Copyright (c) 1997-2019 Intel Corporation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -============================================================================== - -Intel Corporation - -Software Grant License Agreement ("Agreement") - -Except for the license granted herein to you, Intel Corporation ("Intel") reserves -all right, title, and interest in and to the Software (defined below). - -Definition - -"Software" means the code and documentation as well as any original work of -authorship, including any modifications or additions to an existing work, that -is intentionally submitted by Intel to llvm.org (http://llvm.org) ("LLVM") for -inclusion in, or documentation of, any of the products owned or managed by LLVM -(the "Work"). For the purposes of this definition, "submitted" means any form of -electronic, verbal, or written communication sent to LLVM or its -representatives, including but not limited to communication on electronic -mailing lists, source code control systems, and issue tracking systems that are -managed by, or on behalf of, LLVM for the purpose of discussing and improving -the Work, but excluding communication that is conspicuously marked otherwise. - -1. Grant of Copyright License. Subject to the terms and conditions of this - Agreement, Intel hereby grants to you and to recipients of the Software - distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, - royalty-free, irrevocable copyright license to reproduce, prepare derivative - works of, publicly display, publicly perform, sublicense, and distribute the - Software and such derivative works. - -2. Grant of Patent License. Subject to the terms and conditions of this - Agreement, Intel hereby grants you and to recipients of the Software - distributed by LLVM a perpetual, worldwide, non-exclusive, no-charge, - royalty-free, irrevocable (except as stated in this section) patent license - to make, have made, use, offer to sell, sell, import, and otherwise transfer - the Work, where such license applies only to those patent claims licensable - by Intel that are necessarily infringed by Intel's Software alone or by - combination of the Software with the Work to which such Software was - submitted. If any entity institutes patent litigation against Intel or any - other entity (including a cross-claim or counterclaim in a lawsuit) alleging - that Intel's Software, or the Work to which Intel has contributed constitutes - direct or contributory patent infringement, then any patent licenses granted - to that entity under this Agreement for the Software or Work shall terminate - as of the date such litigation is filed. - -Unless required by applicable law or agreed to in writing, the software is -provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -either express or implied, including, without limitation, any warranties or -conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -PARTICULAR PURPOSE. - -============================================================================== - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== -University of Illinois/NCSA -Open Source License - -Copyright (c) 2007-2019 University of Illinois at Urbana-Champaign. -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== -University of Illinois/NCSA -Open Source License - -Copyright (c) 2007-2019 University of Illinois at Urbana-Champaign. -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== -The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: -============================================================================== - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. - -============================================================================== -Software from third parties included in the LLVM Project: -============================================================================== -The LLVM Project contains third party software which is under different license -terms. All such code will be identified clearly using at least one of two -mechanisms: -1) It will be in a separate directory tree with its own `LICENSE.txt` or - `LICENSE` file at the top containing the specific license and restrictions - which apply to that software, or -2) It will contain specific license and restriction terms at the top of every - file. - -============================================================================== -Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): -============================================================================== -University of Illinois/NCSA -Open Source License - -Copyright (c) 2011-2019 by the contributors listed in CREDITS.TXT -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. diff --git a/clang-r353983c/bin/bisect_driver.py b/clang-r353983c/bin/bisect_driver.py deleted file mode 100755 index 95d0ad13b44f58da2c288d80c4428db346d5ac14..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/bisect_driver.py +++ /dev/null @@ -1,337 +0,0 @@ -# Copyright 2016 Google Inc. All Rights Reserved. -# -# This script is used to help the compiler wrapper in the Android build system -# bisect for bad object files. -"""Utilities for bisection of Android object files. - -This module contains a set of utilities to allow bisection between -two sets (good and bad) of object files. Mostly used to find compiler -bugs. - -Reference page: -https://sites.google.com/a/google.com/chromeos-toolchain-team-home2/home/team-tools-and-scripts/bisecting-chromeos-compiler-problems/bisection-compiler-wrapper - -Design doc: -https://docs.google.com/document/d/1yDgaUIa2O5w6dc3sSTe1ry-1ehKajTGJGQCbyn0fcEM -""" - -from __future__ import print_function - -import contextlib -import fcntl -import os -import shutil -import subprocess -import sys - -VALID_MODES = ['POPULATE_GOOD', 'POPULATE_BAD', 'TRIAGE'] -GOOD_CACHE = 'good' -BAD_CACHE = 'bad' -LIST_FILE = os.path.join(GOOD_CACHE, '_LIST') - -CONTINUE_ON_MISSING = os.environ.get('BISECT_CONTINUE_ON_MISSING', None) == '1' -WRAPPER_SAFE_MODE = os.environ.get('BISECT_WRAPPER_SAFE_MODE', None) == '1' - - -class Error(Exception): - """The general compiler wrapper error class.""" - pass - - -@contextlib.contextmanager -def lock_file(path, mode): - """Lock file and block if other process has lock on file. - - Acquire exclusive lock for file. Only blocks other processes if they attempt - to also acquire lock through this method. If only reading (modes 'r' and 'rb') - then the lock is shared (i.e. many reads can happen concurrently, but only one - process may write at a time). - - This function is a contextmanager, meaning it's meant to be used with the - "with" statement in Python. This is so cleanup and setup happens automatically - and cleanly. Execution of the outer "with" statement happens at the "yield" - statement. Execution resumes after the yield when the outer "with" statement - ends. - - Args: - path: path to file being locked - mode: mode to open file with ('w', 'r', etc.) - """ - with open(path, mode) as f: - # Share the lock if just reading, make lock exclusive if writing - if f.mode == 'r' or f.mode == 'rb': - lock_type = fcntl.LOCK_SH - else: - lock_type = fcntl.LOCK_EX - - try: - fcntl.lockf(f, lock_type) - yield f - f.flush() - except: - raise - finally: - fcntl.lockf(f, fcntl.LOCK_UN) - - -def log_to_file(path, execargs, link_from=None, link_to=None): - """Common logging function. - - Log current working directory, current execargs, and a from-to relationship - between files. - """ - with lock_file(path, 'a') as log: - log.write('cd: %s; %s\n' % (os.getcwd(), ' '.join(execargs))) - if link_from and link_to: - log.write('%s -> %s\n' % (link_from, link_to)) - - -def exec_and_return(execargs): - """Execute process and return. - - Execute according to execargs and return immediately. Don't inspect - stderr or stdout. - """ - return subprocess.call(execargs) - - -def which_cache(obj_file): - """Determine which cache an object belongs to. - - The binary search tool creates two files for each search iteration listing - the full set of bad objects and full set of good objects. We use this to - determine where an object file should be linked from (good or bad). - """ - bad_set_file = os.environ.get('BISECT_BAD_SET') - ret = subprocess.call(['grep', '-x', '-q', obj_file, bad_set_file]) - if ret == 0: - return BAD_CACHE - else: - return GOOD_CACHE - - -def makedirs(path): - """Try to create directories in path.""" - try: - os.makedirs(path) - except os.error: - if not os.path.isdir(path): - raise - - -def get_obj_path(execargs): - """Get the object path for the object file in the list of arguments. - - Returns: - Absolute object path from execution args (-o argument). If no object being - outputted or output doesn't end in ".o" then return empty string. - """ - try: - i = execargs.index('-o') - except ValueError: - return '' - - obj_path = execargs[i + 1] - if not obj_path.endswith(('.o',)): - # TODO: what suffixes do we need to contemplate - # TODO: add this as a warning - # TODO: need to handle -r compilations - return '' - - return os.path.abspath(obj_path) - - -def get_dep_path(execargs): - """Get the dep file path for the dep file in the list of arguments. - - Returns: - Absolute path of dependency file path from execution args (-o argument). If - no dependency being outputted then return empty string. - """ - if '-MD' not in execargs and '-MMD' not in execargs: - return '' - - # If -MF given this is the path of the dependency file. Otherwise the - # dependency file is the value of -o but with a .d extension - if '-MF' in execargs: - i = execargs.index('-MF') - dep_path = execargs[i + 1] - return os.path.abspath(dep_path) - - full_obj_path = get_obj_path(execargs) - if not full_obj_path: - return '' - - return full_obj_path[:-2] + '.d' - - -def get_dwo_path(execargs): - """Get the dwo file path for the dwo file in the list of arguments. - - Returns: - Absolute dwo file path from execution args (-gsplit-dwarf argument) If no - dwo file being outputted then return empty string. - """ - if '-gsplit-dwarf' not in execargs: - return '' - - full_obj_path = get_obj_path(execargs) - if not full_obj_path: - return '' - - return full_obj_path[:-2] + '.dwo' - - -def in_object_list(obj_name, list_filename): - """Check if object file name exist in file with object list.""" - if not obj_name: - return False - - with lock_file(list_filename, 'r') as list_file: - for line in list_file: - if line.strip() == obj_name: - return True - - return False - - -def get_side_effects(execargs): - """Determine side effects generated by compiler - - Returns: - List of paths of objects that the compiler generates as side effects. - """ - side_effects = [] - - # Cache dependency files - full_dep_path = get_dep_path(execargs) - if full_dep_path: - side_effects.append(full_dep_path) - - # Cache dwo files - full_dwo_path = get_dwo_path(execargs) - if full_dwo_path: - side_effects.append(full_dwo_path) - - return side_effects - - -def cache_file(execargs, bisect_dir, cache, abs_file_path): - """Cache compiler output file (.o/.d/.dwo).""" - # os.path.join fails with absolute paths, use + instead - bisect_path = os.path.join(bisect_dir, cache) + abs_file_path - bisect_path_dir = os.path.dirname(bisect_path) - makedirs(bisect_path_dir) - pop_log = os.path.join(bisect_dir, cache, '_POPULATE_LOG') - log_to_file(pop_log, execargs, abs_file_path, bisect_path) - - try: - if os.path.exists(abs_file_path): - shutil.copy2(abs_file_path, bisect_path) - except Exception: - print('Could not cache file %s' % abs_file_path, file=sys.stderr) - raise - - -def restore_file(bisect_dir, cache, abs_file_path): - """Restore file from cache (.o/.d/.dwo).""" - # os.path.join fails with absolute paths, use + instead - cached_path = os.path.join(bisect_dir, cache) + abs_file_path - if os.path.exists(cached_path): - if os.path.exists(abs_file_path): - os.remove(abs_file_path) - try: - os.link(cached_path, abs_file_path) - except OSError: - shutil.copyfile(cached_path, abs_file_path) - else: - raise Error(('%s is missing from %s cache! Unsure how to proceed. Make ' - 'will now crash.' % (cache, cached_path))) - - -def bisect_populate(execargs, bisect_dir, population_name): - """Add necessary information to the bisect cache for the given execution. - - Extract the necessary information for bisection from the compiler - execution arguments and put it into the bisection cache. This - includes copying the created object file, adding the object - file path to the cache list and keeping a log of the execution. - - Args: - execargs: compiler execution arguments. - bisect_dir: bisection directory. - population_name: name of the cache being populated (good/bad). - """ - retval = exec_and_return(execargs) - if retval: - return retval - - full_obj_path = get_obj_path(execargs) - # If not a normal compiler call then just exit - if not full_obj_path: - return - - cache_file(execargs, bisect_dir, population_name, full_obj_path) - - population_dir = os.path.join(bisect_dir, population_name) - with lock_file(os.path.join(population_dir, '_LIST'), 'a') as object_list: - object_list.write('%s\n' % full_obj_path) - - for side_effect in get_side_effects(execargs): - cache_file(execargs, bisect_dir, population_name, side_effect) - - -def bisect_triage(execargs, bisect_dir): - full_obj_path = get_obj_path(execargs) - obj_list = os.path.join(bisect_dir, LIST_FILE) - - # If the output isn't an object file just call compiler - if not full_obj_path: - return exec_and_return(execargs) - - # If this isn't a bisected object just call compiler - # This shouldn't happen! - if not in_object_list(full_obj_path, obj_list): - if CONTINUE_ON_MISSING: - log_file = os.path.join(bisect_dir, '_MISSING_CACHED_OBJ_LOG') - log_to_file(log_file, execargs, '? compiler', full_obj_path) - return exec_and_return(execargs) - else: - raise Error(('%s is missing from cache! To ignore export ' - 'BISECT_CONTINUE_ON_MISSING=1. See documentation for more ' - 'details on this option.' % full_obj_path)) - - cache = which_cache(full_obj_path) - - # If using safe WRAPPER_SAFE_MODE option call compiler and overwrite the - # result from the good/bad cache. This option is safe and covers all compiler - # side effects, but is very slow! - if WRAPPER_SAFE_MODE: - retval = exec_and_return(execargs) - if retval: - return retval - os.remove(full_obj_path) - restore_file(bisect_dir, cache, full_obj_path) - return - - # Generate compiler side effects. Trick Make into thinking compiler was - # actually executed. - for side_effect in get_side_effects(execargs): - restore_file(bisect_dir, cache, side_effect) - - # If generated object file happened to be pruned/cleaned by Make then link it - # over from cache again. - if not os.path.exists(full_obj_path): - restore_file(bisect_dir, cache, full_obj_path) - - -def bisect_driver(bisect_stage, bisect_dir, execargs): - """Call appropriate bisection stage according to value in bisect_stage.""" - if bisect_stage == 'POPULATE_GOOD': - bisect_populate(execargs, bisect_dir, GOOD_CACHE) - elif bisect_stage == 'POPULATE_BAD': - bisect_populate(execargs, bisect_dir, BAD_CACHE) - elif bisect_stage == 'TRIAGE': - bisect_triage(execargs, bisect_dir) - else: - raise ValueError('wrong value for BISECT_STAGE: %s' % bisect_stage) diff --git a/clang-r353983c/bin/clang b/clang-r353983c/bin/clang deleted file mode 100755 index 081cb20a8b5c28f63a012789ec96922afc390c8c..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/clang +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# pylint: disable=not-callable, relative-import - -# Note that adding top-level imports is discouraged unless they're guaranteed to -# be used. Unnecessary imports eat a measurable number of cycles of this -# wrapper. -import os -import sys - -BISECT_STAGE = os.environ.get('BISECT_STAGE') -# We do not need bisect functionality with Goma and clang. -# Goma server does not have bisect_driver, so we only import -# bisect_driver when needed. See http://b/34862041 -# We should be careful when doing imports because of Goma. -if BISECT_STAGE: - import bisect_driver - -DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT') -BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR -STDERR_REDIRECT_KEY = 'ANDROID_LLVM_STDERR_REDIRECT' -PREBUILT_COMPILER_PATH_KEY = 'ANDROID_LLVM_PREBUILT_COMPILER_PATH' -DISABLED_WARNINGS_KEY = 'ANDROID_LLVM_FALLBACK_DISABLED_WARNINGS' - - -def ProcessArgFile(arg_file): - import shlex - - args = [] - # Read in entire file at once and parse as if in shell - with open(arg_file, 'rb') as f: - args.extend(shlex.split(f.read())) - return args - - -def write_log(path, command, log): - import errno - import fcntl - import time - - with open(path, 'a+') as f: - while True: - try: - fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - break - except IOError as e: - if e.errno == errno.EAGAIN or e.errno == errno.EACCES: - time.sleep(0.5) - f.write('==================COMMAND:====================\n') - f.write(' '.join(command) + '\n\n') - f.write(log) - f.write('==============================================\n\n') - - -class CompilerWrapper(object): - - def __init__(self, argv): - self.argv0_current = argv[0] - self.args = argv[1:] - self.execargs = [] - self.real_compiler = None - self.argv0 = None - self.append_flags = [] - self.prepend_flags = [] - self.custom_flags = {'--gomacc-path': None} - - def set_real_compiler(self): - """Find the real compiler with the absolute path.""" - compiler_path = os.path.dirname(self.argv0_current) - if os.path.islink(__file__): - compiler = os.path.basename(os.readlink(__file__)) - else: - compiler = os.path.basename(os.path.abspath(__file__)) - self.real_compiler = os.path.join(compiler_path, compiler + '.real') - self.argv0 = self.real_compiler - - def process_gomacc_command(self): - """Return the gomacc command if '--gomacc-path' is set.""" - gomacc = self.custom_flags['--gomacc-path'] - if gomacc and os.path.isfile(gomacc): - self.argv0 = gomacc - self.execargs += [gomacc] - - def parse_custom_flags(self): - i = 0 - args = [] - while i < len(self.args): - if self.args[i] in self.custom_flags: - if i >= len(self.args) - 1: - sys.exit('The value of {} is not set.'.format(self.args[i])) - self.custom_flags[self.args[i]] = self.args[i + 1] - i = i + 2 - else: - args.append(self.args[i]) - i = i + 1 - self.args = args - - def add_flags(self): - self.args = self.prepend_flags + self.args + self.append_flags - - def prepare_compiler_args(self, enable_fallback=False): - self.set_real_compiler() - self.parse_custom_flags() - # Goma should not be enabled for new prebuilt. - if not enable_fallback: - self.process_gomacc_command() - self.add_flags() - self.execargs += [self.real_compiler] + self.args - - def exec_clang_with_fallback(self): - import subprocess - - extra_args_begin = len(self.execargs) - - # We only want to pass extra flags to clang and clang++. - if os.path.basename(__file__) in ['clang', 'clang++']: - # We may introduce some new warnings after rebasing and we need to - # disable them before we fix those warnings. - disabled_warnings_env = os.environ.get(DISABLED_WARNINGS_KEY, '') - disabled_warnings = disabled_warnings_env.split(' ') - self.execargs += ['-fno-color-diagnostics'] + disabled_warnings - - p = subprocess.Popen(self.execargs, stderr=subprocess.PIPE) - (_, err) = p.communicate() - sys.stderr.write(err) - if p.returncode != 0: - redirect_path = os.environ[STDERR_REDIRECT_KEY] - write_log(redirect_path, self.execargs, err) - fallback_arg0 = os.path.join(os.environ[PREBUILT_COMPILER_PATH_KEY], - os.path.basename(__file__)) - - # Delete PREBUILT_COMPILER_PATH_KEY so the fallback doesn't keep - # calling itself in case of an error. - del os.environ[PREBUILT_COMPILER_PATH_KEY] - - # Strip extra args added (from DISABLED_WARNINGS_KEY) for clang and - # clang++ above. They may not be recognized by the fallback clang. - self.execargs = self.execargs[:extra_args_begin] - - os.execv(fallback_arg0, [fallback_arg0] + self.execargs[1:]) - - def invoke_compiler(self): - enable_fallback = PREBUILT_COMPILER_PATH_KEY in os.environ - self.prepare_compiler_args(enable_fallback) - if enable_fallback: - self.exec_clang_with_fallback() - else: - os.execv(self.argv0, self.execargs) - - def bisect(self): - self.prepare_compiler_args() - # Handle @file argument syntax with compiler - idx = 0 - # The length of self.execargs can be changed during the @file argument - # expansion, so we need to use while loop instead of for loop. - while idx < len(self.execargs): - if self.execargs[idx][0] == '@': - args_in_file = ProcessArgFile(self.execargs[idx][1:]) - self.execargs = self.execargs[0:idx] + args_in_file +\ - self.execargs[idx + 1:] - # Skip update of idx, since we want to recursively expand - # response files. - else: - idx = idx + 1 - bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, self.execargs) - - -def main(argv): - cw = CompilerWrapper(argv) - if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES\ - and '-o' in argv: - cw.bisect() - else: - cw.invoke_compiler() - - -if __name__ == '__main__': - main(sys.argv) diff --git a/clang-r353983c/bin/clang++ b/clang-r353983c/bin/clang++ deleted file mode 100755 index 081cb20a8b5c28f63a012789ec96922afc390c8c..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/clang++ +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# pylint: disable=not-callable, relative-import - -# Note that adding top-level imports is discouraged unless they're guaranteed to -# be used. Unnecessary imports eat a measurable number of cycles of this -# wrapper. -import os -import sys - -BISECT_STAGE = os.environ.get('BISECT_STAGE') -# We do not need bisect functionality with Goma and clang. -# Goma server does not have bisect_driver, so we only import -# bisect_driver when needed. See http://b/34862041 -# We should be careful when doing imports because of Goma. -if BISECT_STAGE: - import bisect_driver - -DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT') -BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR -STDERR_REDIRECT_KEY = 'ANDROID_LLVM_STDERR_REDIRECT' -PREBUILT_COMPILER_PATH_KEY = 'ANDROID_LLVM_PREBUILT_COMPILER_PATH' -DISABLED_WARNINGS_KEY = 'ANDROID_LLVM_FALLBACK_DISABLED_WARNINGS' - - -def ProcessArgFile(arg_file): - import shlex - - args = [] - # Read in entire file at once and parse as if in shell - with open(arg_file, 'rb') as f: - args.extend(shlex.split(f.read())) - return args - - -def write_log(path, command, log): - import errno - import fcntl - import time - - with open(path, 'a+') as f: - while True: - try: - fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - break - except IOError as e: - if e.errno == errno.EAGAIN or e.errno == errno.EACCES: - time.sleep(0.5) - f.write('==================COMMAND:====================\n') - f.write(' '.join(command) + '\n\n') - f.write(log) - f.write('==============================================\n\n') - - -class CompilerWrapper(object): - - def __init__(self, argv): - self.argv0_current = argv[0] - self.args = argv[1:] - self.execargs = [] - self.real_compiler = None - self.argv0 = None - self.append_flags = [] - self.prepend_flags = [] - self.custom_flags = {'--gomacc-path': None} - - def set_real_compiler(self): - """Find the real compiler with the absolute path.""" - compiler_path = os.path.dirname(self.argv0_current) - if os.path.islink(__file__): - compiler = os.path.basename(os.readlink(__file__)) - else: - compiler = os.path.basename(os.path.abspath(__file__)) - self.real_compiler = os.path.join(compiler_path, compiler + '.real') - self.argv0 = self.real_compiler - - def process_gomacc_command(self): - """Return the gomacc command if '--gomacc-path' is set.""" - gomacc = self.custom_flags['--gomacc-path'] - if gomacc and os.path.isfile(gomacc): - self.argv0 = gomacc - self.execargs += [gomacc] - - def parse_custom_flags(self): - i = 0 - args = [] - while i < len(self.args): - if self.args[i] in self.custom_flags: - if i >= len(self.args) - 1: - sys.exit('The value of {} is not set.'.format(self.args[i])) - self.custom_flags[self.args[i]] = self.args[i + 1] - i = i + 2 - else: - args.append(self.args[i]) - i = i + 1 - self.args = args - - def add_flags(self): - self.args = self.prepend_flags + self.args + self.append_flags - - def prepare_compiler_args(self, enable_fallback=False): - self.set_real_compiler() - self.parse_custom_flags() - # Goma should not be enabled for new prebuilt. - if not enable_fallback: - self.process_gomacc_command() - self.add_flags() - self.execargs += [self.real_compiler] + self.args - - def exec_clang_with_fallback(self): - import subprocess - - extra_args_begin = len(self.execargs) - - # We only want to pass extra flags to clang and clang++. - if os.path.basename(__file__) in ['clang', 'clang++']: - # We may introduce some new warnings after rebasing and we need to - # disable them before we fix those warnings. - disabled_warnings_env = os.environ.get(DISABLED_WARNINGS_KEY, '') - disabled_warnings = disabled_warnings_env.split(' ') - self.execargs += ['-fno-color-diagnostics'] + disabled_warnings - - p = subprocess.Popen(self.execargs, stderr=subprocess.PIPE) - (_, err) = p.communicate() - sys.stderr.write(err) - if p.returncode != 0: - redirect_path = os.environ[STDERR_REDIRECT_KEY] - write_log(redirect_path, self.execargs, err) - fallback_arg0 = os.path.join(os.environ[PREBUILT_COMPILER_PATH_KEY], - os.path.basename(__file__)) - - # Delete PREBUILT_COMPILER_PATH_KEY so the fallback doesn't keep - # calling itself in case of an error. - del os.environ[PREBUILT_COMPILER_PATH_KEY] - - # Strip extra args added (from DISABLED_WARNINGS_KEY) for clang and - # clang++ above. They may not be recognized by the fallback clang. - self.execargs = self.execargs[:extra_args_begin] - - os.execv(fallback_arg0, [fallback_arg0] + self.execargs[1:]) - - def invoke_compiler(self): - enable_fallback = PREBUILT_COMPILER_PATH_KEY in os.environ - self.prepare_compiler_args(enable_fallback) - if enable_fallback: - self.exec_clang_with_fallback() - else: - os.execv(self.argv0, self.execargs) - - def bisect(self): - self.prepare_compiler_args() - # Handle @file argument syntax with compiler - idx = 0 - # The length of self.execargs can be changed during the @file argument - # expansion, so we need to use while loop instead of for loop. - while idx < len(self.execargs): - if self.execargs[idx][0] == '@': - args_in_file = ProcessArgFile(self.execargs[idx][1:]) - self.execargs = self.execargs[0:idx] + args_in_file +\ - self.execargs[idx + 1:] - # Skip update of idx, since we want to recursively expand - # response files. - else: - idx = idx + 1 - bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, self.execargs) - - -def main(argv): - cw = CompilerWrapper(argv) - if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES\ - and '-o' in argv: - cw.bisect() - else: - cw.invoke_compiler() - - -if __name__ == '__main__': - main(sys.argv) diff --git a/clang-r353983c/bin/clang++.real b/clang-r353983c/bin/clang++.real deleted file mode 120000 index 5f658f398bf17919e714d958dcada6a8c483f75d..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/clang++.real +++ /dev/null @@ -1 +0,0 @@ -clang.real \ No newline at end of file diff --git a/clang-r353983c/bin/clang-9 b/clang-r353983c/bin/clang-9 deleted file mode 100755 index 3051fa51778560d80dfd75483b0ae3b418abbbff..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/clang-9 and /dev/null differ diff --git a/clang-r353983c/bin/clang-check b/clang-r353983c/bin/clang-check deleted file mode 100755 index c239976920921cfff79d9ef354ac25043d0dd4b0..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/clang-check and /dev/null differ diff --git a/clang-r353983c/bin/clang-format b/clang-r353983c/bin/clang-format deleted file mode 100755 index 2064aa916476c96b4da5a2f9a9408037f919057d..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/clang-format and /dev/null differ diff --git a/clang-r353983c/bin/clang-tidy b/clang-r353983c/bin/clang-tidy deleted file mode 100755 index 081cb20a8b5c28f63a012789ec96922afc390c8c..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/clang-tidy +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# pylint: disable=not-callable, relative-import - -# Note that adding top-level imports is discouraged unless they're guaranteed to -# be used. Unnecessary imports eat a measurable number of cycles of this -# wrapper. -import os -import sys - -BISECT_STAGE = os.environ.get('BISECT_STAGE') -# We do not need bisect functionality with Goma and clang. -# Goma server does not have bisect_driver, so we only import -# bisect_driver when needed. See http://b/34862041 -# We should be careful when doing imports because of Goma. -if BISECT_STAGE: - import bisect_driver - -DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT') -BISECT_DIR = os.environ.get('BISECT_DIR') or DEFAULT_BISECT_DIR -STDERR_REDIRECT_KEY = 'ANDROID_LLVM_STDERR_REDIRECT' -PREBUILT_COMPILER_PATH_KEY = 'ANDROID_LLVM_PREBUILT_COMPILER_PATH' -DISABLED_WARNINGS_KEY = 'ANDROID_LLVM_FALLBACK_DISABLED_WARNINGS' - - -def ProcessArgFile(arg_file): - import shlex - - args = [] - # Read in entire file at once and parse as if in shell - with open(arg_file, 'rb') as f: - args.extend(shlex.split(f.read())) - return args - - -def write_log(path, command, log): - import errno - import fcntl - import time - - with open(path, 'a+') as f: - while True: - try: - fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - break - except IOError as e: - if e.errno == errno.EAGAIN or e.errno == errno.EACCES: - time.sleep(0.5) - f.write('==================COMMAND:====================\n') - f.write(' '.join(command) + '\n\n') - f.write(log) - f.write('==============================================\n\n') - - -class CompilerWrapper(object): - - def __init__(self, argv): - self.argv0_current = argv[0] - self.args = argv[1:] - self.execargs = [] - self.real_compiler = None - self.argv0 = None - self.append_flags = [] - self.prepend_flags = [] - self.custom_flags = {'--gomacc-path': None} - - def set_real_compiler(self): - """Find the real compiler with the absolute path.""" - compiler_path = os.path.dirname(self.argv0_current) - if os.path.islink(__file__): - compiler = os.path.basename(os.readlink(__file__)) - else: - compiler = os.path.basename(os.path.abspath(__file__)) - self.real_compiler = os.path.join(compiler_path, compiler + '.real') - self.argv0 = self.real_compiler - - def process_gomacc_command(self): - """Return the gomacc command if '--gomacc-path' is set.""" - gomacc = self.custom_flags['--gomacc-path'] - if gomacc and os.path.isfile(gomacc): - self.argv0 = gomacc - self.execargs += [gomacc] - - def parse_custom_flags(self): - i = 0 - args = [] - while i < len(self.args): - if self.args[i] in self.custom_flags: - if i >= len(self.args) - 1: - sys.exit('The value of {} is not set.'.format(self.args[i])) - self.custom_flags[self.args[i]] = self.args[i + 1] - i = i + 2 - else: - args.append(self.args[i]) - i = i + 1 - self.args = args - - def add_flags(self): - self.args = self.prepend_flags + self.args + self.append_flags - - def prepare_compiler_args(self, enable_fallback=False): - self.set_real_compiler() - self.parse_custom_flags() - # Goma should not be enabled for new prebuilt. - if not enable_fallback: - self.process_gomacc_command() - self.add_flags() - self.execargs += [self.real_compiler] + self.args - - def exec_clang_with_fallback(self): - import subprocess - - extra_args_begin = len(self.execargs) - - # We only want to pass extra flags to clang and clang++. - if os.path.basename(__file__) in ['clang', 'clang++']: - # We may introduce some new warnings after rebasing and we need to - # disable them before we fix those warnings. - disabled_warnings_env = os.environ.get(DISABLED_WARNINGS_KEY, '') - disabled_warnings = disabled_warnings_env.split(' ') - self.execargs += ['-fno-color-diagnostics'] + disabled_warnings - - p = subprocess.Popen(self.execargs, stderr=subprocess.PIPE) - (_, err) = p.communicate() - sys.stderr.write(err) - if p.returncode != 0: - redirect_path = os.environ[STDERR_REDIRECT_KEY] - write_log(redirect_path, self.execargs, err) - fallback_arg0 = os.path.join(os.environ[PREBUILT_COMPILER_PATH_KEY], - os.path.basename(__file__)) - - # Delete PREBUILT_COMPILER_PATH_KEY so the fallback doesn't keep - # calling itself in case of an error. - del os.environ[PREBUILT_COMPILER_PATH_KEY] - - # Strip extra args added (from DISABLED_WARNINGS_KEY) for clang and - # clang++ above. They may not be recognized by the fallback clang. - self.execargs = self.execargs[:extra_args_begin] - - os.execv(fallback_arg0, [fallback_arg0] + self.execargs[1:]) - - def invoke_compiler(self): - enable_fallback = PREBUILT_COMPILER_PATH_KEY in os.environ - self.prepare_compiler_args(enable_fallback) - if enable_fallback: - self.exec_clang_with_fallback() - else: - os.execv(self.argv0, self.execargs) - - def bisect(self): - self.prepare_compiler_args() - # Handle @file argument syntax with compiler - idx = 0 - # The length of self.execargs can be changed during the @file argument - # expansion, so we need to use while loop instead of for loop. - while idx < len(self.execargs): - if self.execargs[idx][0] == '@': - args_in_file = ProcessArgFile(self.execargs[idx][1:]) - self.execargs = self.execargs[0:idx] + args_in_file +\ - self.execargs[idx + 1:] - # Skip update of idx, since we want to recursively expand - # response files. - else: - idx = idx + 1 - bisect_driver.bisect_driver(BISECT_STAGE, BISECT_DIR, self.execargs) - - -def main(argv): - cw = CompilerWrapper(argv) - if BISECT_STAGE and BISECT_STAGE in bisect_driver.VALID_MODES\ - and '-o' in argv: - cw.bisect() - else: - cw.invoke_compiler() - - -if __name__ == '__main__': - main(sys.argv) diff --git a/clang-r353983c/bin/clang-tidy.real b/clang-r353983c/bin/clang-tidy.real deleted file mode 100755 index 5d685dbde2f66b70ef8e24573b5a8ded7fbd8e27..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/clang-tidy.real and /dev/null differ diff --git a/clang-r353983c/bin/clang.real b/clang-r353983c/bin/clang.real deleted file mode 120000 index 8a637b0ff088ea6af612394bc479fd4ee860cc6d..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/clang.real +++ /dev/null @@ -1 +0,0 @@ -clang-9 \ No newline at end of file diff --git a/clang-r353983c/bin/dsymutil b/clang-r353983c/bin/dsymutil deleted file mode 100755 index f4a2b589d3833b82e92f51b992a2f2affbdae79e..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/dsymutil and /dev/null differ diff --git a/clang-r353983c/bin/git-clang-format b/clang-r353983c/bin/git-clang-format deleted file mode 100755 index 2696d099e4c7f71900cce571d5b04616b3767dd9..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/git-clang-format +++ /dev/null @@ -1,579 +0,0 @@ -#!/usr/bin/env python -# -#===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===# -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===------------------------------------------------------------------------===# - -r""" -clang-format git integration -============================ - -This file provides a clang-format integration for git. Put it somewhere in your -path and ensure that it is executable. Then, "git clang-format" will invoke -clang-format on the changes in current files or a specific commit. - -For further details, run: -git clang-format -h - -Requires Python 2.7 or Python 3 -""" - -from __future__ import absolute_import, division, print_function -import argparse -import collections -import contextlib -import errno -import os -import re -import subprocess -import sys - -usage = 'git clang-format [OPTIONS] [] [] [--] [...]' - -desc = ''' -If zero or one commits are given, run clang-format on all lines that differ -between the working directory and , which defaults to HEAD. Changes are -only applied to the working directory. - -If two commits are given (requires --diff), run clang-format on all lines in the -second that differ from the first . - -The following git-config settings set the default of the corresponding option: - clangFormat.binary - clangFormat.commit - clangFormat.extension - clangFormat.style -''' - -# Name of the temporary index file in which save the output of clang-format. -# This file is created within the .git directory. -temp_index_basename = 'clang-format-index' - - -Range = collections.namedtuple('Range', 'start, count') - - -def main(): - config = load_git_config() - - # In order to keep '--' yet allow options after positionals, we need to - # check for '--' ourselves. (Setting nargs='*' throws away the '--', while - # nargs=argparse.REMAINDER disallows options after positionals.) - argv = sys.argv[1:] - try: - idx = argv.index('--') - except ValueError: - dash_dash = [] - else: - dash_dash = argv[idx:] - argv = argv[:idx] - - default_extensions = ','.join([ - # From clang/lib/Frontend/FrontendOptions.cpp, all lower case - 'c', 'h', # C - 'm', # ObjC - 'mm', # ObjC++ - 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++ - 'cu', # CUDA - # Other languages that clang-format supports - 'proto', 'protodevel', # Protocol Buffers - 'java', # Java - 'js', # JavaScript - 'ts', # TypeScript - ]) - - p = argparse.ArgumentParser( - usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter, - description=desc) - p.add_argument('--binary', - default=config.get('clangformat.binary', 'clang-format'), - help='path to clang-format'), - p.add_argument('--commit', - default=config.get('clangformat.commit', 'HEAD'), - help='default commit to use if none is specified'), - p.add_argument('--diff', action='store_true', - help='print a diff instead of applying the changes') - p.add_argument('--extensions', - default=config.get('clangformat.extensions', - default_extensions), - help=('comma-separated list of file extensions to format, ' - 'excluding the period and case-insensitive')), - p.add_argument('-f', '--force', action='store_true', - help='allow changes to unstaged files') - p.add_argument('-p', '--patch', action='store_true', - help='select hunks interactively') - p.add_argument('-q', '--quiet', action='count', default=0, - help='print less information') - p.add_argument('--style', - default=config.get('clangformat.style', None), - help='passed to clang-format'), - p.add_argument('-v', '--verbose', action='count', default=0, - help='print extra information') - # We gather all the remaining positional arguments into 'args' since we need - # to use some heuristics to determine whether or not was present. - # However, to print pretty messages, we make use of metavar and help. - p.add_argument('args', nargs='*', metavar='', - help='revision from which to compute the diff') - p.add_argument('ignored', nargs='*', metavar='...', - help='if specified, only consider differences in these files') - opts = p.parse_args(argv) - - opts.verbose -= opts.quiet - del opts.quiet - - commits, files = interpret_args(opts.args, dash_dash, opts.commit) - if len(commits) > 1: - if not opts.diff: - die('--diff is required when two commits are given') - else: - if len(commits) > 2: - die('at most two commits allowed; %d given' % len(commits)) - changed_lines = compute_diff_and_extract_lines(commits, files) - if opts.verbose >= 1: - ignored_files = set(changed_lines) - filter_by_extension(changed_lines, opts.extensions.lower().split(',')) - if opts.verbose >= 1: - ignored_files.difference_update(changed_lines) - if ignored_files: - print('Ignoring changes in the following files (wrong extension):') - for filename in ignored_files: - print(' %s' % filename) - if changed_lines: - print('Running clang-format on the following files:') - for filename in changed_lines: - print(' %s' % filename) - if not changed_lines: - print('no modified files to format') - return - # The computed diff outputs absolute paths, so we must cd before accessing - # those files. - cd_to_toplevel() - if len(commits) > 1: - old_tree = commits[1] - new_tree = run_clang_format_and_save_to_tree(changed_lines, - revision=commits[1], - binary=opts.binary, - style=opts.style) - else: - old_tree = create_tree_from_workdir(changed_lines) - new_tree = run_clang_format_and_save_to_tree(changed_lines, - binary=opts.binary, - style=opts.style) - if opts.verbose >= 1: - print('old tree: %s' % old_tree) - print('new tree: %s' % new_tree) - if old_tree == new_tree: - if opts.verbose >= 0: - print('clang-format did not modify any files') - elif opts.diff: - print_diff(old_tree, new_tree) - else: - changed_files = apply_changes(old_tree, new_tree, force=opts.force, - patch_mode=opts.patch) - if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: - print('changed files:') - for filename in changed_files: - print(' %s' % filename) - - -def load_git_config(non_string_options=None): - """Return the git configuration as a dictionary. - - All options are assumed to be strings unless in `non_string_options`, in which - is a dictionary mapping option name (in lower case) to either "--bool" or - "--int".""" - if non_string_options is None: - non_string_options = {} - out = {} - for entry in run('git', 'config', '--list', '--null').split('\0'): - if entry: - name, value = entry.split('\n', 1) - if name in non_string_options: - value = run('git', 'config', non_string_options[name], name) - out[name] = value - return out - - -def interpret_args(args, dash_dash, default_commit): - """Interpret `args` as "[commits] [--] [files]" and return (commits, files). - - It is assumed that "--" and everything that follows has been removed from - args and placed in `dash_dash`. - - If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its - left (if present) are taken as commits. Otherwise, the arguments are checked - from left to right if they are commits or files. If commits are not given, - a list with `default_commit` is used.""" - if dash_dash: - if len(args) == 0: - commits = [default_commit] - else: - commits = args - for commit in commits: - object_type = get_object_type(commit) - if object_type not in ('commit', 'tag'): - if object_type is None: - die("'%s' is not a commit" % commit) - else: - die("'%s' is a %s, but a commit was expected" % (commit, object_type)) - files = dash_dash[1:] - elif args: - commits = [] - while args: - if not disambiguate_revision(args[0]): - break - commits.append(args.pop(0)) - if not commits: - commits = [default_commit] - files = args - else: - commits = [default_commit] - files = [] - return commits, files - - -def disambiguate_revision(value): - """Returns True if `value` is a revision, False if it is a file, or dies.""" - # If `value` is ambiguous (neither a commit nor a file), the following - # command will die with an appropriate error message. - run('git', 'rev-parse', value, verbose=False) - object_type = get_object_type(value) - if object_type is None: - return False - if object_type in ('commit', 'tag'): - return True - die('`%s` is a %s, but a commit or filename was expected' % - (value, object_type)) - - -def get_object_type(value): - """Returns a string description of an object's type, or None if it is not - a valid git object.""" - cmd = ['git', 'cat-file', '-t', value] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - if p.returncode != 0: - return None - return convert_string(stdout.strip()) - - -def compute_diff_and_extract_lines(commits, files): - """Calls compute_diff() followed by extract_lines().""" - diff_process = compute_diff(commits, files) - changed_lines = extract_lines(diff_process.stdout) - diff_process.stdout.close() - diff_process.wait() - if diff_process.returncode != 0: - # Assume error was already printed to stderr. - sys.exit(2) - return changed_lines - - -def compute_diff(commits, files): - """Return a subprocess object producing the diff from `commits`. - - The return value's `stdin` file object will produce a patch with the - differences between the working directory and the first commit if a single - one was specified, or the difference between both specified commits, filtered - on `files` (if non-empty). Zero context lines are used in the patch.""" - git_tool = 'diff-index' - if len(commits) > 1: - git_tool = 'diff-tree' - cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--'] - cmd.extend(files) - p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - p.stdin.close() - return p - - -def extract_lines(patch_file): - """Extract the changed lines in `patch_file`. - - The return value is a dictionary mapping filename to a list of (start_line, - line_count) pairs. - - The input must have been produced with ``-U0``, meaning unidiff format with - zero lines of context. The return value is a dict mapping filename to a - list of line `Range`s.""" - matches = {} - for line in patch_file: - line = convert_string(line) - match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) - if match: - filename = match.group(1).rstrip('\r\n') - match = re.search(r'^@@ -[0-9,]+ \+(\d+)(,(\d+))?', line) - if match: - start_line = int(match.group(1)) - line_count = 1 - if match.group(3): - line_count = int(match.group(3)) - if line_count > 0: - matches.setdefault(filename, []).append(Range(start_line, line_count)) - return matches - - -def filter_by_extension(dictionary, allowed_extensions): - """Delete every key in `dictionary` that doesn't have an allowed extension. - - `allowed_extensions` must be a collection of lowercase file extensions, - excluding the period.""" - allowed_extensions = frozenset(allowed_extensions) - for filename in list(dictionary.keys()): - base_ext = filename.rsplit('.', 1) - if len(base_ext) == 1 and '' in allowed_extensions: - continue - if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions: - del dictionary[filename] - - -def cd_to_toplevel(): - """Change to the top level of the git repository.""" - toplevel = run('git', 'rev-parse', '--show-toplevel') - os.chdir(toplevel) - - -def create_tree_from_workdir(filenames): - """Create a new git tree with the given files from the working directory. - - Returns the object ID (SHA-1) of the created tree.""" - return create_tree(filenames, '--stdin') - - -def run_clang_format_and_save_to_tree(changed_lines, revision=None, - binary='clang-format', style=None): - """Run clang-format on each file and save the result to a git tree. - - Returns the object ID (SHA-1) of the created tree.""" - def iteritems(container): - try: - return container.iteritems() # Python 2 - except AttributeError: - return container.items() # Python 3 - def index_info_generator(): - for filename, line_ranges in iteritems(changed_lines): - if revision: - git_metadata_cmd = ['git', 'ls-tree', - '%s:%s' % (revision, os.path.dirname(filename)), - os.path.basename(filename)] - git_metadata = subprocess.Popen(git_metadata_cmd, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) - stdout = git_metadata.communicate()[0] - mode = oct(int(stdout.split()[0], 8)) - else: - mode = oct(os.stat(filename).st_mode) - # Adjust python3 octal format so that it matches what git expects - if mode.startswith('0o'): - mode = '0' + mode[2:] - blob_id = clang_format_to_blob(filename, line_ranges, - revision=revision, - binary=binary, - style=style) - yield '%s %s\t%s' % (mode, blob_id, filename) - return create_tree(index_info_generator(), '--index-info') - - -def create_tree(input_lines, mode): - """Create a tree object from the given input. - - If mode is '--stdin', it must be a list of filenames. If mode is - '--index-info' is must be a list of values suitable for "git update-index - --index-info", such as " ". Any other mode - is invalid.""" - assert mode in ('--stdin', '--index-info') - cmd = ['git', 'update-index', '--add', '-z', mode] - with temporary_index_file(): - p = subprocess.Popen(cmd, stdin=subprocess.PIPE) - for line in input_lines: - p.stdin.write(to_bytes('%s\0' % line)) - p.stdin.close() - if p.wait() != 0: - die('`%s` failed' % ' '.join(cmd)) - tree_id = run('git', 'write-tree') - return tree_id - - -def clang_format_to_blob(filename, line_ranges, revision=None, - binary='clang-format', style=None): - """Run clang-format on the given file and save the result to a git blob. - - Runs on the file in `revision` if not None, or on the file in the working - directory if `revision` is None. - - Returns the object ID (SHA-1) of the created blob.""" - clang_format_cmd = [binary] - if style: - clang_format_cmd.extend(['-style='+style]) - clang_format_cmd.extend([ - '-lines=%s:%s' % (start_line, start_line+line_count-1) - for start_line, line_count in line_ranges]) - if revision: - clang_format_cmd.extend(['-assume-filename='+filename]) - git_show_cmd = ['git', 'cat-file', 'blob', '%s:%s' % (revision, filename)] - git_show = subprocess.Popen(git_show_cmd, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) - git_show.stdin.close() - clang_format_stdin = git_show.stdout - else: - clang_format_cmd.extend([filename]) - git_show = None - clang_format_stdin = subprocess.PIPE - try: - clang_format = subprocess.Popen(clang_format_cmd, stdin=clang_format_stdin, - stdout=subprocess.PIPE) - if clang_format_stdin == subprocess.PIPE: - clang_format_stdin = clang_format.stdin - except OSError as e: - if e.errno == errno.ENOENT: - die('cannot find executable "%s"' % binary) - else: - raise - clang_format_stdin.close() - hash_object_cmd = ['git', 'hash-object', '-w', '--path='+filename, '--stdin'] - hash_object = subprocess.Popen(hash_object_cmd, stdin=clang_format.stdout, - stdout=subprocess.PIPE) - clang_format.stdout.close() - stdout = hash_object.communicate()[0] - if hash_object.returncode != 0: - die('`%s` failed' % ' '.join(hash_object_cmd)) - if clang_format.wait() != 0: - die('`%s` failed' % ' '.join(clang_format_cmd)) - if git_show and git_show.wait() != 0: - die('`%s` failed' % ' '.join(git_show_cmd)) - return convert_string(stdout).rstrip('\r\n') - - -@contextlib.contextmanager -def temporary_index_file(tree=None): - """Context manager for setting GIT_INDEX_FILE to a temporary file and deleting - the file afterward.""" - index_path = create_temporary_index(tree) - old_index_path = os.environ.get('GIT_INDEX_FILE') - os.environ['GIT_INDEX_FILE'] = index_path - try: - yield - finally: - if old_index_path is None: - del os.environ['GIT_INDEX_FILE'] - else: - os.environ['GIT_INDEX_FILE'] = old_index_path - os.remove(index_path) - - -def create_temporary_index(tree=None): - """Create a temporary index file and return the created file's path. - - If `tree` is not None, use that as the tree to read in. Otherwise, an - empty index is created.""" - gitdir = run('git', 'rev-parse', '--git-dir') - path = os.path.join(gitdir, temp_index_basename) - if tree is None: - tree = '--empty' - run('git', 'read-tree', '--index-output='+path, tree) - return path - - -def print_diff(old_tree, new_tree): - """Print the diff between the two trees to stdout.""" - # We use the porcelain 'diff' and not plumbing 'diff-tree' because the output - # is expected to be viewed by the user, and only the former does nice things - # like color and pagination. - # - # We also only print modified files since `new_tree` only contains the files - # that were modified, so unmodified files would show as deleted without the - # filter. - subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree, - '--']) - - -def apply_changes(old_tree, new_tree, force=False, patch_mode=False): - """Apply the changes in `new_tree` to the working directory. - - Bails if there are local changes in those files and not `force`. If - `patch_mode`, runs `git checkout --patch` to select hunks interactively.""" - changed_files = run('git', 'diff-tree', '--diff-filter=M', '-r', '-z', - '--name-only', old_tree, - new_tree).rstrip('\0').split('\0') - if not force: - unstaged_files = run('git', 'diff-files', '--name-status', *changed_files) - if unstaged_files: - print('The following files would be modified but ' - 'have unstaged changes:', file=sys.stderr) - print(unstaged_files, file=sys.stderr) - print('Please commit, stage, or stash them first.', file=sys.stderr) - sys.exit(2) - if patch_mode: - # In patch mode, we could just as well create an index from the new tree - # and checkout from that, but then the user will be presented with a - # message saying "Discard ... from worktree". Instead, we use the old - # tree as the index and checkout from new_tree, which gives the slightly - # better message, "Apply ... to index and worktree". This is not quite - # right, since it won't be applied to the user's index, but oh well. - with temporary_index_file(old_tree): - subprocess.check_call(['git', 'checkout', '--patch', new_tree]) - index_tree = old_tree - else: - with temporary_index_file(new_tree): - run('git', 'checkout-index', '-a', '-f') - return changed_files - - -def run(*args, **kwargs): - stdin = kwargs.pop('stdin', '') - verbose = kwargs.pop('verbose', True) - strip = kwargs.pop('strip', True) - for name in kwargs: - raise TypeError("run() got an unexpected keyword argument '%s'" % name) - p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - stdout, stderr = p.communicate(input=stdin) - - stdout = convert_string(stdout) - stderr = convert_string(stderr) - - if p.returncode == 0: - if stderr: - if verbose: - print('`%s` printed to stderr:' % ' '.join(args), file=sys.stderr) - print(stderr.rstrip(), file=sys.stderr) - if strip: - stdout = stdout.rstrip('\r\n') - return stdout - if verbose: - print('`%s` returned %s' % (' '.join(args), p.returncode), file=sys.stderr) - if stderr: - print(stderr.rstrip(), file=sys.stderr) - sys.exit(2) - - -def die(message): - print('error:', message, file=sys.stderr) - sys.exit(2) - - -def to_bytes(str_input): - # Encode to UTF-8 to get binary data. - if isinstance(str_input, bytes): - return str_input - return str_input.encode('utf-8') - - -def to_string(bytes_input): - if isinstance(bytes_input, str): - return bytes_input - return bytes_input.encode('utf-8') - - -def convert_string(bytes_input): - try: - return to_string(bytes_input.decode('utf-8')) - except AttributeError: # 'str' object has no attribute 'decode'. - return str(bytes_input) - except UnicodeError: - return str(bytes_input) - -if __name__ == '__main__': - main() diff --git a/clang-r353983c/bin/ld.lld b/clang-r353983c/bin/ld.lld deleted file mode 120000 index 02416ace5e341379e1693f750b6bee574be7f22a..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/ld.lld +++ /dev/null @@ -1 +0,0 @@ -lld \ No newline at end of file diff --git a/clang-r353983c/bin/ld64.lld b/clang-r353983c/bin/ld64.lld deleted file mode 120000 index 02416ace5e341379e1693f750b6bee574be7f22a..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/ld64.lld +++ /dev/null @@ -1 +0,0 @@ -lld \ No newline at end of file diff --git a/clang-r353983c/bin/lld b/clang-r353983c/bin/lld deleted file mode 100755 index 471628cdc4f4d169052abd5d7f6b4ad3373d84be..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/lld and /dev/null differ diff --git a/clang-r353983c/bin/lld-link b/clang-r353983c/bin/lld-link deleted file mode 120000 index 02416ace5e341379e1693f750b6bee574be7f22a..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/lld-link +++ /dev/null @@ -1 +0,0 @@ -lld \ No newline at end of file diff --git a/clang-r353983c/bin/llvm-ar b/clang-r353983c/bin/llvm-ar deleted file mode 100755 index ac10e0ac493c6748fdc495d4d51b3805b64878c2..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-ar and /dev/null differ diff --git a/clang-r353983c/bin/llvm-as b/clang-r353983c/bin/llvm-as deleted file mode 100755 index 6d2f4a4959c8be6ee1e3817c05c893673a4504e9..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-as and /dev/null differ diff --git a/clang-r353983c/bin/llvm-cfi-verify b/clang-r353983c/bin/llvm-cfi-verify deleted file mode 100755 index 211ffcc2904f65ea31e071562927720a87336b5c..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-cfi-verify and /dev/null differ diff --git a/clang-r353983c/bin/llvm-config b/clang-r353983c/bin/llvm-config deleted file mode 100755 index c991475dd8d8a8d5bbfa25933a2045da731c4201..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-config and /dev/null differ diff --git a/clang-r353983c/bin/llvm-cov b/clang-r353983c/bin/llvm-cov deleted file mode 100755 index 5d669a8ec2671136eff452b01e666c7a8ec7e560..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-cov and /dev/null differ diff --git a/clang-r353983c/bin/llvm-dis b/clang-r353983c/bin/llvm-dis deleted file mode 100755 index e59ad4f63916d7b8b745dfc45e56c0c91b7f0751..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-dis and /dev/null differ diff --git a/clang-r353983c/bin/llvm-link b/clang-r353983c/bin/llvm-link deleted file mode 100755 index ea8c24e66cb5c3dc0a5c8e2ca9a85c684195386b..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-link and /dev/null differ diff --git a/clang-r353983c/bin/llvm-modextract b/clang-r353983c/bin/llvm-modextract deleted file mode 100755 index 16f82721b1dfaa102555988eafa688afb5ae3ea9..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-modextract and /dev/null differ diff --git a/clang-r353983c/bin/llvm-nm b/clang-r353983c/bin/llvm-nm deleted file mode 100755 index 8a0caf14ecaf8b5a78ef8f695f74cc13d2f90dc5..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-nm and /dev/null differ diff --git a/clang-r353983c/bin/llvm-objcopy b/clang-r353983c/bin/llvm-objcopy deleted file mode 100755 index c1ad8e90638ba4a00ec7ef43c64e2208554102d4..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-objcopy and /dev/null differ diff --git a/clang-r353983c/bin/llvm-objdump b/clang-r353983c/bin/llvm-objdump deleted file mode 100755 index 9122f2f1c242ea5d4b08967ff93dfcf00eaac171..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-objdump and /dev/null differ diff --git a/clang-r353983c/bin/llvm-profdata b/clang-r353983c/bin/llvm-profdata deleted file mode 100755 index b8ac3ae3038cd440cbc536618b5c02523d71cc9b..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-profdata and /dev/null differ diff --git a/clang-r353983c/bin/llvm-readobj b/clang-r353983c/bin/llvm-readobj deleted file mode 100755 index ea47277031a8ab7ba4b5131d5a9057a84f7cecc2..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-readobj and /dev/null differ diff --git a/clang-r353983c/bin/llvm-strip b/clang-r353983c/bin/llvm-strip deleted file mode 120000 index caea5a718f0a6764657322db061ba7f1d9914bd8..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/llvm-strip +++ /dev/null @@ -1 +0,0 @@ -llvm-objcopy \ No newline at end of file diff --git a/clang-r353983c/bin/llvm-symbolizer b/clang-r353983c/bin/llvm-symbolizer deleted file mode 100755 index 7eea9d2d85eb1381f58d922348e1d42358f84628..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/llvm-symbolizer and /dev/null differ diff --git a/clang-r353983c/bin/sancov b/clang-r353983c/bin/sancov deleted file mode 100755 index ff57770cda67d78784c8c7e9ae724097624d5e8a..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/sancov and /dev/null differ diff --git a/clang-r353983c/bin/sanstats b/clang-r353983c/bin/sanstats deleted file mode 100755 index 4a4e9f1ec84408c18edfc83eeac506659d85d907..0000000000000000000000000000000000000000 Binary files a/clang-r353983c/bin/sanstats and /dev/null differ diff --git a/clang-r353983c/bin/scan-build b/clang-r353983c/bin/scan-build deleted file mode 100755 index ed68b3b5a4e42f7a748c9474d4d39ab94b941774..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/scan-build +++ /dev/null @@ -1,1929 +0,0 @@ -#!/usr/bin/env perl -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -##===----------------------------------------------------------------------===## -# -# A script designed to wrap a build so that all calls to gcc are intercepted -# and piped to the static analyzer. -# -##===----------------------------------------------------------------------===## - -use strict; -use warnings; -use FindBin qw($RealBin); -use Digest::MD5; -use File::Basename; -use File::Find; -use File::Copy qw(copy); -use File::Path qw( rmtree mkpath ); -use Term::ANSIColor; -use Term::ANSIColor qw(:constants); -use Cwd qw/ getcwd abs_path /; -use Sys::Hostname; -use Hash::Util qw(lock_keys); - -my $Prog = "scan-build"; -my $BuildName; -my $BuildDate; - -my $TERM = $ENV{'TERM'}; -my $UseColor = (defined $TERM and $TERM =~ 'xterm-.*color' and -t STDOUT - and defined $ENV{'SCAN_BUILD_COLOR'}); - -# Portability: getpwuid is not implemented for Win32 (see Perl language -# reference, perlport), use getlogin instead. -my $UserName = HtmlEscape(getlogin() || getpwuid($<) || 'unknown'); -my $HostName = HtmlEscape(hostname() || 'unknown'); -my $CurrentDir = HtmlEscape(getcwd()); - -my $CmdArgs; - -my $Date = localtime(); - -# Command-line/config arguments. -my %Options = ( - Verbose => 0, # Verbose output from this script. - AnalyzeHeaders => 0, - OutputDir => undef, # Parent directory to store HTML files. - HtmlTitle => basename($CurrentDir)." - scan-build results", - IgnoreErrors => 0, # Ignore build errors. - KeepCC => 0, # Do not override CC and CXX make variables - ViewResults => 0, # View results when the build terminates. - ExitStatusFoundBugs => 0, # Exit status reflects whether bugs were found - ShowDescription => 0, # Display the description of the defect in the list - KeepEmpty => 0, # Don't remove output directory even with 0 results. - EnableCheckers => {}, - DisableCheckers => {}, - Excludes => [], - UseCC => undef, # C compiler to use for compilation. - UseCXX => undef, # C++ compiler to use for compilation. - AnalyzerTarget => undef, - StoreModel => undef, - ConstraintsModel => undef, - InternalStats => undef, - OutputFormat => "html", - ConfigOptions => [], # Options to pass through to the analyzer's -analyzer-config flag. - ReportFailures => undef, - AnalyzerStats => 0, - MaxLoop => 0, - PluginsToLoad => [], - AnalyzerDiscoveryMethod => undef, - OverrideCompiler => 0, # The flag corresponding to the --override-compiler command line option. - ForceAnalyzeDebugCode => 0 -); -lock_keys(%Options); - -##----------------------------------------------------------------------------## -# Diagnostics -##----------------------------------------------------------------------------## - -sub Diag { - if ($UseColor) { - print BOLD, MAGENTA "$Prog: @_"; - print RESET; - } - else { - print "$Prog: @_"; - } -} - -sub ErrorDiag { - if ($UseColor) { - print STDERR BOLD, RED "$Prog: "; - print STDERR RESET, RED @_; - print STDERR RESET; - } else { - print STDERR "$Prog: @_"; - } -} - -sub DiagCrashes { - my $Dir = shift; - Diag ("The analyzer encountered problems on some source files.\n"); - Diag ("Preprocessed versions of these sources were deposited in '$Dir/failures'.\n"); - Diag ("Please consider submitting a bug report using these files:\n"); - Diag (" http://clang-analyzer.llvm.org/filing_bugs.html\n") -} - -sub DieDiag { - if ($UseColor) { - print STDERR BOLD, RED "$Prog: "; - print STDERR RESET, RED @_; - print STDERR RESET; - } - else { - print STDERR "$Prog: ", @_; - } - exit 1; -} - -##----------------------------------------------------------------------------## -# Print default checker names -##----------------------------------------------------------------------------## - -if (grep /^--help-checkers$/, @ARGV) { - my @options = qx($0 -h); - foreach (@options) { - next unless /^ \+/; - s/^\s*//; - my ($sign, $name, @text) = split ' ', $_; - print $name, $/ if $sign eq '+'; - } - exit 0; -} - -##----------------------------------------------------------------------------## -# Declaration of Clang options. Populated later. -##----------------------------------------------------------------------------## - -my $Clang; -my $ClangSB; -my $ClangCXX; -my $ClangVersion; - -##----------------------------------------------------------------------------## -# GetHTMLRunDir - Construct an HTML directory name for the current sub-run. -##----------------------------------------------------------------------------## - -sub GetHTMLRunDir { - die "Not enough arguments." if (@_ == 0); - my $Dir = shift @_; - my $TmpMode = 0; - if (!defined $Dir) { - $Dir = $ENV{'TMPDIR'} || $ENV{'TEMP'} || $ENV{'TMP'} || "/tmp"; - $TmpMode = 1; - } - - # Chop off any trailing '/' characters. - while ($Dir =~ /\/$/) { chop $Dir; } - - # Get current date and time. - my @CurrentTime = localtime(); - my $year = $CurrentTime[5] + 1900; - my $day = $CurrentTime[3]; - my $month = $CurrentTime[4] + 1; - my $hour = $CurrentTime[2]; - my $min = $CurrentTime[1]; - my $sec = $CurrentTime[0]; - - my $TimeString = sprintf("%02d%02d%02d", $hour, $min, $sec); - my $DateString = sprintf("%d-%02d-%02d-%s-$$", - $year, $month, $day, $TimeString); - - # Determine the run number. - my $RunNumber; - - if (-d $Dir) { - if (! -r $Dir) { - DieDiag("directory '$Dir' exists but is not readable.\n"); - } - # Iterate over all files in the specified directory. - my $max = 0; - opendir(DIR, $Dir); - my @FILES = grep { -d "$Dir/$_" } readdir(DIR); - closedir(DIR); - - foreach my $f (@FILES) { - # Strip the prefix '$Prog-' if we are dumping files to /tmp. - if ($TmpMode) { - next if (!($f =~ /^$Prog-(.+)/)); - $f = $1; - } - - my @x = split/-/, $f; - next if (scalar(@x) != 4); - next if ($x[0] != $year); - next if ($x[1] != $month); - next if ($x[2] != $day); - next if ($x[3] != $TimeString); - next if ($x[4] != $$); - - if ($x[5] > $max) { - $max = $x[5]; - } - } - - $RunNumber = $max + 1; - } - else { - - if (-x $Dir) { - DieDiag("'$Dir' exists but is not a directory.\n"); - } - - if ($TmpMode) { - DieDiag("The directory '/tmp' does not exist or cannot be accessed.\n"); - } - - # $Dir does not exist. It will be automatically created by the - # clang driver. Set the run number to 1. - - $RunNumber = 1; - } - - die "RunNumber must be defined!" if (!defined $RunNumber); - - # Append the run number. - my $NewDir; - if ($TmpMode) { - $NewDir = "$Dir/$Prog-$DateString-$RunNumber"; - } - else { - $NewDir = "$Dir/$DateString-$RunNumber"; - } - - # Make sure that the directory does not exist in order to avoid hijack. - if (-e $NewDir) { - DieDiag("The directory '$NewDir' already exists.\n"); - } - - mkpath($NewDir); - return $NewDir; -} - -sub SetHtmlEnv { - - die "Wrong number of arguments." if (scalar(@_) != 2); - - my $Args = shift; - my $Dir = shift; - - die "No build command." if (scalar(@$Args) == 0); - - my $Cmd = $$Args[0]; - - if ($Cmd =~ /configure/ || $Cmd =~ /autogen/) { - return; - } - - if ($Options{Verbose}) { - Diag("Emitting reports for this run to '$Dir'.\n"); - } - - $ENV{'CCC_ANALYZER_HTML'} = $Dir; -} - -##----------------------------------------------------------------------------## -# ComputeDigest - Compute a digest of the specified file. -##----------------------------------------------------------------------------## - -sub ComputeDigest { - my $FName = shift; - DieDiag("Cannot read $FName to compute Digest.\n") if (! -r $FName); - - # Use Digest::MD5. We don't have to be cryptographically secure. We're - # just looking for duplicate files that come from a non-malicious source. - # We use Digest::MD5 because it is a standard Perl module that should - # come bundled on most systems. - open(FILE, $FName) or DieDiag("Cannot open $FName when computing Digest.\n"); - binmode FILE; - my $Result = Digest::MD5->new->addfile(*FILE)->hexdigest; - close(FILE); - - # Return the digest. - return $Result; -} - -##----------------------------------------------------------------------------## -# UpdatePrefix - Compute the common prefix of files. -##----------------------------------------------------------------------------## - -my $Prefix; - -sub UpdatePrefix { - my $x = shift; - my $y = basename($x); - $x =~ s/\Q$y\E$//; - - if (!defined $Prefix) { - $Prefix = $x; - return; - } - - chop $Prefix while (!($x =~ /^\Q$Prefix/)); -} - -sub GetPrefix { - return $Prefix; -} - -##----------------------------------------------------------------------------## -# UpdateInFilePath - Update the path in the report file. -##----------------------------------------------------------------------------## - -sub UpdateInFilePath { - my $fname = shift; - my $regex = shift; - my $newtext = shift; - - open (RIN, $fname) or die "cannot open $fname"; - open (ROUT, ">", "$fname.tmp") or die "cannot open $fname.tmp"; - - while () { - s/$regex/$newtext/; - print ROUT $_; - } - - close (ROUT); - close (RIN); - rename("$fname.tmp", $fname) -} - -##----------------------------------------------------------------------------## -# AddStatLine - Decode and insert a statistics line into the database. -##----------------------------------------------------------------------------## - -sub AddStatLine { - my $Line = shift; - my $Stats = shift; - my $File = shift; - - print $Line . "\n"; - - my $Regex = qr/(.*?)\ ->\ Total\ CFGBlocks:\ (\d+)\ \|\ Unreachable - \ CFGBlocks:\ (\d+)\ \|\ Exhausted\ Block:\ (yes|no)\ \|\ Empty\ WorkList: - \ (yes|no)/x; - - if ($Line !~ $Regex) { - return; - } - - # Create a hash of the interesting fields - my $Row = { - Filename => $File, - Function => $1, - Total => $2, - Unreachable => $3, - Aborted => $4, - Empty => $5 - }; - - # Add them to the stats array - push @$Stats, $Row; -} - -##----------------------------------------------------------------------------## -# ScanFile - Scan a report file for various identifying attributes. -##----------------------------------------------------------------------------## - -# Sometimes a source file is scanned more than once, and thus produces -# multiple error reports. We use a cache to solve this problem. - -my %AlreadyScanned; - -sub ScanFile { - - my $Index = shift; - my $Dir = shift; - my $FName = shift; - my $Stats = shift; - - # Compute a digest for the report file. Determine if we have already - # scanned a file that looks just like it. - - my $digest = ComputeDigest("$Dir/$FName"); - - if (defined $AlreadyScanned{$digest}) { - # Redundant file. Remove it. - unlink("$Dir/$FName"); - return; - } - - $AlreadyScanned{$digest} = 1; - - # At this point the report file is not world readable. Make it happen. - chmod(0644, "$Dir/$FName"); - - # Scan the report file for tags. - open(IN, "$Dir/$FName") or DieDiag("Cannot open '$Dir/$FName'\n"); - - my $BugType = ""; - my $BugFile = ""; - my $BugFunction = ""; - my $BugCategory = ""; - my $BugDescription = ""; - my $BugPathLength = 1; - my $BugLine = 0; - - while () { - last if (//); - - if (/$/) { - $BugType = $1; - } - elsif (/$/) { - $BugFile = abs_path($1); - if (!defined $BugFile) { - # The file no longer exists: use the original path. - $BugFile = $1; - } - - # Get just the path - my $p = dirname($BugFile); - # Check if the path is found in the list of exclude - if (grep { $p =~ m/$_/ } @{$Options{Excludes}}) { - if ($Options{Verbose}) { - Diag("File '$BugFile' deleted: part of an ignored directory.\n"); - } - - # File in an ignored directory. Remove it - unlink("$Dir/$FName"); - return; - } - - UpdatePrefix($BugFile); - } - elsif (/$/) { - $BugPathLength = $1; - } - elsif (/$/) { - $BugLine = $1; - } - elsif (/$/) { - $BugCategory = $1; - } - elsif (/$/) { - $BugDescription = $1; - } - elsif (/$/) { - $BugFunction = $1; - } - - } - - - close(IN); - - if (!defined $BugCategory) { - $BugCategory = "Other"; - } - - # Don't add internal statistics to the bug reports - if ($BugCategory =~ /statistics/i) { - AddStatLine($BugDescription, $Stats, $BugFile); - return; - } - - push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugFunction, $BugLine, - $BugPathLength ]; - - if ($Options{ShowDescription}) { - push @{ $Index->[-1] }, $BugDescription - } -} - -##----------------------------------------------------------------------------## -# CopyFiles - Copy resource files to target directory. -##----------------------------------------------------------------------------## - -sub CopyFiles { - - my $Dir = shift; - - my $JS = Cwd::realpath("$RealBin/../share/scan-build/sorttable.js"); - - DieDiag("Cannot find 'sorttable.js'.\n") - if (! -r $JS); - - copy($JS, "$Dir"); - - DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n") - if (! -r "$Dir/sorttable.js"); - - my $CSS = Cwd::realpath("$RealBin/../share/scan-build/scanview.css"); - - DieDiag("Cannot find 'scanview.css'.\n") - if (! -r $CSS); - - copy($CSS, "$Dir"); - - DieDiag("Could not copy 'scanview.css' to '$Dir'.\n") - if (! -r $CSS); -} - -##----------------------------------------------------------------------------## -# CalcStats - Calculates visitation statistics and returns the string. -##----------------------------------------------------------------------------## - -sub CalcStats { - my $Stats = shift; - - my $TotalBlocks = 0; - my $UnreachedBlocks = 0; - my $TotalFunctions = scalar(@$Stats); - my $BlockAborted = 0; - my $WorkListAborted = 0; - my $Aborted = 0; - - # Calculate the unique files - my $FilesHash = {}; - - foreach my $Row (@$Stats) { - $FilesHash->{$Row->{Filename}} = 1; - $TotalBlocks += $Row->{Total}; - $UnreachedBlocks += $Row->{Unreachable}; - $BlockAborted++ if $Row->{Aborted} eq 'yes'; - $WorkListAborted++ if $Row->{Empty} eq 'no'; - $Aborted++ if $Row->{Aborted} eq 'yes' || $Row->{Empty} eq 'no'; - } - - my $TotalFiles = scalar(keys(%$FilesHash)); - - # Calculations - my $PercentAborted = sprintf("%.2f", $Aborted / $TotalFunctions * 100); - my $PercentBlockAborted = sprintf("%.2f", $BlockAborted / $TotalFunctions - * 100); - my $PercentWorkListAborted = sprintf("%.2f", $WorkListAborted / - $TotalFunctions * 100); - my $PercentBlocksUnreached = sprintf("%.2f", $UnreachedBlocks / $TotalBlocks - * 100); - - my $StatsString = "Analyzed $TotalBlocks blocks in $TotalFunctions functions" - . " in $TotalFiles files\n" - . "$Aborted functions aborted early ($PercentAborted%)\n" - . "$BlockAborted had aborted blocks ($PercentBlockAborted%)\n" - . "$WorkListAborted had unfinished worklists ($PercentWorkListAborted%)\n" - . "$UnreachedBlocks blocks were never reached ($PercentBlocksUnreached%)\n"; - - return $StatsString; -} - -##----------------------------------------------------------------------------## -# Postprocess - Postprocess the results of an analysis scan. -##----------------------------------------------------------------------------## - -my @filesFound; -my $baseDir; -sub FileWanted { - my $baseDirRegEx = quotemeta $baseDir; - my $file = $File::Find::name; - - # The name of the file is generated by clang binary (HTMLDiagnostics.cpp) - if ($file =~ /report-.*\.html$/) { - my $relative_file = $file; - $relative_file =~ s/$baseDirRegEx//g; - push @filesFound, $relative_file; - } -} - -sub Postprocess { - - my $Dir = shift; - my $BaseDir = shift; - my $AnalyzerStats = shift; - my $KeepEmpty = shift; - - die "No directory specified." if (!defined $Dir); - - if (! -d $Dir) { - Diag("No bugs found.\n"); - return 0; - } - - $baseDir = $Dir . "/"; - find({ wanted => \&FileWanted, follow => 0}, $Dir); - - if (scalar(@filesFound) == 0 and ! -e "$Dir/failures") { - if (! $KeepEmpty) { - Diag("Removing directory '$Dir' because it contains no reports.\n"); - rmtree($Dir) or die "Cannot rmtree '$Dir' : $!"; - } - Diag("No bugs found.\n"); - return 0; - } - - # Scan each report file and build an index. - my @Index; - my @Stats; - foreach my $file (@filesFound) { ScanFile(\@Index, $Dir, $file, \@Stats); } - - # Scan the failures directory and use the information in the .info files - # to update the common prefix directory. - my @failures; - my @attributes_ignored; - if (-d "$Dir/failures") { - opendir(DIR, "$Dir/failures"); - @failures = grep { /[.]info.txt$/ && !/attribute_ignored/; } readdir(DIR); - closedir(DIR); - opendir(DIR, "$Dir/failures"); - @attributes_ignored = grep { /^attribute_ignored/; } readdir(DIR); - closedir(DIR); - foreach my $file (@failures) { - open IN, "$Dir/failures/$file" or DieDiag("cannot open $file\n"); - my $Path = ; - if (defined $Path) { UpdatePrefix($Path); } - close IN; - } - } - - # Generate an index.html file. - my $FName = "$Dir/index.html"; - open(OUT, ">", $FName) or DieDiag("Cannot create file '$FName'\n"); - - # Print out the header. - -print OUT < - -${Options{HtmlTitle}} - - - - - - -

${Options{HtmlTitle}}

- - - - - - - -ENDTEXT - -print OUT "\n" - if (defined($BuildName) && defined($BuildDate)); - -print OUT < -ENDTEXT - - if (scalar(@filesFound)) { - # Print out the summary table. - my %Totals; - - for my $row ( @Index ) { - my $bug_type = ($row->[2]); - my $bug_category = ($row->[1]); - my $key = "$bug_category:$bug_type"; - - if (!defined $Totals{$key}) { $Totals{$key} = [1,$bug_category,$bug_type]; } - else { $Totals{$key}->[0]++; } - } - - print OUT "

Bug Summary

"; - - if (defined $BuildName) { - print OUT "\n

Results in this analysis run are based on analyzer build $BuildName.

\n" - } - - my $TotalBugs = scalar(@Index); -print OUT < -
- -ENDTEXT - - my $last_category; - - for my $key ( - sort { - my $x = $Totals{$a}; - my $y = $Totals{$b}; - my $res = $x->[1] cmp $y->[1]; - $res = $x->[2] cmp $y->[2] if ($res == 0); - $res - } keys %Totals ) - { - my $val = $Totals{$key}; - my $category = $val->[1]; - if (!defined $last_category or $last_category ne $category) { - $last_category = $category; - print OUT "\n"; - } - my $x = lc $key; - $x =~ s/[ ,'":\/()]+/_/g; - print OUT "\n"; - } - - # Print out the table of errors. - -print OUT < -

Reports

- -
User:${UserName}\@${HostName}
Working Directory:${CurrentDir}
Command Line:${CmdArgs}
Clang Version:${ClangVersion}
Date:${Date}
Version:${BuildName} (${BuildDate})
Bug TypeQuantityDisplay?
All Bugs$TotalBugs
$category
"; - print OUT $val->[2]; - print OUT ""; - print OUT $val->[0]; - print OUT "
- - - - - - - -ENDTEXT - -if ($Options{ShowDescription}) { -print OUT <Description -ENDTEXT -} - -print OUT < - - - -ENDTEXT - - my $prefix = GetPrefix(); - my $regex; - my $InFileRegex; - my $InFilePrefix = "File:"; - print OUT ""; - print OUT ""; - - # Update the file prefix. - my $fname = $row->[3]; - - if (defined $regex) { - $fname =~ s/$regex//; - UpdateInFilePath("$Dir/$ReportFile", $InFileRegex, $InFilePrefix) - } - - print OUT ""; - - print OUT ""; - - # Print out the quantities. - for my $j ( 5 .. 6 ) { # Line & Path length - print OUT ""; - } - - # Print the rest of the columns. - for (my $j = 7; $j <= $#{$row}; ++$j) { - print OUT "" - } - - # Emit the "View" link. - print OUT ""; - - # Emit REPORTBUG markers. - print OUT "\n\n"; - - # End the row. - print OUT "\n"; - } - - print OUT "\n
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
"; - - if (defined $prefix) { - $regex = qr/^\Q$prefix\E/is; - $InFileRegex = qr/\Q$InFilePrefix$prefix\E/is; - } - - for my $row ( sort { $a->[2] cmp $b->[2] } @Index ) { - my $x = "$row->[1]:$row->[2]"; - $x = lc $x; - $x =~ s/[ ,'":\/()]+/_/g; - - my $ReportFile = $row->[0]; - - print OUT "
"; - print OUT $row->[1]; # $BugCategory - print OUT ""; - print OUT $row->[2]; # $BugType - print OUT ""; - my @fname = split /\//,$fname; - if ($#fname > 0) { - while ($#fname >= 0) { - my $x = shift @fname; - print OUT $x; - if ($#fname >= 0) { - print OUT "/"; - } - } - } - else { - print OUT $fname; - } - print OUT ""; - print OUT $row->[4]; # Function - print OUT "$row->[$j]$row->[$j]View Report
\n\n"; - } - - if (scalar (@failures) || scalar(@attributes_ignored)) { - print OUT "

Analyzer Failures

\n"; - - if (scalar @attributes_ignored) { - print OUT "The analyzer's parser ignored the following attributes:

\n"; - print OUT "\n"; - print OUT "\n"; - foreach my $file (sort @attributes_ignored) { - die "cannot demangle attribute name\n" if (! ($file =~ /^attribute_ignored_(.+).txt/)); - my $attribute = $1; - # Open the attribute file to get the first file that failed. - next if (!open (ATTR, "$Dir/failures/$file")); - my $ppfile = ; - chomp $ppfile; - close ATTR; - next if (! -e "$Dir/failures/$ppfile"); - # Open the info file and get the name of the source file. - open (INFO, "$Dir/failures/$ppfile.info.txt") or - die "Cannot open $Dir/failures/$ppfile.info.txt\n"; - my $srcfile = ; - chomp $srcfile; - close (INFO); - # Print the information in the table. - my $prefix = GetPrefix(); - if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; } - print OUT "\n"; - my $ppfile_clang = $ppfile; - $ppfile_clang =~ s/[.](.+)$/.clang.$1/; - print OUT " \n"; - } - print OUT "
AttributeSource FilePreprocessed FileSTDERR Output
$attribute$srcfile$ppfile$ppfile.stderr.txt
\n"; - } - - if (scalar @failures) { - print OUT "

The analyzer had problems processing the following files:

\n"; - print OUT "\n"; - print OUT "\n"; - foreach my $file (sort @failures) { - $file =~ /(.+).info.txt$/; - # Get the preprocessed file. - my $ppfile = $1; - # Open the info file and get the name of the source file. - open (INFO, "$Dir/failures/$file") or - die "Cannot open $Dir/failures/$file\n"; - my $srcfile = ; - chomp $srcfile; - my $problem = ; - chomp $problem; - close (INFO); - # Print the information in the table. - my $prefix = GetPrefix(); - if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; } - print OUT "\n"; - my $ppfile_clang = $ppfile; - $ppfile_clang =~ s/[.](.+)$/.clang.$1/; - print OUT " \n"; - } - print OUT "
ProblemSource FilePreprocessed FileSTDERR Output
$problem$srcfile$ppfile$ppfile.stderr.txt
\n"; - } - print OUT "

Please consider submitting preprocessed files as bug reports.

\n"; - } - - print OUT "\n"; - close(OUT); - CopyFiles($Dir); - - # Make sure $Dir and $BaseDir are world readable/executable. - chmod(0755, $Dir); - if (defined $BaseDir) { chmod(0755, $BaseDir); } - - # Print statistics - print CalcStats(\@Stats) if $AnalyzerStats; - - my $Num = scalar(@Index); - if ($Num == 1) { - Diag("$Num bug found.\n"); - } else { - Diag("$Num bugs found.\n"); - } - if ($Num > 0 && -r "$Dir/index.html") { - Diag("Run 'scan-view $Dir' to examine bug reports.\n"); - } - - DiagCrashes($Dir) if (scalar @failures || scalar @attributes_ignored); - - return $Num; -} - -##----------------------------------------------------------------------------## -# RunBuildCommand - Run the build command. -##----------------------------------------------------------------------------## - -sub AddIfNotPresent { - my $Args = shift; - my $Arg = shift; - my $found = 0; - - foreach my $k (@$Args) { - if ($k eq $Arg) { - $found = 1; - last; - } - } - - if ($found == 0) { - push @$Args, $Arg; - } -} - -sub SetEnv { - my $EnvVars = shift @_; - foreach my $var ('CC', 'CXX', 'CLANG', 'CLANG_CXX', - 'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS', - 'CCC_ANALYZER_CONFIG') { - die "$var is undefined\n" if (!defined $var); - $ENV{$var} = $EnvVars->{$var}; - } - foreach my $var ('CCC_ANALYZER_STORE_MODEL', - 'CCC_ANALYZER_CONSTRAINTS_MODEL', - 'CCC_ANALYZER_INTERNAL_STATS', - 'CCC_ANALYZER_OUTPUT_FORMAT', - 'CCC_CC', - 'CCC_CXX', - 'CCC_REPORT_FAILURES', - 'CLANG_ANALYZER_TARGET', - 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE') { - my $x = $EnvVars->{$var}; - if (defined $x) { $ENV{$var} = $x } - } - my $Verbose = $EnvVars->{'VERBOSE'}; - if ($Verbose >= 2) { - $ENV{'CCC_ANALYZER_VERBOSE'} = 1; - } - if ($Verbose >= 3) { - $ENV{'CCC_ANALYZER_LOG'} = 1; - } -} - -sub RunXcodebuild { - my $Args = shift; - my $IgnoreErrors = shift; - my $CCAnalyzer = shift; - my $CXXAnalyzer = shift; - my $EnvVars = shift; - - if ($IgnoreErrors) { - AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES"); - } - - # Detect the version of Xcode. If Xcode 4.6 or higher, use new - # in situ support for analyzer interposition without needed to override - # the compiler. - open(DETECT_XCODE, "-|", $Args->[0], "-version") or - die "error: cannot detect version of xcodebuild\n"; - - my $oldBehavior = 1; - - while() { - if (/^Xcode (.+)$/) { - my $ver = $1; - if ($ver =~ /^([0-9]+[.][0-9]+)[^0-9]?/) { - if ($1 >= 4.6) { - $oldBehavior = 0; - last; - } - } - } - } - close(DETECT_XCODE); - - # If --override-compiler is explicitly requested, resort to the old - # behavior regardless of Xcode version. - if ($Options{OverrideCompiler}) { - $oldBehavior = 1; - } - - if ($oldBehavior == 0) { - my $OutputDir = $EnvVars->{"OUTPUT_DIR"}; - my $CLANG = $EnvVars->{"CLANG"}; - my $OtherFlags = $EnvVars->{"CCC_ANALYZER_ANALYSIS"}; - push @$Args, - "RUN_CLANG_STATIC_ANALYZER=YES", - "CLANG_ANALYZER_OUTPUT=plist-html", - "CLANG_ANALYZER_EXEC=$CLANG", - "CLANG_ANALYZER_OUTPUT_DIR=$OutputDir", - "CLANG_ANALYZER_OTHER_FLAGS=$OtherFlags"; - - return (system(@$Args) >> 8); - } - - # Default to old behavior where we insert a bogus compiler. - SetEnv($EnvVars); - - # Check if using iPhone SDK 3.0 (simulator). If so the compiler being - # used should be gcc-4.2. - if (!defined $ENV{"CCC_CC"}) { - for (my $i = 0 ; $i < scalar(@$Args); ++$i) { - if ($Args->[$i] eq "-sdk" && $i + 1 < scalar(@$Args)) { - if (@$Args[$i+1] =~ /^iphonesimulator3/) { - $ENV{"CCC_CC"} = "gcc-4.2"; - $ENV{"CCC_CXX"} = "g++-4.2"; - } - } - } - } - - # Disable PCH files until clang supports them. - AddIfNotPresent($Args,"GCC_PRECOMPILE_PREFIX_HEADER=NO"); - - # When 'CC' is set, xcodebuild uses it to do all linking, even if we are - # linking C++ object files. Set 'LDPLUSPLUS' so that xcodebuild uses 'g++' - # (via c++-analyzer) when linking such files. - $ENV{"LDPLUSPLUS"} = $CXXAnalyzer; - - return (system(@$Args) >> 8); -} - -sub RunBuildCommand { - my $Args = shift; - my $IgnoreErrors = shift; - my $KeepCC = shift; - my $Cmd = $Args->[0]; - my $CCAnalyzer = shift; - my $CXXAnalyzer = shift; - my $EnvVars = shift; - - if ($Cmd =~ /\bxcodebuild$/) { - return RunXcodebuild($Args, $IgnoreErrors, $CCAnalyzer, $CXXAnalyzer, $EnvVars); - } - - # Setup the environment. - SetEnv($EnvVars); - - if ($Cmd =~ /(.*\/?gcc[^\/]*$)/ or - $Cmd =~ /(.*\/?cc[^\/]*$)/ or - $Cmd =~ /(.*\/?llvm-gcc[^\/]*$)/ or - $Cmd =~ /(.*\/?clang[^\/]*$)/ or - $Cmd =~ /(.*\/?ccc-analyzer[^\/]*$)/) { - - if (!($Cmd =~ /ccc-analyzer/) and !defined $ENV{"CCC_CC"}) { - $ENV{"CCC_CC"} = $1; - } - - shift @$Args; - unshift @$Args, $CCAnalyzer; - } - elsif ($Cmd =~ /(.*\/?g\+\+[^\/]*$)/ or - $Cmd =~ /(.*\/?c\+\+[^\/]*$)/ or - $Cmd =~ /(.*\/?llvm-g\+\+[^\/]*$)/ or - $Cmd =~ /(.*\/?clang\+\+$)/ or - $Cmd =~ /(.*\/?c\+\+-analyzer[^\/]*$)/) { - if (!($Cmd =~ /c\+\+-analyzer/) and !defined $ENV{"CCC_CXX"}) { - $ENV{"CCC_CXX"} = $1; - } - shift @$Args; - unshift @$Args, $CXXAnalyzer; - } - elsif ($Cmd eq "make" or $Cmd eq "gmake" or $Cmd eq "mingw32-make") { - if (!$KeepCC) { - AddIfNotPresent($Args, "CC=$CCAnalyzer"); - AddIfNotPresent($Args, "CXX=$CXXAnalyzer"); - } - if ($IgnoreErrors) { - AddIfNotPresent($Args,"-k"); - AddIfNotPresent($Args,"-i"); - } - } - - return (system(@$Args) >> 8); -} - -##----------------------------------------------------------------------------## -# DisplayHelp - Utility function to display all help options. -##----------------------------------------------------------------------------## - -sub DisplayHelp { - - my $ArgClangNotFoundErrMsg = shift; -print < [build options] - -ENDTEXT - - if (defined $BuildName) { - print "ANALYZER BUILD: $BuildName ($BuildDate)\n\n"; - } - -print < - - Specifies the output directory for analyzer reports. Subdirectories will be - created as needed to represent separate "runs" of the analyzer. If this - option is not specified, a directory is created in /tmp (TMPDIR on Mac OS X) - to store the reports. - - -h - --help - - Display this message. - - -k - --keep-going - - Add a "keep on going" option to the specified build command. This option - currently supports make and xcodebuild. This is a convenience option; one - can specify this behavior directly using build options. - - --keep-cc - - Do not override CC and CXX make variables. Useful when running make in - autoconf-based (and similar) projects where configure can add extra flags - to those variables. - - --html-title [title] - --html-title=[title] - - Specify the title used on generated HTML pages. If not specified, a default - title will be used. - - --show-description - - Display the description of defects in the list - - -sarif - - By default the output of scan-build is a set of HTML files. This option - outputs the results in SARIF format. - - -plist - - By default the output of scan-build is a set of HTML files. This option - outputs the results as a set of .plist files. - - -plist-html - - By default the output of scan-build is a set of HTML files. This option - outputs the results as a set of HTML and .plist files. - - --status-bugs - - By default, the exit status of scan-build is the same as the executed build - command. Specifying this option causes the exit status of scan-build to be 1 - if it found potential bugs and the exit status of the build itself otherwise. - - --exclude - - Do not run static analyzer against files found in this - directory (You can specify this option multiple times). - Could be useful when project contains 3rd party libraries. - - --use-cc [compiler path] - --use-cc=[compiler path] - - scan-build analyzes a project by interposing a "fake compiler", which - executes a real compiler for compilation and the static analyzer for analysis. - Because of the current implementation of interposition, scan-build does not - know what compiler your project normally uses. Instead, it simply overrides - the CC environment variable, and guesses your default compiler. - - In the future, this interposition mechanism to be improved, but if you need - scan-build to use a specific compiler for *compilation* then you can use - this option to specify a path to that compiler. - - If the given compiler is a cross compiler, you may also need to provide - --analyzer-target option to properly analyze the source code because static - analyzer runs as if the code is compiled for the host machine by default. - - --use-c++ [compiler path] - --use-c++=[compiler path] - - This is the same as "--use-cc" but for C++ code. - - --analyzer-target [target triple name for analysis] - --analyzer-target=[target triple name for analysis] - - This provides target triple information to clang static analyzer. - It only changes the target for analysis but doesn't change the target of a - real compiler given by --use-cc and --use-c++ options. - - -v - - Enable verbose output from scan-build. A second and third '-v' increases - verbosity. - - -V - --view - - View analysis results in a web browser when the build completes. - -ADVANCED OPTIONS: - - -no-failure-reports - - Do not create a 'failures' subdirectory that includes analyzer crash reports - and preprocessed source files. - - -stats - - Generates visitation statistics for the project being analyzed. - - -maxloop - - Specify the number of times a block can be visited before giving up. - Default is 4. Increase for more comprehensive coverage at a cost of speed. - - -internal-stats - - Generate internal analyzer statistics. - - --use-analyzer [Xcode|path to clang] - --use-analyzer=[Xcode|path to clang] - - scan-build uses the 'clang' executable relative to itself for static - analysis. One can override this behavior with this option by using the - 'clang' packaged with Xcode (on OS X) or from the PATH. - - --keep-empty - - Don't remove the build results directory even if no issues were reported. - - --override-compiler - Always resort to the ccc-analyzer even when better interposition methods - are available. - - -analyzer-config - - Provide options to pass through to the analyzer's -analyzer-config flag. - Several options are separated with comma: 'key1=val1,key2=val2' - - Available options: - * stable-report-filename=true or false (default) - Switch the page naming to: - report---.html - instead of report-XXXXXX.html - -CONTROLLING CHECKERS: - - A default group of checkers are always run unless explicitly disabled. - Checkers may be enabled/disabled using the following options: - - -enable-checker [checker name] - -disable-checker [checker name] - -LOADING CHECKERS: - - Loading external checkers using the clang plugin interface: - - -load-plugin [plugin library] -ENDTEXT - - if (defined $Clang && -x $Clang) { - # Query clang for list of checkers that are enabled. - - # create a list to load the plugins via the 'Xclang' command line - # argument - my @PluginLoadCommandline_xclang; - foreach my $param ( @{$Options{PluginsToLoad}} ) { - push ( @PluginLoadCommandline_xclang, "-Xclang" ); - push ( @PluginLoadCommandline_xclang, "-load" ); - push ( @PluginLoadCommandline_xclang, "-Xclang" ); - push ( @PluginLoadCommandline_xclang, $param ); - } - - my %EnabledCheckers; - foreach my $lang ("c", "objective-c", "objective-c++", "c++") { - my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, "--analyze", "-x", $lang, "-", "-###", "2>&1", "|"); - open(PS, $ExecLine); - while () { - foreach my $val (split /\s+/) { - $val =~ s/\"//g; - if ($val =~ /-analyzer-checker\=([^\s]+)/) { - $EnabledCheckers{$1} = 1; - } - } - } - } - - # Query clang for complete list of checkers. - my @PluginLoadCommandline; - foreach my $param ( @{$Options{PluginsToLoad}} ) { - push ( @PluginLoadCommandline, "-load" ); - push ( @PluginLoadCommandline, $param ); - } - - my $ExecLine = join(' ', qq/"$Clang"/, "-cc1", @PluginLoadCommandline, "-analyzer-checker-help", "2>&1", "|"); - open(PS, $ExecLine); - my $foundCheckers = 0; - while () { - if (/CHECKERS:/) { - $foundCheckers = 1; - last; - } - } - if (!$foundCheckers) { - print " *** Could not query Clang for the list of available checkers."; - } - else { - print("\nAVAILABLE CHECKERS:\n\n"); - my $skip = 0; - while() { - if (/experimental/) { - $skip = 1; - next; - } - if ($skip) { - next if (!/^\s\s[^\s]/); - $skip = 0; - } - s/^\s\s//; - if (/^([^\s]+)/) { - # Is the checker enabled? - my $checker = $1; - my $enabled = 0; - my $aggregate = ""; - foreach my $domain (split /\./, $checker) { - $aggregate .= $domain; - if ($EnabledCheckers{$aggregate}) { - $enabled =1; - last; - } - # append a dot, if an additional domain is added in the next iteration - $aggregate .= "."; - } - - if ($enabled) { - print " + "; - } - else { - print " "; - } - } - else { - print " "; - } - print $_; - } - print "\nNOTE: \"+\" indicates that an analysis is enabled by default.\n"; - } - close PS; - } - else { - print " *** Could not query Clang for the list of available checkers.\n"; - if (defined $ArgClangNotFoundErrMsg) { - print " *** Reason: $ArgClangNotFoundErrMsg\n"; - } - } - -print </>/g; - return $tmp; -} - -##----------------------------------------------------------------------------## -# ShellEscape - backslash escape characters that are special to the shell -##----------------------------------------------------------------------------## - -sub ShellEscape { - # copy argument to new variable so we don't clobber the original - my $arg = shift || ''; - if ($arg =~ /["\s]/) { return "'" . $arg . "'"; } - return $arg; -} - -##----------------------------------------------------------------------------## -# FindClang - searches for 'clang' executable. -##----------------------------------------------------------------------------## - -sub FindClang { - if (!defined $Options{AnalyzerDiscoveryMethod}) { - $Clang = Cwd::realpath("$RealBin/bin/clang") if (-f "$RealBin/bin/clang"); - if (!defined $Clang || ! -x $Clang) { - $Clang = Cwd::realpath("$RealBin/clang") if (-f "$RealBin/clang"); - } - if (!defined $Clang || ! -x $Clang) { - return "error: Cannot find an executable 'clang' relative to" . - " scan-build. Consider using --use-analyzer to pick a version of" . - " 'clang' to use for static analysis.\n"; - } - } - else { - if ($Options{AnalyzerDiscoveryMethod} =~ /^[Xx]code$/) { - my $xcrun = `which xcrun`; - chomp $xcrun; - if ($xcrun eq "") { - return "Cannot find 'xcrun' to find 'clang' for analysis.\n"; - } - $Clang = `$xcrun -toolchain XcodeDefault -find clang`; - chomp $Clang; - if ($Clang eq "") { - return "No 'clang' executable found by 'xcrun'\n"; - } - } - else { - $Clang = $Options{AnalyzerDiscoveryMethod}; - if (!defined $Clang or not -x $Clang) { - return "Cannot find an executable clang at '$Options{AnalyzerDiscoveryMethod}'\n"; - } - } - } - return undef; -} - -##----------------------------------------------------------------------------## -# Process command-line arguments. -##----------------------------------------------------------------------------## - -my $RequestDisplayHelp = 0; -my $ForceDisplayHelp = 0; - -sub ProcessArgs { - my $Args = shift; - my $NumArgs = 0; - - while (@$Args) { - - $NumArgs++; - - # Scan for options we recognize. - - my $arg = $Args->[0]; - - if ($arg eq "-h" or $arg eq "--help") { - $RequestDisplayHelp = 1; - shift @$Args; - next; - } - - if ($arg eq '-analyze-headers') { - shift @$Args; - $Options{AnalyzeHeaders} = 1; - next; - } - - if ($arg eq "-o") { - shift @$Args; - - if (!@$Args) { - DieDiag("'-o' option requires a target directory name.\n"); - } - - # Construct an absolute path. Uses the current working directory - # as a base if the original path was not absolute. - my $OutDir = shift @$Args; - mkpath($OutDir) unless (-e $OutDir); # abs_path wants existing dir - $Options{OutputDir} = abs_path($OutDir); - - next; - } - - if ($arg =~ /^--html-title(=(.+))?$/) { - shift @$Args; - - if (!defined $2 || $2 eq '') { - if (!@$Args) { - DieDiag("'--html-title' option requires a string.\n"); - } - - $Options{HtmlTitle} = shift @$Args; - } else { - $Options{HtmlTitle} = $2; - } - - next; - } - - if ($arg eq "-k" or $arg eq "--keep-going") { - shift @$Args; - $Options{IgnoreErrors} = 1; - next; - } - - if ($arg eq "--keep-cc") { - shift @$Args; - $Options{KeepCC} = 1; - next; - } - - if ($arg =~ /^--use-cc(=(.+))?$/) { - shift @$Args; - my $cc; - - if (!defined $2 || $2 eq "") { - if (!@$Args) { - DieDiag("'--use-cc' option requires a compiler executable name.\n"); - } - $cc = shift @$Args; - } - else { - $cc = $2; - } - - $Options{UseCC} = $cc; - next; - } - - if ($arg =~ /^--use-c\+\+(=(.+))?$/) { - shift @$Args; - my $cxx; - - if (!defined $2 || $2 eq "") { - if (!@$Args) { - DieDiag("'--use-c++' option requires a compiler executable name.\n"); - } - $cxx = shift @$Args; - } - else { - $cxx = $2; - } - - $Options{UseCXX} = $cxx; - next; - } - - if ($arg =~ /^--analyzer-target(=(.+))?$/) { - shift @ARGV; - my $AnalyzerTarget; - - if (!defined $2 || $2 eq "") { - if (!@ARGV) { - DieDiag("'--analyzer-target' option requires a target triple name.\n"); - } - $AnalyzerTarget = shift @ARGV; - } - else { - $AnalyzerTarget = $2; - } - - $Options{AnalyzerTarget} = $AnalyzerTarget; - next; - } - - if ($arg eq "-v") { - shift @$Args; - $Options{Verbose}++; - next; - } - - if ($arg eq "-V" or $arg eq "--view") { - shift @$Args; - $Options{ViewResults} = 1; - next; - } - - if ($arg eq "--status-bugs") { - shift @$Args; - $Options{ExitStatusFoundBugs} = 1; - next; - } - - if ($arg eq "--show-description") { - shift @$Args; - $Options{ShowDescription} = 1; - next; - } - - if ($arg eq "-store") { - shift @$Args; - $Options{StoreModel} = shift @$Args; - next; - } - - if ($arg eq "-constraints") { - shift @$Args; - $Options{ConstraintsModel} = shift @$Args; - next; - } - - if ($arg eq "-internal-stats") { - shift @$Args; - $Options{InternalStats} = 1; - next; - } - - if ($arg eq "-sarif") { - shift @$Args; - $Options{OutputFormat} = "sarif"; - next; - } - - if ($arg eq "-plist") { - shift @$Args; - $Options{OutputFormat} = "plist"; - next; - } - - if ($arg eq "-plist-html") { - shift @$Args; - $Options{OutputFormat} = "plist-html"; - next; - } - - if ($arg eq "-analyzer-config") { - shift @$Args; - push @{$Options{ConfigOptions}}, shift @$Args; - next; - } - - if ($arg eq "-no-failure-reports") { - shift @$Args; - $Options{ReportFailures} = 0; - next; - } - - if ($arg eq "-stats") { - shift @$Args; - $Options{AnalyzerStats} = 1; - next; - } - - if ($arg eq "-maxloop") { - shift @$Args; - $Options{MaxLoop} = shift @$Args; - next; - } - - if ($arg eq "-enable-checker") { - shift @$Args; - my $Checker = shift @$Args; - # Store $NumArgs to preserve the order the checkers were enabled. - $Options{EnableCheckers}{$Checker} = $NumArgs; - delete $Options{DisableCheckers}{$Checker}; - next; - } - - if ($arg eq "-disable-checker") { - shift @$Args; - my $Checker = shift @$Args; - # Store $NumArgs to preserve the order the checkers were disabled. - $Options{DisableCheckers}{$Checker} = $NumArgs; - delete $Options{EnableCheckers}{$Checker}; - next; - } - - if ($arg eq "--exclude") { - shift @$Args; - my $arg = shift @$Args; - # Remove the trailing slash if any - $arg =~ s|/$||; - push @{$Options{Excludes}}, $arg; - next; - } - - if ($arg eq "-load-plugin") { - shift @$Args; - push @{$Options{PluginsToLoad}}, shift @$Args; - next; - } - - if ($arg eq "--use-analyzer") { - shift @$Args; - $Options{AnalyzerDiscoveryMethod} = shift @$Args; - next; - } - - if ($arg =~ /^--use-analyzer=(.+)$/) { - shift @$Args; - $Options{AnalyzerDiscoveryMethod} = $1; - next; - } - - if ($arg eq "--keep-empty") { - shift @$Args; - $Options{KeepEmpty} = 1; - next; - } - - if ($arg eq "--override-compiler") { - shift @$Args; - $Options{OverrideCompiler} = 1; - next; - } - - if ($arg eq "--force-analyze-debug-code") { - shift @$Args; - $Options{ForceAnalyzeDebugCode} = 1; - next; - } - - DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/); - - $NumArgs--; - last; - } - return $NumArgs; -} - -if (!@ARGV) { - $ForceDisplayHelp = 1 -} - -ProcessArgs(\@ARGV); -# All arguments are now shifted from @ARGV. The rest is a build command, if any. - -if (!@ARGV and !$RequestDisplayHelp) { - ErrorDiag("No build command specified.\n\n"); - $ForceDisplayHelp = 1; -} - -my $ClangNotFoundErrMsg = FindClang(); - -if ($ForceDisplayHelp || $RequestDisplayHelp) { - DisplayHelp($ClangNotFoundErrMsg); - exit $ForceDisplayHelp; -} - -DieDiag($ClangNotFoundErrMsg) if (defined $ClangNotFoundErrMsg); - -$ClangCXX = $Clang; -if ($Clang !~ /\+\+(\.exe)?$/) { - # If $Clang holds the name of the clang++ executable then we leave - # $ClangCXX and $Clang equal, otherwise construct the name of the clang++ - # executable from the clang executable name. - - # Determine operating system under which this copy of Perl was built. - my $IsWinBuild = ($^O =~/msys|cygwin|MSWin32/); - if($IsWinBuild) { - $ClangCXX =~ s/.exe$/++.exe/; - } - else { - $ClangCXX =~ s/\-\d+\.\d+$//; - $ClangCXX .= "++"; - } -} - -# Make sure to use "" to handle paths with spaces. -$ClangVersion = HtmlEscape(`"$Clang" --version`); - -# Determine where results go. -$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV))); - -# Determine the output directory for the HTML reports. -my $BaseDir = $Options{OutputDir}; -$Options{OutputDir} = GetHTMLRunDir($Options{OutputDir}); - -# Determine the location of ccc-analyzer. -my $AbsRealBin = Cwd::realpath($RealBin); -my $Cmd = "$AbsRealBin/../libexec/ccc-analyzer"; -my $CmdCXX = "$AbsRealBin/../libexec/c++-analyzer"; - -# Portability: use less strict but portable check -e (file exists) instead of -# non-portable -x (file is executable). On some windows ports -x just checks -# file extension to determine if a file is executable (see Perl language -# reference, perlport) -if (!defined $Cmd || ! -e $Cmd) { - $Cmd = "$AbsRealBin/ccc-analyzer"; - DieDiag("'ccc-analyzer' does not exist at '$Cmd'\n") if(! -e $Cmd); -} -if (!defined $CmdCXX || ! -e $CmdCXX) { - $CmdCXX = "$AbsRealBin/c++-analyzer"; - DieDiag("'c++-analyzer' does not exist at '$CmdCXX'\n") if(! -e $CmdCXX); -} - -Diag("Using '$Clang' for static analysis\n"); - -SetHtmlEnv(\@ARGV, $Options{OutputDir}); - -my @AnalysesToRun; -foreach (sort { $Options{EnableCheckers}{$a} <=> $Options{EnableCheckers}{$b} } - keys %{$Options{EnableCheckers}}) { - # Push checkers in order they were enabled. - push @AnalysesToRun, "-analyzer-checker", $_; -} -foreach (sort { $Options{DisableCheckers}{$a} <=> $Options{DisableCheckers}{$b} } - keys %{$Options{DisableCheckers}}) { - # Push checkers in order they were disabled. - push @AnalysesToRun, "-analyzer-disable-checker", $_; -} -if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; } -if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; } -if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; } - -# Delay setting up other environment variables in case we can do true -# interposition. -my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun; -my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}}; -my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}}; -my %EnvVars = ( - 'CC' => $Cmd, - 'CXX' => $CmdCXX, - 'CLANG' => $Clang, - 'CLANG_CXX' => $ClangCXX, - 'VERBOSE' => $Options{Verbose}, - 'CCC_ANALYZER_ANALYSIS' => $CCC_ANALYZER_ANALYSIS, - 'CCC_ANALYZER_PLUGINS' => $CCC_ANALYZER_PLUGINS, - 'CCC_ANALYZER_CONFIG' => $CCC_ANALYZER_CONFIG, - 'OUTPUT_DIR' => $Options{OutputDir}, - 'CCC_CC' => $Options{UseCC}, - 'CCC_CXX' => $Options{UseCXX}, - 'CCC_REPORT_FAILURES' => $Options{ReportFailures}, - 'CCC_ANALYZER_STORE_MODEL' => $Options{StoreModel}, - 'CCC_ANALYZER_CONSTRAINTS_MODEL' => $Options{ConstraintsModel}, - 'CCC_ANALYZER_INTERNAL_STATS' => $Options{InternalStats}, - 'CCC_ANALYZER_OUTPUT_FORMAT' => $Options{OutputFormat}, - 'CLANG_ANALYZER_TARGET' => $Options{AnalyzerTarget}, - 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE' => $Options{ForceAnalyzeDebugCode} -); - -# Run the build. -my $ExitStatus = RunBuildCommand(\@ARGV, $Options{IgnoreErrors}, $Options{KeepCC}, - $Cmd, $CmdCXX, \%EnvVars); - -if (defined $Options{OutputFormat}) { - if ($Options{OutputFormat} =~ /plist/ || - $Options{OutputFormat} =~ /sarif/) { - Diag "Analysis run complete.\n"; - Diag "Analysis results (" . - ($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") . - " files) deposited in '$Options{OutputDir}'\n"; - } - if ($Options{OutputFormat} =~ /html/) { - # Postprocess the HTML directory. - my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir, - $Options{AnalyzerStats}, $Options{KeepEmpty}); - - if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") { - Diag "Analysis run complete.\n"; - Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n"; - my $ScanView = Cwd::realpath("$RealBin/scan-view"); - if (! -x $ScanView) { $ScanView = "scan-view"; } - if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); } - exec $ScanView, "$Options{OutputDir}"; - } - - if ($Options{ExitStatusFoundBugs}) { - exit 1 if ($NumBugs > 0); - exit $ExitStatus; - } - } -} - -exit $ExitStatus; diff --git a/clang-r353983c/bin/scan-view b/clang-r353983c/bin/scan-view deleted file mode 100755 index 6165432e7af8458a91cf93c55a024ea68b0ee287..0000000000000000000000000000000000000000 --- a/clang-r353983c/bin/scan-view +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -"""The clang static analyzer results viewer. -""" - -import sys -import imp -import os -import posixpath -import threading -import time -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen -import webbrowser - -# How long to wait for server to start. -kSleepTimeout = .05 -kMaxSleeps = int(60 / kSleepTimeout) - -# Default server parameters - -kDefaultHost = '127.0.0.1' -kDefaultPort = 8181 -kMaxPortsToTry = 100 - -### - - -def url_is_up(url): - try: - o = urlopen(url) - except IOError: - return False - o.close() - return True - - -def start_browser(port, options): - import webbrowser - - url = 'http://%s:%d' % (options.host, port) - - # Wait for server to start... - if options.debug: - sys.stderr.write('%s: Waiting for server.' % sys.argv[0]) - sys.stderr.flush() - for i in range(kMaxSleeps): - if url_is_up(url): - break - if options.debug: - sys.stderr.write('.') - sys.stderr.flush() - time.sleep(kSleepTimeout) - else: - print('WARNING: Unable to detect that server started.', file=sys.stderr) - - if options.debug: - print('%s: Starting webbrowser...' % sys.argv[0], file=sys.stderr) - webbrowser.open(url) - - -def run(port, options, root): - # Prefer to look relative to the installed binary - share = os.path.dirname(__file__) + "/../share/scan-view" - if not os.path.isdir(share): - # Otherwise look relative to the source - share = os.path.dirname(__file__) + "/../../scan-view/share" - sys.path.append(share) - - import ScanView - try: - print('Starting scan-view at: http://%s:%d' % (options.host, - port)) - print(' Use Ctrl-C to exit.') - httpd = ScanView.create_server((options.host, port), - options, root) - httpd.serve_forever() - except KeyboardInterrupt: - pass - - -def port_is_open(port): - try: - import socketserver - except ImportError: - import SocketServer as socketserver - try: - t = socketserver.TCPServer((kDefaultHost, port), None) - except: - return False - t.server_close() - return True - - -def main(): - import argparse - parser = argparse.ArgumentParser(description="The clang static analyzer " - "results viewer.") - parser.add_argument("root", metavar="", type=str) - parser.add_argument( - '--host', dest="host", default=kDefaultHost, type=str, - help="Host interface to listen on. (default=%s)" % kDefaultHost) - parser.add_argument('--port', dest="port", default=None, type=int, - help="Port to listen on. (default=%s)" % kDefaultPort) - parser.add_argument("--debug", dest="debug", default=0, - action="count", - help="Print additional debugging information.") - parser.add_argument("--auto-reload", dest="autoReload", default=False, - action="store_true", - help="Automatically update module for each request.") - parser.add_argument("--no-browser", dest="startBrowser", default=True, - action="store_false", - help="Don't open a webbrowser on startup.") - parser.add_argument("--allow-all-hosts", dest="onlyServeLocal", - default=True, action="store_false", - help='Allow connections from any host (access ' - 'restricted to "127.0.0.1" by default)') - args = parser.parse_args() - - # Make sure this directory is in a reasonable state to view. - if not posixpath.exists(posixpath.join(args.root, 'index.html')): - parser.error('Invalid directory, analysis results not found!') - - # Find an open port. We aren't particularly worried about race - # conditions here. Note that if the user specified a port we only - # use that one. - if args.port is not None: - port = args.port - else: - for i in range(kMaxPortsToTry): - if port_is_open(kDefaultPort + i): - port = kDefaultPort + i - break - else: - parser.error('Unable to find usable port in [%d,%d)' % - (kDefaultPort, kDefaultPort+kMaxPortsToTry)) - - # Kick off thread to wait for server and start web browser, if - # requested. - if args.startBrowser: - threading.Thread(target=start_browser, args=(port, args)).start() - - run(port, args, args.root) - -if __name__ == '__main__': - main() diff --git a/clang-r353983c/include/c++/v1/__bit_reference b/clang-r353983c/include/c++/v1/__bit_reference deleted file mode 100644 index 4fd1d2f6c28a4fbf0dba394972142c896fa429c1..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__bit_reference +++ /dev/null @@ -1,1280 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___BIT_REFERENCE -#define _LIBCPP___BIT_REFERENCE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class __bit_iterator; -template class __bit_const_reference; - -template -struct __has_storage_type -{ - static const bool value = false; -}; - -template ::value> -class __bit_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; - - __storage_pointer __seg_; - __storage_type __mask_; - - friend typename _Cp::__self; - - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, false>; -public: - _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT - {return static_cast(*__seg_ & __mask_);} - _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT - {return !static_cast(*this);} - - _LIBCPP_INLINE_VISIBILITY - __bit_reference& operator=(bool __x) _NOEXCEPT - { - if (__x) - *__seg_ |= __mask_; - else - *__seg_ &= ~__mask_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT - {return operator=(static_cast(__x));} - - _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;} - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, false>(__seg_, static_cast(__ctz(__mask_)));} -private: - _LIBCPP_INLINE_VISIBILITY - __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} -}; - -template -class __bit_reference<_Cp, false> -{ -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -class __bit_const_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__const_storage_pointer __storage_pointer; - - __storage_pointer __seg_; - __storage_type __mask_; - - friend typename _Cp::__self; - friend class __bit_iterator<_Cp, true>; -public: - _LIBCPP_INLINE_VISIBILITY - __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT - : __seg_(__x.__seg_), __mask_(__x.__mask_) {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT - {return static_cast(*__seg_ & __mask_);} - - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, true>(__seg_, static_cast(__ctz(__mask_)));} -private: - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR - __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} - - __bit_const_reference& operator=(const __bit_const_reference& __x); -}; - -// find - -template -__bit_iterator<_Cp, _IsConst> -__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - if (*__first.__seg_) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(*__first.__seg_))); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - return _It(__first.__seg_, static_cast(__n)); -} - -template -__bit_iterator<_Cp, _IsConst> -__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - { - __storage_type __b = ~*__first.__seg_; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - return _It(__first.__seg_, static_cast(__n)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, _IsConst> -find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) -{ - if (static_cast(__value_)) - return __find_bool_true(__first, static_cast(__last - __first)); - return __find_bool_false(__first, static_cast(__last - __first)); -} - -// count - -template -typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__popcount(*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__popcount(*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__popcount(*__first.__seg_ & __m); - } - return __r; -} - -template -typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__popcount(~*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__popcount(~*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__popcount(~*__first.__seg_ & __m); - } - return __r; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __bit_iterator<_Cp, _IsConst>::difference_type -count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) -{ - if (static_cast(__value_)) - return __count_bool_true(__first, static_cast(__last - __first)); - return __count_bool_false(__first, static_cast(__last - __first)); -} - -// fill_n - -template -void -__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ &= ~__m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ &= ~__m; - } -} - -template -void -__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ |= __m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ |= __m; - } -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) -{ - if (__n > 0) - { - if (__value_) - __fill_n_true(__first, __n); - else - __fill_n_false(__first, __n); - } -} - -// fill - -template -inline _LIBCPP_INLINE_VISIBILITY -void -fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_) -{ - _VSTD::fill_n(__first, static_cast(__last - __first), __value_); -} - -// copy - -template -__bit_iterator<_Cp, false> -__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__first.__seg_), - __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - __result.__seg_ += __nw; - // do last word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(__n); - } - } - return __result; -} - -template -__bit_iterator<_Cp, false> -__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - static const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); - else - *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); - __result.__ctz_ = static_cast(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b = *__first.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - ++__result.__seg_; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b >> __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __dn; - __result.__ctz_ = static_cast(__n); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__first.__ctz_ == __result.__ctz_) - return __copy_aligned(__first, __last, __result); - return __copy_unaligned(__first, __last, __result); -} - -// copy_backward - -template -__bit_iterator<_Cp, false> -__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); - __storage_type __b = *__last.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ == 0 || __n == 0 - // do middle words - __storage_type __nw = __n / __bits_per_word; - __result.__seg_ -= __nw; - __last.__seg_ -= __nw; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__last.__seg_), - __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - *--__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); - } - } - return __result; -} - -template -__bit_iterator<_Cp, false> -__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz_l = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); - __storage_type __b = *__last.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min(__dn, static_cast(__result.__ctz_)); - if (__ddn > 0) - { - __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __last.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - else - *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); - __result.__ctz_ = static_cast(((-__ddn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - } - if (__dn > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast(-__dn & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - __last.__ctz_ -= __dn + __ddn; - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - } - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ != 0 || __n == 0 - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) >> __clz_r; - for (; __n >= __bits_per_word; __n -= __bits_per_word) - { - __storage_type __b = *--__last.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __clz_r; - *--__result.__seg_ &= __m; - *__result.__seg_ |= __b << __result.__ctz_; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __dn = _VSTD::min(__n, static_cast(__result.__ctz_)); - __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); - __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__last.__ctz_ == __result.__ctz_) - return __copy_backward_aligned(__first, __last, __result); - return __copy_backward_unaligned(__first, __last, __result); -} - -// move - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy(__first, __last, __result); -} - -// move_backward - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy_backward(__first, __last, __result); -} - -// swap_ranges - -template -__bit_iterator<__C2, false> -__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) -{ - typedef __bit_iterator<__C1, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) - swap(*__first.__seg_, *__result.__seg_); - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__ctz_ = static_cast(__n); - } - } - return __result; -} - -template -__bit_iterator<__C2, false> -__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) -{ - typedef __bit_iterator<__C1, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - { - unsigned __s = __result.__ctz_ - __first.__ctz_; - *__result.__seg_ |= __b1 << __s; - *__first.__seg_ |= __b2 >> __s; - } - else - { - unsigned __s = __first.__ctz_ - __result.__ctz_; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - } - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - unsigned __s = __first.__ctz_ + __ddn; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - __result.__ctz_ = static_cast(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b1 = *__first.__seg_; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ = __b2 >> __result.__ctz_; - ++__result.__seg_; - __b2 = *__result.__seg_ & ~__m; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b1 >> __clz_r; - *__first.__seg_ |= __b2 << __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ |= __b2 >> __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 >> __dn; - *__first.__seg_ |= __b2 << __dn; - __result.__ctz_ = static_cast(__n); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<__C2, false> -swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1, - __bit_iterator<__C2, false> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return __swap_ranges_aligned(__first1, __last1, __first2); - return __swap_ranges_unaligned(__first1, __last1, __first2); -} - -// rotate - -template -struct __bit_array -{ - typedef typename _Cp::difference_type difference_type; - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; - typedef typename _Cp::iterator iterator; - static const unsigned __bits_per_word = _Cp::__bits_per_word; - static const unsigned _Np = 4; - - difference_type __size_; - __storage_type __word_[_Np]; - - _LIBCPP_INLINE_VISIBILITY static difference_type capacity() - {return static_cast(_Np * __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} - _LIBCPP_INLINE_VISIBILITY iterator begin() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); - } - _LIBCPP_INLINE_VISIBILITY iterator end() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, - static_cast(__size_ % __bits_per_word)); - } -}; - -template -__bit_iterator<_Cp, false> -rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) -{ - typedef __bit_iterator<_Cp, false> _I1; - typedef typename _I1::difference_type difference_type; - difference_type __d1 = __middle - __first; - difference_type __d2 = __last - __middle; - _I1 __r = __first + __d2; - while (__d1 != 0 && __d2 != 0) - { - if (__d1 <= __d2) - { - if (__d1 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d1); - _VSTD::copy(__first, __middle, __b.begin()); - _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle); - __first = __middle; - __middle = __mp; - __d2 -= __d1; - } - } - else - { - if (__d2 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d2); - _VSTD::copy(__middle, __last, __b.begin()); - _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = __first + __d2; - _VSTD::swap_ranges(__first, __mp, __middle); - __first = __mp; - __d1 -= __d2; - } - } - } - return __r; -} - -// equal - -template -bool -__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first1.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - if (__first2.__ctz_ > __first1.__ctz_) - { - if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) - return false; - } - else - { - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) - return false; - } - __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast((__ddn + __first2.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) - return false; - __first2.__ctz_ = static_cast(__dn); - } - ++__first1.__seg_; - // __first1.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __m = ~__storage_type(0) << __first2.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) - { - __storage_type __b = *__first1.__seg_; - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - ++__first2.__seg_; - if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) - return false; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first1.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast((__dn + __first2.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (__b >> __dn)) - return false; - } - } - } - return true; -} - -template -bool -__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - ++__first2.__seg_; - ++__first1.__seg_; - // __first1.__ctz_ = 0; - // __first2.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // __first2.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) - if (*__first2.__seg_ != *__first1.__seg_) - return false; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - } - } - return true; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return __equal_aligned(__first1, __last1, __first2); - return __equal_unaligned(__first1, __last1, __first2); -} - -template -class __bit_iterator -{ -public: - typedef typename _Cp::difference_type difference_type; - typedef bool value_type; - typedef __bit_iterator pointer; - typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference; - typedef random_access_iterator_tag iterator_category; - -private: - typedef typename _Cp::__storage_type __storage_type; - typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer, - typename _Cp::__storage_pointer>::type __storage_pointer; - static const unsigned __bits_per_word = _Cp::__bits_per_word; - - __storage_pointer __seg_; - unsigned __ctz_; - -public: - _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __seg_(nullptr), __ctz_(0) -#endif - {} - - _LIBCPP_INLINE_VISIBILITY - __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT - : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT - {return reference(__seg_, __storage_type(1) << __ctz_);} - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++() - { - if (__ctz_ != __bits_per_word-1) - ++__ctz_; - else - { - __ctz_ = 0; - ++__seg_; - } - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int) - { - __bit_iterator __tmp = *this; - ++(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--() - { - if (__ctz_ != 0) - --__ctz_; - else - { - __ctz_ = __bits_per_word - 1; - --__seg_; - } - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int) - { - __bit_iterator __tmp = *this; - --(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n) - { - if (__n >= 0) - __seg_ += (__n + __ctz_) / __bits_per_word; - else - __seg_ += static_cast(__n - __bits_per_word + __ctz_ + 1) - / static_cast(__bits_per_word); - __n &= (__bits_per_word - 1); - __ctz_ = static_cast((__n + __ctz_) % __bits_per_word); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n) - { - return *this += -__n; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const - { - __bit_iterator __t(*this); - __t += __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const - { - __bit_iterator __t(*this); - __t -= __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;} - - _LIBCPP_INLINE_VISIBILITY - friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y) - {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x == __y);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) - {return __y < __x;} - - _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__y < __x);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x < __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT - : __seg_(__s), __ctz_(__ctz) {} - - friend typename _Cp::__self; - - friend class __bit_reference<_Cp>; - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, true>; - template friend struct __bit_array; - template friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> __swap_ranges_unaligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>); - template friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool equal(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); - template friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); - template friend typename __bit_iterator<_Dp, _IC>::difference_type - __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); - template friend typename __bit_iterator<_Dp, _IC>::difference_type - __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); -}; - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___BIT_REFERENCE diff --git a/clang-r353983c/include/c++/v1/__bsd_locale_defaults.h b/clang-r353983c/include/c++/v1/__bsd_locale_defaults.h deleted file mode 100644 index 2ace2a21cb01e1e3ffc09774b2dfc26058c48514..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__bsd_locale_defaults.h +++ /dev/null @@ -1,36 +0,0 @@ -// -*- C++ -*- -//===---------------------- __bsd_locale_defaults.h -----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// The BSDs have lots of *_l functions. We don't want to define those symbols -// on other platforms though, for fear of conflicts with user code. So here, -// we will define the mapping from an internal macro to the real BSD symbol. -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H -#define _LIBCPP_BSD_LOCALE_DEFAULTS_H - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc) -#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc) -#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc) -#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc) -#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc) -#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc) -#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l) -#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l) -#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l) -#define __libcpp_localeconv_l(l) localeconv_l(l) -#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l) -#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__) -#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__) -#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__) - -#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H diff --git a/clang-r353983c/include/c++/v1/__bsd_locale_fallbacks.h b/clang-r353983c/include/c++/v1/__bsd_locale_fallbacks.h deleted file mode 100644 index a807fe03955436b408a3592bbb6b0e3487e3ff18..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__bsd_locale_fallbacks.h +++ /dev/null @@ -1,139 +0,0 @@ -// -*- C++ -*- -//===---------------------- __bsd_locale_fallbacks.h ----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// The BSDs have lots of *_l functions. This file provides reimplementations -// of those functions for non-BSD platforms. -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H -#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H - -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -inline _LIBCPP_INLINE_VISIBILITY -decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return MB_CUR_MAX; -} - -inline _LIBCPP_INLINE_VISIBILITY -wint_t __libcpp_btowc_l(int __c, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return btowc(__c); -} - -inline _LIBCPP_INLINE_VISIBILITY -int __libcpp_wctob_l(wint_t __c, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wctob(__c); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, - size_t __len, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wcsnrtombs(__dest, __src, __nwc, __len, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wcrtomb(__s, __wc, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, - size_t __len, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbsnrtowcs(__dest, __src, __nms, __len, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, - mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbrtowc(__pwc, __s, __n, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbtowc(__pwc, __pmb, __max); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbrlen(__s, __n, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -lconv *__libcpp_localeconv_l(locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return localeconv(); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, - mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbsrtowcs(__dest, __src, __len, __ps); -} - -inline -int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vsnprintf(__s, __n, __format, __va); - va_end(__va); - return __res; -} - -inline -int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vasprintf(__s, __format, __va); - va_end(__va); - return __res; -} - -inline -int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vsscanf(__s, __format, __va); - va_end(__va); - return __res; -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H diff --git a/clang-r353983c/include/c++/v1/__config b/clang-r353983c/include/c++/v1/__config deleted file mode 100644 index 3ca6615169765be933e869fba91e9fcf557faa4d..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__config +++ /dev/null @@ -1,1443 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __config ---------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_CONFIG -#define _LIBCPP_CONFIG - -#if defined(_MSC_VER) && !defined(__clang__) -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -# endif -#endif - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -#ifdef __cplusplus - -#ifdef __GNUC__ -# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) -// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme -// introduced in GCC 5.0. -# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) -#else -# define _GNUC_VER 0 -# define _GNUC_VER_NEW 0 -#endif - -#define _LIBCPP_VERSION 9000 - -#ifndef _LIBCPP_ABI_VERSION -# define _LIBCPP_ABI_VERSION 1 -#endif - -#ifndef _LIBCPP_STD_VER -# if __cplusplus <= 201103L -# define _LIBCPP_STD_VER 11 -# elif __cplusplus <= 201402L -# define _LIBCPP_STD_VER 14 -# elif __cplusplus <= 201703L -# define _LIBCPP_STD_VER 17 -# else -# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification -# endif -#endif // _LIBCPP_STD_VER - -#if defined(__ELF__) -# define _LIBCPP_OBJECT_FORMAT_ELF 1 -#elif defined(__MACH__) -# define _LIBCPP_OBJECT_FORMAT_MACHO 1 -#elif defined(_WIN32) -# define _LIBCPP_OBJECT_FORMAT_COFF 1 -#elif defined(__wasm__) -# define _LIBCPP_OBJECT_FORMAT_WASM 1 -#else -# error Unknown object file format -#endif - -#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 -// Change short string representation so that string data starts at offset 0, -// improving its alignment in some cases. -# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -// Fix deque iterator type in order to support incomplete types. -# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE -// Fix undefined behavior in how std::list stores its linked nodes. -# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB -// Fix undefined behavior in how __tree stores its end and parent nodes. -# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB -// Fix undefined behavior in how __hash_table stores its pointer types. -# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB -# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB -# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE -// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr -// provided under the alternate keyword __nullptr, which changes the mangling -// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. -# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR -// Define the `pointer_safety` enum as a C++11 strongly typed enumeration -// instead of as a class simulating an enum. If this option is enabled -// `pointer_safety` and `get_pointer_safety()` will no longer be available -// in C++03. -# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE -// Define a key function for `bad_function_call` in the library, to centralize -// its vtable and typeinfo to libc++ rather than having all other libraries -// using that class define their own copies. -# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION -// Enable optimized version of __do_get_(un)signed which avoids redundant copies. -# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET -// Use the smallest possible integer type to represent the index of the variant. -// Previously libc++ used "unsigned int" exclusivly. -# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION -// Unstable attempt to provide a more optimized std::function -# define _LIBCPP_ABI_OPTIMIZED_FUNCTION -#elif _LIBCPP_ABI_VERSION == 1 -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) -// Enable compiling copies of now inline methods into the dylib to support -// applications compiled against older libraries. This is unnecessary with -// COFF dllexport semantics, since dllexport forces a non-inline definition -// of inline functions to be emitted anyway. Our own non-inline copy would -// conflict with the dllexport-emitted copy, so we disable it. -# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS -# endif -// Feature macros for disabling pre ABI v1 features. All of these options -// are deprecated. -# if defined(__FreeBSD__) -# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR -# endif -#endif - -#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR -#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ - use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead -#endif - -#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y -#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) - -#ifndef _LIBCPP_ABI_NAMESPACE -# define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) -#endif - -#if __cplusplus < 201103L -#define _LIBCPP_CXX03_LANG -#endif - -#ifndef __has_attribute -#define __has_attribute(__x) 0 -#endif - -#ifndef __has_builtin -#define __has_builtin(__x) 0 -#endif - -#ifndef __has_extension -#define __has_extension(__x) 0 -#endif - -#ifndef __has_feature -#define __has_feature(__x) 0 -#endif - -#ifndef __has_cpp_attribute -#define __has_cpp_attribute(__x) 0 -#endif - -// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by -// the compiler and '1' otherwise. -#ifndef __is_identifier -#define __is_identifier(__x) 1 -#endif - -#ifndef __has_declspec_attribute -#define __has_declspec_attribute(__x) 0 -#endif - -#define __has_keyword(__x) !(__is_identifier(__x)) - -#ifndef __has_include -#define __has_include(...) 0 -#endif - -#if defined(__clang__) -# define _LIBCPP_COMPILER_CLANG -# ifndef __apple_build_version__ -# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) -# endif -#elif defined(__GNUC__) -# define _LIBCPP_COMPILER_GCC -#elif defined(_MSC_VER) -# define _LIBCPP_COMPILER_MSVC -#elif defined(__IBMCPP__) -# define _LIBCPP_COMPILER_IBM -#endif - -#ifndef _LIBCPP_CLANG_VER -#define _LIBCPP_CLANG_VER 0 -#endif - -// FIXME: ABI detection should be done via compiler builtin macros. This -// is just a placeholder until Clang implements such macros. For now assume -// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, -// and allow the user to explicitly specify the ABI to handle cases where this -// heuristic falls short. -#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" -#elif defined(_LIBCPP_ABI_FORCE_ITANIUM) -# define _LIBCPP_ABI_ITANIUM -#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# define _LIBCPP_ABI_MICROSOFT -#else -# if defined(_WIN32) && defined(_MSC_VER) -# define _LIBCPP_ABI_MICROSOFT -# else -# define _LIBCPP_ABI_ITANIUM -# endif -#endif - -// Need to detect which libc we're using if we're on Linux. -#if defined(__linux__) -# include -# if defined(__GLIBC_PREREQ) -# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) -# else -# define _LIBCPP_GLIBC_PREREQ(a, b) 0 -# endif // defined(__GLIBC_PREREQ) -#endif // defined(__linux__) - -#ifdef __LITTLE_ENDIAN__ -# if __LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# endif // __LITTLE_ENDIAN__ -#endif // __LITTLE_ENDIAN__ - -#ifdef __BIG_ENDIAN__ -# if __BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BIG_ENDIAN__ -#endif // __BIG_ENDIAN__ - -#ifdef __BYTE_ORDER__ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#endif // __BYTE_ORDER__ - -#ifdef __FreeBSD__ -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# ifndef __LONG_LONG_SUPPORTED -# define _LIBCPP_HAS_NO_LONG_LONG -# endif // __LONG_LONG_SUPPORTED -#endif // __FreeBSD__ - -#ifdef __NetBSD__ -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_HAS_QUICK_EXIT -#endif // __NetBSD__ - -#if defined(_WIN32) -# define _LIBCPP_WIN32API -# define _LIBCPP_LITTLE_ENDIAN -# define _LIBCPP_SHORT_WCHAR 1 -// Both MinGW and native MSVC provide a "MSVC"-like enviroment -# define _LIBCPP_MSVCRT_LIKE -// If mingw not explicitly detected, assume using MS C runtime only if -// a MS compatibility version is specified. -# if defined(_MSC_VER) && !defined(__MINGW32__) -# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library -# endif -# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) -# define _LIBCPP_HAS_BITSCAN64 -# endif -# define _LIBCPP_HAS_OPEN_WITH_WCHAR -# if defined(_LIBCPP_MSVCRT) -# define _LIBCPP_HAS_QUICK_EXIT -# endif - -// Some CRT APIs are unavailable to store apps -# if defined(WINAPI_FAMILY) -# include -# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ - (!defined(WINAPI_PARTITION_SYSTEM) || \ - !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) -# define _LIBCPP_WINDOWS_STORE_APP -# endif -# endif -#endif // defined(_WIN32) - -#ifdef __sun__ -# include -# ifdef _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else -# define _LIBCPP_BIG_ENDIAN -# endif -#endif // __sun__ - -#if defined(__CloudABI__) - // Certain architectures provide arc4random(). Prefer using - // arc4random() over /dev/{u,}random to make it possible to obtain - // random data even when using sandboxing mechanisms such as chroots, - // Capsicum, etc. -# define _LIBCPP_USING_ARC4_RANDOM -#elif defined(__Fuchsia__) -# define _LIBCPP_USING_GETENTROPY -#elif defined(__native_client__) - // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, - // including accesses to the special files under /dev. C++11's - // std::random_device is instead exposed through a NaCl syscall. -# define _LIBCPP_USING_NACL_RANDOM -#elif defined(_LIBCPP_WIN32API) -# define _LIBCPP_USING_WIN32_RANDOM -#else -# define _LIBCPP_USING_DEV_RANDOM -#endif - -#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) -# include -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER == __BIG_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# else // __BYTE_ORDER == __BIG_ENDIAN -# error unable to determine endian -# endif -#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) - -#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) -#else -# define _LIBCPP_NO_CFI -#endif - -#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L -# if defined(__FreeBSD__) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_C11_FEATURES -# elif defined(__Fuchsia__) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_TIMESPEC_GET -# define _LIBCPP_HAS_C11_FEATURES -# elif defined(__linux__) -# if !defined(_LIBCPP_HAS_MUSL_LIBC) -# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) -# define _LIBCPP_HAS_QUICK_EXIT -# endif -# if _LIBCPP_GLIBC_PREREQ(2, 17) -# define _LIBCPP_HAS_C11_FEATURES -# define _LIBCPP_HAS_TIMESPEC_GET -# endif -# else // defined(_LIBCPP_HAS_MUSL_LIBC) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_TIMESPEC_GET -# define _LIBCPP_HAS_C11_FEATURES -# endif -# endif // __linux__ -#endif - -#ifndef _LIBCPP_CXX03_LANG -# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) -#elif defined(_LIBCPP_COMPILER_CLANG) -# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) -#else -// This definition is potentially buggy, but it's only taken with GCC in C++03, -// which we barely support anyway. See llvm.org/PR39713 -# define _LIBCPP_ALIGNOF(_Tp) __alignof(_Tp) -#endif - -#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) - -#if defined(_LIBCPP_COMPILER_CLANG) - -// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for -// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. -#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \ - defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) -#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -#endif - -#if __has_feature(cxx_alignas) -# define _ALIGNAS_TYPE(x) alignas(x) -# define _ALIGNAS(x) alignas(x) -#else -# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -# define _ALIGNAS(x) __attribute__((__aligned__(x))) -#endif - -#if __cplusplus < 201103L -typedef __char16_t char16_t; -typedef __char32_t char32_t; -#endif - -#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) -#define _LIBCPP_NO_EXCEPTIONS -#endif - -#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI) -#define _LIBCPP_NO_RTTI -#endif - -#if !(__has_feature(cxx_strong_enums)) -#define _LIBCPP_HAS_NO_STRONG_ENUMS -#endif - -#if !(__has_feature(cxx_decltype)) -#define _LIBCPP_HAS_NO_DECLTYPE -#endif - -#if __has_feature(cxx_attributes) -# define _LIBCPP_NORETURN [[noreturn]] -#else -# define _LIBCPP_NORETURN __attribute__ ((noreturn)) -#endif - -#if !(__has_feature(cxx_lambdas)) -#define _LIBCPP_HAS_NO_LAMBDAS -#endif - -#if !(__has_feature(cxx_nullptr)) -# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) -# define nullptr __nullptr -# else -# define _LIBCPP_HAS_NO_NULLPTR -# endif -#endif - -#if !(__has_feature(cxx_rvalue_references)) -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - -#if !(__has_feature(cxx_auto_type)) -#define _LIBCPP_HAS_NO_AUTO_TYPE -#endif - -#if !(__has_feature(cxx_variadic_templates)) -#define _LIBCPP_HAS_NO_VARIADICS -#endif - -#if !(__has_feature(cxx_generalized_initializers)) -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#endif - -#if __has_feature(is_base_of) -#define _LIBCPP_HAS_IS_BASE_OF -#endif - -#if __has_feature(is_final) -#define _LIBCPP_HAS_IS_FINAL -#endif - -// Objective-C++ features (opt-in) -#if __has_feature(objc_arc) -#define _LIBCPP_HAS_OBJC_ARC -#endif - -#if __has_feature(objc_arc_weak) -#define _LIBCPP_HAS_OBJC_ARC_WEAK -#endif - -#if !(__has_feature(cxx_constexpr)) -#define _LIBCPP_HAS_NO_CONSTEXPR -#endif - -#if !(__has_feature(cxx_relaxed_constexpr)) -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#endif - -#if !(__has_feature(cxx_variable_templates)) -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#endif - -#if !(__has_feature(cxx_noexcept)) -#define _LIBCPP_HAS_NO_NOEXCEPT -#endif - -#if __has_feature(underlying_type) -#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) -#endif - -#if __has_feature(is_literal) -#define _LIBCPP_IS_LITERAL(T) __is_literal(T) -#endif - -#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) -#define _LIBCPP_HAS_NO_ASAN -#endif - -// Allow for build-time disabling of unsigned integer sanitization -#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) -#endif - -#if __has_builtin(__builtin_launder) -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#endif - -#if !__is_identifier(__has_unique_object_representations) -#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS -#endif - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -// No apple compilers support ""d and ""y at this time. -#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__) -#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS -#endif - -#elif defined(_LIBCPP_COMPILER_GCC) - -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) - -#define _LIBCPP_NORETURN __attribute__((noreturn)) - -#if _GNUC_VER >= 407 -#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) -#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) -#define _LIBCPP_HAS_IS_FINAL -#endif - -#if defined(__GNUC__) && _GNUC_VER >= 403 -#define _LIBCPP_HAS_IS_BASE_OF -#endif - -#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) -#define _LIBCPP_NO_EXCEPTIONS -#endif - -// constexpr was added to GCC in 4.6. -#if _GNUC_VER < 406 -# define _LIBCPP_HAS_NO_CONSTEXPR -// Can only use constexpr in c++11 mode. -#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L -# define _LIBCPP_HAS_NO_CONSTEXPR -#endif - -// Determine if GCC supports relaxed constexpr -#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#endif - -// GCC 5 will support variable templates -#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#endif - -#ifndef __GXX_EXPERIMENTAL_CXX0X__ - -#define _LIBCPP_HAS_NO_DECLTYPE -#define _LIBCPP_HAS_NO_NULLPTR -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_NO_VARIADICS -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#define _LIBCPP_HAS_NO_STRONG_ENUMS -#define _LIBCPP_HAS_NO_NOEXCEPT - -#else // __GXX_EXPERIMENTAL_CXX0X__ - -#if _GNUC_VER < 403 -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - - -#if _GNUC_VER < 404 -#define _LIBCPP_HAS_NO_DECLTYPE -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_NO_VARIADICS -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#endif // _GNUC_VER < 404 - -#if _GNUC_VER < 406 -#define _LIBCPP_HAS_NO_NOEXCEPT -#define _LIBCPP_HAS_NO_NULLPTR -#endif - -#endif // __GXX_EXPERIMENTAL_CXX0X__ - -#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) -#define _LIBCPP_HAS_NO_ASAN -#endif - -#if _GNUC_VER >= 700 -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#endif - -#if _GNUC_VER >= 700 -#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS -#endif - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#elif defined(_LIBCPP_COMPILER_MSVC) - -#define _LIBCPP_TOSTRING2(x) #x -#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) -#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) - -#if _MSC_VER < 1900 -#error "MSVC versions prior to Visual Studio 2015 are not supported" -#endif - -#define _LIBCPP_HAS_IS_BASE_OF -#define _LIBCPP_HAS_NO_CONSTEXPR -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#define _LIBCPP_HAS_NO_NOEXCEPT -#define __alignof__ __alignof -#define _LIBCPP_NORETURN __declspec(noreturn) -#define _ALIGNAS(x) __declspec(align(x)) -#define _ALIGNAS_TYPE(x) alignas(x) -#define _LIBCPP_HAS_NO_VARIADICS - -#define _LIBCPP_WEAK - -#define _LIBCPP_HAS_NO_ASAN - -#define _LIBCPP_ALWAYS_INLINE __forceinline - -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - -#elif defined(_LIBCPP_COMPILER_IBM) - -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -#define _ATTRIBUTE(x) __attribute__((x)) -#define _LIBCPP_NORETURN __attribute__((noreturn)) - -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#define _LIBCPP_HAS_NO_NOEXCEPT -#define _LIBCPP_HAS_NO_NULLPTR -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_IS_BASE_OF -#define _LIBCPP_HAS_IS_FINAL -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES - -#if defined(_AIX) -#define __MULTILOCALE_API -#endif - -#define _LIBCPP_HAS_NO_ASAN - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - -#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] - -#if defined(_LIBCPP_OBJECT_FORMAT_COFF) - -#ifdef _DLL -# define _LIBCPP_CRT_FUNC __declspec(dllimport) -#else -# define _LIBCPP_CRT_FUNC -#endif - -#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_DLL_VIS -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS -# define _LIBCPP_EXPORTED_FROM_ABI -#elif defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_DLL_VIS __declspec(dllexport) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) -#else -# define _LIBCPP_DLL_VIS __declspec(dllimport) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS -# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) -#endif - -#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS -#define _LIBCPP_HIDDEN -#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -#define _LIBCPP_TEMPLATE_VIS -#define _LIBCPP_ENUM_VIS - -#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) - -#ifndef _LIBCPP_HIDDEN -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) -# else -# define _LIBCPP_HIDDEN -# endif -#endif - -#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -// The inline should be removed once PR32114 is resolved -# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN -# else -# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -# endif -#endif - -#ifndef _LIBCPP_FUNC_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_FUNC_VIS -# endif -#endif - -#ifndef _LIBCPP_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_TYPE_VIS -# endif -#endif - -#ifndef _LIBCPP_TEMPLATE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# if __has_attribute(__type_visibility__) -# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) -# else -# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) -# endif -# else -# define _LIBCPP_TEMPLATE_VIS -# endif -#endif - -#ifndef _LIBCPP_EXPORTED_FROM_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_EXPORTED_FROM_ABI -# endif -#endif - -#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS -#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS -#endif - -#ifndef _LIBCPP_EXCEPTION_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_EXCEPTION_ABI -# endif -#endif - -#ifndef _LIBCPP_ENUM_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) -# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) -# else -# define _LIBCPP_ENUM_VIS -# endif -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# endif -#endif - -#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -#endif - -#if __has_attribute(internal_linkage) -# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) -#else -# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE -#endif - -#if __has_attribute(exclude_from_explicit_instantiation) -# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) -#else - // Try to approximate the effect of exclude_from_explicit_instantiation - // (which is that entities are not assumed to be provided by explicit - // template instantitations in the dylib) by always inlining those entities. -# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE -#endif - -#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU -# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT -# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 -# else -# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 -# endif -#endif - -#ifndef _LIBCPP_HIDE_FROM_ABI -# if _LIBCPP_HIDE_FROM_ABI_PER_TU -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE -# else -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION -# endif -#endif - -#ifdef _LIBCPP_BUILDING_LIBRARY -# if _LIBCPP_ABI_VERSION > 1 -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI -# else -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 -# endif -#else -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI -#endif - -// Just so we can migrate to the new macros gradually. -#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI - -// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { -#define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std::_LIBCPP_ABI_NAMESPACE -_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD - -#if _LIBCPP_STD_VER >= 17 -#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ - _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { -#else -#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ - _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { -#endif - -#define _LIBCPP_END_NAMESPACE_FILESYSTEM \ - _LIBCPP_END_NAMESPACE_STD } } - -#define _VSTD_FS _VSTD::__fs::filesystem - -#ifndef _LIBCPP_PREFERRED_OVERLOAD -# if __has_attribute(__enable_if__) -# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) -# endif -#endif - -#ifndef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT noexcept -# define _NOEXCEPT_(x) noexcept(x) -#else -# define _NOEXCEPT throw() -# define _NOEXCEPT_(x) -#endif - -#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) -# if !defined(_LIBCPP_DEBUG) -# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined -# endif -# ifdef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT_DEBUG -# define _NOEXCEPT_DEBUG_(x) -# else -# define _NOEXCEPT_DEBUG noexcept(false) -# define _NOEXCEPT_DEBUG_(x) noexcept(false) -# endif -#else -# define _NOEXCEPT_DEBUG _NOEXCEPT -# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x) -#endif - -#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef unsigned short char16_t; -typedef unsigned int char32_t; -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - -#ifndef __SIZEOF_INT128__ -#define _LIBCPP_HAS_NO_INT128 -#endif - -#ifdef _LIBCPP_CXX03_LANG -# if __has_extension(c_static_assert) -# define static_assert(__b, __m) _Static_assert(__b, __m) -# else -extern "C++" { -template struct __static_assert_test; -template <> struct __static_assert_test {}; -template struct __static_assert_check {}; -} -# define static_assert(__b, __m) \ - typedef __static_assert_check)> \ - _LIBCPP_CONCAT(__t, __LINE__) -# endif // __has_extension(c_static_assert) -#endif // _LIBCPP_CXX03_LANG - -#ifdef _LIBCPP_HAS_NO_DECLTYPE -// GCC 4.6 provides __decltype in all standard modes. -# if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406 -# define decltype(__x) __decltype(__x) -# else -# define decltype(__x) __typeof__(__x) -# endif -#endif - -#ifdef _LIBCPP_HAS_NO_CONSTEXPR -# define _LIBCPP_CONSTEXPR -#else -# define _LIBCPP_CONSTEXPR constexpr -#endif - -#ifdef _LIBCPP_CXX03_LANG -# define _LIBCPP_DEFAULT {} -#else -# define _LIBCPP_DEFAULT = default; -#endif - -#ifdef _LIBCPP_CXX03_LANG -# define _LIBCPP_EQUAL_DELETE -#else -# define _LIBCPP_EQUAL_DELETE = delete -#endif - -#ifdef __GNUC__ -# define _NOALIAS __attribute__((__malloc__)) -#else -# define _NOALIAS -#endif - -#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ - (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions -# define _LIBCPP_EXPLICIT explicit -#else -# define _LIBCPP_EXPLICIT -#endif - -#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) -#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE -#endif - -#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS -# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx -# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ - __lx __v_; \ - _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ - _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ - _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ - }; -#else // _LIBCPP_HAS_NO_STRONG_ENUMS -# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x -# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) -#endif // _LIBCPP_HAS_NO_STRONG_ENUMS - -#ifdef _LIBCPP_DEBUG -# if _LIBCPP_DEBUG == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG are 0 and 1 -# endif -# if !defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_EXTERN_TEMPLATE(...) -# endif -#endif - -#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) -#define _LIBCPP_EXTERN_TEMPLATE2(...) -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE2 -#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; -#endif - -#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) -#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ - defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) -#define _LIBCPP_LOCALE__L_EXTENSIONS 1 -#endif - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -// Most unix variants have catopen. These are the specific ones that don't. -# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_CATOPEN 1 -# endif -#endif - -#ifdef __FreeBSD__ -#define _DECLARE_C99_LDBL_MATH 1 -#endif - -#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) -# define _LIBCPP_DEFER_NEW_TO_VCRUNTIME -#endif - -// If we are getting operator new from the MSVC CRT, then allocation overloads -// for align_val_t were added in 19.12, aka VS 2017 version 15.3. -#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -#elif defined(_LIBCPP_DEFER_NEW_TO_VCRUNTIME) && !defined(__cpp_aligned_new) - // We're defering to Microsoft's STL to provide aligned new et al. We don't - // have it unless the language feature test macro is defined. -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -#endif - -#if defined(__APPLE__) -# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ - defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) -# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -# endif -#endif // defined(__APPLE__) - -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ - (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ - (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) -#define _LIBCPP_HAS_DEFAULTRUNELOCALE -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) -#define _LIBCPP_WCTYPE_IS_MASK -#endif - -#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) -#define _LIBCPP_NO_HAS_CHAR8_T -#endif - -// Deprecation macros. -// Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined. -#if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS) -# if __has_attribute(deprecated) -# define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) -# elif _LIBCPP_STD_VER > 11 -# define _LIBCPP_DEPRECATED [[deprecated]] -# else -# define _LIBCPP_DEPRECATED -# endif -#else -# define _LIBCPP_DEPRECATED -#endif - -#if !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX11 -#endif - -#if _LIBCPP_STD_VER >= 14 -# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX14 -#endif - -#if _LIBCPP_STD_VER >= 17 -# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX17 -#endif - -#if _LIBCPP_STD_VER <= 11 -# define _LIBCPP_EXPLICIT_AFTER_CXX11 -#else -# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit -#endif - -#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 -#endif - -#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 -#endif - -// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other -// NODISCARD macros to the correct attribute. -#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) -# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]] -#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]] -#else -// We can't use GCC's [[gnu::warn_unused_result]] and -// __attribute__((warn_unused_result)), because GCC does not silence them via -// (void) cast. -# define _LIBCPP_NODISCARD_ATTRIBUTE -#endif - -// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not -// specified as such as an extension. -#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) -# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE -#else -# define _LIBCPP_NODISCARD_EXT -#endif - -#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ - (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) -# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE -#else -# define _LIBCPP_NODISCARD_AFTER_CXX17 -#endif - -#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) -# define _LIBCPP_INLINE_VAR inline -#else -# define _LIBCPP_INLINE_VAR -#endif - -#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES -# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) -#else -# define _LIBCPP_EXPLICIT_MOVE(x) (x) -#endif - -#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG -#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -#define _LIBCPP_CONSTEXPR_IF_NODEBUG -#else -#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr -#endif -#endif - -#ifndef _LIBCPP_HAS_NO_ASAN -_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( - const void *, const void *, const void *, const void *); -#endif - -// Try to find out if RTTI is disabled. -// g++ and cl.exe have RTTI on by default and define a macro when it is. -// g++ only defines the macro in 4.3.2 and onwards. -#if !defined(_LIBCPP_NO_RTTI) -# if defined(__GNUC__) && \ - ((__GNUC__ >= 5) || \ - (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \ - !defined(__GXX_RTTI) -# define _LIBCPP_NO_RTTI -# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) -# define _LIBCPP_NO_RTTI -# endif -#endif - -#ifndef _LIBCPP_WEAK -#define _LIBCPP_WEAK __attribute__((__weak__)) -#endif - -// Thread API -#if !defined(_LIBCPP_HAS_NO_THREADS) && \ - !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ - !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ - !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -# if defined(__FreeBSD__) || \ - defined(__Fuchsia__) || \ - defined(__NetBSD__) || \ - defined(__linux__) || \ - defined(__GNU__) || \ - defined(__APPLE__) || \ - defined(__CloudABI__) || \ - defined(__sun__) || \ - (defined(__MINGW32__) && __has_include()) -# define _LIBCPP_HAS_THREAD_API_PTHREAD -# elif defined(_LIBCPP_WIN32API) -# define _LIBCPP_HAS_THREAD_API_WIN32 -# else -# error "No thread API" -# endif // _LIBCPP_HAS_THREAD_API -#endif // _LIBCPP_HAS_NO_THREADS - -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ - _LIBCPP_HAS_NO_THREADS is not defined. -#endif - -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ - _LIBCPP_HAS_NO_THREADS is defined. -#endif - -#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) -#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ - _LIBCPP_HAS_NO_THREADS is defined. -#endif - -// Systems that use capability-based security (FreeBSD with Capsicum, -// Nuxi CloudABI) may only provide local filesystem access (using *at()). -// Functions like open(), rename(), unlink() and stat() should not be -// used, as they attempt to access the global filesystem namespace. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE -#endif - -// CloudABI is intended for running networked services. Processes do not -// have standard input and output channels. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_STDIN -#define _LIBCPP_HAS_NO_STDOUT -#endif - -#if defined(__BIONIC__) || defined(__CloudABI__) || \ - defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC) -#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE -#endif - -// Thread-unsafe functions such as strtok() and localtime() -// are not available. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS -#endif - -#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) -# define _LIBCPP_HAS_C_ATOMIC_IMP -#elif _GNUC_VER > 407 -# define _LIBCPP_HAS_GCC_ATOMIC_IMP -#endif - -#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ - || defined(_LIBCPP_HAS_NO_THREADS) -#define _LIBCPP_HAS_NO_ATOMIC_HEADER -#endif - -#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#endif - -#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) -# if defined(__clang__) && __has_attribute(acquire_capability) -// Work around the attribute handling in clang. When both __declspec and -// __attribute__ are present, the processing goes awry preventing the definition -// of the types. -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) -# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# endif -# endif -#endif - -#if __has_attribute(require_constant_initialization) -# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) -#else -# define _LIBCPP_SAFE_STATIC -#endif - -#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 -#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF -#endif - -#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) -# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS -# endif -#endif - -#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) -# define _LIBCPP_DIAGNOSE_WARNING(...) \ - __attribute__((diagnose_if(__VA_ARGS__, "warning"))) -# define _LIBCPP_DIAGNOSE_ERROR(...) \ - __attribute__((diagnose_if(__VA_ARGS__, "error"))) -#else -# define _LIBCPP_DIAGNOSE_WARNING(...) -# define _LIBCPP_DIAGNOSE_ERROR(...) -#endif - -// Use a function like macro to imply that it must be followed by a semicolon -#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) -# define _LIBCPP_FALLTHROUGH() [[fallthrough]] -#elif __has_cpp_attribute(clang::fallthrough) -# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] -#elif __has_attribute(fallthough) || _GNUC_VER >= 700 -# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) -#else -# define _LIBCPP_FALLTHROUGH() ((void)0) -#endif - -#if defined(_LIBCPP_ABI_MICROSOFT) && \ - (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) -# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) -#else -# define _LIBCPP_DECLSPEC_EMPTY_BASES -#endif - -#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) -#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE -#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS -#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES - -#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 -#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES -#endif - -#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) -#define _LIBCPP_HAS_NO_IS_AGGREGATE -#endif - -#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L -#define _LIBCPP_HAS_NO_COROUTINES -#endif - -// FIXME: Correct this macro when either (A) a feature test macro for the -// spaceship operator is provided, or (B) a compiler provides a complete -// implementation. -#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR - -// Decide whether to use availability macros. -#if !defined(_LIBCPP_BUILDING_LIBRARY) && \ - !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ - __has_feature(attribute_availability_with_strict) && \ - __has_feature(attribute_availability_in_templates) -# ifdef __APPLE__ -# define _LIBCPP_USE_AVAILABILITY_APPLE -# endif -#endif - -// Define availability macros. -#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) -# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ - __attribute__((availability(macosx,strict,introduced=10.14))) \ - __attribute__((availability(ios,strict,introduced=12.0))) \ - __attribute__((availability(tvos,strict,introduced=12.0))) \ - __attribute__((availability(watchos,strict,introduced=5.0))) -# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ - _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ - _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ - __attribute__((availability(ios,strict,introduced=6.0))) -# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -#else -# define _LIBCPP_AVAILABILITY_SHARED_MUTEX -# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS -# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST -# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS -# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE -# define _LIBCPP_AVAILABILITY_FUTURE_ERROR -# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE -# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY -# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR -#endif - -// Define availability that depends on _LIBCPP_NO_EXCEPTIONS. -#ifdef _LIBCPP_NO_EXCEPTIONS -# define _LIBCPP_AVAILABILITY_FUTURE -# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS -#else -# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR -# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST -# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS -#endif - -// The stream API was dropped and re-added in the dylib shipped on macOS -// and iOS. We can only assume the dylib to provide these definitions for -// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available -// from the headers, but not from the dylib. Explicit instantiation -// declarations for streams exist conditionally to this; if we provide -// an explicit instantiation declaration and we try to deploy to a dylib -// that does not provide those symbols, we'll get a load-time error. -#if !defined(_LIBCPP_BUILDING_LIBRARY) && \ - ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \ - (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)) -# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB -#endif - -#if defined(_LIBCPP_COMPILER_IBM) -#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO -#endif - -#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) -# define _LIBCPP_PUSH_MACROS -# define _LIBCPP_POP_MACROS -#else - // Don't warn about macro conflicts when we can restore them at the - // end of the header. -# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS -# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS -# endif -# if defined(_LIBCPP_COMPILER_MSVC) -# define _LIBCPP_PUSH_MACROS \ - __pragma(push_macro("min")) \ - __pragma(push_macro("max")) -# define _LIBCPP_POP_MACROS \ - __pragma(pop_macro("min")) \ - __pragma(pop_macro("max")) -# else -# define _LIBCPP_PUSH_MACROS \ - _Pragma("push_macro(\"min\")") \ - _Pragma("push_macro(\"max\")") -# define _LIBCPP_POP_MACROS \ - _Pragma("pop_macro(\"min\")") \ - _Pragma("pop_macro(\"max\")") -# endif -#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) - -#ifndef _LIBCPP_NO_AUTO_LINK -# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) -# if defined(_DLL) -# pragma comment(lib, "c++.lib") -# else -# pragma comment(lib, "libc++.lib") -# endif -# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) -#endif // _LIBCPP_NO_AUTO_LINK - -#define _LIBCPP_UNUSED_VAR(x) ((void)(x)) - -#endif // __cplusplus - -#endif // _LIBCPP_CONFIG diff --git a/clang-r353983c/include/c++/v1/__cxxabi_config.h b/clang-r353983c/include/c++/v1/__cxxabi_config.h deleted file mode 100644 index c5e6e895baedc1730d99279535dc510647f94b2d..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__cxxabi_config.h +++ /dev/null @@ -1,72 +0,0 @@ -//===-------------------------- __cxxabi_config.h -------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef ____CXXABI_CONFIG_H -#define ____CXXABI_CONFIG_H - -#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ - !defined(__ARM_DWARF_EH__) -#define _LIBCXXABI_ARM_EHABI -#endif - -#if !defined(__has_attribute) -#define __has_attribute(_attribute_) 0 -#endif - -#if defined(_WIN32) - #if defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LIBCXXABI_TYPE_VIS - #elif defined(_LIBCXXABI_BUILDING_LIBRARY) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS __declspec(dllexport) - #define _LIBCXXABI_FUNC_VIS __declspec(dllexport) - #define _LIBCXXABI_TYPE_VIS __declspec(dllexport) - #else - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS __declspec(dllimport) - #define _LIBCXXABI_FUNC_VIS __declspec(dllimport) - #define _LIBCXXABI_TYPE_VIS __declspec(dllimport) - #endif -#else - #if !defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) - #define _LIBCXXABI_HIDDEN __attribute__((__visibility__("hidden"))) - #define _LIBCXXABI_DATA_VIS __attribute__((__visibility__("default"))) - #define _LIBCXXABI_FUNC_VIS __attribute__((__visibility__("default"))) - #if __has_attribute(__type_visibility__) - #define _LIBCXXABI_TYPE_VIS __attribute__((__type_visibility__("default"))) - #else - #define _LIBCXXABI_TYPE_VIS __attribute__((__visibility__("default"))) - #endif - #else - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LIBCXXABI_TYPE_VIS - #endif -#endif - -#if defined(_WIN32) -#define _LIBCXXABI_WEAK -#else -#define _LIBCXXABI_WEAK __attribute__((__weak__)) -#endif - -#if defined(__clang__) -#define _LIBCXXABI_COMPILER_CLANG -#endif - -#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG) -#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi"))) -#else -#define _LIBCXXABI_NO_CFI -#endif - -#endif // ____CXXABI_CONFIG_H diff --git a/clang-r353983c/include/c++/v1/__debug b/clang-r353983c/include/c++/v1/__debug deleted file mode 100644 index 6ccb72cb8ad0e25e416fcf7a87ea4129bf241f72..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__debug +++ /dev/null @@ -1,301 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __debug ----------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_DEBUG_H -#define _LIBCPP_DEBUG_H - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if defined(_LIBCPP_HAS_NO_NULLPTR) -# include -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -# include -# include -# include -# include -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT) -# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \ - _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 2 -#ifndef _LIBCPP_DEBUG_ASSERT -#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) -#endif -#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__ -#endif - -#ifndef _LIBCPP_ASSERT -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif -#ifndef _LIBCPP_DEBUG_ASSERT -# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) -#endif -#ifndef _LIBCPP_DEBUG_MODE -#define _LIBCPP_DEBUG_MODE(...) ((void)0) -#endif - -#if _LIBCPP_DEBUG_LEVEL < 1 -class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception; -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - __libcpp_debug_info() - : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m) - : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {} - const char* __file_; - int __line_; - const char* __pred_; - const char* __msg_; -}; - -/// __libcpp_debug_function_type - The type of the assertion failure handler. -typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&); - -/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT -/// fails. -extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function; - -/// __libcpp_abort_debug_function - A debug handler that aborts when called. -_LIBCPP_NORETURN _LIBCPP_FUNC_VIS -void __libcpp_abort_debug_function(__libcpp_debug_info const&); - -/// __libcpp_throw_debug_function - A debug handler that throws -/// an instance of __libcpp_debug_exception when called. - _LIBCPP_NORETURN _LIBCPP_FUNC_VIS -void __libcpp_throw_debug_function(__libcpp_debug_info const&); - -/// __libcpp_set_debug_function - Set the debug handler to the specified -/// function. -_LIBCPP_FUNC_VIS -bool __libcpp_set_debug_function(__libcpp_debug_function_type __func); - -// Setup the throwing debug handler during dynamic initialization. -#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) -# if defined(_LIBCPP_NO_EXCEPTIONS) -# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled. -# endif -static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function); -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception { -public: - __libcpp_debug_exception() _NOEXCEPT; - explicit __libcpp_debug_exception(__libcpp_debug_info const& __i); - __libcpp_debug_exception(__libcpp_debug_exception const&); - ~__libcpp_debug_exception() _NOEXCEPT; - const char* what() const _NOEXCEPT; -private: - struct __libcpp_debug_exception_imp; - __libcpp_debug_exception_imp *__imp_; -}; -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) - -struct _LIBCPP_TYPE_VIS __c_node; - -struct _LIBCPP_TYPE_VIS __i_node -{ - void* __i_; - __i_node* __next_; - __c_node* __c_; - -#ifndef _LIBCPP_CXX03_LANG - __i_node(const __i_node&) = delete; - __i_node& operator=(const __i_node&) = delete; -#else -private: - __i_node(const __i_node&); - __i_node& operator=(const __i_node&); -public: -#endif - _LIBCPP_INLINE_VISIBILITY - __i_node(void* __i, __i_node* __next, __c_node* __c) - : __i_(__i), __next_(__next), __c_(__c) {} - ~__i_node(); -}; - -struct _LIBCPP_TYPE_VIS __c_node -{ - void* __c_; - __c_node* __next_; - __i_node** beg_; - __i_node** end_; - __i_node** cap_; - -#ifndef _LIBCPP_CXX03_LANG - __c_node(const __c_node&) = delete; - __c_node& operator=(const __c_node&) = delete; -#else -private: - __c_node(const __c_node&); - __c_node& operator=(const __c_node&); -public: -#endif - _LIBCPP_INLINE_VISIBILITY - __c_node(void* __c, __c_node* __next) - : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} - virtual ~__c_node(); - - virtual bool __dereferenceable(const void*) const = 0; - virtual bool __decrementable(const void*) const = 0; - virtual bool __addable(const void*, ptrdiff_t) const = 0; - virtual bool __subscriptable(const void*, ptrdiff_t) const = 0; - - void __add(__i_node* __i); - _LIBCPP_HIDDEN void __remove(__i_node* __i); -}; - -template -struct _C_node - : public __c_node -{ - _C_node(void* __c, __c_node* __n) - : __c_node(__c, __n) {} - - virtual bool __dereferenceable(const void*) const; - virtual bool __decrementable(const void*) const; - virtual bool __addable(const void*, ptrdiff_t) const; - virtual bool __subscriptable(const void*, ptrdiff_t) const; -}; - -template -inline bool -_C_node<_Cont>::__dereferenceable(const void* __i) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__dereferenceable(__j); -} - -template -inline bool -_C_node<_Cont>::__decrementable(const void* __i) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__decrementable(__j); -} - -template -inline bool -_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__addable(__j, __n); -} - -template -inline bool -_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__subscriptable(__j, __n); -} - -class _LIBCPP_TYPE_VIS __libcpp_db -{ - __c_node** __cbeg_; - __c_node** __cend_; - size_t __csz_; - __i_node** __ibeg_; - __i_node** __iend_; - size_t __isz_; - - __libcpp_db(); -public: -#ifndef _LIBCPP_CXX03_LANG - __libcpp_db(const __libcpp_db&) = delete; - __libcpp_db& operator=(const __libcpp_db&) = delete; -#else -private: - __libcpp_db(const __libcpp_db&); - __libcpp_db& operator=(const __libcpp_db&); -public: -#endif - ~__libcpp_db(); - - class __db_c_iterator; - class __db_c_const_iterator; - class __db_i_iterator; - class __db_i_const_iterator; - - __db_c_const_iterator __c_end() const; - __db_i_const_iterator __i_end() const; - - template - _LIBCPP_INLINE_VISIBILITY - void __insert_c(_Cont* __c) - { - __c_node* __n = __insert_c(static_cast(__c)); - ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_); - } - - void __insert_i(void* __i); - __c_node* __insert_c(void* __c); - void __erase_c(void* __c); - - void __insert_ic(void* __i, const void* __c); - void __iterator_copy(void* __i, const void* __i0); - void __erase_i(void* __i); - - void* __find_c_from_i(void* __i) const; - void __invalidate_all(void* __c); - __c_node* __find_c_and_lock(void* __c) const; - __c_node* __find_c(void* __c) const; - void unlock() const; - - void swap(void* __c1, void* __c2); - - - bool __dereferenceable(const void* __i) const; - bool __decrementable(const void* __i) const; - bool __addable(const void* __i, ptrdiff_t __n) const; - bool __subscriptable(const void* __i, ptrdiff_t __n) const; - bool __less_than_comparable(const void* __i, const void* __j) const; -private: - _LIBCPP_HIDDEN - __i_node* __insert_iterator(void* __i); - _LIBCPP_HIDDEN - __i_node* __find_iterator(const void* __i) const; - - friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db(); -}; - -_LIBCPP_FUNC_VIS __libcpp_db* __get_db(); -_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); - - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_DEBUG_H - diff --git a/clang-r353983c/include/c++/v1/__errc b/clang-r353983c/include/c++/v1/__errc deleted file mode 100644 index a8ad29f364ac44497f75f90b4c89ed6ff5818f82..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__errc +++ /dev/null @@ -1,217 +0,0 @@ -// -*- C++ -*- -//===---------------------------- __errc ----------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ERRC -#define _LIBCPP___ERRC - -/* - system_error synopsis - -namespace std -{ - -enum class errc -{ - address_family_not_supported, // EAFNOSUPPORT - address_in_use, // EADDRINUSE - address_not_available, // EADDRNOTAVAIL - already_connected, // EISCONN - argument_list_too_long, // E2BIG - argument_out_of_domain, // EDOM - bad_address, // EFAULT - bad_file_descriptor, // EBADF - bad_message, // EBADMSG - broken_pipe, // EPIPE - connection_aborted, // ECONNABORTED - connection_already_in_progress, // EALREADY - connection_refused, // ECONNREFUSED - connection_reset, // ECONNRESET - cross_device_link, // EXDEV - destination_address_required, // EDESTADDRREQ - device_or_resource_busy, // EBUSY - directory_not_empty, // ENOTEMPTY - executable_format_error, // ENOEXEC - file_exists, // EEXIST - file_too_large, // EFBIG - filename_too_long, // ENAMETOOLONG - function_not_supported, // ENOSYS - host_unreachable, // EHOSTUNREACH - identifier_removed, // EIDRM - illegal_byte_sequence, // EILSEQ - inappropriate_io_control_operation, // ENOTTY - interrupted, // EINTR - invalid_argument, // EINVAL - invalid_seek, // ESPIPE - io_error, // EIO - is_a_directory, // EISDIR - message_size, // EMSGSIZE - network_down, // ENETDOWN - network_reset, // ENETRESET - network_unreachable, // ENETUNREACH - no_buffer_space, // ENOBUFS - no_child_process, // ECHILD - no_link, // ENOLINK - no_lock_available, // ENOLCK - no_message_available, // ENODATA - no_message, // ENOMSG - no_protocol_option, // ENOPROTOOPT - no_space_on_device, // ENOSPC - no_stream_resources, // ENOSR - no_such_device_or_address, // ENXIO - no_such_device, // ENODEV - no_such_file_or_directory, // ENOENT - no_such_process, // ESRCH - not_a_directory, // ENOTDIR - not_a_socket, // ENOTSOCK - not_a_stream, // ENOSTR - not_connected, // ENOTCONN - not_enough_memory, // ENOMEM - not_supported, // ENOTSUP - operation_canceled, // ECANCELED - operation_in_progress, // EINPROGRESS - operation_not_permitted, // EPERM - operation_not_supported, // EOPNOTSUPP - operation_would_block, // EWOULDBLOCK - owner_dead, // EOWNERDEAD - permission_denied, // EACCES - protocol_error, // EPROTO - protocol_not_supported, // EPROTONOSUPPORT - read_only_file_system, // EROFS - resource_deadlock_would_occur, // EDEADLK - resource_unavailable_try_again, // EAGAIN - result_out_of_range, // ERANGE - state_not_recoverable, // ENOTRECOVERABLE - stream_timeout, // ETIME - text_file_busy, // ETXTBSY - timed_out, // ETIMEDOUT - too_many_files_open_in_system, // ENFILE - too_many_files_open, // EMFILE - too_many_links, // EMLINK - too_many_symbolic_link_levels, // ELOOP - value_too_large, // EOVERFLOW - wrong_protocol_type // EPROTOTYPE -}; - -*/ - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -// Some error codes are not present on all platforms, so we provide equivalents -// for them: - -//enum class errc -_LIBCPP_DECLARE_STRONG_ENUM(errc) -{ - address_family_not_supported = EAFNOSUPPORT, - address_in_use = EADDRINUSE, - address_not_available = EADDRNOTAVAIL, - already_connected = EISCONN, - argument_list_too_long = E2BIG, - argument_out_of_domain = EDOM, - bad_address = EFAULT, - bad_file_descriptor = EBADF, - bad_message = EBADMSG, - broken_pipe = EPIPE, - connection_aborted = ECONNABORTED, - connection_already_in_progress = EALREADY, - connection_refused = ECONNREFUSED, - connection_reset = ECONNRESET, - cross_device_link = EXDEV, - destination_address_required = EDESTADDRREQ, - device_or_resource_busy = EBUSY, - directory_not_empty = ENOTEMPTY, - executable_format_error = ENOEXEC, - file_exists = EEXIST, - file_too_large = EFBIG, - filename_too_long = ENAMETOOLONG, - function_not_supported = ENOSYS, - host_unreachable = EHOSTUNREACH, - identifier_removed = EIDRM, - illegal_byte_sequence = EILSEQ, - inappropriate_io_control_operation = ENOTTY, - interrupted = EINTR, - invalid_argument = EINVAL, - invalid_seek = ESPIPE, - io_error = EIO, - is_a_directory = EISDIR, - message_size = EMSGSIZE, - network_down = ENETDOWN, - network_reset = ENETRESET, - network_unreachable = ENETUNREACH, - no_buffer_space = ENOBUFS, - no_child_process = ECHILD, - no_link = ENOLINK, - no_lock_available = ENOLCK, -#ifdef ENODATA - no_message_available = ENODATA, -#else - no_message_available = ENOMSG, -#endif - no_message = ENOMSG, - no_protocol_option = ENOPROTOOPT, - no_space_on_device = ENOSPC, -#ifdef ENOSR - no_stream_resources = ENOSR, -#else - no_stream_resources = ENOMEM, -#endif - no_such_device_or_address = ENXIO, - no_such_device = ENODEV, - no_such_file_or_directory = ENOENT, - no_such_process = ESRCH, - not_a_directory = ENOTDIR, - not_a_socket = ENOTSOCK, -#ifdef ENOSTR - not_a_stream = ENOSTR, -#else - not_a_stream = EINVAL, -#endif - not_connected = ENOTCONN, - not_enough_memory = ENOMEM, - not_supported = ENOTSUP, - operation_canceled = ECANCELED, - operation_in_progress = EINPROGRESS, - operation_not_permitted = EPERM, - operation_not_supported = EOPNOTSUPP, - operation_would_block = EWOULDBLOCK, - owner_dead = EOWNERDEAD, - permission_denied = EACCES, - protocol_error = EPROTO, - protocol_not_supported = EPROTONOSUPPORT, - read_only_file_system = EROFS, - resource_deadlock_would_occur = EDEADLK, - resource_unavailable_try_again = EAGAIN, - result_out_of_range = ERANGE, - state_not_recoverable = ENOTRECOVERABLE, -#ifdef ETIME - stream_timeout = ETIME, -#else - stream_timeout = ETIMEDOUT, -#endif - text_file_busy = ETXTBSY, - timed_out = ETIMEDOUT, - too_many_files_open_in_system = ENFILE, - too_many_files_open = EMFILE, - too_many_links = EMLINK, - too_many_symbolic_link_levels = ELOOP, - value_too_large = EOVERFLOW, - wrong_protocol_type = EPROTOTYPE -}; -_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ERRC diff --git a/clang-r353983c/include/c++/v1/__functional_03 b/clang-r353983c/include/c++/v1/__functional_03 deleted file mode 100644 index a90cbb75b2adb8517fbbee82a198c0b947991e9a..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__functional_03 +++ /dev/null @@ -1,1591 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_03 -#define _LIBCPP_FUNCTIONAL_03 - -// manual variadic expansion for - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -namespace __function { - -template class __base; - -template -class __base<_Rp()> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()() = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0, _A1)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0, _A1) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0, _A1, _A2)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0, _A1, _A2) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template class __func; - -template -class __func<_Fp, _Alloc, _Rp()> - : public __base<_Rp()> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp()>* __clone() const; - virtual void __clone(__base<_Rp()>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp()>* -__func<_Fp, _Alloc, _Rp()>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp()>::operator()() -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first()); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp()>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0)> - : public __base<_Rp(_A0)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0)>* __clone() const; - virtual void __clone(__base<_Rp(_A0)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0)>* -__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0, _A1)> - : public __base<_Rp(_A0, _A1)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0, _A1)>* __clone() const; - virtual void __clone(__base<_Rp(_A0, _A1)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0, _A1); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0, _A1)>* -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0, __a1); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> - : public __base<_Rp(_A0, _A1, _A2)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const; - virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0, _A1, _A2); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0, _A1, _A2)>* -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0, __a1, __a2); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -} // __function - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp()> -{ - typedef __function::__base<_Rp()> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2()>&) const;// = delete; - template - bool operator!=(const function<_R2()>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()() const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp()>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp()>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp()> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp()>& -function<_Rp()>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp()>& -function<_Rp()>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp()>& ->::type -function<_Rp()>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp()>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp()>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp()>::operator()() const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp()>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp()>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp()>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)> - : public unary_function<_A0, _Rp> -{ - typedef __function::__base<_Rp(_A0)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0)>& -function<_Rp(_A0)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0)>& -function<_Rp(_A0)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0)>& ->::type -function<_Rp(_A0)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0)>::operator()(_A0 __a0) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)> - : public binary_function<_A0, _A1, _Rp> -{ - typedef __function::__base<_Rp(_A0, _A1)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0, _A1) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0, _A1)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0, _A1)>& -function<_Rp(_A0, _A1)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0, _A1)>& -function<_Rp(_A0, _A1)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0, _A1)>& ->::type -function<_Rp(_A0, _A1)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0, _A1)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0, _A1)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0, __a1); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0, _A1)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0, _A1)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0, _A1)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)> -{ - typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0, _A1, _A2) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0, _A1, _A2)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&, - const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0, _A1, _A2)>& -function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0, _A1, _A2)>& -function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0, _A1, _A2)>& ->::type -function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0, _A1, _A2)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0, _A1, _A2)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0, __a1, __a2); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0, _A1, _A2)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0, _A1, _A2)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0, _A1, _A2)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const function<_Fp>& __f, nullptr_t) {return !__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(nullptr_t, const function<_Fp>& __f) {return !__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(function<_Fp>& __x, function<_Fp>& __y) -{return __x.swap(__y);} - -#endif // _LIBCPP_FUNCTIONAL_03 diff --git a/clang-r353983c/include/c++/v1/__functional_base b/clang-r353983c/include/c++/v1/__functional_base deleted file mode 100644 index 8da8324545e0bff5180e0bdd1b7ea4610ce8487c..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__functional_base +++ /dev/null @@ -1,652 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_BASE -#define _LIBCPP_FUNCTIONAL_BASE - -#include <__config> -#include -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -struct _LIBCPP_TEMPLATE_VIS binary_function -{ - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; -}; - -template -struct __has_result_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::result_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -#if _LIBCPP_STD_VER > 11 -template -#else -template -#endif -struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> -{ - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Tp& __x, const _Tp& __y) const - {return __x < __y;} -}; - -#if _LIBCPP_STD_VER > 11 -template <> -struct _LIBCPP_TEMPLATE_VIS less -{ - template - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - auto operator()(_T1&& __t, _T2&& __u) const - _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) - -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } - typedef void is_transparent; -}; -#endif - -// __weak_result_type - -template -struct __derives_from_unary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static unary_function<_Ap, _Rp> - __test(const volatile unary_function<_Ap, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template -struct __derives_from_binary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static binary_function<_A1, _A2, _Rp> - __test(const volatile binary_function<_A1, _A2, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template ::value> -struct __maybe_derive_from_unary_function // bool is true - : public __derives_from_unary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_unary_function<_Tp, false> -{ -}; - -template ::value> -struct __maybe_derive_from_binary_function // bool is true - : public __derives_from_binary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_binary_function<_Tp, false> -{ -}; - -template ::value> -struct __weak_result_type_imp // bool is true - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ - typedef typename _Tp::result_type result_type; -}; - -template -struct __weak_result_type_imp<_Tp, false> - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ -}; - -template -struct __weak_result_type - : public __weak_result_type_imp<_Tp> -{ -}; - -// 0 argument case - -template -struct __weak_result_type<_Rp ()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)()> -{ - typedef _Rp result_type; -}; - -// 1 argument case - -template -struct __weak_result_type<_Rp (_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)()> - : public unary_function<_Cp*, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() volatile> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const volatile> - : public unary_function -{ -}; - -// 2 argument case - -template -struct __weak_result_type<_Rp (_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1)> - : public binary_function<_Cp*, _A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> - : public binary_function -{ -}; - - -#ifndef _LIBCPP_CXX03_LANG -// 3 or more arguments - -template -struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> -{ - typedef _Rp result_type; -}; - -template -struct __invoke_return -{ - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; -}; - -#else // defined(_LIBCPP_CXX03_LANG) - -#include <__functional_base_03> - -#endif // !defined(_LIBCPP_CXX03_LANG) - - -template -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static _Ret __call(_Args&&... __args) { - return __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static _Ret __call(_Fn __f) { - return __invoke(__f); - } - - template - static _Ret __call(_Fn __f, _A0& __a0) { - return __invoke(__f, __a0); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { - return __invoke(__f, __a0, __a1); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ - return __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template <> -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static void __call(_Args&&... __args) { - __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static void __call(_Fn __f) { - __invoke(__f); - } - - template - static void __call(_Fn __f, _A0& __a0) { - __invoke(__f, __a0); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1) { - __invoke(__f, __a0, __a1); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { - __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template -class _LIBCPP_TEMPLATE_VIS reference_wrapper - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type* __f_; - -public: - // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT - : __f_(_VSTD::addressof(__f)) {} -#ifndef _LIBCPP_CXX03_LANG - private: reference_wrapper(type&&); public: // = delete; // do not bind to temps -#endif - - // access - _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;} - _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;} - -#ifndef _LIBCPP_CXX03_LANG - // invoke - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } -#else - - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() () const { - return __invoke(get()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0 const& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } -#endif // _LIBCPP_CXX03_LANG -}; - - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(_Tp& __t) _NOEXCEPT -{ - return reference_wrapper<_Tp>(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return ref(__t.get()); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(const _Tp& __t) _NOEXCEPT -{ - return reference_wrapper(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return cref(__t.get()); -} - -#ifndef _LIBCPP_CXX03_LANG -template void ref(const _Tp&&) = delete; -template void cref(const _Tp&&) = delete; -#endif - -#if _LIBCPP_STD_VER > 11 -template -struct __is_transparent : false_type {}; - -template -struct __is_transparent<_Tp, _Up, - typename __void_t::type> - : true_type {}; -#endif - -// allocator_arg_t - -struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { }; - -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; -#else -/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template ::value> -struct __uses_allocator - : public integral_constant::value> -{ -}; - -template -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#if _LIBCPP_STD_VER > 14 -template -_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; -#endif - -#ifndef _LIBCPP_CXX03_LANG - -// allocator construction - -template -struct __uses_alloc_ctor_imp -{ - typedef typename __uncvref<_Alloc>::type _RawAlloc; - static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template -struct __uses_alloc_ctor - : integral_constant::value> - {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); -} - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_FUNCTIONAL_BASE diff --git a/clang-r353983c/include/c++/v1/__functional_base_03 b/clang-r353983c/include/c++/v1/__functional_base_03 deleted file mode 100644 index e6dac90c84f7aaa0178d7de65efd0d3238db0f7d..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__functional_base_03 +++ /dev/null @@ -1,223 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_BASE_03 -#define _LIBCPP_FUNCTIONAL_BASE_03 - -// manual variadic expansion for - -// __invoke - -template -struct __enable_invoke_imp; - -template -struct __enable_invoke_imp<_Ret, _T1, true, true> { - typedef _Ret _Bullet1; - typedef _Bullet1 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, true, false> { - typedef _Ret _Bullet2; - typedef _Bullet2 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, false, true> { - typedef typename add_lvalue_reference< - typename __apply_cv<_T1, _Ret>::type - >::type _Bullet3; - typedef _Bullet3 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, false, false> { - typedef typename add_lvalue_reference< - typename __apply_cv()), _Ret>::type - >::type _Bullet4; - typedef _Bullet4 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1*, false, false> { - typedef typename add_lvalue_reference< - typename __apply_cv<_T1, _Ret>::type - >::type _Bullet4; - typedef _Bullet4 type; -}; - -template , - class _Ret = typename _Traits::_ReturnType, - class _Class = typename _Traits::_ClassType> -struct __enable_invoke : __enable_invoke_imp< - _Ret, _T1, - is_member_function_pointer<_Fn>::value, - is_base_of<_Class, typename remove_reference<_T1>::type>::value> -{ -}; - -__nat __invoke(__any, ...); - -// first bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1) { - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0) { - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1) { - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0) { - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet3 -__invoke(_Fn __f, _T1& __t1) { - return __t1.*__f; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet4 -__invoke(_Fn __f, _T1& __t1) { - return (*__t1).*__f; -} - -// fifth bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()()) -__invoke(_Fp& __f) -{ - return __f(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>())) -__invoke(_Fp& __f, _A0& __a0) -{ - return __f(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>())) -__invoke(_Fp& __f, _A0& __a0, _A1& __a1) -{ - return __f(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>())) -__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return __f(__a0, __a1, __a2); -} - -template >::value> -struct __invoke_return -{ - typedef typename __weak_result_type<_Fp>::result_type type; -}; - -template -struct __invoke_return<_Fp, false> -{ - typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type; -}; - -template -struct __invoke_return0 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type; -}; - -template -struct __invoke_return0<_Rp _Tp::*, _A0> -{ - typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; -}; - -template -struct __invoke_return1 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), - _VSTD::declval<_A1&>())) type; -}; - -template -struct __invoke_return1<_Rp _Class::*, _A0, _A1> { - typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; -}; - -template -struct __invoke_return2 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), - _VSTD::declval<_A1&>(), - _VSTD::declval<_A2&>())) type; -}; - -template -struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { - typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; -}; -#endif // _LIBCPP_FUNCTIONAL_BASE_03 diff --git a/clang-r353983c/include/c++/v1/__hash_table b/clang-r353983c/include/c++/v1/__hash_table deleted file mode 100644 index 4409d6dc564badf3a31260d588327455fdf49d76..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__hash_table +++ /dev/null @@ -1,2913 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP__HASH_TABLE -#define _LIBCPP__HASH_TABLE - -#include <__config> -#include -#include -#include -#include -#include -#include -#include - -#include <__debug> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -struct __hash_value_type; - -#ifndef _LIBCPP_CXX03_LANG -template -struct __is_hash_value_type_imp : false_type {}; - -template -struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {}; - -template -struct __is_hash_value_type : false_type {}; - -template -struct __is_hash_value_type<_One> : __is_hash_value_type_imp::type> {}; -#endif - -_LIBCPP_FUNC_VIS -size_t __next_prime(size_t __n); - -template -struct __hash_node_base -{ - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef __hash_node_base __first_node; - typedef typename __rebind_pointer<_NodePtr, __first_node>::type __node_base_pointer; - typedef _NodePtr __node_pointer; - -#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB) - typedef __node_base_pointer __next_pointer; -#else - typedef typename conditional< - is_pointer<__node_pointer>::value, - __node_base_pointer, - __node_pointer>::type __next_pointer; -#endif - - __next_pointer __next_; - - _LIBCPP_INLINE_VISIBILITY - __next_pointer __ptr() _NOEXCEPT { - return static_cast<__next_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(*this)); - } - - _LIBCPP_INLINE_VISIBILITY - __node_pointer __upcast() _NOEXCEPT { - return static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(*this)); - } - - _LIBCPP_INLINE_VISIBILITY - size_t __hash() const _NOEXCEPT { - return static_cast<__node_type const&>(*this).__hash_; - } - - _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {} -}; - -template -struct __hash_node - : public __hash_node_base - < - typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type - > -{ - typedef _Tp __node_value_type; - - size_t __hash_; - __node_value_type __value_; -}; - -inline _LIBCPP_INLINE_VISIBILITY -bool -__is_hash_power2(size_t __bc) -{ - return __bc > 2 && !(__bc & (__bc - 1)); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -__constrain_hash(size_t __h, size_t __bc) -{ - return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : - (__h < __bc ? __h : __h % __bc); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -__next_hash_pow2(size_t __n) -{ - return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits - __clz(__n-1))); -} - - -template class __hash_table; - -template class _LIBCPP_TEMPLATE_VIS __hash_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_local_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; - -template -struct __hash_key_value_types { - static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, ""); - typedef _Tp key_type; - typedef _Tp __node_value_type; - typedef _Tp __container_value_type; - static const bool __is_map = false; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(_Tp const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& __get_value(__node_value_type const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static __container_value_type&& __move(__node_value_type& __v) { - return _VSTD::move(__v); - } -#endif -}; - -template -struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { - typedef _Key key_type; - typedef _Tp mapped_type; - typedef __hash_value_type<_Key, _Tp> __node_value_type; - typedef pair __container_value_type; - typedef __container_value_type __map_value_type; - static const bool __is_map = true; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(__container_value_type const& __v) { - return __v.first; - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t.__get_value(); - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n.__get_value()); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static pair __move(__node_value_type& __v) { - return __v.__move(); - } -#endif - -}; - -template , - bool = _KVTypes::__is_map> -struct __hash_map_pointer_types {}; - -template -struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { - typedef typename _KVTypes::__map_value_type _Mv; - typedef typename __rebind_pointer<_AllocPtr, _Mv>::type - __map_value_type_pointer; - typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type - __const_map_value_type_pointer; -}; - -template ::element_type> -struct __hash_node_types; - -template -struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> > - : public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr> - -{ - typedef __hash_key_value_types<_Tp> __base; - -public: - typedef ptrdiff_t difference_type; - typedef size_t size_type; - - typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer; - - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef _NodePtr __node_pointer; - - typedef __hash_node_base<__node_pointer> __node_base_type; - typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type - __node_base_pointer; - - typedef typename __node_base_type::__next_pointer __next_pointer; - - typedef _Tp __node_value_type; - typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type - __node_value_type_pointer; - typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type - __const_node_value_type_pointer; - -private: - static_assert(!is_const<__node_type>::value, - "_NodePtr should never be a pointer to const"); - static_assert((is_same::element_type, void>::value), - "_VoidPtr does not point to unqualified void type"); - static_assert((is_same::type, - _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr."); -}; - -template -struct __hash_node_types_from_iterator; -template -struct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; - - -template -struct __make_hash_node_types { - typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp; - typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr; - typedef __hash_node_types<_NodePtr> type; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_iterator -{ - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - -public: - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(const __hash_iterator& __i) - : __node_(__i.__node_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator& operator=(const __hash_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container iterator"); - __node_ = __node_->__next_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator operator++(int) - { - __hash_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_iterator& __x, const __hash_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT - : __node_(__node) - { - __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_const_iterator -{ - static_assert(!is_const::element_type>::value, ""); - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - -public: - typedef __hash_iterator<_NodePtr> __non_const_iterator; - - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - - _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT - : __node_(__x.__node_) - { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(const __hash_const_iterator& __i) - : __node_(__i.__node_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_const_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator& operator=(const __hash_const_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_iterator"); - return __node_->__upcast()->__value_; - } - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_iterator"); - __node_ = __node_->__next_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator operator++(int) - { - __hash_const_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT - : __node_(__node) - { - __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_local_iterator -{ - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - size_t __bucket_; - size_t __bucket_count_; - -public: - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(const __hash_local_iterator& __i) - : __node_(__i.__node_), - __bucket_(__i.__bucket_), - __bucket_count_(__i.__bucket_count_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_local_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator& operator=(const __hash_local_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - __bucket_ = __i.__bucket_; - __bucket_count_ = __i.__bucket_count_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container local_iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container local_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container local_iterator"); - __node_ = __node_->__next_; - if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) - __node_ = nullptr; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator operator++(int) - { - __hash_local_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count, const void* __c) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - __get_db()->__insert_ic(this, __c); - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator -{ - typedef __hash_node_types<_ConstNodePtr> _NodeTypes; - typedef _ConstNodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - size_t __bucket_; - size_t __bucket_count_; - - typedef pointer_traits<__node_pointer> __pointer_traits; - typedef typename __pointer_traits::element_type __node; - typedef typename remove_const<__node>::type __non_const_node; - typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type - __non_const_node_pointer; -public: - typedef __hash_local_iterator<__non_const_node_pointer> - __non_const_iterator; - - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - - _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT - : __node_(__x.__node_), - __bucket_(__x.__bucket_), - __bucket_count_(__x.__bucket_count_) - { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(const __hash_const_local_iterator& __i) - : __node_(__i.__node_), - __bucket_(__i.__bucket_), - __bucket_count_(__i.__bucket_count_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_const_local_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - __bucket_ = __i.__bucket_; - __bucket_count_ = __i.__bucket_count_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_local_iterator"); - __node_ = __node_->__next_; - if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) - __node_ = nullptr; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator operator++(int) - { - __hash_const_local_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count, const void* __c) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - __get_db()->__insert_ic(this, __c); - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; -}; - -template -class __bucket_list_deallocator -{ - typedef _Alloc allocator_type; - typedef allocator_traits __alloc_traits; - typedef typename __alloc_traits::size_type size_type; - - __compressed_pair __data_; -public: - typedef typename __alloc_traits::pointer pointer; - - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __data_(0) {} - - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator(const allocator_type& __a, size_type __size) - _NOEXCEPT_(is_nothrow_copy_constructible::value) - : __data_(__size, __a) {} - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator(__bucket_list_deallocator&& __x) - _NOEXCEPT_(is_nothrow_move_constructible::value) - : __data_(_VSTD::move(__x.__data_)) - { - __x.size() = 0; - } -#endif - - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __data_.first();} - _LIBCPP_INLINE_VISIBILITY - size_type size() const _NOEXCEPT {return __data_.first();} - - _LIBCPP_INLINE_VISIBILITY - allocator_type& __alloc() _NOEXCEPT {return __data_.second();} - _LIBCPP_INLINE_VISIBILITY - const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - __alloc_traits::deallocate(__alloc(), __p, size()); - } -}; - -template class __hash_map_node_destructor; - -template -class __hash_node_destructor -{ - typedef _Alloc allocator_type; - typedef allocator_traits __alloc_traits; - -public: - typedef typename __alloc_traits::pointer pointer; -private: - typedef __hash_node_types _NodeTypes; - - allocator_type& __na_; - - __hash_node_destructor& operator=(const __hash_node_destructor&); - -public: - bool __value_constructed; - - _LIBCPP_INLINE_VISIBILITY - explicit __hash_node_destructor(allocator_type& __na, - bool __constructed = false) _NOEXCEPT - : __na_(__na), - __value_constructed(__constructed) - {} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - if (__value_constructed) - __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); - if (__p) - __alloc_traits::deallocate(__na_, __p, 1); - } - - template friend class __hash_map_node_destructor; -}; - -#if _LIBCPP_STD_VER > 14 -template -struct __generic_container_node_destructor; - -template -struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc> - : __hash_node_destructor<_Alloc> -{ - using __hash_node_destructor<_Alloc>::__hash_node_destructor; -}; -#endif - -template -struct __enforce_unordered_container_requirements { -#ifndef _LIBCPP_CXX03_LANG - static_assert(__check_hash_requirements<_Key, _Hash>::value, - "the specified hash does not meet the Hash requirements"); - static_assert(is_copy_constructible<_Equal>::value, - "the specified comparator is required to be copy constructible"); -#endif - typedef int type; -}; - -template -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value, - "the specified comparator type does not provide a const call operator") - _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value, - "the specified hash functor does not provide a const call operator") -#endif -typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type -__diagnose_unordered_container_requirements(int); - -// This dummy overload is used so that the compiler won't emit a spurious -// "no matching function for call to __diagnose_unordered_xxx" diagnostic -// when the overload above causes a hard error. -template -int __diagnose_unordered_container_requirements(void*); - -template -class __hash_table -{ -public: - typedef _Tp value_type; - typedef _Hash hasher; - typedef _Equal key_equal; - typedef _Alloc allocator_type; - -private: - typedef allocator_traits __alloc_traits; - typedef typename - __make_hash_node_types::type - _NodeTypes; -public: - - typedef typename _NodeTypes::__node_value_type __node_value_type; - typedef typename _NodeTypes::__container_value_type __container_value_type; - typedef typename _NodeTypes::key_type key_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; -#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE - typedef typename __alloc_traits::size_type size_type; -#else - typedef typename _NodeTypes::size_type size_type; -#endif - typedef typename _NodeTypes::difference_type difference_type; -public: - // Create __node - - typedef typename _NodeTypes::__node_type __node; - typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; - typedef allocator_traits<__node_allocator> __node_traits; - typedef typename _NodeTypes::__void_pointer __void_pointer; - typedef typename _NodeTypes::__node_pointer __node_pointer; - typedef typename _NodeTypes::__node_pointer __node_const_pointer; - typedef typename _NodeTypes::__node_base_type __first_node; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - -private: - // check for sane allocator pointer rebinding semantics. Rebinding the - // allocator for a new pointer type should be exactly the same as rebinding - // the pointer using 'pointer_traits'. - static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type - __node_base_allocator; - typedef allocator_traits<__node_base_allocator> __node_base_traits; - static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - -private: - - typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator; - typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter; - typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list; - typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits; - typedef typename __bucket_list_deleter::pointer __node_pointer_pointer; - - // --- Member data begin --- - __bucket_list __bucket_list_; - __compressed_pair<__first_node, __node_allocator> __p1_; - __compressed_pair __p2_; - __compressed_pair __p3_; - // --- Member data end --- - - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __p2_.first();} -public: - _LIBCPP_INLINE_VISIBILITY - size_type size() const _NOEXCEPT {return __p2_.first();} - - _LIBCPP_INLINE_VISIBILITY - hasher& hash_function() _NOEXCEPT {return __p2_.second();} - _LIBCPP_INLINE_VISIBILITY - const hasher& hash_function() const _NOEXCEPT {return __p2_.second();} - - _LIBCPP_INLINE_VISIBILITY - float& max_load_factor() _NOEXCEPT {return __p3_.first();} - _LIBCPP_INLINE_VISIBILITY - float max_load_factor() const _NOEXCEPT {return __p3_.first();} - - _LIBCPP_INLINE_VISIBILITY - key_equal& key_eq() _NOEXCEPT {return __p3_.second();} - _LIBCPP_INLINE_VISIBILITY - const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();} - - _LIBCPP_INLINE_VISIBILITY - __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();} - _LIBCPP_INLINE_VISIBILITY - const __node_allocator& __node_alloc() const _NOEXCEPT - {return __p1_.second();} - -public: - typedef __hash_iterator<__node_pointer> iterator; - typedef __hash_const_iterator<__node_pointer> const_iterator; - typedef __hash_local_iterator<__node_pointer> local_iterator; - typedef __hash_const_local_iterator<__node_pointer> const_local_iterator; - - _LIBCPP_INLINE_VISIBILITY - __hash_table() - _NOEXCEPT_( - is_nothrow_default_constructible<__bucket_list>::value && - is_nothrow_default_constructible<__first_node>::value && - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY - __hash_table(const hasher& __hf, const key_equal& __eql); - __hash_table(const hasher& __hf, const key_equal& __eql, - const allocator_type& __a); - explicit __hash_table(const allocator_type& __a); - __hash_table(const __hash_table& __u); - __hash_table(const __hash_table& __u, const allocator_type& __a); -#ifndef _LIBCPP_CXX03_LANG - __hash_table(__hash_table&& __u) - _NOEXCEPT_( - is_nothrow_move_constructible<__bucket_list>::value && - is_nothrow_move_constructible<__first_node>::value && - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - __hash_table(__hash_table&& __u, const allocator_type& __a); -#endif // _LIBCPP_CXX03_LANG - ~__hash_table(); - - __hash_table& operator=(const __hash_table& __u); -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - __hash_table& operator=(__hash_table&& __u) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); -#endif - template - void __assign_unique(_InputIterator __first, _InputIterator __last); - template - void __assign_multi(_InputIterator __first, _InputIterator __last); - - _LIBCPP_INLINE_VISIBILITY - size_type max_size() const _NOEXCEPT - { - return std::min( - __node_traits::max_size(__node_alloc()), - numeric_limits::max() - ); - } - -private: - _LIBCPP_INLINE_VISIBILITY - __next_pointer __node_insert_multi_prepare(size_t __cp_hash, - value_type& __cp_val); - _LIBCPP_INLINE_VISIBILITY - void __node_insert_multi_perform(__node_pointer __cp, - __next_pointer __pn) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY - __next_pointer __node_insert_unique_prepare(size_t __nd_hash, - value_type& __nd_val); - _LIBCPP_INLINE_VISIBILITY - void __node_insert_unique_perform(__node_pointer __ptr) _NOEXCEPT; - -public: - _LIBCPP_INLINE_VISIBILITY - pair __node_insert_unique(__node_pointer __nd); - _LIBCPP_INLINE_VISIBILITY - iterator __node_insert_multi(__node_pointer __nd); - _LIBCPP_INLINE_VISIBILITY - iterator __node_insert_multi(const_iterator __p, - __node_pointer __nd); - -#ifndef _LIBCPP_CXX03_LANG - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const& __k, _Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_impl(_Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Pp&& __x) { - return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { - return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Args&&... __args) { - return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { - return __emplace_unique_impl(_VSTD::forward<_Pp>(__x)); - } - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { - return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x)); - } - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { - return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_multi(_Args&&... __args); - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); - - - _LIBCPP_INLINE_VISIBILITY - pair - __insert_unique(__container_value_type&& __x) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x)); - } - - template ::value - >::type> - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(_Pp&& __x) { - return __emplace_unique(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(_Pp&& __x) { - return __emplace_multi(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, _Pp&& __x) { - return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x)); - } - -#else // !defined(_LIBCPP_CXX03_LANG) - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const&, _Args& __args); - - iterator __insert_multi(const __container_value_type& __x); - iterator __insert_multi(const_iterator __p, const __container_value_type& __x); -#endif - - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(const __container_value_type& __x) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x); - } - -#if _LIBCPP_STD_VER > 14 - template - _LIBCPP_INLINE_VISIBILITY - _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_unique(const_iterator __hint, - _NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - void __node_handle_merge_unique(_Table& __source); - - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(_NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - void __node_handle_merge_multi(_Table& __source); - - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(key_type const& __key); - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(const_iterator __it); -#endif - - void clear() _NOEXCEPT; - void rehash(size_type __n); - _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) - {rehash(static_cast(ceil(__n / max_load_factor())));} - - _LIBCPP_INLINE_VISIBILITY - size_type bucket_count() const _NOEXCEPT - { - return __bucket_list_.get_deleter().size(); - } - - _LIBCPP_INLINE_VISIBILITY - iterator begin() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - iterator end() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - const_iterator end() const _NOEXCEPT; - - template - _LIBCPP_INLINE_VISIBILITY - size_type bucket(const _Key& __k) const - { - _LIBCPP_ASSERT(bucket_count() > 0, - "unordered container::bucket(key) called when bucket_count() == 0"); - return __constrain_hash(hash_function()(__k), bucket_count()); - } - - template - iterator find(const _Key& __x); - template - const_iterator find(const _Key& __x) const; - - typedef __hash_node_destructor<__node_allocator> _Dp; - typedef unique_ptr<__node, _Dp> __node_holder; - - iterator erase(const_iterator __p); - iterator erase(const_iterator __first, const_iterator __last); - template - size_type __erase_unique(const _Key& __k); - template - size_type __erase_multi(const _Key& __k); - __node_holder remove(const_iterator __p) _NOEXCEPT; - - template - _LIBCPP_INLINE_VISIBILITY - size_type __count_unique(const _Key& __k) const; - template - size_type __count_multi(const _Key& __k) const; - - template - pair - __equal_range_unique(const _Key& __k); - template - pair - __equal_range_unique(const _Key& __k) const; - - template - pair - __equal_range_multi(const _Key& __k); - template - pair - __equal_range_multi(const _Key& __k) const; - - void swap(__hash_table& __u) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_DEBUG_( - __is_nothrow_swappable::value && __is_nothrow_swappable::value - && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value - || __is_nothrow_swappable<__pointer_allocator>::value) - && (!__node_traits::propagate_on_container_swap::value - || __is_nothrow_swappable<__node_allocator>::value) - ); -#else - _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && __is_nothrow_swappable::value); -#endif - - _LIBCPP_INLINE_VISIBILITY - size_type max_bucket_count() const _NOEXCEPT - {return max_size(); } - size_type bucket_size(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT - { - size_type __bc = bucket_count(); - return __bc != 0 ? (float)size() / __bc : 0.f; - } - _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT - { - _LIBCPP_ASSERT(__mlf > 0, - "unordered container::max_load_factor(lf) called with lf <= 0"); - max_load_factor() = _VSTD::max(__mlf, load_factor()); - } - - _LIBCPP_INLINE_VISIBILITY - local_iterator - begin(size_type __n) - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::begin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - local_iterator - end(size_type __n) - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::end(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return local_iterator(nullptr, __n, bucket_count(), this); -#else - return local_iterator(nullptr, __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - const_local_iterator - cbegin(size_type __n) const - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::cbegin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - const_local_iterator - cend(size_type __n) const - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::cend(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_local_iterator(nullptr, __n, bucket_count(), this); -#else - return const_local_iterator(nullptr, __n, bucket_count()); -#endif - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - - bool __dereferenceable(const const_iterator* __i) const; - bool __decrementable(const const_iterator* __i) const; - bool __addable(const const_iterator* __i, ptrdiff_t __n) const; - bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - -private: - void __rehash(size_type __n); - -#ifndef _LIBCPP_CXX03_LANG - template - __node_holder __construct_node(_Args&& ...__args); - - template - __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest); -#else // _LIBCPP_CXX03_LANG - __node_holder __construct_node(const __container_value_type& __v); - __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v); -#endif - - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __hash_table& __u) - {__copy_assign_alloc(__u, integral_constant());} - void __copy_assign_alloc(const __hash_table& __u, true_type); - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __hash_table&, false_type) {} - -#ifndef _LIBCPP_CXX03_LANG - void __move_assign(__hash_table& __u, false_type); - void __move_assign(__hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table& __u) - _NOEXCEPT_( - !__node_traits::propagate_on_container_move_assignment::value || - (is_nothrow_move_assignable<__pointer_allocator>::value && - is_nothrow_move_assignable<__node_allocator>::value)) - {__move_assign_alloc(__u, integral_constant());} - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__pointer_allocator>::value && - is_nothrow_move_assignable<__node_allocator>::value) - { - __bucket_list_.get_deleter().__alloc() = - _VSTD::move(__u.__bucket_list_.get_deleter().__alloc()); - __node_alloc() = _VSTD::move(__u.__node_alloc()); - } - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} -#endif // _LIBCPP_CXX03_LANG - - void __deallocate_node(__next_pointer __np) _NOEXCEPT; - __next_pointer __detach() _NOEXCEPT; - - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() - _NOEXCEPT_( - is_nothrow_default_constructible<__bucket_list>::value && - is_nothrow_default_constructible<__first_node>::value && - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value) - : __p2_(0), - __p3_(1.0f) -{ -} - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, - const key_equal& __eql) - : __bucket_list_(nullptr, __bucket_list_deleter()), - __p1_(), - __p2_(0, __hf), - __p3_(1.0f, __eql) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, - const key_equal& __eql, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, __hf), - __p3_(1.0f, __eql) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0), - __p3_(1.0f) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) - : __bucket_list_(nullptr, - __bucket_list_deleter(allocator_traits<__pointer_allocator>:: - select_on_container_copy_construction( - __u.__bucket_list_.get_deleter().__alloc()), 0)), - __p1_(__second_tag(), allocator_traits<__node_allocator>:: - select_on_container_copy_construction(__u.__node_alloc())), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) -{ -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) - _NOEXCEPT_( - is_nothrow_move_constructible<__bucket_list>::value && - is_nothrow_move_constructible<__first_node>::value && - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value) - : __bucket_list_(_VSTD::move(__u.__bucket_list_)), - __p1_(_VSTD::move(__u.__p1_)), - __p2_(_VSTD::move(__u.__p2_)), - __p3_(_VSTD::move(__u.__p3_)) -{ - if (size() > 0) - { - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; - __u.size() = 0; - } -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, _VSTD::move(__u.hash_function())), - __p3_(_VSTD::move(__u.__p3_)) -{ - if (__a == allocator_type(__u.__node_alloc())) - { - __bucket_list_.reset(__u.__bucket_list_.release()); - __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); - __u.__bucket_list_.get_deleter().size() = 0; - if (__u.size() > 0) - { - __p1_.first().__next_ = __u.__p1_.first().__next_; - __u.__p1_.first().__next_ = nullptr; - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - size() = __u.size(); - __u.size() = 0; - } - } -} - -#endif // _LIBCPP_CXX03_LANG - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() -{ -#if defined(_LIBCPP_CXX03_LANG) - static_assert((is_copy_constructible::value), - "Predicate must be copy-constructible."); - static_assert((is_copy_constructible::value), - "Hasher must be copy-constructible."); -#endif - - __deallocate_node(__p1_.first().__next_); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__erase_c(this); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc( - const __hash_table& __u, true_type) -{ - if (__node_alloc() != __u.__node_alloc()) - { - clear(); - __bucket_list_.reset(); - __bucket_list_.get_deleter().size() = 0; - } - __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc(); - __node_alloc() = __u.__node_alloc(); -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>& -__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) -{ - if (this != &__u) - { - __copy_assign_alloc(__u); - hash_function() = __u.hash_function(); - key_eq() = __u.key_eq(); - max_load_factor() = __u.max_load_factor(); - __assign_multi(__u.begin(), __u.end()); - } - return *this; -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) - _NOEXCEPT -{ - __node_allocator& __na = __node_alloc(); - while (__np != nullptr) - { - __next_pointer __next = __np->__next_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - __c_node* __c = __get_db()->__find_c_and_lock(this); - for (__i_node** __p = __c->end_; __p != __c->beg_; ) - { - --__p; - iterator* __i = static_cast((*__p)->__i_); - if (__i->__node_ == __np) - { - (*__p)->__c_ = nullptr; - if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); - } - } - __get_db()->unlock(); -#endif - __node_pointer __real_np = __np->__upcast(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__value_)); - __node_traits::deallocate(__na, __real_np, 1); - __np = __next; - } -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT -{ - size_type __bc = bucket_count(); - for (size_type __i = 0; __i < __bc; ++__i) - __bucket_list_[__i] = nullptr; - size() = 0; - __next_pointer __cache = __p1_.first().__next_; - __p1_.first().__next_ = nullptr; - return __cache; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( - __hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value) -{ - clear(); - __bucket_list_.reset(__u.__bucket_list_.release()); - __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); - __u.__bucket_list_.get_deleter().size() = 0; - __move_assign_alloc(__u); - size() = __u.size(); - hash_function() = _VSTD::move(__u.hash_function()); - max_load_factor() = __u.max_load_factor(); - key_eq() = _VSTD::move(__u.key_eq()); - __p1_.first().__next_ = __u.__p1_.first().__next_; - if (size() > 0) - { - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; - __u.size() = 0; - } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->swap(this, &__u); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( - __hash_table& __u, false_type) -{ - if (__node_alloc() == __u.__node_alloc()) - __move_assign(__u, true_type()); - else - { - hash_function() = _VSTD::move(__u.hash_function()); - key_eq() = _VSTD::move(__u.key_eq()); - max_load_factor() = __u.max_load_factor(); - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - const_iterator __i = __u.begin(); - while (__cache != nullptr && __u.size() != 0) - { - __cache->__upcast()->__value_ = - _VSTD::move(__u.remove(__i++)->__value_); - __next_pointer __next = __cache->__next_; - __node_insert_multi(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - const_iterator __i = __u.begin(); - while (__u.size() != 0) - { - __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_)); - __node_insert_multi(__h.get()); - __h.release(); - } - } -} - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>& -__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value) -{ - __move_assign(__u, integral_constant()); - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, - _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value), - "__assign_unique may only be called with the containers value type"); - - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__upcast()->__value_ = *__first; - __next_pointer __next = __cache->__next_; - __node_insert_unique(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - for (; __first != __last; ++__first) - __insert_unique(*__first); -} - -template -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, - _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value || - is_same<_ItValueType, __node_value_type>::value), - "__assign_multi may only be called with the containers value type" - " or the nodes value type"); - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__upcast()->__value_ = *__first; - __next_pointer __next = __cache->__next_; - __node_insert_multi(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - for (; __first != __last; ++__first) - __insert_multi(_NodeTypes::__get_value(*__first)); -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__p1_.first().__next_, this); -#else - return iterator(__p1_.first().__next_); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(nullptr, this); -#else - return iterator(nullptr); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(__p1_.first().__next_, this); -#else - return const_iterator(__p1_.first().__next_); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(nullptr, this); -#else - return const_iterator(nullptr); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT -{ - if (size() > 0) - { - __deallocate_node(__p1_.first().__next_); - __p1_.first().__next_ = nullptr; - size_type __bc = bucket_count(); - for (size_type __i = 0; __i < __bc; ++__i) - __bucket_list_[__i] = nullptr; - size() = 0; - } -} - - -// Prepare the container for an insertion of the value __value with the hash -// __hash. This does a lookup into the container to see if __value is already -// present, and performs a rehash if necessary. Returns a pointer to the -// existing element if it exists, otherwise nullptr. -// -// Note that this function does forward exceptions if key_eq() throws, and never -// mutates __value or actually inserts into the map. -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare( - size_t __hash, value_type& __value) -{ - size_type __bc = bucket_count(); - - if (__bc != 0) - { - size_t __chash = __constrain_hash(__hash, __bc); - __next_pointer __ndptr = __bucket_list_[__chash]; - if (__ndptr != nullptr) - { - for (__ndptr = __ndptr->__next_; __ndptr != nullptr && - __constrain_hash(__ndptr->__hash(), __bc) == __chash; - __ndptr = __ndptr->__next_) - { - if (key_eq()(__ndptr->__upcast()->__value_, __value)) - return __ndptr; - } - } - } - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - } - return nullptr; -} - -// Insert the node __nd into the container by pushing it into the right bucket, -// and updating size(). Assumes that __nd->__hash is up-to-date, and that -// rehashing has already occurred and that no element with the same key exists -// in the map. -template -_LIBCPP_INLINE_VISIBILITY -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform( - __node_pointer __nd) _NOEXCEPT -{ - size_type __bc = bucket_count(); - size_t __chash = __constrain_hash(__nd->__hash(), __bc); - // insert_after __bucket_list_[__chash], or __first_node if bucket is null - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn == nullptr) - { - __pn =__p1_.first().__ptr(); - __nd->__next_ = __pn->__next_; - __pn->__next_ = __nd->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__nd->__next_ != nullptr) - __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr(); - } - else - { - __nd->__next_ = __pn->__next_; - __pn->__next_ = __nd->__ptr(); - } - ++size(); -} - -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd) -{ - __nd->__hash_ = hash_function()(__nd->__value_); - __next_pointer __existing_node = - __node_insert_unique_prepare(__nd->__hash(), __nd->__value_); - - // Insert the node, unless it already exists in the container. - bool __inserted = false; - if (__existing_node == nullptr) - { - __node_insert_unique_perform(__nd); - __existing_node = __nd->__ptr(); - __inserted = true; - } -#if _LIBCPP_DEBUG_LEVEL >= 2 - return pair(iterator(__existing_node, this), __inserted); -#else - return pair(iterator(__existing_node), __inserted); -#endif -} - -// Prepare the container for an insertion of the value __cp_val with the hash -// __cp_hash. This does a lookup into the container to see if __cp_value is -// already present, and performs a rehash if necessary. Returns a pointer to the -// last occurance of __cp_val in the map. -// -// Note that this function does forward exceptions if key_eq() throws, and never -// mutates __value or actually inserts into the map. -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare( - size_t __cp_hash, value_type& __cp_val) -{ - size_type __bc = bucket_count(); - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - } - size_t __chash = __constrain_hash(__cp_hash, __bc); - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn != nullptr) - { - for (bool __found = false; __pn->__next_ != nullptr && - __constrain_hash(__pn->__next_->__hash(), __bc) == __chash; - __pn = __pn->__next_) - { - // __found key_eq() action - // false false loop - // true true loop - // false true set __found to true - // true false break - if (__found != (__pn->__next_->__hash() == __cp_hash && - key_eq()(__pn->__next_->__upcast()->__value_, __cp_val))) - { - if (!__found) - __found = true; - else - break; - } - } - } - return __pn; -} - -// Insert the node __cp into the container after __pn (which is the last node in -// the bucket that compares equal to __cp). Rehashing, and checking for -// uniqueness has already been performed (in __node_insert_multi_prepare), so -// all we need to do is update the bucket and size(). Assumes that __cp->__hash -// is up-to-date. -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform( - __node_pointer __cp, __next_pointer __pn) _NOEXCEPT -{ - size_type __bc = bucket_count(); - size_t __chash = __constrain_hash(__cp->__hash_, __bc); - if (__pn == nullptr) - { - __pn =__p1_.first().__ptr(); - __cp->__next_ = __pn->__next_; - __pn->__next_ = __cp->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__cp->__next_ != nullptr) - __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)] - = __cp->__ptr(); - } - else - { - __cp->__next_ = __pn->__next_; - __pn->__next_ = __cp->__ptr(); - if (__cp->__next_ != nullptr) - { - size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc); - if (__nhash != __chash) - __bucket_list_[__nhash] = __cp->__ptr(); - } - } - ++size(); -} - - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp) -{ - __cp->__hash_ = hash_function()(__cp->__value_); - __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_); - __node_insert_multi_perform(__cp, __pn); - -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__cp->__ptr(), this); -#else - return iterator(__cp->__ptr()); -#endif -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( - const_iterator __p, __node_pointer __cp) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); -#endif - if (__p != end() && key_eq()(*__p, __cp->__value_)) - { - __next_pointer __np = __p.__node_; - __cp->__hash_ = __np->__hash(); - size_type __bc = bucket_count(); - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - } - size_t __chash = __constrain_hash(__cp->__hash_, __bc); - __next_pointer __pp = __bucket_list_[__chash]; - while (__pp->__next_ != __np) - __pp = __pp->__next_; - __cp->__next_ = __np; - __pp->__next_ = static_cast<__next_pointer>(__cp); - ++size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(static_cast<__next_pointer>(__cp), this); -#else - return iterator(static_cast<__next_pointer>(__cp)); -#endif - } - return __node_insert_multi(__cp); -} - - - -#ifndef _LIBCPP_CXX03_LANG -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) -#else -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args) -#endif -{ - - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - bool __inserted = false; - __next_pointer __nd; - size_t __chash; - if (__bc != 0) - { - __chash = __constrain_hash(__hash, __bc); - __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__nd->__hash() == __hash || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if (key_eq()(__nd->__upcast()->__value_, __k)) - goto __done; - } - } - } - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node_hash(__hash, __args); -#endif - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - __chash = __constrain_hash(__hash, __bc); - } - // insert_after __bucket_list_[__chash], or __first_node if bucket is null - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn == nullptr) - { - __pn = __p1_.first().__ptr(); - __h->__next_ = __pn->__next_; - __pn->__next_ = __h.get()->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__h->__next_ != nullptr) - __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)] - = __h.get()->__ptr(); - } - else - { - __h->__next_ = __pn->__next_; - __pn->__next_ = static_cast<__next_pointer>(__h.get()); - } - __nd = static_cast<__next_pointer>(__h.release()); - // increment size - ++size(); - __inserted = true; - } -__done: -#if _LIBCPP_DEBUG_LEVEL >= 2 - return pair(iterator(__nd, this), __inserted); -#else - return pair(iterator(__nd), __inserted); -#endif -} - -#ifndef _LIBCPP_CXX03_LANG - -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - pair __r = __node_insert_unique(__h.get()); - if (__r.second) - __h.release(); - return __r; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - iterator __r = __node_insert_multi(__h.get()); - __h.release(); - return __r; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( - const_iterator __p, _Args&&... __args) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); -#endif - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - iterator __r = __node_insert_multi(__p, __h.get()); - __h.release(); - return __r; -} - -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x) -{ - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__h.get()); - __h.release(); - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, - const __container_value_type& __x) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::insert(const_iterator, lvalue) called with an iterator not" - " referring to this unordered container"); -#endif - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__p, __h.get()); - __h.release(); - return __r; -} - -#endif // _LIBCPP_CXX03_LANG - -#if _LIBCPP_STD_VER > 14 -template -template -_LIBCPP_INLINE_VISIBILITY -_InsertReturnType -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return _InsertReturnType{end(), false, _NodeHandle()}; - pair __result = __node_insert_unique(__nh.__ptr_); - if (__result.second) - __nh.__release(); - return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)}; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique( - const_iterator, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - pair __result = __node_insert_unique(__nh.__ptr_); - if (__result.second) - __nh.__release(); - return __result.first; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract( - key_type const& __key) -{ - iterator __i = find(__key); - if (__i == end()) - return _NodeHandle(); - return __node_handle_extract<_NodeHandle>(__i); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract( - const_iterator __p) -{ - allocator_type __alloc(__node_alloc()); - return _NodeHandle(remove(__p).release(), __alloc); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_unique( - _Table& __source) -{ - static_assert(is_same<__node, typename _Table::__node>::value, ""); - - for (typename _Table::iterator __it = __source.begin(); - __it != __source.end();) - { - __node_pointer __src_ptr = __it.__node_->__upcast(); - size_t __hash = hash_function()(__src_ptr->__value_); - __next_pointer __existing_node = - __node_insert_unique_prepare(__hash, __src_ptr->__value_); - auto __prev_iter = __it++; - if (__existing_node == nullptr) - { - (void)__source.remove(__prev_iter).release(); - __src_ptr->__hash_ = __hash; - __node_insert_unique_perform(__src_ptr); - } - } -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - iterator __result = __node_insert_multi(__nh.__ptr_); - __nh.__release(); - return __result; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - iterator __result = __node_insert_multi(__hint, __nh.__ptr_); - __nh.__release(); - return __result; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi( - _Table& __source) -{ - static_assert(is_same::value, ""); - - for (typename _Table::iterator __it = __source.begin(); - __it != __source.end();) - { - __node_pointer __src_ptr = __it.__node_->__upcast(); - size_t __src_hash = hash_function()(__src_ptr->__value_); - __next_pointer __pn = - __node_insert_multi_prepare(__src_hash, __src_ptr->__value_); - (void)__source.remove(__it++).release(); - __src_ptr->__hash_ = __src_hash; - __node_insert_multi_perform(__src_ptr, __pn); - } -} -#endif // _LIBCPP_STD_VER > 14 - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) -_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -{ - if (__n == 1) - __n = 2; - else if (__n & (__n - 1)) - __n = __next_prime(__n); - size_type __bc = bucket_count(); - if (__n > __bc) - __rehash(__n); - else if (__n < __bc) - { - __n = _VSTD::max - ( - __n, - __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) : - __next_prime(size_t(ceil(float(size()) / max_load_factor()))) - ); - if (__n < __bc) - __rehash(__n); - } -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__invalidate_all(this); -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); - __bucket_list_.reset(__nbc > 0 ? - __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); - __bucket_list_.get_deleter().size() = __nbc; - if (__nbc > 0) - { - for (size_type __i = 0; __i < __nbc; ++__i) - __bucket_list_[__i] = nullptr; - __next_pointer __pp = __p1_.first().__ptr(); - __next_pointer __cp = __pp->__next_; - if (__cp != nullptr) - { - size_type __chash = __constrain_hash(__cp->__hash(), __nbc); - __bucket_list_[__chash] = __pp; - size_type __phash = __chash; - for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr; - __cp = __pp->__next_) - { - __chash = __constrain_hash(__cp->__hash(), __nbc); - if (__chash == __phash) - __pp = __cp; - else - { - if (__bucket_list_[__chash] == nullptr) - { - __bucket_list_[__chash] = __pp; - __pp = __cp; - __phash = __chash; - } - else - { - __next_pointer __np = __cp; - for (; __np->__next_ != nullptr && - key_eq()(__cp->__upcast()->__value_, - __np->__next_->__upcast()->__value_); - __np = __np->__next_) - ; - __pp->__next_ = __np->__next_; - __np->__next_ = __bucket_list_[__chash]->__next_; - __bucket_list_[__chash]->__next_ = __cp; - - } - } - } - } - } -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) -{ - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - if (__bc != 0) - { - size_t __chash = __constrain_hash(__hash, __bc); - __next_pointer __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__nd->__hash() == __hash - || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__nd, this); -#else - return iterator(__nd); -#endif - } - } - } - return end(); -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const -{ - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - if (__bc != 0) - { - size_t __chash = __constrain_hash(__hash, __bc); - __next_pointer __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__hash == __nd->__hash() - || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(__nd, this); -#else - return const_iterator(__nd); -#endif - } - } - - } - return end(); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args) -{ - static_assert(!__is_hash_value_type<_Args...>::value, - "Construct cannot be called with a hash value type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; - return __h; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash( - size_t __hash, _First&& __f, _Rest&& ...__rest) -{ - static_assert(!__is_hash_value_type<_First, _Rest...>::value, - "Construct cannot be called with a hash value type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), - _VSTD::forward<_First>(__f), - _VSTD::forward<_Rest>(__rest)...); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; - return __h; -} - -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, - const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -#endif // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) -{ - __next_pointer __np = __p.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container erase(iterator) called with an iterator not" - " referring to this container"); - _LIBCPP_ASSERT(__p != end(), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - iterator __r(__np, this); -#else - iterator __r(__np); -#endif - ++__r; - remove(__p); - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, - const_iterator __last) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); -#endif - for (const_iterator __p = __first; __first != __last; __p = __first) - { - ++__first; - erase(__p); - } - __next_pointer __np = __last.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator (__np, this); -#else - return iterator (__np); -#endif -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k) -{ - iterator __i = find(__k); - if (__i == end()) - return 0; - erase(__i); - return 1; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k) -{ - size_type __r = 0; - iterator __i = find(__k); - if (__i != end()) - { - iterator __e = end(); - do - { - erase(__i++); - ++__r; - } while (__i != __e && key_eq()(*__i, __k)); - } - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT -{ - // current node - __next_pointer __cn = __p.__node_; - size_type __bc = bucket_count(); - size_t __chash = __constrain_hash(__cn->__hash(), __bc); - // find previous node - __next_pointer __pn = __bucket_list_[__chash]; - for (; __pn->__next_ != __cn; __pn = __pn->__next_) - ; - // Fix up __bucket_list_ - // if __pn is not in same bucket (before begin is not in same bucket) && - // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) - if (__pn == __p1_.first().__ptr() - || __constrain_hash(__pn->__hash(), __bc) != __chash) - { - if (__cn->__next_ == nullptr - || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash) - __bucket_list_[__chash] = nullptr; - } - // if __cn->__next_ is not in same bucket (nullptr is in same bucket) - if (__cn->__next_ != nullptr) - { - size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc); - if (__nhash != __chash) - __bucket_list_[__nhash] = __pn; - } - // remove __cn - __pn->__next_ = __cn->__next_; - __cn->__next_ = nullptr; - --size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __c_node* __c = __get_db()->__find_c_and_lock(this); - for (__i_node** __dp = __c->end_; __dp != __c->beg_; ) - { - --__dp; - iterator* __i = static_cast((*__dp)->__i_); - if (__i->__node_ == __cn) - { - (*__dp)->__c_ = nullptr; - if (--__c->end_ != __dp) - memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); - } - } - __get_db()->unlock(); -#endif - return __node_holder(__cn->__upcast(), _Dp(__node_alloc(), true)); -} - -template -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const -{ - return static_cast(find(__k) != end()); -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const -{ - size_type __r = 0; - const_iterator __i = find(__k); - if (__i != end()) - { - const_iterator __e = end(); - do - { - ++__i; - ++__r; - } while (__i != __e && key_eq()(*__i, __k)); - } - return __r; -} - -template -template -pair::iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( - const _Key& __k) -{ - iterator __i = find(__k); - iterator __j = __i; - if (__i != end()) - ++__j; - return pair(__i, __j); -} - -template -template -pair::const_iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( - const _Key& __k) const -{ - const_iterator __i = find(__k); - const_iterator __j = __i; - if (__i != end()) - ++__j; - return pair(__i, __j); -} - -template -template -pair::iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( - const _Key& __k) -{ - iterator __i = find(__k); - iterator __j = __i; - if (__i != end()) - { - iterator __e = end(); - do - { - ++__j; - } while (__j != __e && key_eq()(*__j, __k)); - } - return pair(__i, __j); -} - -template -template -pair::const_iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( - const _Key& __k) const -{ - const_iterator __i = find(__k); - const_iterator __j = __i; - if (__i != end()) - { - const_iterator __e = end(); - do - { - ++__j; - } while (__j != __e && key_eq()(*__j, __k)); - } - return pair(__i, __j); -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_DEBUG_( - __is_nothrow_swappable::value && __is_nothrow_swappable::value - && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value - || __is_nothrow_swappable<__pointer_allocator>::value) - && (!__node_traits::propagate_on_container_swap::value - || __is_nothrow_swappable<__node_allocator>::value) - ) -#else - _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) -#endif -{ - _LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value || - this->__node_alloc() == __u.__node_alloc(), - "list::swap: Either propagate_on_container_swap must be true" - " or the allocators must compare equal"); - { - __node_pointer_pointer __npp = __bucket_list_.release(); - __bucket_list_.reset(__u.__bucket_list_.release()); - __u.__bucket_list_.reset(__npp); - } - _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); - __swap_allocator(__bucket_list_.get_deleter().__alloc(), - __u.__bucket_list_.get_deleter().__alloc()); - __swap_allocator(__node_alloc(), __u.__node_alloc()); - _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_); - __p2_.swap(__u.__p2_); - __p3_.swap(__u.__p3_); - if (size() > 0) - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - if (__u.size() > 0) - __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = - __u.__p1_.first().__ptr(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->swap(this, &__u); -#endif -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const -{ - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::bucket_size(n) called with n >= bucket_count()"); - __next_pointer __np = __bucket_list_[__n]; - size_type __bc = bucket_count(); - size_type __r = 0; - if (__np != nullptr) - { - for (__np = __np->__next_; __np != nullptr && - __constrain_hash(__np->__hash(), __bc) == __n; - __np = __np->__next_, ++__r) - ; - } - return __r; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, - __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -#if _LIBCPP_DEBUG_LEVEL >= 2 - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const -{ - return __i->__node_ != nullptr; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const -{ - return false; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const -{ - return false; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const -{ - return false; -} - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP__HASH_TABLE diff --git a/clang-r353983c/include/c++/v1/__libcpp_version b/clang-r353983c/include/c++/v1/__libcpp_version deleted file mode 100644 index d58c55a31dc70845d945049f7405c6d9307f9c8b..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__libcpp_version +++ /dev/null @@ -1 +0,0 @@ -9000 diff --git a/clang-r353983c/include/c++/v1/__locale b/clang-r353983c/include/c++/v1/__locale deleted file mode 100644 index d1d66f94d0d757c27ec9d4d8dfa5ffaf15f4da32..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__locale +++ /dev/null @@ -1,1522 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___LOCALE -#define _LIBCPP___LOCALE - -#include <__config> -#include -#include -#include -#include -#include -#include -#include -#if defined(_LIBCPP_MSVCRT_LIKE) -# include -#elif defined(_AIX) -# include -#elif defined(__ANDROID__) -# include -#elif defined(__sun__) -# include -# include -#elif defined(_NEWLIB_VERSION) -# include -#elif (defined(__APPLE__) || defined(__FreeBSD__) \ - || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) -# include -#elif defined(__Fuchsia__) -# include -#elif defined(_LIBCPP_HAS_MUSL_LIBC) -# include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS) -struct __libcpp_locale_guard { - _LIBCPP_INLINE_VISIBILITY - __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {} - - _LIBCPP_INLINE_VISIBILITY - ~__libcpp_locale_guard() { - if (__old_loc_) - uselocale(__old_loc_); - } - - locale_t __old_loc_; -private: - __libcpp_locale_guard(__libcpp_locale_guard const&); - __libcpp_locale_guard& operator=(__libcpp_locale_guard const&); -}; -#elif defined(_LIBCPP_MSVCRT_LIKE) -struct __libcpp_locale_guard { - __libcpp_locale_guard(locale_t __l) : - __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)), - __locale_collate(setlocale(LC_COLLATE, __l.__get_locale())), - __locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())), - __locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())), - __locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())), - __locale_time(setlocale(LC_TIME, __l.__get_locale())) - // LC_MESSAGES is not supported on Windows. - {} - ~__libcpp_locale_guard() { - setlocale(LC_COLLATE, __locale_collate); - setlocale(LC_CTYPE, __locale_ctype); - setlocale(LC_MONETARY, __locale_monetary); - setlocale(LC_NUMERIC, __locale_numeric); - setlocale(LC_TIME, __locale_time); - _configthreadlocale(__status); - } - int __status; - char* __locale_collate; - char* __locale_ctype; - char* __locale_monetary; - char* __locale_numeric; - char* __locale_time; -}; -#endif - - -class _LIBCPP_TYPE_VIS locale; - -template -_LIBCPP_INLINE_VISIBILITY -bool -has_facet(const locale&) _NOEXCEPT; - -template -_LIBCPP_INLINE_VISIBILITY -const _Facet& -use_facet(const locale&); - -class _LIBCPP_TYPE_VIS locale -{ -public: - // types: - class _LIBCPP_TYPE_VIS facet; - class _LIBCPP_TYPE_VIS id; - - typedef int category; - _LIBCPP_AVAILABILITY_LOCALE_CATEGORY - static const category // values assigned here are for exposition only - none = 0, - collate = LC_COLLATE_MASK, - ctype = LC_CTYPE_MASK, - monetary = LC_MONETARY_MASK, - numeric = LC_NUMERIC_MASK, - time = LC_TIME_MASK, - messages = LC_MESSAGES_MASK, - all = collate | ctype | monetary | numeric | time | messages; - - // construct/copy/destroy: - locale() _NOEXCEPT; - locale(const locale&) _NOEXCEPT; - explicit locale(const char*); - explicit locale(const string&); - locale(const locale&, const char*, category); - locale(const locale&, const string&, category); - template - _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*); - locale(const locale&, const locale&, category); - - ~locale(); - - const locale& operator=(const locale&) _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - locale combine(const locale&) const; - - // locale operations: - string name() const; - bool operator==(const locale&) const; - bool operator!=(const locale& __y) const {return !(*this == __y);} - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, - const basic_string<_CharT, _Traits, _Allocator>&) const; - - // global locale objects: - static locale global(const locale&); - static const locale& classic(); - -private: - class __imp; - __imp* __locale_; - - void __install_ctor(const locale&, facet*, long); - static locale& __global(); - bool has_facet(id&) const; - const facet* use_facet(id&) const; - - template friend bool has_facet(const locale&) _NOEXCEPT; - template friend const _Facet& use_facet(const locale&); -}; - -class _LIBCPP_TYPE_VIS locale::facet - : public __shared_count -{ -protected: - _LIBCPP_INLINE_VISIBILITY - explicit facet(size_t __refs = 0) - : __shared_count(static_cast(__refs)-1) {} - - virtual ~facet(); - -// facet(const facet&) = delete; // effectively done in __shared_count -// void operator=(const facet&) = delete; -private: - virtual void __on_zero_shared() _NOEXCEPT; -}; - -class _LIBCPP_TYPE_VIS locale::id -{ - once_flag __flag_; - int32_t __id_; - - static int32_t __next_id; -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} -private: - void __init(); - void operator=(const id&); // = delete; - id(const id&); // = delete; -public: // only needed for tests - long __get(); - - friend class locale; - friend class locale::__imp; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -locale::locale(const locale& __other, _Facet* __f) -{ - __install_ctor(__other, __f, __f ? __f->id.__get() : 0); -} - -template -locale -locale::combine(const locale& __other) const -{ - if (!_VSTD::has_facet<_Facet>(__other)) - __throw_runtime_error("locale::combine: locale missing facet"); - - return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -has_facet(const locale& __l) _NOEXCEPT -{ - return __l.has_facet(_Facet::id); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -const _Facet& -use_facet(const locale& __l) -{ - return static_cast(*__l.use_facet(_Facet::id)); -} - -// template class collate; - -template -class _LIBCPP_TEMPLATE_VIS collate - : public locale::facet -{ -public: - typedef _CharT char_type; - typedef basic_string string_type; - - _LIBCPP_INLINE_VISIBILITY - explicit collate(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - int compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const - { - return do_compare(__lo1, __hi1, __lo2, __hi2); - } - - _LIBCPP_INLINE_VISIBILITY - string_type transform(const char_type* __lo, const char_type* __hi) const - { - return do_transform(__lo, __hi); - } - - _LIBCPP_INLINE_VISIBILITY - long hash(const char_type* __lo, const char_type* __hi) const - { - return do_hash(__lo, __hi); - } - - static locale::id id; - -protected: - ~collate(); - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const - {return string_type(__lo, __hi);} - virtual long do_hash(const char_type* __lo, const char_type* __hi) const; -}; - -template locale::id collate<_CharT>::id; - -template -collate<_CharT>::~collate() -{ -} - -template -int -collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const -{ - for (; __lo2 != __hi2; ++__lo1, ++__lo2) - { - if (__lo1 == __hi1 || *__lo1 < *__lo2) - return -1; - if (*__lo2 < *__lo1) - return 1; - } - return __lo1 != __hi1; -} - -template -long -collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const -{ - size_t __h = 0; - const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; - const size_t __mask = size_t(0xF) << (__sr + 4); - for(const char_type* __p = __lo; __p != __hi; ++__p) - { - __h = (__h << 4) + static_cast(*__p); - size_t __g = __h & __mask; - __h ^= __g | (__g >> __sr); - } - return static_cast(__h); -} - -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) - -// template class collate_byname; - -template class _LIBCPP_TEMPLATE_VIS collate_byname; - -template <> -class _LIBCPP_TYPE_VIS collate_byname - : public collate -{ - locale_t __l; -public: - typedef char char_type; - typedef basic_string string_type; - - explicit collate_byname(const char* __n, size_t __refs = 0); - explicit collate_byname(const string& __n, size_t __refs = 0); - -protected: - ~collate_byname(); - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; -}; - -template <> -class _LIBCPP_TYPE_VIS collate_byname - : public collate -{ - locale_t __l; -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit collate_byname(const char* __n, size_t __refs = 0); - explicit collate_byname(const string& __n, size_t __refs = 0); - -protected: - ~collate_byname(); - - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; -}; - -template -bool -locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, - const basic_string<_CharT, _Traits, _Allocator>& __y) const -{ - return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare( - __x.data(), __x.data() + __x.size(), - __y.data(), __y.data() + __y.size()) < 0; -} - -// template class ctype - -class _LIBCPP_TYPE_VIS ctype_base -{ -public: -#if defined(__GLIBC__) - typedef unsigned short mask; - static const mask space = _ISspace; - static const mask print = _ISprint; - static const mask cntrl = _IScntrl; - static const mask upper = _ISupper; - static const mask lower = _ISlower; - static const mask alpha = _ISalpha; - static const mask digit = _ISdigit; - static const mask punct = _ISpunct; - static const mask xdigit = _ISxdigit; - static const mask blank = _ISblank; -#elif defined(_LIBCPP_MSVCRT_LIKE) - typedef unsigned short mask; - static const mask space = _SPACE; - static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; - static const mask cntrl = _CONTROL; - static const mask upper = _UPPER; - static const mask lower = _LOWER; - static const mask alpha = _ALPHA; - static const mask digit = _DIGIT; - static const mask punct = _PUNCT; - static const mask xdigit = _HEX; - static const mask blank = _BLANK; -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT -#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) -# ifdef __APPLE__ - typedef __uint32_t mask; -# elif defined(__FreeBSD__) - typedef unsigned long mask; -# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) - typedef unsigned short mask; -# endif - static const mask space = _CTYPE_S; - static const mask print = _CTYPE_R; - static const mask cntrl = _CTYPE_C; - static const mask upper = _CTYPE_U; - static const mask lower = _CTYPE_L; - static const mask alpha = _CTYPE_A; - static const mask digit = _CTYPE_D; - static const mask punct = _CTYPE_P; - static const mask xdigit = _CTYPE_X; - -# if defined(__NetBSD__) - static const mask blank = _CTYPE_BL; -# else - static const mask blank = _CTYPE_B; -# endif -#elif defined(__sun__) || defined(_AIX) - typedef unsigned int mask; - static const mask space = _ISSPACE; - static const mask print = _ISPRINT; - static const mask cntrl = _ISCNTRL; - static const mask upper = _ISUPPER; - static const mask lower = _ISLOWER; - static const mask alpha = _ISALPHA; - static const mask digit = _ISDIGIT; - static const mask punct = _ISPUNCT; - static const mask xdigit = _ISXDIGIT; - static const mask blank = _ISBLANK; -#elif defined(_NEWLIB_VERSION) - // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. - typedef char mask; - static const mask space = _S; - static const mask print = _P | _U | _L | _N | _B; - static const mask cntrl = _C; - static const mask upper = _U; - static const mask lower = _L; - static const mask alpha = _U | _L; - static const mask digit = _N; - static const mask punct = _P; - static const mask xdigit = _X | _N; - static const mask blank = _B; -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT -#else - typedef unsigned long mask; - static const mask space = 1<<0; - static const mask print = 1<<1; - static const mask cntrl = 1<<2; - static const mask upper = 1<<3; - static const mask lower = 1<<4; - static const mask alpha = 1<<5; - static const mask digit = 1<<6; - static const mask punct = 1<<7; - static const mask xdigit = 1<<8; - static const mask blank = 1<<9; -#endif - static const mask alnum = alpha | digit; - static const mask graph = alnum | punct; - - _LIBCPP_INLINE_VISIBILITY ctype_base() {} -}; - -template class _LIBCPP_TEMPLATE_VIS ctype; - -template <> -class _LIBCPP_TYPE_VIS ctype - : public locale::facet, - public ctype_base -{ -public: - typedef wchar_t char_type; - - _LIBCPP_INLINE_VISIBILITY - explicit ctype(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - bool is(mask __m, char_type __c) const - { - return do_is(__m, __c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const - { - return do_is(__low, __high, __vec); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const - { - return do_scan_is(__m, __low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const - { - return do_scan_not(__m, __low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type toupper(char_type __c) const - { - return do_toupper(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* toupper(char_type* __low, const char_type* __high) const - { - return do_toupper(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type tolower(char_type __c) const - { - return do_tolower(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* tolower(char_type* __low, const char_type* __high) const - { - return do_tolower(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type widen(char __c) const - { - return do_widen(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char* widen(const char* __low, const char* __high, char_type* __to) const - { - return do_widen(__low, __high, __to); - } - - _LIBCPP_INLINE_VISIBILITY - char narrow(char_type __c, char __dfault) const - { - return do_narrow(__c, __dfault); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const - { - return do_narrow(__low, __high, __dfault, __to); - } - - static locale::id id; - -protected: - ~ctype(); - virtual bool do_is(mask __m, char_type __c) const; - virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; - virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; - virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; - virtual char do_narrow(char_type, char __dfault) const; - virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; -}; - -template <> -class _LIBCPP_TYPE_VIS ctype - : public locale::facet, public ctype_base -{ - const mask* __tab_; - bool __del_; -public: - typedef char char_type; - - explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY - bool is(mask __m, char_type __c) const - { - return isascii(__c) ? (__tab_[static_cast(__c)] & __m) !=0 : false; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const - { - for (; __low != __high; ++__low, ++__vec) - *__vec = isascii(*__low) ? __tab_[static_cast(*__low)] : 0; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const - { - for (; __low != __high; ++__low) - if (isascii(*__low) && (__tab_[static_cast(*__low)] & __m)) - break; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const - { - for (; __low != __high; ++__low) - if (!(isascii(*__low) && (__tab_[static_cast(*__low)] & __m))) - break; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - char_type toupper(char_type __c) const - { - return do_toupper(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* toupper(char_type* __low, const char_type* __high) const - { - return do_toupper(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type tolower(char_type __c) const - { - return do_tolower(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* tolower(char_type* __low, const char_type* __high) const - { - return do_tolower(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type widen(char __c) const - { - return do_widen(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char* widen(const char* __low, const char* __high, char_type* __to) const - { - return do_widen(__low, __high, __to); - } - - _LIBCPP_INLINE_VISIBILITY - char narrow(char_type __c, char __dfault) const - { - return do_narrow(__c, __dfault); - } - - _LIBCPP_INLINE_VISIBILITY - const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const - { - return do_narrow(__low, __high, __dfault, __to); - } - - static locale::id id; - -#ifdef _CACHED_RUNES - static const size_t table_size = _CACHED_RUNES; -#else - static const size_t table_size = 256; // FIXME: Don't hardcode this. -#endif - _LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;} - static const mask* classic_table() _NOEXCEPT; -#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) - static const int* __classic_upper_table() _NOEXCEPT; - static const int* __classic_lower_table() _NOEXCEPT; -#endif -#if defined(__NetBSD__) - static const short* __classic_upper_table() _NOEXCEPT; - static const short* __classic_lower_table() _NOEXCEPT; -#endif - -protected: - ~ctype(); - virtual char_type do_toupper(char_type __c) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type __c) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char __c) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const; - virtual char do_narrow(char_type __c, char __dfault) const; - virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const; -}; - -// template class ctype_byname; - -template class _LIBCPP_TEMPLATE_VIS ctype_byname; - -template <> -class _LIBCPP_TYPE_VIS ctype_byname - : public ctype -{ - locale_t __l; - -public: - explicit ctype_byname(const char*, size_t = 0); - explicit ctype_byname(const string&, size_t = 0); - -protected: - ~ctype_byname(); - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; -}; - -template <> -class _LIBCPP_TYPE_VIS ctype_byname - : public ctype -{ - locale_t __l; - -public: - explicit ctype_byname(const char*, size_t = 0); - explicit ctype_byname(const string&, size_t = 0); - -protected: - ~ctype_byname(); - virtual bool do_is(mask __m, char_type __c) const; - virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; - virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; - virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; - virtual char do_narrow(char_type, char __dfault) const; - virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isspace(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::space, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isprint(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::print, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -iscntrl(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::cntrl, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isupper(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::upper, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -islower(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::lower, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isalpha(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::alpha, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isdigit(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::digit, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -ispunct(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::punct, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isxdigit(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::xdigit, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isalnum(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::alnum, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isgraph(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::graph, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_CharT -toupper(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).toupper(__c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_CharT -tolower(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).tolower(__c); -} - -// codecvt_base - -class _LIBCPP_TYPE_VIS codecvt_base -{ -public: - _LIBCPP_INLINE_VISIBILITY codecvt_base() {} - enum result {ok, partial, error, noconv}; -}; - -// template class codecvt; - -template class _LIBCPP_TEMPLATE_VIS codecvt; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ - locale_t __l; -public: - typedef wchar_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - explicit codecvt(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - explicit codecvt(const char*, size_t __refs = 0); - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char16_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char32_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template class codecvt_byname - -template -class _LIBCPP_TEMPLATE_VIS codecvt_byname - : public codecvt<_InternT, _ExternT, _StateT> -{ -public: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt_byname(const char* __nm, size_t __refs = 0) - : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} - _LIBCPP_INLINE_VISIBILITY - explicit codecvt_byname(const string& __nm, size_t __refs = 0) - : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {} -protected: - ~codecvt_byname(); -}; - -template -codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() -{ -} - -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) - -_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); - -template -struct __narrow_to_utf8 -{ - template - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const; -}; - -template <> -struct __narrow_to_utf8<8> -{ - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - for (; __wb < __we; ++__wb, ++__s) - *__s = *__wb; - return __s; - } -}; - -template <> -struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __narrow_to_utf8() : codecvt(1) {} - - _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - result __r = ok; - mbstate_t __mb; - while (__wb < __we && __r != error) - { - const int __sz = 32; - char __buf[__sz]; - char* __bn; - const char16_t* __wn = (const char16_t*)__wb; - __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) - __throw_runtime_error("locale not supported"); - for (const char* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = *__p; - __wb = (const _CharT*)__wn; - } - return __s; - } -}; - -template <> -struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __narrow_to_utf8() : codecvt(1) {} - - _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - result __r = ok; - mbstate_t __mb; - while (__wb < __we && __r != error) - { - const int __sz = 32; - char __buf[__sz]; - char* __bn; - const char32_t* __wn = (const char32_t*)__wb; - __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) - __throw_runtime_error("locale not supported"); - for (const char* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = *__p; - __wb = (const _CharT*)__wn; - } - return __s; - } -}; - -template -struct __widen_from_utf8 -{ - template - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const; -}; - -template <> -struct __widen_from_utf8<8> -{ - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - for (; __nb < __ne; ++__nb, ++__s) - *__s = *__nb; - return __s; - } -}; - -template <> -struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __widen_from_utf8() : codecvt(1) {} - - _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - result __r = ok; - mbstate_t __mb; - while (__nb < __ne && __r != error) - { - const int __sz = 32; - char16_t __buf[__sz]; - char16_t* __bn; - const char* __nn = __nb; - __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __nn == __nb) - __throw_runtime_error("locale not supported"); - for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = (wchar_t)*__p; - __nb = __nn; - } - return __s; - } -}; - -template <> -struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __widen_from_utf8() : codecvt(1) {} - - _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - result __r = ok; - mbstate_t __mb; - while (__nb < __ne && __r != error) - { - const int __sz = 32; - char32_t __buf[__sz]; - char32_t* __bn; - const char* __nn = __nb; - __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __nn == __nb) - __throw_runtime_error("locale not supported"); - for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = (wchar_t)*__p; - __nb = __nn; - } - return __s; - } -}; - -// template class numpunct - -template class _LIBCPP_TEMPLATE_VIS numpunct; - -template <> -class _LIBCPP_TYPE_VIS numpunct - : public locale::facet -{ -public: - typedef char char_type; - typedef basic_string string_type; - - explicit numpunct(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} - _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} - _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} - _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} - _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} - - static locale::id id; - -protected: - ~numpunct(); - virtual char_type do_decimal_point() const; - virtual char_type do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_truename() const; - virtual string_type do_falsename() const; - - char_type __decimal_point_; - char_type __thousands_sep_; - string __grouping_; -}; - -template <> -class _LIBCPP_TYPE_VIS numpunct - : public locale::facet -{ -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit numpunct(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} - _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} - _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} - _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} - _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} - - static locale::id id; - -protected: - ~numpunct(); - virtual char_type do_decimal_point() const; - virtual char_type do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_truename() const; - virtual string_type do_falsename() const; - - char_type __decimal_point_; - char_type __thousands_sep_; - string __grouping_; -}; - -// template class numpunct_byname - -template class _LIBCPP_TEMPLATE_VIS numpunct_byname; - -template <> -class _LIBCPP_TYPE_VIS numpunct_byname -: public numpunct -{ -public: - typedef char char_type; - typedef basic_string string_type; - - explicit numpunct_byname(const char* __nm, size_t __refs = 0); - explicit numpunct_byname(const string& __nm, size_t __refs = 0); - -protected: - ~numpunct_byname(); - -private: - void __init(const char*); -}; - -template <> -class _LIBCPP_TYPE_VIS numpunct_byname -: public numpunct -{ -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit numpunct_byname(const char* __nm, size_t __refs = 0); - explicit numpunct_byname(const string& __nm, size_t __refs = 0); - -protected: - ~numpunct_byname(); - -private: - void __init(const char*); -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___LOCALE diff --git a/clang-r353983c/include/c++/v1/__mutex_base b/clang-r353983c/include/c++/v1/__mutex_base deleted file mode 100644 index 008be9594e33914606d888fec328937062b6a2b7..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__mutex_base +++ /dev/null @@ -1,439 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___MUTEX_BASE -#define _LIBCPP___MUTEX_BASE - -#include <__config> -#include -#include -#include <__threading_support> - - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -#ifndef _LIBCPP_HAS_NO_THREADS - -#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION -# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) -# else -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) -# endif -#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION - -class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex -{ -#ifndef _LIBCPP_CXX03_LANG - __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; -#else - __libcpp_mutex_t __m_; -#endif - -public: - _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_CXX03_LANG - constexpr mutex() = default; -#else - mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} -#endif - ~mutex(); - -private: - mutex(const mutex&);// = delete; - mutex& operator=(const mutex&);// = delete; - -public: - void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability()); - bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true)); - void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()); - - typedef __libcpp_mutex_t* native_handle_type; - _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} -}; - -static_assert(is_nothrow_default_constructible::value, - "the default constructor for std::mutex must be nothrow"); - -struct _LIBCPP_TYPE_VIS defer_lock_t {}; -struct _LIBCPP_TYPE_VIS try_to_lock_t {}; -struct _LIBCPP_TYPE_VIS adopt_lock_t {}; - -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) - -extern _LIBCPP_EXPORTED_FROM_ABI const defer_lock_t defer_lock; -extern _LIBCPP_EXPORTED_FROM_ABI const try_to_lock_t try_to_lock; -extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock; - -#else - -/* _LIBCPP_INLINE_VAR */ constexpr defer_lock_t defer_lock = defer_lock_t(); -/* _LIBCPP_INLINE_VAR */ constexpr try_to_lock_t try_to_lock = try_to_lock_t(); -/* _LIBCPP_INLINE_VAR */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); - -#endif - -template -class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) -lock_guard -{ -public: - typedef _Mutex mutex_type; - -private: - mutex_type& __m_; -public: - - _LIBCPP_INLINE_VISIBILITY - explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) - : __m_(__m) {__m_.lock();} - _LIBCPP_INLINE_VISIBILITY - lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) - : __m_(__m) {} - _LIBCPP_INLINE_VISIBILITY - ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();} - -private: - lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE; - lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE; -}; - -template -class _LIBCPP_TEMPLATE_VIS unique_lock -{ -public: - typedef _Mutex mutex_type; - -private: - mutex_type* __m_; - bool __owns_; - -public: - _LIBCPP_INLINE_VISIBILITY - unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} - _LIBCPP_INLINE_VISIBILITY - explicit unique_lock(mutex_type& __m) - : __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT - : __m_(_VSTD::addressof(__m)), __owns_(false) {} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, try_to_lock_t) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, adopt_lock_t) - : __m_(_VSTD::addressof(__m)), __owns_(true) {} - template - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} - template - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} - _LIBCPP_INLINE_VISIBILITY - ~unique_lock() - { - if (__owns_) - __m_->unlock(); - } - -private: - unique_lock(unique_lock const&); // = delete; - unique_lock& operator=(unique_lock const&); // = delete; - -public: -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - unique_lock(unique_lock&& __u) _NOEXCEPT - : __m_(__u.__m_), __owns_(__u.__owns_) - {__u.__m_ = nullptr; __u.__owns_ = false;} - _LIBCPP_INLINE_VISIBILITY - unique_lock& operator=(unique_lock&& __u) _NOEXCEPT - { - if (__owns_) - __m_->unlock(); - __m_ = __u.__m_; - __owns_ = __u.__owns_; - __u.__m_ = nullptr; - __u.__owns_ = false; - return *this; - } - -#endif // _LIBCPP_CXX03_LANG - - void lock(); - bool try_lock(); - - template - bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); - template - bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); - - void unlock(); - - _LIBCPP_INLINE_VISIBILITY - void swap(unique_lock& __u) _NOEXCEPT - { - _VSTD::swap(__m_, __u.__m_); - _VSTD::swap(__owns_, __u.__owns_); - } - _LIBCPP_INLINE_VISIBILITY - mutex_type* release() _NOEXCEPT - { - mutex_type* __m = __m_; - __m_ = nullptr; - __owns_ = false; - return __m; - } - - _LIBCPP_INLINE_VISIBILITY - bool owns_lock() const _NOEXCEPT {return __owns_;} - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_EXPLICIT - operator bool () const _NOEXCEPT {return __owns_;} - _LIBCPP_INLINE_VISIBILITY - mutex_type* mutex() const _NOEXCEPT {return __m_;} -}; - -template -void -unique_lock<_Mutex>::lock() -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::lock: already locked"); - __m_->lock(); - __owns_ = true; -} - -template -bool -unique_lock<_Mutex>::try_lock() -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked"); - __owns_ = __m_->try_lock(); - return __owns_; -} - -template -template -bool -unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked"); - __owns_ = __m_->try_lock_for(__d); - return __owns_; -} - -template -template -bool -unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked"); - __owns_ = __m_->try_lock_until(__t); - return __owns_; -} - -template -void -unique_lock<_Mutex>::unlock() -{ - if (!__owns_) - __throw_system_error(EPERM, "unique_lock::unlock: not locked"); - __m_->unlock(); - __owns_ = false; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT - {__x.swap(__y);} - -//enum class cv_status -_LIBCPP_DECLARE_STRONG_ENUM(cv_status) -{ - no_timeout, - timeout -}; -_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) - -class _LIBCPP_TYPE_VIS condition_variable -{ -#ifndef _LIBCPP_CXX03_LANG - __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; -#else - __libcpp_condvar_t __cv_; -#endif - -public: - _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_CXX03_LANG - constexpr condition_variable() _NOEXCEPT = default; -#else - condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} -#endif - ~condition_variable(); - -private: - condition_variable(const condition_variable&); // = delete; - condition_variable& operator=(const condition_variable&); // = delete; - -public: - void notify_one() _NOEXCEPT; - void notify_all() _NOEXCEPT; - - void wait(unique_lock& __lk) _NOEXCEPT; - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - void wait(unique_lock& __lk, _Predicate __pred); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - cv_status - wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - bool - wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t, - _Predicate __pred); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - cv_status - wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d); - - template - bool - _LIBCPP_INLINE_VISIBILITY - wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d, - _Predicate __pred); - - typedef __libcpp_condvar_t* native_handle_type; - _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;} - -private: - void __do_timed_wait(unique_lock& __lk, - chrono::time_point) _NOEXCEPT; -}; -#endif // !_LIBCPP_HAS_NO_THREADS - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - chrono::__is_duration<_To>::value, - _To ->::type -__ceil(chrono::duration<_Rep, _Period> __d) -{ - using namespace chrono; - _To __r = duration_cast<_To>(__d); - if (__r < __d) - ++__r; - return __r; -} - -#ifndef _LIBCPP_HAS_NO_THREADS -template -void -condition_variable::wait(unique_lock& __lk, _Predicate __pred) -{ - while (!__pred()) - wait(__lk); -} - -template -cv_status -condition_variable::wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t) -{ - using namespace chrono; - wait_for(__lk, __t - _Clock::now()); - return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout; -} - -template -bool -condition_variable::wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t, - _Predicate __pred) -{ - while (!__pred()) - { - if (wait_until(__lk, __t) == cv_status::timeout) - return __pred(); - } - return true; -} - -template -cv_status -condition_variable::wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d) -{ - using namespace chrono; - if (__d <= __d.zero()) - return cv_status::timeout; - typedef time_point > __sys_tpf; - typedef time_point __sys_tpi; - __sys_tpf _Max = __sys_tpi::max(); - steady_clock::time_point __c_now = steady_clock::now(); - system_clock::time_point __s_now = system_clock::now(); - if (_Max - __d > __s_now) - __do_timed_wait(__lk, __s_now + __ceil(__d)); - else - __do_timed_wait(__lk, __sys_tpi::max()); - return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : - cv_status::timeout; -} - -template -inline -bool -condition_variable::wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d, - _Predicate __pred) -{ - return wait_until(__lk, chrono::steady_clock::now() + __d, - _VSTD::move(__pred)); -} - -#endif // !_LIBCPP_HAS_NO_THREADS - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___MUTEX_BASE diff --git a/clang-r353983c/include/c++/v1/__node_handle b/clang-r353983c/include/c++/v1/__node_handle deleted file mode 100644 index 7f3bd9da88bc8fad30827433603bbe03b04f5307..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__node_handle +++ /dev/null @@ -1,209 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___NODE_HANDLE -#define _LIBCPP___NODE_HANDLE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 14 - -// Specialized in __tree & __hash_table for their _NodeType. -template -struct __generic_container_node_destructor; - -template class _MapOrSetSpecifics> -class _LIBCPP_TEMPLATE_VIS __basic_node_handle - : public _MapOrSetSpecifics< - _NodeType, - __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> -{ - template - friend class __tree; - template - friend class __hash_table; - friend struct _MapOrSetSpecifics< - _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>; - - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_pointer::type - __node_pointer_type; - -public: - typedef _Alloc allocator_type; - -private: - __node_pointer_type __ptr_ = nullptr; - optional __alloc_; - - _LIBCPP_INLINE_VISIBILITY - void __release() - { - __ptr_ = nullptr; - __alloc_ = _VSTD::nullopt; - } - - _LIBCPP_INLINE_VISIBILITY - void __destroy_node_pointer() - { - if (__ptr_ != nullptr) - { - typedef typename __allocator_traits_rebind< - allocator_type, _NodeType>::type __node_alloc_type; - __node_alloc_type __alloc(*__alloc_); - __generic_container_node_destructor<_NodeType, __node_alloc_type>( - __alloc, true)(__ptr_); - __ptr_ = nullptr; - } - } - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle(__node_pointer_type __ptr, - allocator_type const& __alloc) - : __ptr_(__ptr), __alloc_(__alloc) - { - } - -public: - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle() = default; - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle(__basic_node_handle&& __other) noexcept - : __ptr_(__other.__ptr_), - __alloc_(_VSTD::move(__other.__alloc_)) - { - __other.__ptr_ = nullptr; - __other.__alloc_ = _VSTD::nullopt; - } - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle& operator=(__basic_node_handle&& __other) - { - _LIBCPP_ASSERT( - __alloc_ == _VSTD::nullopt || - __alloc_traits::propagate_on_container_move_assignment::value || - __alloc_ == __other.__alloc_, - "node_type with incompatible allocator passed to " - "node_type::operator=(node_type&&)"); - - __destroy_node_pointer(); - __ptr_ = __other.__ptr_; - - if (__alloc_traits::propagate_on_container_move_assignment::value || - __alloc_ == _VSTD::nullopt) - __alloc_ = _VSTD::move(__other.__alloc_); - - __other.__ptr_ = nullptr; - __other.__alloc_ = _VSTD::nullopt; - - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const { return *__alloc_; } - - _LIBCPP_INLINE_VISIBILITY - explicit operator bool() const { return __ptr_ != nullptr; } - - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY - bool empty() const { return __ptr_ == nullptr; } - - _LIBCPP_INLINE_VISIBILITY - void swap(__basic_node_handle& __other) noexcept( - __alloc_traits::propagate_on_container_swap::value || - __alloc_traits::is_always_equal::value) - { - using _VSTD::swap; - swap(__ptr_, __other.__ptr_); - if (__alloc_traits::propagate_on_container_swap::value || - __alloc_ == _VSTD::nullopt || __other.__alloc_ == _VSTD::nullopt) - swap(__alloc_, __other.__alloc_); - } - - _LIBCPP_INLINE_VISIBILITY - friend void swap(__basic_node_handle& __a, __basic_node_handle& __b) - noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); } - - _LIBCPP_INLINE_VISIBILITY - ~__basic_node_handle() - { - __destroy_node_pointer(); - } -}; - -template -struct __set_node_handle_specifics -{ - typedef typename _NodeType::__node_value_type value_type; - - _LIBCPP_INLINE_VISIBILITY - value_type& value() const - { - return static_cast<_Derived const*>(this)->__ptr_->__value_; - } -}; - -template -struct __map_node_handle_specifics -{ - typedef typename _NodeType::__node_value_type::key_type key_type; - typedef typename _NodeType::__node_value_type::mapped_type mapped_type; - - _LIBCPP_INLINE_VISIBILITY - key_type& key() const - { - return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().first; - } - - _LIBCPP_INLINE_VISIBILITY - mapped_type& mapped() const - { - return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().second; - } -}; - -template -using __set_node_handle = - __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>; - -template -using __map_node_handle = - __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; - -template -_LIBCPP_TEMPLATE_VIS -struct __insert_return_type -{ - _Iterator position; - bool inserted; - _NodeType node; -}; - -#endif // _LIBCPP_STD_VER > 14 - -_LIBCPP_END_NAMESPACE_STD -_LIBCPP_POP_MACROS - -#endif diff --git a/clang-r353983c/include/c++/v1/__nullptr b/clang-r353983c/include/c++/v1/__nullptr deleted file mode 100644 index 45529a710b637dbe9838e9533da5a028fd387a15..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__nullptr +++ /dev/null @@ -1,61 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __nullptr --------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_NULLPTR -#define _LIBCPP_NULLPTR - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#ifdef _LIBCPP_HAS_NO_NULLPTR - -_LIBCPP_BEGIN_NAMESPACE_STD - -struct _LIBCPP_TEMPLATE_VIS nullptr_t -{ - void* __lx; - - struct __nat {int __for_bool_;}; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - operator _Tp* () const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY - operator _Tp _Up::* () const {return 0;} - - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} -}; - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} - -#define nullptr _VSTD::__get_nullptr_t() - -_LIBCPP_END_NAMESPACE_STD - -#else // _LIBCPP_HAS_NO_NULLPTR - -namespace std -{ - typedef decltype(nullptr) nullptr_t; -} - -#endif // _LIBCPP_HAS_NO_NULLPTR - -#endif // _LIBCPP_NULLPTR diff --git a/clang-r353983c/include/c++/v1/__split_buffer b/clang-r353983c/include/c++/v1/__split_buffer deleted file mode 100644 index 1daa4e5ada3dd4c0188a1582a42110222ff0ff8b..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__split_buffer +++ /dev/null @@ -1,637 +0,0 @@ -// -*- C++ -*- -#ifndef _LIBCPP_SPLIT_BUFFER -#define _LIBCPP_SPLIT_BUFFER - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -class __split_buffer_common -{ -protected: - void __throw_length_error() const; - void __throw_out_of_range() const; -}; - -template > -struct __split_buffer - : private __split_buffer_common -{ -private: - __split_buffer(const __split_buffer&); - __split_buffer& operator=(const __split_buffer&); -public: - typedef _Tp value_type; - typedef _Allocator allocator_type; - typedef typename remove_reference::type __alloc_rr; - typedef allocator_traits<__alloc_rr> __alloc_traits; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_type; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; - typedef pointer iterator; - typedef const_pointer const_iterator; - - pointer __first_; - pointer __begin_; - pointer __end_; - __compressed_pair __end_cap_; - - typedef typename add_lvalue_reference::type __alloc_ref; - typedef typename add_lvalue_reference::type __alloc_const_ref; - - _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} - - _LIBCPP_INLINE_VISIBILITY - __split_buffer() - _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY - explicit __split_buffer(__alloc_rr& __a); - _LIBCPP_INLINE_VISIBILITY - explicit __split_buffer(const __alloc_rr& __a); - __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); - ~__split_buffer(); - -#ifndef _LIBCPP_CXX03_LANG - __split_buffer(__split_buffer&& __c) - _NOEXCEPT_(is_nothrow_move_constructible::value); - __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); - __split_buffer& operator=(__split_buffer&& __c) - _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) || - !__alloc_traits::propagate_on_container_move_assignment::value); -#endif // _LIBCPP_CXX03_LANG - - _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} - - _LIBCPP_INLINE_VISIBILITY - void clear() _NOEXCEPT - {__destruct_at_end(__begin_);} - _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast(__end_ - __begin_);} - _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} - _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast(__end_cap() - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast(__begin_ - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast(__end_cap() - __end_);} - - _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} - _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} - - void reserve(size_type __n); - void shrink_to_fit() _NOEXCEPT; - void push_front(const_reference __x); - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); -#ifndef _LIBCPP_CXX03_LANG - void push_front(value_type&& __x); - void push_back(value_type&& __x); - template - void emplace_back(_Args&&... __args); -#endif // !defined(_LIBCPP_CXX03_LANG) - - _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} - _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} - - void __construct_at_end(size_type __n); - void __construct_at_end(size_type __n, const_reference __x); - template - typename enable_if - < - __is_input_iterator<_InputIter>::value && - !__is_forward_iterator<_InputIter>::value, - void - >::type - __construct_at_end(_InputIter __first, _InputIter __last); - template - typename enable_if - < - __is_forward_iterator<_ForwardIterator>::value, - void - >::type - __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); - - _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) - {__destruct_at_begin(__new_begin, is_trivially_destructible());} - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_begin(pointer __new_begin, false_type); - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_begin(pointer __new_begin, true_type); - - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last) _NOEXCEPT - {__destruct_at_end(__new_last, false_type());} - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; - - void swap(__split_buffer& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable<__alloc_rr>::value); - - bool __invariants() const; - -private: - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__split_buffer& __c, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value) - { - __alloc() = _VSTD::move(__c.__alloc()); - } - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT - {} -}; - -template -bool -__split_buffer<_Tp, _Allocator>::__invariants() const -{ - if (__first_ == nullptr) - { - if (__begin_ != nullptr) - return false; - if (__end_ != nullptr) - return false; - if (__end_cap() != nullptr) - return false; - } - else - { - if (__begin_ < __first_) - return false; - if (__end_ < __begin_) - return false; - if (__end_cap() < __end_) - return false; - } - return true; -} - -// Default constructs __n objects starting at __end_ -// throws if construction throws -// Precondition: __n > 0 -// Precondition: size() + __n <= capacity() -// Postcondition: size() == size() + __n -template -void -__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) -{ - __alloc_rr& __a = this->__alloc(); - do - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); - ++this->__end_; - --__n; - } while (__n > 0); -} - -// Copy constructs __n objects starting at __end_ from __x -// throws if construction throws -// Precondition: __n > 0 -// Precondition: size() + __n <= capacity() -// Postcondition: size() == old size() + __n -// Postcondition: [i] == __x for all i in [size() - __n, __n) -template -void -__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) -{ - __alloc_rr& __a = this->__alloc(); - do - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); - ++this->__end_; - --__n; - } while (__n > 0); -} - -template -template -typename enable_if -< - __is_input_iterator<_InputIter>::value && - !__is_forward_iterator<_InputIter>::value, - void ->::type -__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) -{ - __alloc_rr& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - if (__end_ == __end_cap()) - { - size_type __old_cap = __end_cap() - __first_; - size_type __new_cap = _VSTD::max(2 * __old_cap, 8); - __split_buffer __buf(__new_cap, 0, __a); - for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_) - __alloc_traits::construct(__buf.__alloc(), - _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p)); - swap(__buf); - } - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - ++this->__end_; - } -} - -template -template -typename enable_if -< - __is_forward_iterator<_ForwardIterator>::value, - void ->::type -__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) -{ - __alloc_rr& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - ++this->__end_; - } -} - -template -inline -void -__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) -{ - while (__begin_ != __new_begin) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++)); -} - -template -inline -void -__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) -{ - __begin_ = __new_begin; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT -{ - while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT -{ - __end_ = __new_last; -} - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) - : __end_cap_(nullptr, __a) -{ - __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr; - __begin_ = __end_ = __first_ + __start; - __end_cap() = __first_ + __cap; -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) -{ -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) -{ -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) -{ -} - -template -__split_buffer<_Tp, _Allocator>::~__split_buffer() -{ - clear(); - if (__first_) - __alloc_traits::deallocate(__alloc(), __first_, capacity()); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) - _NOEXCEPT_(is_nothrow_move_constructible::value) - : __first_(_VSTD::move(__c.__first_)), - __begin_(_VSTD::move(__c.__begin_)), - __end_(_VSTD::move(__c.__end_)), - __end_cap_(_VSTD::move(__c.__end_cap_)) -{ - __c.__first_ = nullptr; - __c.__begin_ = nullptr; - __c.__end_ = nullptr; - __c.__end_cap() = nullptr; -} - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) - : __end_cap_(__second_tag(), __a) -{ - if (__a == __c.__alloc()) - { - __first_ = __c.__first_; - __begin_ = __c.__begin_; - __end_ = __c.__end_; - __end_cap() = __c.__end_cap(); - __c.__first_ = nullptr; - __c.__begin_ = nullptr; - __c.__end_ = nullptr; - __c.__end_cap() = nullptr; - } - else - { - size_type __cap = __c.size(); - __first_ = __alloc_traits::allocate(__alloc(), __cap); - __begin_ = __end_ = __first_; - __end_cap() = __first_ + __cap; - typedef move_iterator _Ip; - __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); - } -} - -template -__split_buffer<_Tp, _Allocator>& -__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) - _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) || - !__alloc_traits::propagate_on_container_move_assignment::value) -{ - clear(); - shrink_to_fit(); - __first_ = __c.__first_; - __begin_ = __c.__begin_; - __end_ = __c.__end_; - __end_cap() = __c.__end_cap(); - __move_assign_alloc(__c, - integral_constant()); - __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable<__alloc_rr>::value) -{ - _VSTD::swap(__first_, __x.__first_); - _VSTD::swap(__begin_, __x.__begin_); - _VSTD::swap(__end_, __x.__end_); - _VSTD::swap(__end_cap(), __x.__end_cap()); - __swap_allocator(__alloc(), __x.__alloc()); -} - -template -void -__split_buffer<_Tp, _Allocator>::reserve(size_type __n) -{ - if (__n < capacity()) - { - __split_buffer __t(__n, 0, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } -} - -template -void -__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT -{ - if (capacity() > size()) - { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - __split_buffer __t(size(), 0, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - __t.__end_ = __t.__begin_ + (__end_ - __begin_); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_NO_EXCEPTIONS - } -} - -template -void -__split_buffer<_Tp, _Allocator>::push_front(const_reference __x) -{ - if (__begin_ == __first_) - { - if (__end_ < __end_cap()) - { - difference_type __d = __end_cap() - __end_; - __d = (__d + 1) / 2; - __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); - __end_ += __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, (__c + 3) / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x); - --__begin_; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) -{ - if (__begin_ == __first_) - { - if (__end_ < __end_cap()) - { - difference_type __d = __end_cap() - __end_; - __d = (__d + 1) / 2; - __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); - __end_ += __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, (__c + 3) / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), - _VSTD::move(__x)); - --__begin_; -} - -#endif // _LIBCPP_CXX03_LANG - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::push_back(const_reference __x) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x); - ++__end_; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), - _VSTD::move(__x)); - ++__end_; -} - -template -template -void -__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), - _VSTD::forward<_Args>(__args)...); - ++__end_; -} - -#endif // _LIBCPP_CXX03_LANG - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP_SPLIT_BUFFER diff --git a/clang-r353983c/include/c++/v1/__sso_allocator b/clang-r353983c/include/c++/v1/__sso_allocator deleted file mode 100644 index 393012873848c334aec12b5e4efba48f41a3004e..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__sso_allocator +++ /dev/null @@ -1,76 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___SSO_ALLOCATOR -#define _LIBCPP___SSO_ALLOCATOR - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class _LIBCPP_HIDDEN __sso_allocator; - -template -class _LIBCPP_HIDDEN __sso_allocator -{ -public: - typedef const void* const_pointer; - typedef void value_type; -}; - -template -class _LIBCPP_HIDDEN __sso_allocator -{ - typename aligned_storage::type buf_; - bool __allocated_; -public: - typedef size_t size_type; - typedef _Tp* pointer; - typedef _Tp value_type; - - _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} - _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} - template _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() - : __allocated_(false) {} -private: - __sso_allocator& operator=(const __sso_allocator&); -public: - _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator::const_pointer = 0) - { - if (!__allocated_ && __n <= _Np) - { - __allocated_ = true; - return (pointer)&buf_; - } - return static_cast(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); - } - _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) - { - if (__p == (pointer)&buf_) - __allocated_ = false; - else - _VSTD::__libcpp_deallocate(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); - } - _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} - - _LIBCPP_INLINE_VISIBILITY - bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;} - _LIBCPP_INLINE_VISIBILITY - bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;} -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___SSO_ALLOCATOR diff --git a/clang-r353983c/include/c++/v1/__std_stream b/clang-r353983c/include/c++/v1/__std_stream deleted file mode 100644 index 5a9a470a97877b516a6aaa7f649b23fcacaf362c..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__std_stream +++ /dev/null @@ -1,361 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___STD_STREAM -#define _LIBCPP___STD_STREAM - -#include <__config> -#include -#include -#include <__locale> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -static const int __limit = 8; - -// __stdinbuf - -template -class _LIBCPP_HIDDEN __stdinbuf - : public basic_streambuf<_CharT, char_traits<_CharT> > -{ -public: - typedef _CharT char_type; - typedef char_traits traits_type; - typedef typename traits_type::int_type int_type; - typedef typename traits_type::pos_type pos_type; - typedef typename traits_type::off_type off_type; - typedef typename traits_type::state_type state_type; - - __stdinbuf(FILE* __fp, state_type* __st); - -protected: - virtual int_type underflow(); - virtual int_type uflow(); - virtual int_type pbackfail(int_type __c = traits_type::eof()); - virtual void imbue(const locale& __loc); - -private: - - FILE* __file_; - const codecvt* __cv_; - state_type* __st_; - int __encoding_; - int_type __last_consumed_; - bool __last_consumed_is_next_; - bool __always_noconv_; - - __stdinbuf(const __stdinbuf&); - __stdinbuf& operator=(const __stdinbuf&); - - int_type __getchar(bool __consume); -}; - -template -__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st) - : __file_(__fp), - __st_(__st), - __last_consumed_(traits_type::eof()), - __last_consumed_is_next_(false) -{ - imbue(this->getloc()); -} - -template -void -__stdinbuf<_CharT>::imbue(const locale& __loc) -{ - __cv_ = &use_facet >(__loc); - __encoding_ = __cv_->encoding(); - __always_noconv_ = __cv_->always_noconv(); - if (__encoding_ > __limit) - __throw_runtime_error("unsupported locale for standard input"); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::underflow() -{ - return __getchar(false); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::uflow() -{ - return __getchar(true); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::__getchar(bool __consume) -{ - if (__last_consumed_is_next_) - { - int_type __result = __last_consumed_; - if (__consume) - { - __last_consumed_ = traits_type::eof(); - __last_consumed_is_next_ = false; - } - return __result; - } - char __extbuf[__limit]; - int __nread = _VSTD::max(1, __encoding_); - for (int __i = 0; __i < __nread; ++__i) - { - int __c = getc(__file_); - if (__c == EOF) - return traits_type::eof(); - __extbuf[__i] = static_cast(__c); - } - char_type __1buf; - if (__always_noconv_) - __1buf = static_cast(__extbuf[0]); - else - { - const char* __enxt; - char_type* __inxt; - codecvt_base::result __r; - do - { - state_type __sv_st = *__st_; - __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt, - &__1buf, &__1buf + 1, __inxt); - switch (__r) - { - case _VSTD::codecvt_base::ok: - break; - case codecvt_base::partial: - *__st_ = __sv_st; - if (__nread == sizeof(__extbuf)) - return traits_type::eof(); - { - int __c = getc(__file_); - if (__c == EOF) - return traits_type::eof(); - __extbuf[__nread] = static_cast(__c); - } - ++__nread; - break; - case codecvt_base::error: - return traits_type::eof(); - case _VSTD::codecvt_base::noconv: - __1buf = static_cast(__extbuf[0]); - break; - } - } while (__r == _VSTD::codecvt_base::partial); - } - if (!__consume) - { - for (int __i = __nread; __i > 0;) - { - if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF) - return traits_type::eof(); - } - } - else - __last_consumed_ = traits_type::to_int_type(__1buf); - return traits_type::to_int_type(__1buf); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::pbackfail(int_type __c) -{ - if (traits_type::eq_int_type(__c, traits_type::eof())) - { - if (!__last_consumed_is_next_) - { - __c = __last_consumed_; - __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_, - traits_type::eof()); - } - return __c; - } - if (__last_consumed_is_next_) - { - char __extbuf[__limit]; - char* __enxt; - const char_type __ci = traits_type::to_char_type(__last_consumed_); - const char_type* __inxt; - switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt, - __extbuf, __extbuf + sizeof(__extbuf), __enxt)) - { - case _VSTD::codecvt_base::ok: - break; - case _VSTD::codecvt_base::noconv: - __extbuf[0] = static_cast(__last_consumed_); - __enxt = __extbuf + 1; - break; - case codecvt_base::partial: - case codecvt_base::error: - return traits_type::eof(); - } - while (__enxt > __extbuf) - if (ungetc(*--__enxt, __file_) == EOF) - return traits_type::eof(); - } - __last_consumed_ = __c; - __last_consumed_is_next_ = true; - return __c; -} - -// __stdoutbuf - -template -class _LIBCPP_HIDDEN __stdoutbuf - : public basic_streambuf<_CharT, char_traits<_CharT> > -{ -public: - typedef _CharT char_type; - typedef char_traits traits_type; - typedef typename traits_type::int_type int_type; - typedef typename traits_type::pos_type pos_type; - typedef typename traits_type::off_type off_type; - typedef typename traits_type::state_type state_type; - - __stdoutbuf(FILE* __fp, state_type* __st); - -protected: - virtual int_type overflow (int_type __c = traits_type::eof()); - virtual streamsize xsputn(const char_type* __s, streamsize __n); - virtual int sync(); - virtual void imbue(const locale& __loc); - -private: - FILE* __file_; - const codecvt* __cv_; - state_type* __st_; - bool __always_noconv_; - - __stdoutbuf(const __stdoutbuf&); - __stdoutbuf& operator=(const __stdoutbuf&); -}; - -template -__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st) - : __file_(__fp), - __cv_(&use_facet >(this->getloc())), - __st_(__st), - __always_noconv_(__cv_->always_noconv()) -{ -} - -template -typename __stdoutbuf<_CharT>::int_type -__stdoutbuf<_CharT>::overflow(int_type __c) -{ - char __extbuf[__limit]; - char_type __1buf; - if (!traits_type::eq_int_type(__c, traits_type::eof())) - { - __1buf = traits_type::to_char_type(__c); - if (__always_noconv_) - { - if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1) - return traits_type::eof(); - } - else - { - char* __extbe = __extbuf; - codecvt_base::result __r; - char_type* pbase = &__1buf; - char_type* pptr = pbase + 1; - do - { - const char_type* __e; - __r = __cv_->out(*__st_, pbase, pptr, __e, - __extbuf, - __extbuf + sizeof(__extbuf), - __extbe); - if (__e == pbase) - return traits_type::eof(); - if (__r == codecvt_base::noconv) - { - if (fwrite(pbase, 1, 1, __file_) != 1) - return traits_type::eof(); - } - else if (__r == codecvt_base::ok || __r == codecvt_base::partial) - { - size_t __nmemb = static_cast(__extbe - __extbuf); - if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb) - return traits_type::eof(); - if (__r == codecvt_base::partial) - { - pbase = const_cast(__e); - } - } - else - return traits_type::eof(); - } while (__r == codecvt_base::partial); - } - } - return traits_type::not_eof(__c); -} - -template -streamsize -__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n) -{ - if (__always_noconv_) - return fwrite(__s, sizeof(char_type), __n, __file_); - streamsize __i = 0; - for (; __i < __n; ++__i, ++__s) - if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof()) - break; - return __i; -} - -template -int -__stdoutbuf<_CharT>::sync() -{ - char __extbuf[__limit]; - codecvt_base::result __r; - do - { - char* __extbe; - __r = __cv_->unshift(*__st_, __extbuf, - __extbuf + sizeof(__extbuf), - __extbe); - size_t __nmemb = static_cast(__extbe - __extbuf); - if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb) - return -1; - } while (__r == codecvt_base::partial); - if (__r == codecvt_base::error) - return -1; - if (fflush(__file_)) - return -1; - return 0; -} - -template -void -__stdoutbuf<_CharT>::imbue(const locale& __loc) -{ - sync(); - __cv_ = &use_facet >(__loc); - __always_noconv_ = __cv_->always_noconv(); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___STD_STREAM diff --git a/clang-r353983c/include/c++/v1/__string b/clang-r353983c/include/c++/v1/__string deleted file mode 100644 index a88b976be3c9bbf238cc40316b358321f17e0b7f..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__string +++ /dev/null @@ -1,973 +0,0 @@ -// -*- C++ -*- -//===-------------------------- __string ----------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___STRING -#define _LIBCPP___STRING - -/* - string synopsis - -namespace std -{ - -template -struct char_traits -{ - typedef charT char_type; - typedef ... int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static constexpr void assign(char_type& c1, const char_type& c2) noexcept; - static constexpr bool eq(char_type c1, char_type c2) noexcept; - static constexpr bool lt(char_type c1, char_type c2) noexcept; - - static constexpr int compare(const char_type* s1, const char_type* s2, size_t n); - static constexpr size_t length(const char_type* s); - static constexpr const char_type* - find(const char_type* s, size_t n, const char_type& a); - static char_type* move(char_type* s1, const char_type* s2, size_t n); - static char_type* copy(char_type* s1, const char_type* s2, size_t n); - static char_type* assign(char_type* s, size_t n, char_type a); - - static constexpr int_type not_eof(int_type c) noexcept; - static constexpr char_type to_char_type(int_type c) noexcept; - static constexpr int_type to_int_type(char_type c) noexcept; - static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; - static constexpr int_type eof() noexcept; -}; - -template <> struct char_traits; -template <> struct char_traits; -template <> struct char_traits; // c++20 - -} // std - -*/ - -#include <__config> -#include // for search and min -#include // For EOF. -#include // for __murmur2_or_cityhash - -#include <__debug> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -// char_traits - -template -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef _CharT char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14 - assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s); - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a); - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a); - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(EOF);} -}; - -template -_LIBCPP_CONSTEXPR_AFTER_CXX14 int -char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -template -inline -_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t -char_traits<_CharT>::length(const char_type* __s) -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -template -inline -_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT* -char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -template -_CharT* -char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -template -inline -_CharT* -char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -template -inline -_CharT* -char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -// char_traits - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return (unsigned char)__c1 < (unsigned char)__c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 - length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} - static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); - } - static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type((unsigned char)__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(EOF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) - return 0; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_memcmp(__s1, __s2, __n); -#elif _LIBCPP_STD_VER <= 14 - return memcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - if (__n == 0) - return nullptr; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_char_memchr(__s, to_int_type(__a), __n); -#elif _LIBCPP_STD_VER <= 14 - return (const char_type*) memchr(__s, to_int_type(__a), __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -// char_traits - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef wchar_t char_type; - typedef wint_t int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} - static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n); - } - static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);} - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(WEOF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) - return 0; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wmemcmp(__s1, __s2, __n); -#elif _LIBCPP_STD_VER <= 14 - return wmemcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wcslen(__s); -#elif _LIBCPP_STD_VER <= 14 - return wcslen(__s); -#else - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const wchar_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - if (__n == 0) - return nullptr; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wmemchr(__s, __a, __n); -#elif _LIBCPP_STD_VER <= 14 - return wmemchr(__s, __a, __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -#ifndef _LIBCPP_NO_HAS_CHAR8_T - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char8_t char_type; - typedef unsigned int int_type; - typedef streamoff off_type; - typedef u8streampos pos_type; - typedef mbstate_t state_type; - - static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept - {__c1 = __c2;} - static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept - {return __c1 < __c2;} - - static constexpr - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - - static constexpr - size_t length(const char_type* __s) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY static constexpr - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} - - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); - } - - static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} - - static inline constexpr int_type not_eof(int_type __c) noexcept - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline constexpr char_type to_char_type(int_type __c) noexcept - {return char_type(__c);} - static inline constexpr int_type to_int_type(char_type __c) noexcept - {return int_type(__c);} - static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr int_type eof() noexcept - {return int_type(EOF);} -}; - -// TODO use '__builtin_strlen' if it ever supports char8_t ?? -inline constexpr -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline constexpr -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_memcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -// TODO use '__builtin_char_memchr' if it ever supports char8_t ?? -inline constexpr -const char8_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -#endif // #_LIBCPP_NO_HAS_CHAR8_T - -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char16_t char_type; - typedef uint_least16_t int_type; - typedef streamoff off_type; - typedef u16streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xFFFF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char16_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline -char16_t* -char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline -char16_t* -char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline -char16_t* -char_traits::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char32_t char_type; - typedef uint_least32_t int_type; - typedef streamoff off_type; - typedef u32streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xFFFFFFFF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char32_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline -char32_t* -char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline -char32_t* -char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline -char32_t* -char_traits::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - -// helper fns for basic_string and string_view - -// __str_find -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos >= __sz) - return __npos; - const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); - if (__r == 0) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT * -__search_substring(const _CharT *__first1, const _CharT *__last1, - const _CharT *__first2, const _CharT *__last2) { - // Take advantage of knowing source and pattern lengths. - // Stop short when source is smaller than pattern. - const ptrdiff_t __len2 = __last2 - __first2; - if (__len2 == 0) - return __first1; - - ptrdiff_t __len1 = __last1 - __first1; - if (__len1 < __len2) - return __last1; - - // First element of __first2 is loop invariant. - _CharT __f2 = *__first2; - while (true) { - __len1 = __last1 - __first1; - // Check whether __first1 still has at least __len2 bytes. - if (__len1 < __len2) - return __last1; - - // Find __f2 the first byte matching in __first1. - __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); - if (__first1 == 0) - return __last1; - - // It is faster to compare from the first byte of __first1 even if we - // already know that it matches the first byte of __first2: this is because - // __first2 is most likely aligned, as it is user's "pattern" string, and - // __first1 + 1 is most likely not aligned, as the match is in the middle of - // the string. - if (_Traits::compare(__first1, __first2, __len2) == 0) - return __first1; - - ++__first1; - } -} - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos > __sz) - return __npos; - - if (__n == 0) // There is nothing to search, just return __pos. - return __pos; - - const _CharT *__r = __search_substring<_CharT, _Traits>( - __p + __pos, __p + __sz, __s, __s + __n); - - if (__r == __p + __sz) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - - -// __str_rfind - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_rfind(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__sz < 1) - return __npos; - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - { - if (_Traits::eq(*--__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_rfind(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - __pos = _VSTD::min(__pos, __sz); - if (__n < __sz - __pos) - __pos += __n; - else - __pos = __sz; - const _CharT* __r = _VSTD::__find_end( - __p, __p + __pos, __s, __s + __n, _Traits::eq, - random_access_iterator_tag(), random_access_iterator_tag()); - if (__n > 0 && __r == __p + __pos) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - -// __str_find_first_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos >= __sz || __n == 0) - return __npos; - const _CharT* __r = _VSTD::__find_first_of_ce - (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); - if (__r == __p + __sz) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - - -// __str_find_last_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT - { - if (__n != 0) - { - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - { - const _CharT* __r = _Traits::find(__s, __n, *--__ps); - if (__r) - return static_cast<_SizeT>(__ps - __p); - } - } - return __npos; -} - - -// __str_find_first_not_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_not_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos < __sz) - { - const _CharT* __pe = __p + __sz; - for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) - if (_Traits::find(__s, __n, *__ps) == 0) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_not_of(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos < __sz) - { - const _CharT* __pe = __p + __sz; - for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) - if (!_Traits::eq(*__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - - -// __str_find_last_not_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_not_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - if (_Traits::find(__s, __n, *--__ps) == 0) - return static_cast<_SizeT>(__ps - __p); - return __npos; -} - - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_not_of(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - if (!_Traits::eq(*--__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - return __npos; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -size_t __do_string_hash(_Ptr __p, _Ptr __e) -{ - typedef typename iterator_traits<_Ptr>::value_type value_type; - return __murmur2_or_cityhash()(__p, (__e-__p)*sizeof(value_type)); -} - -template > -struct __quoted_output_proxy -{ - _Iter __first; - _Iter __last; - _CharT __delim; - _CharT __escape; - - __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) - : __first(__f), __last(__l), __delim(__d), __escape(__e) {} - // This would be a nice place for a string_ref -}; - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___STRING diff --git a/clang-r353983c/include/c++/v1/__threading_support b/clang-r353983c/include/c++/v1/__threading_support deleted file mode 100644 index baa1222c304941a163d98ff844a02955938f52e5..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__threading_support +++ /dev/null @@ -1,401 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_THREADING_SUPPORT -#define _LIBCPP_THREADING_SUPPORT - -#include <__config> -#include -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -# include <__external_threading> -#elif !defined(_LIBCPP_HAS_NO_THREADS) - -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -# include -# include -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_HAS_THREAD_API_WIN32) -#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS -#else -#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY -#endif - -#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) -#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) -#else -#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -// Mutex -typedef pthread_mutex_t __libcpp_mutex_t; -#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - -typedef pthread_mutex_t __libcpp_recursive_mutex_t; - -// Condition Variable -typedef pthread_cond_t __libcpp_condvar_t; -#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER - -// Execute once -typedef pthread_once_t __libcpp_exec_once_flag; -#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT - -// Thread id -typedef pthread_t __libcpp_thread_id; - -// Thread -#define _LIBCPP_NULL_THREAD 0U - -typedef pthread_t __libcpp_thread_t; - -// Thread Local Storage -typedef pthread_key_t __libcpp_tls_key; - -#define _LIBCPP_TLS_DESTRUCTOR_CC -#else -// Mutex -typedef void* __libcpp_mutex_t; -#define _LIBCPP_MUTEX_INITIALIZER 0 - -#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__) -typedef void* __libcpp_recursive_mutex_t[6]; -#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__) -typedef void* __libcpp_recursive_mutex_t[5]; -#else -# error Unsupported architecture -#endif - -// Condition Variable -typedef void* __libcpp_condvar_t; -#define _LIBCPP_CONDVAR_INITIALIZER 0 - -// Execute Once -typedef void* __libcpp_exec_once_flag; -#define _LIBCPP_EXEC_ONCE_INITIALIZER 0 - -// Thread ID -typedef long __libcpp_thread_id; - -// Thread -#define _LIBCPP_NULL_THREAD 0U - -typedef void* __libcpp_thread_t; - -// Thread Local Storage -typedef long __libcpp_tls_key; - -#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall -#endif - -// Mutex -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_mutex_lock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_destroy(__libcpp_mutex_t *__m); - -// Condition variable -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, - timespec *__ts); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); - -// Execute once -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_execute_once(__libcpp_exec_once_flag *flag, - void (*init_routine)(void)); - -// Thread id -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); - -// Thread -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_isnull(const __libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), - void *__arg); - -_LIBCPP_THREAD_ABI_VISIBILITY -__libcpp_thread_id __libcpp_thread_get_current_id(); - -_LIBCPP_THREAD_ABI_VISIBILITY -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_join(__libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_detach(__libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -void __libcpp_thread_yield(); - -_LIBCPP_THREAD_ABI_VISIBILITY -void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); - -// Thread local storage -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_tls_create(__libcpp_tls_key* __key, - void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); - -_LIBCPP_THREAD_ABI_VISIBILITY -void *__libcpp_tls_get(__libcpp_tls_key __key); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); - -#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \ - defined(_LIBCPP_HAS_THREAD_API_PTHREAD) - -int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) -{ - pthread_mutexattr_t attr; - int __ec = pthread_mutexattr_init(&attr); - if (__ec) - return __ec; - __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - if (__ec) { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutex_init(__m, &attr); - if (__ec) { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutexattr_destroy(&attr); - if (__ec) { - pthread_mutex_destroy(__m); - return __ec; - } - return 0; -} - -int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_lock(__m); -} - -bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_trylock(__m) == 0; -} - -int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_unlock(__m); -} - -int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_destroy(__m); -} - -int __libcpp_mutex_lock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_lock(__m); -} - -bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_trylock(__m) == 0; -} - -int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_unlock(__m); -} - -int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) -{ - return pthread_mutex_destroy(__m); -} - -// Condition Variable -int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) -{ - return pthread_cond_signal(__cv); -} - -int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) -{ - return pthread_cond_broadcast(__cv); -} - -int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) -{ - return pthread_cond_wait(__cv, __m); -} - -int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, - timespec *__ts) -{ - return pthread_cond_timedwait(__cv, __m, __ts); -} - -int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) -{ - return pthread_cond_destroy(__cv); -} - -// Execute once -int __libcpp_execute_once(__libcpp_exec_once_flag *flag, - void (*init_routine)(void)) { - return pthread_once(flag, init_routine); -} - -// Thread id -// Returns non-zero if the thread ids are equal, otherwise 0 -bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) -{ - return pthread_equal(t1, t2) != 0; -} - -// Returns non-zero if t1 < t2, otherwise 0 -bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) -{ - return t1 < t2; -} - -// Thread -bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) { - return *__t == 0; -} - -int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), - void *__arg) -{ - return pthread_create(__t, 0, __func, __arg); -} - -__libcpp_thread_id __libcpp_thread_get_current_id() -{ - return pthread_self(); -} - -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) -{ - return *__t; -} - -int __libcpp_thread_join(__libcpp_thread_t *__t) -{ - return pthread_join(*__t, 0); -} - -int __libcpp_thread_detach(__libcpp_thread_t *__t) -{ - return pthread_detach(*__t); -} - -void __libcpp_thread_yield() -{ - sched_yield(); -} - -void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) -{ - using namespace chrono; - seconds __s = duration_cast(__ns); - timespec __ts; - typedef decltype(__ts.tv_sec) ts_sec; - _LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits::max(); - - if (__s.count() < __ts_sec_max) - { - __ts.tv_sec = static_cast(__s.count()); - __ts.tv_nsec = static_cast((__ns - __s).count()); - } - else - { - __ts.tv_sec = __ts_sec_max; - __ts.tv_nsec = 999999999; // (10^9 - 1) - } - - while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR); -} - -// Thread local storage -int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *)) -{ - return pthread_key_create(__key, __at_exit); -} - -void *__libcpp_tls_get(__libcpp_tls_key __key) -{ - return pthread_getspecific(__key); -} - -int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) -{ - return pthread_setspecific(__key, __p); -} - -#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // !_LIBCPP_HAS_NO_THREADS - -#endif // _LIBCPP_THREADING_SUPPORT diff --git a/clang-r353983c/include/c++/v1/__tree b/clang-r353983c/include/c++/v1/__tree deleted file mode 100644 index 9f0931ee940711d25cccabe02e45ad97c2d519de..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__tree +++ /dev/null @@ -1,2885 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TREE -#define _LIBCPP___TREE - -#include <__config> -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if defined(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804 -template class _LIBCPP_TEMPLATE_VIS map; -template class _LIBCPP_TEMPLATE_VIS multimap; -template class _LIBCPP_TEMPLATE_VIS set; -template class _LIBCPP_TEMPLATE_VIS multiset; -#endif - -template class __tree; -template - class _LIBCPP_TEMPLATE_VIS __tree_iterator; -template - class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; - -template class __tree_end_node; -template class __tree_node_base; -template class __tree_node; - -template -struct __value_type; - -template class __map_node_destructor; -template class _LIBCPP_TEMPLATE_VIS __map_iterator; -template class _LIBCPP_TEMPLATE_VIS __map_const_iterator; - -/* - -_NodePtr algorithms - -The algorithms taking _NodePtr are red black tree algorithms. Those -algorithms taking a parameter named __root should assume that __root -points to a proper red black tree (unless otherwise specified). - -Each algorithm herein assumes that __root->__parent_ points to a non-null -structure which has a member __left_ which points back to __root. No other -member is read or written to at __root->__parent_. - -__root->__parent_ will be referred to below (in comments only) as end_node. -end_node->__left_ is an externably accessible lvalue for __root, and can be -changed by node insertion and removal (without explicit reference to end_node). - -All nodes (with the exception of end_node), even the node referred to as -__root, have a non-null __parent_ field. - -*/ - -// Returns: true if __x is a left child of its parent, else false -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -bool -__tree_is_left_child(_NodePtr __x) _NOEXCEPT -{ - return __x == __x->__parent_->__left_; -} - -// Determines if the subtree rooted at __x is a proper red black subtree. If -// __x is a proper subtree, returns the black height (null counts as 1). If -// __x is an improper subtree, returns 0. -template -unsigned -__tree_sub_invariant(_NodePtr __x) -{ - if (__x == nullptr) - return 1; - // parent consistency checked by caller - // check __x->__left_ consistency - if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x) - return 0; - // check __x->__right_ consistency - if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x) - return 0; - // check __x->__left_ != __x->__right_ unless both are nullptr - if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr) - return 0; - // If this is red, neither child can be red - if (!__x->__is_black_) - { - if (__x->__left_ && !__x->__left_->__is_black_) - return 0; - if (__x->__right_ && !__x->__right_->__is_black_) - return 0; - } - unsigned __h = __tree_sub_invariant(__x->__left_); - if (__h == 0) - return 0; // invalid left subtree - if (__h != __tree_sub_invariant(__x->__right_)) - return 0; // invalid or different height right subtree - return __h + __x->__is_black_; // return black height of this node -} - -// Determines if the red black tree rooted at __root is a proper red black tree. -// __root == nullptr is a proper tree. Returns true is __root is a proper -// red black tree, else returns false. -template -bool -__tree_invariant(_NodePtr __root) -{ - if (__root == nullptr) - return true; - // check __x->__parent_ consistency - if (__root->__parent_ == nullptr) - return false; - if (!__tree_is_left_child(__root)) - return false; - // root must be black - if (!__root->__is_black_) - return false; - // do normal node checks - return __tree_sub_invariant(__root) != 0; -} - -// Returns: pointer to the left-most node under __x. -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_min(_NodePtr __x) _NOEXCEPT -{ - while (__x->__left_ != nullptr) - __x = __x->__left_; - return __x; -} - -// Returns: pointer to the right-most node under __x. -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_max(_NodePtr __x) _NOEXCEPT -{ - while (__x->__right_ != nullptr) - __x = __x->__right_; - return __x; -} - -// Returns: pointer to the next in-order node after __x. -// Precondition: __x != nullptr. -template -_NodePtr -__tree_next(_NodePtr __x) _NOEXCEPT -{ - if (__x->__right_ != nullptr) - return __tree_min(__x->__right_); - while (!__tree_is_left_child(__x)) - __x = __x->__parent_unsafe(); - return __x->__parent_unsafe(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_EndNodePtr -__tree_next_iter(_NodePtr __x) _NOEXCEPT -{ - if (__x->__right_ != nullptr) - return static_cast<_EndNodePtr>(__tree_min(__x->__right_)); - while (!__tree_is_left_child(__x)) - __x = __x->__parent_unsafe(); - return static_cast<_EndNodePtr>(__x->__parent_); -} - -// Returns: pointer to the previous in-order node before __x. -// Precondition: __x != nullptr. -// Note: __x may be the end node. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT -{ - if (__x->__left_ != nullptr) - return __tree_max(__x->__left_); - _NodePtr __xx = static_cast<_NodePtr>(__x); - while (__tree_is_left_child(__xx)) - __xx = __xx->__parent_unsafe(); - return __xx->__parent_unsafe(); -} - -// Returns: pointer to a node which has no children -// Precondition: __x != nullptr. -template -_NodePtr -__tree_leaf(_NodePtr __x) _NOEXCEPT -{ - while (true) - { - if (__x->__left_ != nullptr) - { - __x = __x->__left_; - continue; - } - if (__x->__right_ != nullptr) - { - __x = __x->__right_; - continue; - } - break; - } - return __x; -} - -// Effects: Makes __x->__right_ the subtree root with __x as its left child -// while preserving in-order order. -// Precondition: __x->__right_ != nullptr -template -void -__tree_left_rotate(_NodePtr __x) _NOEXCEPT -{ - _NodePtr __y = __x->__right_; - __x->__right_ = __y->__left_; - if (__x->__right_ != nullptr) - __x->__right_->__set_parent(__x); - __y->__parent_ = __x->__parent_; - if (__tree_is_left_child(__x)) - __x->__parent_->__left_ = __y; - else - __x->__parent_unsafe()->__right_ = __y; - __y->__left_ = __x; - __x->__set_parent(__y); -} - -// Effects: Makes __x->__left_ the subtree root with __x as its right child -// while preserving in-order order. -// Precondition: __x->__left_ != nullptr -template -void -__tree_right_rotate(_NodePtr __x) _NOEXCEPT -{ - _NodePtr __y = __x->__left_; - __x->__left_ = __y->__right_; - if (__x->__left_ != nullptr) - __x->__left_->__set_parent(__x); - __y->__parent_ = __x->__parent_; - if (__tree_is_left_child(__x)) - __x->__parent_->__left_ = __y; - else - __x->__parent_unsafe()->__right_ = __y; - __y->__right_ = __x; - __x->__set_parent(__y); -} - -// Effects: Rebalances __root after attaching __x to a leaf. -// Precondition: __root != nulptr && __x != nullptr. -// __x has no children. -// __x == __root or == a direct or indirect child of __root. -// If __x were to be unlinked from __root (setting __root to -// nullptr if __root == __x), __tree_invariant(__root) == true. -// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_ -// may be different than the value passed in as __root. -template -void -__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT -{ - __x->__is_black_ = __x == __root; - while (__x != __root && !__x->__parent_unsafe()->__is_black_) - { - // __x->__parent_ != __root because __x->__parent_->__is_black == false - if (__tree_is_left_child(__x->__parent_unsafe())) - { - _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_; - if (__y != nullptr && !__y->__is_black_) - { - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = __x == __root; - __y->__is_black_ = true; - } - else - { - if (!__tree_is_left_child(__x)) - { - __x = __x->__parent_unsafe(); - __tree_left_rotate(__x); - } - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = false; - __tree_right_rotate(__x); - break; - } - } - else - { - _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_; - if (__y != nullptr && !__y->__is_black_) - { - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = __x == __root; - __y->__is_black_ = true; - } - else - { - if (__tree_is_left_child(__x)) - { - __x = __x->__parent_unsafe(); - __tree_right_rotate(__x); - } - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = false; - __tree_left_rotate(__x); - break; - } - } - } -} - -// Precondition: __root != nullptr && __z != nullptr. -// __tree_invariant(__root) == true. -// __z == __root or == a direct or indirect child of __root. -// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed. -// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_ -// nor any of its children refer to __z. end_node->__left_ -// may be different than the value passed in as __root. -template -void -__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT -{ - // __z will be removed from the tree. Client still needs to destruct/deallocate it - // __y is either __z, or if __z has two children, __tree_next(__z). - // __y will have at most one child. - // __y will be the initial hole in the tree (make the hole at a leaf) - _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ? - __z : __tree_next(__z); - // __x is __y's possibly null single child - _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_; - // __w is __x's possibly null uncle (will become __x's sibling) - _NodePtr __w = nullptr; - // link __x to __y's parent, and find __w - if (__x != nullptr) - __x->__parent_ = __y->__parent_; - if (__tree_is_left_child(__y)) - { - __y->__parent_->__left_ = __x; - if (__y != __root) - __w = __y->__parent_unsafe()->__right_; - else - __root = __x; // __w == nullptr - } - else - { - __y->__parent_unsafe()->__right_ = __x; - // __y can't be root if it is a right child - __w = __y->__parent_->__left_; - } - bool __removed_black = __y->__is_black_; - // If we didn't remove __z, do so now by splicing in __y for __z, - // but copy __z's color. This does not impact __x or __w. - if (__y != __z) - { - // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr - __y->__parent_ = __z->__parent_; - if (__tree_is_left_child(__z)) - __y->__parent_->__left_ = __y; - else - __y->__parent_unsafe()->__right_ = __y; - __y->__left_ = __z->__left_; - __y->__left_->__set_parent(__y); - __y->__right_ = __z->__right_; - if (__y->__right_ != nullptr) - __y->__right_->__set_parent(__y); - __y->__is_black_ = __z->__is_black_; - if (__root == __z) - __root = __y; - } - // There is no need to rebalance if we removed a red, or if we removed - // the last node. - if (__removed_black && __root != nullptr) - { - // Rebalance: - // __x has an implicit black color (transferred from the removed __y) - // associated with it, no matter what its color is. - // If __x is __root (in which case it can't be null), it is supposed - // to be black anyway, and if it is doubly black, then the double - // can just be ignored. - // If __x is red (in which case it can't be null), then it can absorb - // the implicit black just by setting its color to black. - // Since __y was black and only had one child (which __x points to), __x - // is either red with no children, else null, otherwise __y would have - // different black heights under left and right pointers. - // if (__x == __root || __x != nullptr && !__x->__is_black_) - if (__x != nullptr) - __x->__is_black_ = true; - else - { - // Else __x isn't root, and is "doubly black", even though it may - // be null. __w can not be null here, else the parent would - // see a black height >= 2 on the __x side and a black height - // of 1 on the __w side (__w must be a non-null black or a red - // with a non-null black child). - while (true) - { - if (!__tree_is_left_child(__w)) // if x is left child - { - if (!__w->__is_black_) - { - __w->__is_black_ = true; - __w->__parent_unsafe()->__is_black_ = false; - __tree_left_rotate(__w->__parent_unsafe()); - // __x is still valid - // reset __root only if necessary - if (__root == __w->__left_) - __root = __w; - // reset sibling, and it still can't be null - __w = __w->__left_->__right_; - } - // __w->__is_black_ is now true, __w may have null children - if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && - (__w->__right_ == nullptr || __w->__right_->__is_black_)) - { - __w->__is_black_ = false; - __x = __w->__parent_unsafe(); - // __x can no longer be null - if (__x == __root || !__x->__is_black_) - { - __x->__is_black_ = true; - break; - } - // reset sibling, and it still can't be null - __w = __tree_is_left_child(__x) ? - __x->__parent_unsafe()->__right_ : - __x->__parent_->__left_; - // continue; - } - else // __w has a red child - { - if (__w->__right_ == nullptr || __w->__right_->__is_black_) - { - // __w left child is non-null and red - __w->__left_->__is_black_ = true; - __w->__is_black_ = false; - __tree_right_rotate(__w); - // __w is known not to be root, so root hasn't changed - // reset sibling, and it still can't be null - __w = __w->__parent_unsafe(); - } - // __w has a right red child, left child may be null - __w->__is_black_ = __w->__parent_unsafe()->__is_black_; - __w->__parent_unsafe()->__is_black_ = true; - __w->__right_->__is_black_ = true; - __tree_left_rotate(__w->__parent_unsafe()); - break; - } - } - else - { - if (!__w->__is_black_) - { - __w->__is_black_ = true; - __w->__parent_unsafe()->__is_black_ = false; - __tree_right_rotate(__w->__parent_unsafe()); - // __x is still valid - // reset __root only if necessary - if (__root == __w->__right_) - __root = __w; - // reset sibling, and it still can't be null - __w = __w->__right_->__left_; - } - // __w->__is_black_ is now true, __w may have null children - if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && - (__w->__right_ == nullptr || __w->__right_->__is_black_)) - { - __w->__is_black_ = false; - __x = __w->__parent_unsafe(); - // __x can no longer be null - if (!__x->__is_black_ || __x == __root) - { - __x->__is_black_ = true; - break; - } - // reset sibling, and it still can't be null - __w = __tree_is_left_child(__x) ? - __x->__parent_unsafe()->__right_ : - __x->__parent_->__left_; - // continue; - } - else // __w has a red child - { - if (__w->__left_ == nullptr || __w->__left_->__is_black_) - { - // __w right child is non-null and red - __w->__right_->__is_black_ = true; - __w->__is_black_ = false; - __tree_left_rotate(__w); - // __w is known not to be root, so root hasn't changed - // reset sibling, and it still can't be null - __w = __w->__parent_unsafe(); - } - // __w has a left red child, right child may be null - __w->__is_black_ = __w->__parent_unsafe()->__is_black_; - __w->__parent_unsafe()->__is_black_ = true; - __w->__left_->__is_black_ = true; - __tree_right_rotate(__w->__parent_unsafe()); - break; - } - } - } - } - } -} - -// node traits - - -#ifndef _LIBCPP_CXX03_LANG -template -struct __is_tree_value_type_imp : false_type {}; - -template -struct __is_tree_value_type_imp<__value_type<_Key, _Value>> : true_type {}; - -template -struct __is_tree_value_type : false_type {}; - -template -struct __is_tree_value_type<_One> : __is_tree_value_type_imp::type> {}; -#endif - -template -struct __tree_key_value_types { - typedef _Tp key_type; - typedef _Tp __node_value_type; - typedef _Tp __container_value_type; - static const bool __is_map = false; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(_Tp const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& __get_value(__node_value_type const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static __container_value_type&& __move(__node_value_type& __v) { - return _VSTD::move(__v); - } -#endif -}; - -template -struct __tree_key_value_types<__value_type<_Key, _Tp> > { - typedef _Key key_type; - typedef _Tp mapped_type; - typedef __value_type<_Key, _Tp> __node_value_type; - typedef pair __container_value_type; - typedef __container_value_type __map_value_type; - static const bool __is_map = true; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& - __get_key(__node_value_type const& __t) { - return __t.__get_value().first; - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - key_type const&>::type - __get_key(_Up& __t) { - return __t.first; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& - __get_value(__node_value_type const& __t) { - return __t.__get_value(); - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n.__get_value()); - } - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static pair __move(__node_value_type& __v) { - return __v.__move(); - } -#endif -}; - -template -struct __tree_node_base_types { - typedef _VoidPtr __void_pointer; - - typedef __tree_node_base<__void_pointer> __node_base_type; - typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type - __node_base_pointer; - - typedef __tree_end_node<__node_base_pointer> __end_node_type; - typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type - __end_node_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) - typedef __end_node_pointer __parent_pointer; -#else - typedef typename conditional< - is_pointer<__end_node_pointer>::value, - __end_node_pointer, - __node_base_pointer>::type __parent_pointer; -#endif - -private: - static_assert((is_same::element_type, void>::value), - "_VoidPtr does not point to unqualified void type"); -}; - -template , - bool = _KVTypes::__is_map> -struct __tree_map_pointer_types {}; - -template -struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { - typedef typename _KVTypes::__map_value_type _Mv; - typedef typename __rebind_pointer<_AllocPtr, _Mv>::type - __map_value_type_pointer; - typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type - __const_map_value_type_pointer; -}; - -template ::element_type> -struct __tree_node_types; - -template -struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> > - : public __tree_node_base_types<_VoidPtr>, - __tree_key_value_types<_Tp>, - __tree_map_pointer_types<_Tp, _VoidPtr> -{ - typedef __tree_node_base_types<_VoidPtr> __base; - typedef __tree_key_value_types<_Tp> __key_base; - typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base; -public: - - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef _NodePtr __node_pointer; - - typedef _Tp __node_value_type; - typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type - __node_value_type_pointer; - typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type - __const_node_value_type_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) - typedef typename __base::__end_node_pointer __iter_pointer; -#else - typedef typename conditional< - is_pointer<__node_pointer>::value, - typename __base::__end_node_pointer, - __node_pointer>::type __iter_pointer; -#endif -private: - static_assert(!is_const<__node_type>::value, - "_NodePtr should never be a pointer to const"); - static_assert((is_same::type, - _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr."); -}; - -template -struct __make_tree_node_types { - typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type - _NodePtr; - typedef __tree_node_types<_NodePtr> type; -}; - -// node - -template -class __tree_end_node -{ -public: - typedef _Pointer pointer; - pointer __left_; - - _LIBCPP_INLINE_VISIBILITY - __tree_end_node() _NOEXCEPT : __left_() {} -}; - -template -class __tree_node_base - : public __tree_node_base_types<_VoidPtr>::__end_node_type -{ - typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes; - -public: - typedef typename _NodeBaseTypes::__node_base_pointer pointer; - typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer; - - pointer __right_; - __parent_pointer __parent_; - bool __is_black_; - - _LIBCPP_INLINE_VISIBILITY - pointer __parent_unsafe() const { return static_cast(__parent_);} - - _LIBCPP_INLINE_VISIBILITY - void __set_parent(pointer __p) { - __parent_ = static_cast<__parent_pointer>(__p); - } - -private: - ~__tree_node_base() _LIBCPP_EQUAL_DELETE; - __tree_node_base(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; - __tree_node_base& operator=(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; -}; - -template -class __tree_node - : public __tree_node_base<_VoidPtr> -{ -public: - typedef _Tp __node_value_type; - - __node_value_type __value_; - -private: - ~__tree_node() _LIBCPP_EQUAL_DELETE; - __tree_node(__tree_node const&) _LIBCPP_EQUAL_DELETE; - __tree_node& operator=(__tree_node const&) _LIBCPP_EQUAL_DELETE; -}; - - -template -class __tree_node_destructor -{ - typedef _Allocator allocator_type; - typedef allocator_traits __alloc_traits; - -public: - typedef typename __alloc_traits::pointer pointer; -private: - typedef __tree_node_types _NodeTypes; - allocator_type& __na_; - - __tree_node_destructor& operator=(const __tree_node_destructor&); - -public: - bool __value_constructed; - - _LIBCPP_INLINE_VISIBILITY - explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT - : __na_(__na), - __value_constructed(__val) - {} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - if (__value_constructed) - __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); - if (__p) - __alloc_traits::deallocate(__na_, __p, 1); - } - - template friend class __map_node_destructor; -}; - -#if _LIBCPP_STD_VER > 14 -template -struct __generic_container_node_destructor; -template -struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> - : __tree_node_destructor<_Alloc> -{ - using __tree_node_destructor<_Alloc>::__tree_node_destructor; -}; -#endif - -template -class _LIBCPP_TEMPLATE_VIS __tree_iterator -{ - typedef __tree_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - typedef pointer_traits<__node_pointer> __pointer_traits; - - __iter_pointer __ptr_; - -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _DiffType difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __ptr_(nullptr) -#endif - {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const - {return __get_np()->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const - {return pointer_traits::pointer_to(__get_np()->__value_);} - - _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator++() { - __ptr_ = static_cast<__iter_pointer>( - __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); - return *this; - } - _LIBCPP_INLINE_VISIBILITY - __tree_iterator operator++(int) - {__tree_iterator __t(*this); ++(*this); return __t;} - - _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator--() { - __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>( - static_cast<__end_node_pointer>(__ptr_))); - return *this; - } - _LIBCPP_INLINE_VISIBILITY - __tree_iterator operator--(int) - {__tree_iterator __t(*this); --(*this); return __t;} - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) - {return __x.__ptr_ == __y.__ptr_;} - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) - {return !(__x == __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } - template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; -}; - -template -class _LIBCPP_TEMPLATE_VIS __tree_const_iterator -{ - typedef __tree_node_types<_NodePtr> _NodeTypes; - typedef typename _NodeTypes::__node_pointer __node_pointer; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - typedef pointer_traits<__node_pointer> __pointer_traits; - - __iter_pointer __ptr_; - -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _DiffType difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __ptr_(nullptr) -#endif - {} - -private: - typedef __tree_iterator - __non_const_iterator; -public: - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT - : __ptr_(__p.__ptr_) {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const - {return __get_np()->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const - {return pointer_traits::pointer_to(__get_np()->__value_);} - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator++() { - __ptr_ = static_cast<__iter_pointer>( - __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator operator++(int) - {__tree_const_iterator __t(*this); ++(*this); return __t;} - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator--() { - __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>( - static_cast<__end_node_pointer>(__ptr_))); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator operator--(int) - {__tree_const_iterator __t(*this); --(*this); return __t;} - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) - {return __x.__ptr_ == __y.__ptr_;} - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) - {return !(__x == __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT - : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT - : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } - - template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; - template friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; - -}; - -template -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value, - "the specified comparator type does not provide a const call operator") -#endif -int __diagnose_non_const_comparator(); - -template -class __tree -{ -public: - typedef _Tp value_type; - typedef _Compare value_compare; - typedef _Allocator allocator_type; - -private: - typedef allocator_traits __alloc_traits; - typedef typename __make_tree_node_types::type - _NodeTypes; - typedef typename _NodeTypes::key_type key_type; -public: - typedef typename _NodeTypes::__node_value_type __node_value_type; - typedef typename _NodeTypes::__container_value_type __container_value_type; - - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_type; - -public: - typedef typename _NodeTypes::__void_pointer __void_pointer; - - typedef typename _NodeTypes::__node_type __node; - typedef typename _NodeTypes::__node_pointer __node_pointer; - - typedef typename _NodeTypes::__node_base_type __node_base; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - - typedef typename _NodeTypes::__end_node_type __end_node_t; - typedef typename _NodeTypes::__end_node_pointer __end_node_ptr; - - typedef typename _NodeTypes::__parent_pointer __parent_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - - typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; - typedef allocator_traits<__node_allocator> __node_traits; - -private: - // check for sane allocator pointer rebinding semantics. Rebinding the - // allocator for a new pointer type should be exactly the same as rebinding - // the pointer using 'pointer_traits'. - static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type - __node_base_allocator; - typedef allocator_traits<__node_base_allocator> __node_base_traits; - static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - -private: - __iter_pointer __begin_node_; - __compressed_pair<__end_node_t, __node_allocator> __pair1_; - __compressed_pair __pair3_; - -public: - _LIBCPP_INLINE_VISIBILITY - __iter_pointer __end_node() _NOEXCEPT - { - return static_cast<__iter_pointer>( - pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first()) - ); - } - _LIBCPP_INLINE_VISIBILITY - __iter_pointer __end_node() const _NOEXCEPT - { - return static_cast<__iter_pointer>( - pointer_traits<__end_node_ptr>::pointer_to( - const_cast<__end_node_t&>(__pair1_.first()) - ) - ); - } - _LIBCPP_INLINE_VISIBILITY - __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();} -private: - _LIBCPP_INLINE_VISIBILITY - const __node_allocator& __node_alloc() const _NOEXCEPT - {return __pair1_.second();} - _LIBCPP_INLINE_VISIBILITY - __iter_pointer& __begin_node() _NOEXCEPT {return __begin_node_;} - _LIBCPP_INLINE_VISIBILITY - const __iter_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;} -public: - _LIBCPP_INLINE_VISIBILITY - allocator_type __alloc() const _NOEXCEPT - {return allocator_type(__node_alloc());} -private: - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __pair3_.first();} -public: - _LIBCPP_INLINE_VISIBILITY - const size_type& size() const _NOEXCEPT {return __pair3_.first();} - _LIBCPP_INLINE_VISIBILITY - value_compare& value_comp() _NOEXCEPT {return __pair3_.second();} - _LIBCPP_INLINE_VISIBILITY - const value_compare& value_comp() const _NOEXCEPT - {return __pair3_.second();} -public: - - _LIBCPP_INLINE_VISIBILITY - __node_pointer __root() const _NOEXCEPT - {return static_cast<__node_pointer>(__end_node()->__left_);} - - __node_base_pointer* __root_ptr() const _NOEXCEPT { - return _VSTD::addressof(__end_node()->__left_); - } - - typedef __tree_iterator iterator; - typedef __tree_const_iterator const_iterator; - - explicit __tree(const value_compare& __comp) - _NOEXCEPT_( - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_copy_constructible::value); - explicit __tree(const allocator_type& __a); - __tree(const value_compare& __comp, const allocator_type& __a); - __tree(const __tree& __t); - __tree& operator=(const __tree& __t); - template - void __assign_unique(_InputIterator __first, _InputIterator __last); - template - void __assign_multi(_InputIterator __first, _InputIterator __last); -#ifndef _LIBCPP_CXX03_LANG - __tree(__tree&& __t) - _NOEXCEPT_( - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value); - __tree(__tree&& __t, const allocator_type& __a); - __tree& operator=(__tree&& __t) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value); -#endif // _LIBCPP_CXX03_LANG - - ~__tree(); - - _LIBCPP_INLINE_VISIBILITY - iterator begin() _NOEXCEPT {return iterator(__begin_node());} - _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());} - _LIBCPP_INLINE_VISIBILITY - iterator end() _NOEXCEPT {return iterator(__end_node());} - _LIBCPP_INLINE_VISIBILITY - const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());} - - _LIBCPP_INLINE_VISIBILITY - size_type max_size() const _NOEXCEPT - {return std::min( - __node_traits::max_size(__node_alloc()), - numeric_limits::max());} - - void clear() _NOEXCEPT; - - void swap(__tree& __t) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_( - __is_nothrow_swappable::value - && (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - ); -#else - _NOEXCEPT_(__is_nothrow_swappable::value); -#endif - -#ifndef _LIBCPP_CXX03_LANG - template - pair - __emplace_unique_key_args(_Key const&, _Args&&... __args); - template - iterator - __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...); - - template - pair __emplace_unique_impl(_Args&&... __args); - - template - iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args); - - template - iterator __emplace_multi(_Args&&... __args); - - template - iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Pp&& __x) { - return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { - return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Args&&... __args) { - return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { - return __emplace_unique_impl(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { - return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { - return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) { - return __emplace_hint_unique_extract_key(__p, _VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - iterator - >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { - return __emplace_hint_unique_key_args(__p, __f, - _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) { - return __emplace_hint_unique_impl(__p, _VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) { - return __emplace_hint_unique_impl(__p, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) { - return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) { - return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x)); - } - -#else - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const&, _Args& __args); - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&); -#endif - - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(const __container_value_type& __v) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, const __container_value_type& __v) { - return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v); - } - -#ifdef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const __container_value_type& __v); - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, const __container_value_type& __v); -#else - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(__container_value_type&& __v) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, __container_value_type&& __v) { - return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)); - } - - template ::type, - __container_value_type - >::value - >::type> - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(_Vp&& __v) { - return __emplace_unique(_VSTD::forward<_Vp>(__v)); - } - - template ::type, - __container_value_type - >::value - >::type> - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, _Vp&& __v) { - return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(__container_value_type&& __v) { - return __emplace_multi(_VSTD::move(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, __container_value_type&& __v) { - return __emplace_hint_multi(__p, _VSTD::move(__v)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(_Vp&& __v) { - return __emplace_multi(_VSTD::forward<_Vp>(__v)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, _Vp&& __v) { - return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v)); - } - -#endif // !_LIBCPP_CXX03_LANG - - _LIBCPP_INLINE_VISIBILITY - pair __node_insert_unique(__node_pointer __nd); - _LIBCPP_INLINE_VISIBILITY - iterator __node_insert_unique(const_iterator __p, - __node_pointer __nd); - - _LIBCPP_INLINE_VISIBILITY - iterator __node_insert_multi(__node_pointer __nd); - _LIBCPP_INLINE_VISIBILITY - iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); - - - _LIBCPP_INLINE_VISIBILITY iterator - __remove_node_pointer(__node_pointer) _NOEXCEPT; - -#if _LIBCPP_STD_VER > 14 - template - _LIBCPP_INLINE_VISIBILITY - _InsertReturnType __node_handle_insert_unique(_NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - void __node_handle_merge_unique(_Tree& __source); - - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(_NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - void __node_handle_merge_multi(_Tree& __source); - - - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(key_type const&); - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(const_iterator); -#endif - - iterator erase(const_iterator __p); - iterator erase(const_iterator __f, const_iterator __l); - template - size_type __erase_unique(const _Key& __k); - template - size_type __erase_multi(const _Key& __k); - - void __insert_node_at(__parent_pointer __parent, - __node_base_pointer& __child, - __node_base_pointer __new_node) _NOEXCEPT; - - template - iterator find(const _Key& __v); - template - const_iterator find(const _Key& __v) const; - - template - size_type __count_unique(const _Key& __k) const; - template - size_type __count_multi(const _Key& __k) const; - - template - _LIBCPP_INLINE_VISIBILITY - iterator lower_bound(const _Key& __v) - {return __lower_bound(__v, __root(), __end_node());} - template - iterator __lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result); - template - _LIBCPP_INLINE_VISIBILITY - const_iterator lower_bound(const _Key& __v) const - {return __lower_bound(__v, __root(), __end_node());} - template - const_iterator __lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const; - template - _LIBCPP_INLINE_VISIBILITY - iterator upper_bound(const _Key& __v) - {return __upper_bound(__v, __root(), __end_node());} - template - iterator __upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result); - template - _LIBCPP_INLINE_VISIBILITY - const_iterator upper_bound(const _Key& __v) const - {return __upper_bound(__v, __root(), __end_node());} - template - const_iterator __upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const; - template - pair - __equal_range_unique(const _Key& __k); - template - pair - __equal_range_unique(const _Key& __k) const; - - template - pair - __equal_range_multi(const _Key& __k); - template - pair - __equal_range_multi(const _Key& __k) const; - - typedef __tree_node_destructor<__node_allocator> _Dp; - typedef unique_ptr<__node, _Dp> __node_holder; - - __node_holder remove(const_iterator __p) _NOEXCEPT; -private: - __node_base_pointer& - __find_leaf_low(__parent_pointer& __parent, const key_type& __v); - __node_base_pointer& - __find_leaf_high(__parent_pointer& __parent, const key_type& __v); - __node_base_pointer& - __find_leaf(const_iterator __hint, - __parent_pointer& __parent, const key_type& __v); - // FIXME: Make this function const qualified. Unfortunetly doing so - // breaks existing code which uses non-const callable comparators. - template - __node_base_pointer& - __find_equal(__parent_pointer& __parent, const _Key& __v); - template - _LIBCPP_INLINE_VISIBILITY __node_base_pointer& - __find_equal(__parent_pointer& __parent, const _Key& __v) const { - return const_cast<__tree*>(this)->__find_equal(__parent, __v); - } - template - __node_base_pointer& - __find_equal(const_iterator __hint, __parent_pointer& __parent, - __node_base_pointer& __dummy, - const _Key& __v); - -#ifndef _LIBCPP_CXX03_LANG - template - __node_holder __construct_node(_Args&& ...__args); -#else - __node_holder __construct_node(const __container_value_type& __v); -#endif - - void destroy(__node_pointer __nd) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree& __t) - {__copy_assign_alloc(__t, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree& __t, true_type) - { - if (__node_alloc() != __t.__node_alloc()) - clear(); - __node_alloc() = __t.__node_alloc(); - } - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree&, false_type) {} - - void __move_assign(__tree& __t, false_type); - void __move_assign(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value); - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree& __t) - _NOEXCEPT_( - !__node_traits::propagate_on_container_move_assignment::value || - is_nothrow_move_assignable<__node_allocator>::value) - {__move_assign_alloc(__t, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) - {__node_alloc() = _VSTD::move(__t.__node_alloc());} - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} - - __node_pointer __detach(); - static __node_pointer __detach(__node_pointer); - - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; -}; - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) - _NOEXCEPT_( - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_copy_constructible::value) - : __pair3_(0, __comp) -{ - __begin_node() = __end_node(); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0) -{ - __begin_node() = __end_node(); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, - const allocator_type& __a) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0, __comp) -{ - __begin_node() = __end_node(); -} - -// Precondition: size() != 0 -template -typename __tree<_Tp, _Compare, _Allocator>::__node_pointer -__tree<_Tp, _Compare, _Allocator>::__detach() -{ - __node_pointer __cache = static_cast<__node_pointer>(__begin_node()); - __begin_node() = __end_node(); - __end_node()->__left_->__parent_ = nullptr; - __end_node()->__left_ = nullptr; - size() = 0; - // __cache->__left_ == nullptr - if (__cache->__right_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__right_); - // __cache->__left_ == nullptr - // __cache->__right_ == nullptr - return __cache; -} - -// Precondition: __cache != nullptr -// __cache->left_ == nullptr -// __cache->right_ == nullptr -// This is no longer a red-black tree -template -typename __tree<_Tp, _Compare, _Allocator>::__node_pointer -__tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache) -{ - if (__cache->__parent_ == nullptr) - return nullptr; - if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) - { - __cache->__parent_->__left_ = nullptr; - __cache = static_cast<__node_pointer>(__cache->__parent_); - if (__cache->__right_ == nullptr) - return __cache; - return static_cast<__node_pointer>(__tree_leaf(__cache->__right_)); - } - // __cache is right child - __cache->__parent_unsafe()->__right_ = nullptr; - __cache = static_cast<__node_pointer>(__cache->__parent_); - if (__cache->__left_ == nullptr) - return __cache; - return static_cast<__node_pointer>(__tree_leaf(__cache->__left_)); -} - -template -__tree<_Tp, _Compare, _Allocator>& -__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) -{ - if (this != &__t) - { - value_comp() = __t.value_comp(); - __copy_assign_alloc(__t); - __assign_multi(__t.begin(), __t.end()); - } - return *this; -} - -template -template -void -__tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value), - "__assign_unique may only be called with the containers value type"); - - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__value_ = *__first; - __node_pointer __next = __detach(__cache); - __node_insert_unique(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - for (; __first != __last; ++__first) - __insert_unique(*__first); -} - -template -template -void -__tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value || - is_same<_ItValueType, __node_value_type>::value), - "__assign_multi may only be called with the containers value type" - " or the nodes value type"); - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__value_ = *__first; - __node_pointer __next = __detach(__cache); - __node_insert_multi(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - for (; __first != __last; ++__first) - __insert_multi(_NodeTypes::__get_value(*__first)); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), - __pair3_(0, __t.value_comp()) -{ - __begin_node() = __end_node(); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) - _NOEXCEPT_( - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value) - : __begin_node_(_VSTD::move(__t.__begin_node_)), - __pair1_(_VSTD::move(__t.__pair1_)), - __pair3_(_VSTD::move(__t.__pair3_)) -{ - if (size() == 0) - __begin_node() = __end_node(); - else - { - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) - : __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0, _VSTD::move(__t.value_comp())) -{ - if (__a == __t.__alloc()) - { - if (__t.size() == 0) - __begin_node() = __end_node(); - else - { - __begin_node() = __t.__begin_node(); - __end_node()->__left_ = __t.__end_node()->__left_; - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - size() = __t.size(); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } - } - else - { - __begin_node() = __end_node(); - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value) -{ - destroy(static_cast<__node_pointer>(__end_node()->__left_)); - __begin_node_ = __t.__begin_node_; - __pair1_.first() = __t.__pair1_.first(); - __move_assign_alloc(__t); - __pair3_ = _VSTD::move(__t.__pair3_); - if (size() == 0) - __begin_node() = __end_node(); - else - { - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) -{ - if (__node_alloc() == __t.__node_alloc()) - __move_assign(__t, true_type()); - else - { - value_comp() = _VSTD::move(__t.value_comp()); - const_iterator __e = end(); - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - while (__cache != nullptr && __t.size() != 0) - { - __cache->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_); - __node_pointer __next = __detach(__cache); - __node_insert_multi(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - while (__t.size() != 0) - __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_)); - } -} - -template -__tree<_Tp, _Compare, _Allocator>& -__tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value) - -{ - __move_assign(__t, integral_constant()); - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -__tree<_Tp, _Compare, _Allocator>::~__tree() -{ - static_assert((is_copy_constructible::value), - "Comparator must be copy-constructible."); - destroy(__root()); -} - -template -void -__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT -{ - if (__nd != nullptr) - { - destroy(static_cast<__node_pointer>(__nd->__left_)); - destroy(static_cast<__node_pointer>(__nd->__right_)); - __node_allocator& __na = __node_alloc(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_)); - __node_traits::deallocate(__na, __nd, 1); - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_( - __is_nothrow_swappable::value - && (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - ) -#else - _NOEXCEPT_(__is_nothrow_swappable::value) -#endif -{ - using _VSTD::swap; - swap(__begin_node_, __t.__begin_node_); - swap(__pair1_.first(), __t.__pair1_.first()); - __swap_allocator(__node_alloc(), __t.__node_alloc()); - __pair3_.swap(__t.__pair3_); - if (size() == 0) - __begin_node() = __end_node(); - else - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - if (__t.size() == 0) - __t.__begin_node() = __t.__end_node(); - else - __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node()); -} - -template -void -__tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT -{ - destroy(__root()); - size() = 0; - __begin_node() = __end_node(); - __end_node()->__left_ = nullptr; -} - -// Find lower_bound place to insert -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, - const key_type& __v) -{ - __node_pointer __nd = __root(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__nd->__value_, __v)) - { - if (__nd->__right_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__right_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - else - { - if (__nd->__left_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__left_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find upper_bound place to insert -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, - const key_type& __v) -{ - __node_pointer __nd = __root(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__v, __nd->__value_)) - { - if (__nd->__left_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__left_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - else - { - if (__nd->__right_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__right_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find leaf place to insert closest to __hint -// First check prior to __hint. -// Next check after __hint. -// Next do O(log N) search. -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, - __parent_pointer& __parent, - const key_type& __v) -{ - if (__hint == end() || !value_comp()(*__hint, __v)) // check before - { - // __v <= *__hint - const_iterator __prior = __hint; - if (__prior == begin() || !value_comp()(__v, *--__prior)) - { - // *prev(__hint) <= __v <= *__hint - if (__hint.__ptr_->__left_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return __parent->__left_; - } - else - { - __parent = static_cast<__parent_pointer>(__prior.__ptr_); - return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; - } - } - // __v < *prev(__hint) - return __find_leaf_high(__parent, __v); - } - // else __v > *__hint - return __find_leaf_low(__parent, __v); -} - -// Find place to insert if __v doesn't exist -// Set __parent to parent of null leaf -// Return reference to null leaf -// If __v exists, set parent to node of __v and return reference to node of __v -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, - const _Key& __v) -{ - __node_pointer __nd = __root(); - __node_base_pointer* __nd_ptr = __root_ptr(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__v, __nd->__value_)) - { - if (__nd->__left_ != nullptr) { - __nd_ptr = _VSTD::addressof(__nd->__left_); - __nd = static_cast<__node_pointer>(__nd->__left_); - } else { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - else if (value_comp()(__nd->__value_, __v)) - { - if (__nd->__right_ != nullptr) { - __nd_ptr = _VSTD::addressof(__nd->__right_); - __nd = static_cast<__node_pointer>(__nd->__right_); - } else { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - else - { - __parent = static_cast<__parent_pointer>(__nd); - return *__nd_ptr; - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find place to insert if __v doesn't exist -// First check prior to __hint. -// Next check after __hint. -// Next do O(log N) search. -// Set __parent to parent of null leaf -// Return reference to null leaf -// If __v exists, set parent to node of __v and return reference to node of __v -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, - __parent_pointer& __parent, - __node_base_pointer& __dummy, - const _Key& __v) -{ - if (__hint == end() || value_comp()(__v, *__hint)) // check before - { - // __v < *__hint - const_iterator __prior = __hint; - if (__prior == begin() || value_comp()(*--__prior, __v)) - { - // *prev(__hint) < __v < *__hint - if (__hint.__ptr_->__left_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return __parent->__left_; - } - else - { - __parent = static_cast<__parent_pointer>(__prior.__ptr_); - return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; - } - } - // __v <= *prev(__hint) - return __find_equal(__parent, __v); - } - else if (value_comp()(*__hint, __v)) // check after - { - // *__hint < __v - const_iterator __next = _VSTD::next(__hint); - if (__next == end() || value_comp()(__v, *__next)) - { - // *__hint < __v < *_VSTD::next(__hint) - if (__hint.__get_np()->__right_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_; - } - else - { - __parent = static_cast<__parent_pointer>(__next.__ptr_); - return __parent->__left_; - } - } - // *next(__hint) <= __v - return __find_equal(__parent, __v); - } - // else __v == *__hint - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); - return __dummy; -} - -template -void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( - __parent_pointer __parent, __node_base_pointer& __child, - __node_base_pointer __new_node) _NOEXCEPT -{ - __new_node->__left_ = nullptr; - __new_node->__right_ = nullptr; - __new_node->__parent_ = __parent; - // __new_node->__is_black_ is initialized in __tree_balance_after_insert - __child = __new_node; - if (__begin_node()->__left_ != nullptr) - __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_); - __tree_balance_after_insert(__end_node()->__left_, __child); - ++size(); -} - -#ifndef _LIBCPP_CXX03_LANG -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) -#else -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args& __args) -#endif -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __k); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node(__args); -#endif - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - - -#ifndef _LIBCPP_CXX03_LANG -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( - const_iterator __p, _Key const& __k, _Args&&... __args) -#else -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( - const_iterator __p, _Key const& __k, _Args& __args) -#endif -{ - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node(__args); -#endif - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - } - return iterator(__r); -} - - -#ifndef _LIBCPP_CXX03_LANG - -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&& ...__args) -{ - static_assert(!__is_tree_value_type<_Args...>::value, - "Cannot construct from __value_type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...); - __h.get_deleter().__value_constructed = true; - return __h; -} - - -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __h->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - } - return iterator(__r); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(static_cast<__node_pointer>(__h.release())); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, - _Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(static_cast<__node_pointer>(__h.release())); -} - - -#else // _LIBCPP_CXX03_LANG - -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::__construct_node(const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -#endif // _LIBCPP_CXX03_LANG - -#ifdef _LIBCPP_CXX03_LANG -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__insert_multi(const __container_value_type& __v) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__v)); - __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(__h.release()); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __container_value_type& __v) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__v)); - __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(__h.release()); -} -#endif - -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __nd->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - __r = __nd; - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p, - __node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __nd->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - __r = __nd; - } - return iterator(__r); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - return iterator(__nd); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, - __node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - return iterator(__nd); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT -{ - iterator __r(__ptr); - ++__r; - if (__begin_node() == __ptr) - __begin_node() = __r.__ptr_; - --size(); - __tree_remove(__end_node()->__left_, - static_cast<__node_base_pointer>(__ptr)); - return __r; -} - -#if _LIBCPP_STD_VER > 14 -template -template -_LIBCPP_INLINE_VISIBILITY -_InsertReturnType -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return _InsertReturnType{end(), false, _NodeHandle()}; - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, - __ptr->__value_); - if (__child != nullptr) - return _InsertReturnType{ - iterator(static_cast<__node_pointer>(__child)), - false, _VSTD::move(__nh)}; - - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return _InsertReturnType{iterator(__ptr), true, _NodeHandle()}; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, - __ptr->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__ptr)); - __r = __ptr; - __nh.__release(); - } - return iterator(__r); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) -{ - iterator __it = find(__key); - if (__it == end()) - return _NodeHandle(); - return __node_handle_extract<_NodeHandle>(__it); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) -{ - __node_pointer __np = __p.__get_np(); - __remove_node_pointer(__np); - return _NodeHandle(__np, __alloc()); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -void -__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(_Tree& __source) -{ - static_assert(is_same::value, ""); - - for (typename _Tree::iterator __i = __source.begin(); - __i != __source.end();) - { - __node_pointer __src_ptr = __i.__get_np(); - __parent_pointer __parent; - __node_base_pointer& __child = - __find_equal(__parent, _NodeTypes::__get_key(__src_ptr->__value_)); - ++__i; - if (__child != nullptr) - continue; - __source.__remove_node_pointer(__src_ptr); - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__src_ptr)); - } -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high( - __parent, _NodeTypes::__get_key(__ptr->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return iterator(__ptr); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__hint, __parent, - _NodeTypes::__get_key(__ptr->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return iterator(__ptr); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -void -__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source) -{ - static_assert(is_same::value, ""); - - for (typename _Tree::iterator __i = __source.begin(); - __i != __source.end();) - { - __node_pointer __src_ptr = __i.__get_np(); - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high( - __parent, _NodeTypes::__get_key(__src_ptr->__value_)); - ++__i; - __source.__remove_node_pointer(__src_ptr); - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__src_ptr)); - } -} - -#endif // _LIBCPP_STD_VER > 14 - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) -{ - __node_pointer __np = __p.__get_np(); - iterator __r = __remove_node_pointer(__np); - __node_allocator& __na = __node_alloc(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr( - const_cast<__node_value_type&>(*__p))); - __node_traits::deallocate(__na, __np, 1); - return __r; -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) -{ - while (__f != __l) - __f = erase(__f); - return iterator(__l.__ptr_); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) -{ - iterator __i = find(__k); - if (__i == end()) - return 0; - erase(__i); - return 1; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) -{ - pair __p = __equal_range_multi(__k); - size_type __r = 0; - for (; __p.first != __p.second; ++__r) - __p.first = erase(__p.first); - return __r; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) -{ - iterator __p = __lower_bound(__v, __root(), __end_node()); - if (__p != end() && !value_comp()(__v, *__p)) - return __p; - return end(); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const -{ - const_iterator __p = __lower_bound(__v, __root(), __end_node()); - if (__p != end() && !value_comp()(__v, *__p)) - return __p; - return end(); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const -{ - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return 1; - } - return 0; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const -{ - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _VSTD::distance( - __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result) - ); - } - return 0; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) -{ - while (__root != nullptr) - { - if (!value_comp()(__root->__value_, __v)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const -{ - while (__root != nullptr) - { - if (!value_comp()(__root->__value_, __v)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return const_iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) -{ - while (__root != nullptr) - { - if (value_comp()(__v, __root->__value_)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const -{ - while (__root != nullptr) - { - if (value_comp()(__v, __root->__value_)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return const_iterator(__result); -} - -template -template -pair::iterator, - typename __tree<_Tp, _Compare, _Allocator>::iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(iterator(__rt), - iterator( - __rt->__right_ != nullptr ? - static_cast<__iter_pointer>(__tree_min(__rt->__right_)) - : __result)); - } - return _Pp(iterator(__result), iterator(__result)); -} - -template -template -pair::const_iterator, - typename __tree<_Tp, _Compare, _Allocator>::const_iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(const_iterator(__rt), - const_iterator( - __rt->__right_ != nullptr ? - static_cast<__iter_pointer>(__tree_min(__rt->__right_)) - : __result)); - } - return _Pp(const_iterator(__result), const_iterator(__result)); -} - -template -template -pair::iterator, - typename __tree<_Tp, _Compare, _Allocator>::iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); - } - return _Pp(iterator(__result), iterator(__result)); -} - -template -template -pair::const_iterator, - typename __tree<_Tp, _Compare, _Allocator>::const_iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); - } - return _Pp(const_iterator(__result), const_iterator(__result)); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT -{ - __node_pointer __np = __p.__get_np(); - if (__begin_node() == __p.__ptr_) - { - if (__np->__right_ != nullptr) - __begin_node() = static_cast<__iter_pointer>(__np->__right_); - else - __begin_node() = static_cast<__iter_pointer>(__np->__parent_); - } - --size(); - __tree_remove(__end_node()->__left_, - static_cast<__node_base_pointer>(__np)); - return __node_holder(__np, _Dp(__node_alloc(), true)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__tree<_Tp, _Compare, _Allocator>& __x, - __tree<_Tp, _Compare, _Allocator>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___TREE diff --git a/clang-r353983c/include/c++/v1/__tuple b/clang-r353983c/include/c++/v1/__tuple deleted file mode 100644 index 89134b5d2e901efaea8da275299d4b8790f0d4f0..0000000000000000000000000000000000000000 --- a/clang-r353983c/include/c++/v1/__tuple +++ /dev/null @@ -1,555 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TUPLE -#define _LIBCPP___TUPLE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template struct _LIBCPP_TEMPLATE_VIS tuple_size; - -#if !defined(_LIBCPP_CXX03_LANG) -template -using __enable_if_tuple_size_imp = _Tp; - -template -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const _Tp, - typename enable_if::value>::type, - integral_constant)>>> - : public integral_constant::value> {}; - -template -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - volatile _Tp, - typename enable_if::value>::type, - integral_constant)>>> - : public integral_constant::value> {}; - -template -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const volatile _Tp, - integral_constant)>>> - : public integral_constant::value> {}; - -#else -template struct _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -template struct _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -template struct _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -#endif - -template class _LIBCPP_TEMPLATE_VIS tuple_element; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> -{ -public: - typedef typename add_const::type>::type type; -}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> -{ -public: - typedef typename add_volatile::type>::type type; -}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> -{ -public: - typedef typename add_cv::type>::type type; -}; - -template struct __tuple_like : false_type {}; - -template struct __tuple_like : public __tuple_like<_Tp> {}; -template struct __tuple_like : public __tuple_like<_Tp> {}; -template struct __tuple_like : public __tuple_like<_Tp> {}; - -// tuple specializations - -#ifndef _LIBCPP_CXX03_LANG - -template struct __tuple_indices {}; - -template -struct __integer_sequence { - template