aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-08-13 15:37:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:04:56 +0000
commit61cfbce3347e4372143bcabf7b197577b9f3958a (patch)
treea996b7140fcecf4ec110b2ac28983b858e5df637
parent972a253a57b6f144b0e4a3e2080a2a0076ec55a0 (diff)
parent677727e8296a802385345db6fa65e68223f4597a (diff)
downloadsrc-61cfbce3347e4372143bcabf7b197577b9f3958a.tar.gz
src-61cfbce3347e4372143bcabf7b197577b9f3958a.zip
Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d. PR: 265425 MFC after: 2 weeks
-rwxr-xr-xcontrib/llvm-project/clang/include/clang/AST/DeclTemplate.h8
-rw-r--r--contrib/llvm-project/clang/include/clang/Basic/Module.h5
-rw-r--r--contrib/llvm-project/clang/include/clang/Sema/Sema.h2
-rw-r--r--contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h3
-rw-r--r--contrib/llvm-project/clang/lib/AST/APValue.cpp8
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp2
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/X86.h4
-rw-r--r--contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp8
-rw-r--r--contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp15
-rw-r--r--contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp10
-rw-r--r--contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp13
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp25
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h3
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp21
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp11
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp10
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp2
-rw-r--r--contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp76
-rw-r--r--contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp5
-rw-r--r--contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp8
-rw-r--r--contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp89
-rw-r--r--contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h2
-rw-r--r--contrib/llvm-project/compiler-rt/lib/builtins/int_types.h2
-rw-r--r--contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h32
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/clamp.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy.h10
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill_n.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h3
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h91
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h259
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h83
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/make_heap.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/make_projected.h98
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move.h26
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move_backward.h38
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h36
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h10
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h42
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h36
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/push_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h65
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_inplace_merge.h52
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_is_permutation.h89
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_make_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h15
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_move_backward.h5
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_next_permutation.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_nth_element.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort_copy.h19
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_partition.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_pop_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h76
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_push_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h55
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy_if.h58
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h69
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy_if.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate.h71
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_sample.h74
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_shuffle.h34
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_sort.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_sort_heap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_partition.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_sort.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_swap_ranges.h11
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_unique.h46
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_unique_copy.h73
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/reverse.h23
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/rotate.h57
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sample.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sift_down.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h62
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unique.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h147
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h97
-rw-r--r--contrib/llvm-project/libcxx/include/__assert11
-rw-r--r--contrib/llvm-project/libcxx/include/__availability41
-rw-r--r--contrib/llvm-project/libcxx/include/__bit_reference243
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h1
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h7
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h14
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/construct_at.h3
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/pointer_traits.h28
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h7
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/size.h1
-rw-r--r--contrib/llvm-project/libcxx/include/__split_buffer134
-rw-r--r--contrib/llvm-project/libcxx/include/__verbose_abort51
-rw-r--r--contrib/llvm-project/libcxx/include/algorithm219
-rw-r--r--contrib/llvm-project/libcxx/include/format101
-rw-r--r--contrib/llvm-project/libcxx/include/memory26
-rw-r--r--contrib/llvm-project/libcxx/include/module.modulemap.in16
-rw-r--r--contrib/llvm-project/libcxx/include/vector557
-rw-r--r--contrib/llvm-project/libcxx/include/version8
-rw-r--r--contrib/llvm-project/libcxx/src/include/sso_allocator.h5
-rw-r--r--contrib/llvm-project/libcxx/src/verbose_abort.cpp (renamed from contrib/llvm-project/libcxx/src/assert.cpp)22
-rw-r--r--contrib/llvm-project/lld/COFF/Driver.cpp17
-rw-r--r--contrib/llvm-project/lld/COFF/Driver.h4
-rw-r--r--contrib/llvm-project/lld/COFF/DriverUtils.cpp3
-rw-r--r--contrib/llvm-project/lld/COFF/MinGW.cpp10
-rw-r--r--contrib/llvm-project/lld/COFF/MinGW.h6
-rw-r--r--contrib/llvm-project/lld/COFF/Options.td2
-rw-r--r--contrib/llvm-project/lld/COFF/PDB.cpp4
-rw-r--r--contrib/llvm-project/lld/ELF/Arch/AArch64.cpp4
-rw-r--r--contrib/llvm-project/lld/ELF/Config.h1
-rw-r--r--contrib/llvm-project/lld/ELF/Driver.cpp6
-rw-r--r--contrib/llvm-project/lld/ELF/Options.td2
-rw-r--r--contrib/llvm-project/lld/ELF/Relocations.cpp3
-rw-r--r--contrib/llvm-project/lld/ELF/SyntheticSections.cpp17
-rw-r--r--contrib/llvm-project/lld/ELF/SyntheticSections.h10
-rw-r--r--contrib/llvm-project/lld/ELF/Writer.cpp5
-rw-r--r--contrib/llvm-project/lld/MachO/Arch/ARM64.cpp2
-rw-r--r--contrib/llvm-project/lld/MachO/DriverUtils.cpp2
-rw-r--r--contrib/llvm-project/lld/MachO/EhFrame.cpp10
-rw-r--r--contrib/llvm-project/lld/MachO/EhFrame.h8
-rw-r--r--contrib/llvm-project/lld/MachO/InputFiles.cpp118
-rw-r--r--contrib/llvm-project/lld/MachO/InputFiles.h17
-rw-r--r--contrib/llvm-project/lld/MachO/UnwindInfoSection.cpp8
-rw-r--r--contrib/llvm-project/lld/MachO/Writer.cpp122
-rw-r--r--contrib/llvm-project/lld/docs/ReleaseNotes.rst144
-rw-r--r--contrib/llvm-project/lldb/source/Core/Disassembler.cpp1
-rw-r--r--contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h9
-rw-r--r--contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h2
-rw-r--r--contrib/llvm-project/llvm/include/llvm/BinaryFormat/ELF.h1
-rw-r--r--contrib/llvm-project/llvm/include/llvm/CodeGen/ISDOpcodes.h5
-rw-r--r--contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeView.h3
-rw-r--r--contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h3
-rw-r--r--contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h3
-rw-r--r--contrib/llvm-project/llvm/include/llvm/IR/Type.h5
-rw-r--r--contrib/llvm-project/llvm/include/llvm/Support/ErrorHandling.h6
-rw-r--r--contrib/llvm-project/llvm/include/llvm/Support/Host.h1
-rw-r--r--contrib/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp4
-rw-r--r--contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp4
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp2
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp45
-rw-r--r--contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp7
-rw-r--r--contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp1
-rw-r--r--contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp22
-rw-r--r--contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp7
-rw-r--r--contrib/llvm-project/llvm/lib/Support/Host.cpp108
-rw-r--r--contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp47
-rw-r--r--contrib/llvm-project/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h4
-rw-r--r--contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp2
-rw-r--r--contrib/llvm-project/llvm/lib/Target/ARM/ARM.td9
-rw-r--r--contrib/llvm-project/llvm/lib/Target/ARM/ARMISelLowering.cpp3
-rw-r--r--contrib/llvm-project/llvm/lib/Target/PowerPC/PPCFastISel.cpp5
-rw-r--r--contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp8
-rw-r--r--contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp25
-rw-r--r--contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp96
-rw-r--r--contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.h12
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp13
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/IPO/OpenMPOpt.cpp12
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp8
-rw-r--r--contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp15
-rw-r--r--contrib/llvm-project/llvm/tools/lli/lli.cpp3
-rw-r--r--contrib/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp33
-rw-r--r--contrib/llvm-project/openmp/runtime/src/kmp_dispatch.cpp2
-rw-r--r--lib/clang/include/VCSVersion.inc6
-rw-r--r--lib/clang/include/lld/Common/Version.inc2
-rw-r--r--lib/clang/include/llvm/Support/VCSRevision.h2
-rw-r--r--lib/clang/libllvm/Makefile4
-rw-r--r--lib/libc++/Makefile11
-rw-r--r--sys/conf/kern.mk5
173 files changed, 3752 insertions, 1469 deletions
diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
index 725bb0bced9c..baed5ca22fa7 100755
--- a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
+++ b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@ public:
return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
}
- ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
- const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+ ConceptDecl *getCanonicalDecl() override {
+ return cast<ConceptDecl>(getPrimaryMergedDecl(this));
+ }
+ const ConceptDecl *getCanonicalDecl() const {
+ return const_cast<ConceptDecl *>(this)->getCanonicalDecl();
+ }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
diff --git a/contrib/llvm-project/clang/include/clang/Basic/Module.h b/contrib/llvm-project/clang/include/clang/Basic/Module.h
index 47d736a3b455..8ef1c5991c56 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/Module.h
+++ b/contrib/llvm-project/clang/include/clang/Basic/Module.h
@@ -525,6 +525,11 @@ public:
Parent->SubModules.push_back(this);
}
+ /// Is this module have similar semantics as headers.
+ bool isHeaderLikeModule() const {
+ return isModuleMapModule() || isHeaderUnit();
+ }
+
/// Is this a module partition.
bool isModulePartition() const {
return Kind == ModulePartitionInterface ||
diff --git a/contrib/llvm-project/clang/include/clang/Sema/Sema.h b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
index 06ea0b417cb3..681a76dfa56a 100644
--- a/contrib/llvm-project/clang/include/clang/Sema/Sema.h
+++ b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
@@ -4479,6 +4479,8 @@ public:
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old);
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old);
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old);
+ bool IsRedefinitionInModule(const NamedDecl *New,
+ const NamedDecl *Old) const;
void DiagnoseAmbiguousLookup(LookupResult &Result);
//@}
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
index cc4ced02876e..dee2744516d5 100644
--- a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
+++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
@@ -1738,7 +1738,8 @@ public:
const LangOptions &LangOpts,
const TargetOptions &TargetOpts,
const PreprocessorOptions &PPOpts,
- StringRef ExistingModuleCachePath);
+ StringRef ExistingModuleCachePath,
+ bool RequireStrictOptionMatches = false);
/// Returns the suggested contents of the predefines buffer,
/// which contains a (typically-empty) subset of the predefines
diff --git a/contrib/llvm-project/clang/lib/AST/APValue.cpp b/contrib/llvm-project/clang/lib/AST/APValue.cpp
index a22031142c7c..d522c87388a5 100644
--- a/contrib/llvm-project/clang/lib/AST/APValue.cpp
+++ b/contrib/llvm-project/clang/lib/AST/APValue.cpp
@@ -637,10 +637,10 @@ static bool TryPrintAsStringLiteral(raw_ostream &Out,
return false;
// Nothing we can do about a sequence that is not null-terminated
- if (!Inits.back().getInt().isZero())
+ if (!Inits.back().isInt() || !Inits.back().getInt().isZero())
return false;
- else
- Inits = Inits.drop_back();
+
+ Inits = Inits.drop_back();
llvm::SmallString<40> Buf;
Buf.push_back('"');
@@ -655,6 +655,8 @@ static bool TryPrintAsStringLiteral(raw_ostream &Out,
}
for (auto &Val : Inits) {
+ if (!Val.isInt())
+ return false;
int64_t Char64 = Val.getInt().getExtValue();
if (!isASCII(Char64))
return false; // Bye bye, see you in integers.
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
index 69afdf8a3584..0f5c366816df 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
@@ -358,6 +358,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasFloat16 = SSELevel >= SSE2;
+ HasBFloat16 = SSELevel >= SSE2;
+
MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch<MMX3DNowEnum>(Feature)
.Case("+3dnowa", AMD3DNowAthlon)
.Case("+3dnow", AMD3DNow)
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
index 224145f4b020..136047a5055c 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
@@ -156,6 +156,8 @@ protected:
public:
X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
: TargetInfo(Triple) {
+ BFloat16Width = BFloat16Align = 16;
+ BFloat16Format = &llvm::APFloat::BFloat();
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
AddrSpaceMap = &X86AddrSpaceMap;
HasStrictFP = true;
@@ -400,6 +402,8 @@ public:
uint64_t getPointerAlignV(unsigned AddrSpace) const override {
return getPointerWidthV(AddrSpace);
}
+
+ const char *getBFloat16Mangling() const override { return "u6__bf16"; };
};
// X86-32 generic target
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp b/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
index 949112c63cc9..6915f950b6ce 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -649,8 +649,8 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
SmallVector<llvm::Function *, 8> ModuleInits;
for (Module *M : AllImports) {
- // No Itanium initializer in module map modules.
- if (M->isModuleMapModule())
+ // No Itanium initializer in header like modules.
+ if (M->isHeaderLikeModule())
continue; // TODO: warn of mixed use of module map modules and C++20?
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
SmallString<256> FnName;
@@ -778,8 +778,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
SmallVector<llvm::Function *, 8> ModuleInits;
if (CXX20ModuleInits)
for (Module *M : ImportedModules) {
- // No Itanium initializer in module map modules.
- if (M->isModuleMapModule())
+ // No Itanium initializer in header like modules.
+ if (M->isHeaderLikeModule())
continue;
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
SmallString<256> FnName;
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp b/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
index 05ab16668743..481438de0e53 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
@@ -2343,6 +2343,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
std::vector<llvm::Type *> ArgElemTypes;
std::vector<llvm::Value*> Args;
llvm::BitVector ResultTypeRequiresCast;
+ llvm::BitVector ResultRegIsFlagReg;
// Keep track of inout constraints.
std::string InOutConstraints;
@@ -2400,6 +2401,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
ResultRegQualTys.push_back(QTy);
ResultRegDests.push_back(Dest);
+ bool IsFlagReg = llvm::StringRef(OutputConstraint).startswith("{@cc");
+ ResultRegIsFlagReg.push_back(IsFlagReg);
+
llvm::Type *Ty = ConvertTypeForMem(QTy);
const bool RequiresCast = Info.allowsRegister() &&
(getTargetHooks().isScalarizableAsmOperand(*this, Ty) ||
@@ -2717,10 +2721,21 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
// ResultRegDests can be also populated by addReturnRegisterOutputs() above,
// in which case its size may grow.
assert(ResultTypeRequiresCast.size() <= ResultRegDests.size());
+ assert(ResultRegIsFlagReg.size() <= ResultRegDests.size());
for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
llvm::Value *Tmp = RegResults[i];
llvm::Type *TruncTy = ResultTruncRegTypes[i];
+ if ((i < ResultRegIsFlagReg.size()) && ResultRegIsFlagReg[i]) {
+ // Target must guarantee the Value `Tmp` here is lowered to a boolean
+ // value.
+ llvm::Constant *Two = llvm::ConstantInt::get(Tmp->getType(), 2);
+ llvm::Value *IsBooleanValue =
+ Builder.CreateCmp(llvm::CmpInst::ICMP_ULT, Tmp, Two);
+ llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+ Builder.CreateCall(FnAssume, IsBooleanValue);
+ }
+
// If the result type of the LLVM IR asm doesn't match the result type of
// the expression, do the conversion.
if (ResultRegTypes[i] != ResultTruncRegTypes[i]) {
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
index 4e8e120d89df..d87692face2a 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ static void setVisibilityFromDLLStorageClass(const clang::LangOptions &LO,
void CodeGenModule::Release() {
Module *Primary = getContext().getModuleForCodeGen();
- if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
+ if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
EmitModuleInitializers(Primary);
EmitDeferred();
DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,21 +2521,23 @@ void CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
// source, first Global Module Fragments, if present.
if (auto GMF = Primary->getGlobalModuleFragment()) {
for (Decl *D : getContext().getModuleInitializers(GMF)) {
- assert(D->getKind() == Decl::Var && "GMF initializer decl is not a var?");
+ if (isa<ImportDecl>(D))
+ continue;
+ assert(isa<VarDecl>(D) && "GMF initializer decl is not a var?");
EmitTopLevelDecl(D);
}
}
// Second any associated with the module, itself.
for (Decl *D : getContext().getModuleInitializers(Primary)) {
// Skip import decls, the inits for those are called explicitly.
- if (D->getKind() == Decl::Import)
+ if (isa<ImportDecl>(D))
continue;
EmitTopLevelDecl(D);
}
// Third any associated with the Privat eMOdule Fragment, if present.
if (auto PMF = Primary->getPrivateModuleFragment()) {
for (Decl *D : getContext().getModuleInitializers(PMF)) {
- assert(D->getKind() == Decl::Var && "PMF initializer decl is not a var?");
+ assert(isa<VarDecl>(D) && "PMF initializer decl is not a var?");
EmitTopLevelDecl(D);
}
}
diff --git a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
index d1ee61eab9d6..195ad8cdc13e 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
@@ -2871,7 +2871,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
} else if (k >= BuiltinType::Bool && k <= BuiltinType::LongLong) {
Current = Integer;
} else if (k == BuiltinType::Float || k == BuiltinType::Double ||
- k == BuiltinType::Float16) {
+ k == BuiltinType::Float16 || k == BuiltinType::BFloat16) {
Current = SSE;
} else if (k == BuiltinType::LongDouble) {
const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();
@@ -3002,7 +3002,8 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
Current = Integer;
else if (Size <= 128)
Lo = Hi = Integer;
- } else if (ET->isFloat16Type() || ET == getContext().FloatTy) {
+ } else if (ET->isFloat16Type() || ET == getContext().FloatTy ||
+ ET->isBFloat16Type()) {
Current = SSE;
} else if (ET == getContext().DoubleTy) {
Lo = Hi = SSE;
@@ -3474,9 +3475,9 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
if (SourceSize > T0Size)
T1 = getFPTypeAtOffset(IRType, IROffset + T0Size, TD);
if (T1 == nullptr) {
- // Check if IRType is a half + float. float type will be in IROffset+4 due
+ // Check if IRType is a half/bfloat + float. float type will be in IROffset+4 due
// to its alignment.
- if (T0->isHalfTy() && SourceSize > 4)
+ if (T0->is16bitFPTy() && SourceSize > 4)
T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
// If we can't get a second FP type, return a simple half or float.
// avx512fp16-abi.c:pr51813_2 shows it works to return float for
@@ -3488,7 +3489,7 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
if (T0->isFloatTy() && T1->isFloatTy())
return llvm::FixedVectorType::get(T0, 2);
- if (T0->isHalfTy() && T1->isHalfTy()) {
+ if (T0->is16bitFPTy() && T1->is16bitFPTy()) {
llvm::Type *T2 = nullptr;
if (SourceSize > 4)
T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
@@ -3497,7 +3498,7 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
return llvm::FixedVectorType::get(T0, 4);
}
- if (T0->isHalfTy() || T1->isHalfTy())
+ if (T0->is16bitFPTy() || T1->is16bitFPTy())
return llvm::FixedVectorType::get(llvm::Type::getHalfTy(getVMContext()), 4);
return llvm::Type::getDoubleTy(getVMContext());
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 70ba8eb2a7d0..2c9d65e7714a 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -12,6 +12,7 @@
#include "clang/Driver/Options.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
using namespace clang::driver;
using namespace clang::driver::tools;
@@ -113,6 +114,30 @@ sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
return ABI;
}
+std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
+ const llvm::Triple &Triple) {
+ if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getSpelling() << Triple.getTriple();
+ return "";
+ }
+
+ if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
+ StringRef CPUName = A->getValue();
+ if (CPUName == "native") {
+ std::string CPU = std::string(llvm::sys::getHostCPUName());
+ if (!CPU.empty() && CPU != "generic")
+ return CPU;
+ return "";
+ }
+ return std::string(CPUName);
+ }
+
+ if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
+ return "v9";
+ return "";
+}
+
void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
std::vector<StringRef> &Features) {
sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
index d12a9a70e264..44658c4259c6 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
@@ -28,6 +28,9 @@ enum class FloatABI {
FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
+std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args,
+ const llvm::Triple &Triple);
+
void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
std::vector<llvm::StringRef> &Features);
const char *getSparcAsmModeForCPU(llvm::StringRef Name,
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
index b62a025c5072..3704ed858668 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2205,6 +2205,18 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
CmdArgs.push_back("-mfloat-abi");
CmdArgs.push_back("hard");
}
+
+ if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
+ StringRef Name = A->getValue();
+ std::string TuneCPU;
+ if (Name == "native")
+ TuneCPU = std::string(llvm::sys::getHostCPUName());
+ else
+ TuneCPU = std::string(Name);
+
+ CmdArgs.push_back("-tune-cpu");
+ CmdArgs.push_back(Args.MakeArgString(TuneCPU));
+ }
}
void Clang::AddSystemZTargetArgs(const ArgList &Args,
@@ -4610,8 +4622,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
TC.addClangWarningOptions(CmdArgs);
// FIXME: Subclass ToolChain for SPIR and move this to addClangWarningOptions.
- if (Triple.isSPIR() || Triple.isSPIRV())
+ if (Triple.isSPIR() || Triple.isSPIRV()) {
CmdArgs.push_back("-Wspir-compat");
+ // SPIR-V support still needs pointer types in some cases as recovering
+ // type from pointer uses is not always possible e.g. for extern functions
+ // (see PR56660).
+ CmdArgs.push_back("-no-opaque-pointers");
+ }
// Select the appropriate action.
RewriteKind rewriteKind = RK_None;
@@ -6576,7 +6593,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// support by default, or just assume that all languages do.
bool HaveModules =
Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
- Std->containsValue("c++latest"));
+ Std->containsValue("c++2b") || Std->containsValue("c++latest"));
RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1d2c085d683e..443725f7d8a8 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -12,6 +12,7 @@
#include "Arch/M68k.h"
#include "Arch/Mips.h"
#include "Arch/PPC.h"
+#include "Arch/Sparc.h"
#include "Arch/SystemZ.h"
#include "Arch/VE.h"
#include "Arch/X86.h"
@@ -431,15 +432,15 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
case llvm::Triple::bpfel:
case llvm::Triple::bpfeb:
- case llvm::Triple::sparc:
- case llvm::Triple::sparcel:
- case llvm::Triple::sparcv9:
if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
return A->getValue();
- if (T.getArch() == llvm::Triple::sparc && T.isOSSolaris())
- return "v9";
return "";
+ case llvm::Triple::sparc:
+ case llvm::Triple::sparcel:
+ case llvm::Triple::sparcv9:
+ return sparc::getSparcTargetCPU(D, Args, T);
+
case llvm::Triple::x86:
case llvm::Triple::x86_64:
return x86::getX86TargetCPU(D, Args, T);
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
index 34396b0b59c2..f203cae1d329 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -631,6 +631,16 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+ // LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+ // forcibly link with libatomic as a workaround.
+ // TODO: Issue #41880 and D118021.
+ if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+ CmdArgs.push_back("--push-state");
+ CmdArgs.push_back("--as-needed");
+ CmdArgs.push_back("-latomic");
+ CmdArgs.push_back("--pop-state");
+ }
+
if (WantPthread && !isAndroid)
CmdArgs.push_back("-lpthread");
diff --git a/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp b/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
index 7b07ab948f64..53cb48d2de9e 100644
--- a/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
@@ -772,7 +772,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
if (ASTReader::isAcceptableASTFile(
Dir->path(), FileMgr, CI.getPCHContainerReader(),
CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
- SpecificModuleCachePath)) {
+ SpecificModuleCachePath, /*RequireStrictOptionMatches=*/true)) {
PPOpts.ImplicitPCHInclude = std::string(Dir->path());
Found = true;
break;
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
index 985005d0b79b..75ffa8b0a90a 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
@@ -1711,6 +1711,80 @@ bool Sema::CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old) {
return false;
}
+// Check the redefinition in C++20 Modules.
+//
+// [basic.def.odr]p14:
+// For any definable item D with definitions in multiple translation units,
+// - if D is a non-inline non-templated function or variable, or
+// - if the definitions in different translation units do not satisfy the
+// following requirements,
+// the program is ill-formed; a diagnostic is required only if the definable
+// item is attached to a named module and a prior definition is reachable at
+// the point where a later definition occurs.
+// - Each such definition shall not be attached to a named module
+// ([module.unit]).
+// - Each such definition shall consist of the same sequence of tokens, ...
+// ...
+//
+// Return true if the redefinition is not allowed. Return false otherwise.
+bool Sema::IsRedefinitionInModule(const NamedDecl *New,
+ const NamedDecl *Old) const {
+ assert(getASTContext().isSameEntity(New, Old) &&
+ "New and Old are not the same definition, we should diagnostic it "
+ "immediately instead of checking it.");
+ assert(const_cast<Sema *>(this)->isReachable(New) &&
+ const_cast<Sema *>(this)->isReachable(Old) &&
+ "We shouldn't see unreachable definitions here.");
+
+ Module *NewM = New->getOwningModule();
+ Module *OldM = Old->getOwningModule();
+
+ // We only checks for named modules here. The header like modules is skipped.
+ // FIXME: This is not right if we import the header like modules in the module
+ // purview.
+ //
+ // For example, assuming "header.h" provides definition for `D`.
+ // ```C++
+ // //--- M.cppm
+ // export module M;
+ // import "header.h"; // or #include "header.h" but import it by clang modules
+ // actually.
+ //
+ // //--- Use.cpp
+ // import M;
+ // import "header.h"; // or uses clang modules.
+ // ```
+ //
+ // In this case, `D` has multiple definitions in multiple TU (M.cppm and
+ // Use.cpp) and `D` is attached to a named module `M`. The compiler should
+ // reject it. But the current implementation couldn't detect the case since we
+ // don't record the information about the importee modules.
+ //
+ // But this might not be painful in practice. Since the design of C++20 Named
+ // Modules suggests us to use headers in global module fragment instead of
+ // module purview.
+ if (NewM && NewM->isHeaderLikeModule())
+ NewM = nullptr;
+ if (OldM && OldM->isHeaderLikeModule())
+ OldM = nullptr;
+
+ if (!NewM && !OldM)
+ return true;
+
+ // [basic.def.odr]p14.3
+ // Each such definition shall not be attached to a named module
+ // ([module.unit]).
+ if ((NewM && NewM->isModulePurview()) || (OldM && OldM->isModulePurview()))
+ return true;
+
+ // Then New and Old lives in the same TU if their share one same module unit.
+ if (NewM)
+ NewM = NewM->getTopLevelModule();
+ if (OldM)
+ OldM = OldM->getTopLevelModule();
+ return OldM == NewM;
+}
+
static bool isUsingDecl(NamedDecl *D) {
return isa<UsingShadowDecl>(D) ||
isa<UnresolvedUsingTypenameDecl>(D) ||
@@ -3960,7 +4034,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
// default argument promotion rules were already checked by
// ASTContext::typesAreCompatible().
if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
- Old->getNumParams() != New->getNumParams()) {
+ Old->getNumParams() != New->getNumParams() && !Old->isImplicit()) {
if (Old->hasInheritedPrototype())
Old = Old->getCanonicalDecl();
Diag(New->getLocation(), diag::err_conflicting_types) << New;
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp b/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
index d72cc33ed0f5..5dc0aadb2d5f 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
@@ -63,9 +63,8 @@ static ExprResult CreateFunctionRefExpr(
// being used.
if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
return ExprError();
- DeclRefExpr *DRE =
- DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), SourceLocation(),
- Fn, false, Loc, Fn->getType(), VK_LValue, FoundDecl);
+ DeclRefExpr *DRE = new (S.Context)
+ DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
if (HadMultipleCandidates)
DRE->setHadMultipleCandidates(true);
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
index 1542a07713fb..ecc9596a87f0 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
@@ -8728,7 +8728,7 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
if (Previous.empty())
return;
- auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl());
+ auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl()->getUnderlyingDecl());
if (!OldConcept) {
auto *Old = Previous.getRepresentativeDecl();
Diag(NewDecl->getLocation(), diag::err_redefinition_different_kind)
@@ -8746,7 +8746,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
AddToScope = false;
return;
}
- if (hasReachableDefinition(OldConcept)) {
+ if (hasReachableDefinition(OldConcept) &&
+ IsRedefinitionInModule(NewDecl, OldConcept)) {
Diag(NewDecl->getLocation(), diag::err_redefinition)
<< NewDecl->getDeclName();
notePreviousDefinition(OldConcept, NewDecl->getLocation());
@@ -8758,7 +8759,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
// Other decls (e.g. namespaces) also have this shortcoming.
return;
}
- Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+ // We unwrap canonical decl late to check for module visibility.
+ Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
}
/// \brief Strips various properties off an implicit instantiation
diff --git a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
index 76281d26b2ae..d1e47c1045de 100644
--- a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
+++ b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
@@ -624,20 +624,28 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts,
}
}
+enum OptionValidation {
+ OptionValidateNone,
+ OptionValidateContradictions,
+ OptionValidateStrictMatches,
+};
+
/// Check the preprocessor options deserialized from the control block
/// against the preprocessor options in an existing preprocessor.
///
/// \param Diags If non-null, produce diagnostics for any mismatches incurred.
-/// \param Validate If true, validate preprocessor options. If false, allow
-/// macros defined by \p ExistingPPOpts to override those defined by
-/// \p PPOpts in SuggestedPredefines.
-static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
- const PreprocessorOptions &ExistingPPOpts,
- DiagnosticsEngine *Diags,
- FileManager &FileMgr,
- std::string &SuggestedPredefines,
- const LangOptions &LangOpts,
- bool Validate = true) {
+/// \param Validation If set to OptionValidateNone, ignore differences in
+/// preprocessor options. If set to OptionValidateContradictions,
+/// require that options passed both in the AST file and on the command
+/// line (-D or -U) match, but tolerate options missing in one or the
+/// other. If set to OptionValidateContradictions, require that there
+/// are no differences in the options between the two.
+static bool checkPreprocessorOptions(
+ const PreprocessorOptions &PPOpts,
+ const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags,
+ FileManager &FileMgr, std::string &SuggestedPredefines,
+ const LangOptions &LangOpts,
+ OptionValidation Validation = OptionValidateContradictions) {
// Check macro definitions.
MacroDefinitionsMap ASTFileMacros;
collectMacroDefinitions(PPOpts, ASTFileMacros);
@@ -653,7 +661,15 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
// Check whether we know anything about this macro name or not.
llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
ASTFileMacros.find(MacroName);
- if (!Validate || Known == ASTFileMacros.end()) {
+ if (Validation == OptionValidateNone || Known == ASTFileMacros.end()) {
+ if (Validation == OptionValidateStrictMatches) {
+ // If strict matches are requested, don't tolerate any extra defines on
+ // the command line that are missing in the AST file.
+ if (Diags) {
+ Diags->Report(diag::err_pch_macro_def_undef) << MacroName << true;
+ }
+ return true;
+ }
// FIXME: Check whether this identifier was referenced anywhere in the
// AST file. If so, we should reject the AST file. Unfortunately, this
// information isn't in the control block. What shall we do about it?
@@ -684,8 +700,10 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
// If the macro was #undef'd in both, or if the macro bodies are identical,
// it's fine.
- if (Existing.second || Existing.first == Known->second.first)
+ if (Existing.second || Existing.first == Known->second.first) {
+ ASTFileMacros.erase(Known);
continue;
+ }
// The macro bodies differ; complain.
if (Diags) {
@@ -694,9 +712,20 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
}
return true;
}
+ if (Validation == OptionValidateStrictMatches) {
+ // If strict matches are requested, don't tolerate any extra defines in
+ // the AST file that are missing on the command line.
+ for (const auto &MacroName : ASTFileMacros.keys()) {
+ if (Diags) {
+ Diags->Report(diag::err_pch_macro_def_undef) << MacroName << false;
+ }
+ return true;
+ }
+ }
// Check whether we're using predefines.
- if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) {
+ if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines &&
+ Validation != OptionValidateNone) {
if (Diags) {
Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines;
}
@@ -705,7 +734,8 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
// Detailed record is important since it is used for the module cache hash.
if (LangOpts.Modules &&
- PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) {
+ PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord &&
+ Validation != OptionValidateNone) {
if (Diags) {
Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord;
}
@@ -766,13 +796,9 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
const PreprocessorOptions &PPOpts,
bool Complain,
std::string &SuggestedPredefines) {
- return checkPreprocessorOptions(PPOpts,
- PP.getPreprocessorOpts(),
- nullptr,
- PP.getFileManager(),
- SuggestedPredefines,
- PP.getLangOpts(),
- false);
+ return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), nullptr,
+ PP.getFileManager(), SuggestedPredefines,
+ PP.getLangOpts(), OptionValidateNone);
}
/// Check the header search options deserialized from the control block
@@ -5138,16 +5164,19 @@ namespace {
const PreprocessorOptions &ExistingPPOpts;
std::string ExistingModuleCachePath;
FileManager &FileMgr;
+ bool StrictOptionMatches;
public:
SimplePCHValidator(const LangOptions &ExistingLangOpts,
const TargetOptions &ExistingTargetOpts,
const PreprocessorOptions &ExistingPPOpts,
- StringRef ExistingModuleCachePath, FileManager &FileMgr)
+ StringRef ExistingModuleCachePath, FileManager &FileMgr,
+ bool StrictOptionMatches)
: ExistingLangOpts(ExistingLangOpts),
ExistingTargetOpts(ExistingTargetOpts),
ExistingPPOpts(ExistingPPOpts),
- ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr) {}
+ ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
+ StrictOptionMatches(StrictOptionMatches) {}
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override {
@@ -5172,9 +5201,11 @@ namespace {
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
bool Complain,
std::string &SuggestedPredefines) override {
- return checkPreprocessorOptions(PPOpts, ExistingPPOpts, /*Diags=*/nullptr,
- FileMgr, SuggestedPredefines,
- ExistingLangOpts);
+ return checkPreprocessorOptions(
+ PPOpts, ExistingPPOpts, /*Diags=*/nullptr, FileMgr,
+ SuggestedPredefines, ExistingLangOpts,
+ StrictOptionMatches ? OptionValidateStrictMatches
+ : OptionValidateContradictions);
}
};
@@ -5451,9 +5482,11 @@ bool ASTReader::isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
const LangOptions &LangOpts,
const TargetOptions &TargetOpts,
const PreprocessorOptions &PPOpts,
- StringRef ExistingModuleCachePath) {
+ StringRef ExistingModuleCachePath,
+ bool RequireStrictOptionMatches) {
SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
- ExistingModuleCachePath, FileMgr);
+ ExistingModuleCachePath, FileMgr,
+ RequireStrictOptionMatches);
return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
/*FindModuleFileExtensions=*/false,
validator,
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h b/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
index 7a54564a3520..91f614528ab3 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
@@ -60,7 +60,7 @@ typedef uint16_t dst_rep_t;
static const int dstSigBits = 10;
#elif defined DST_BFLOAT
-typedef uint16_t dst_t;
+typedef __bf16 dst_t;
typedef uint16_t dst_rep_t;
#define DST_REP_C UINT16_C
static const int dstSigBits = 7;
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h b/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
index 9ee5a327b28a..7a72de480676 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
@@ -64,7 +64,7 @@ typedef union {
} udwords;
#if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
- defined(__riscv) || defined(_WIN64) || defined(__powerpc__)
+ defined(__riscv) || defined(_WIN64)
#define CRT_HAS_128BIT
#endif
diff --git a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index ea4e5b015d11..32005eef08cd 100644
--- a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -90,7 +90,7 @@
# else
# define SANITIZER_IOSSIM 0
# endif
-# if TARGET_OS_DRIVERKIT
+# if defined(TARGET_OS_DRIVERKIT) && TARGET_OS_DRIVERKIT
# define SANITIZER_DRIVERKIT 1
# else
# define SANITIZER_DRIVERKIT 0
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h b/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h
index 83d8c260f27a..1089bb20d5b2 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h
@@ -11,8 +11,10 @@
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,25 +22,31 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
+__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ if (__first == __last)
+ return __first;
+ _Iter __i = __first;
+ while (++__i != __last) {
+ if (__pred(*__first, *__i))
+ return __first;
+ __first = __i;
+ }
+ return __i;
+}
+
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
- if (__first != __last) {
- _ForwardIterator __i = __first;
- while (++__i != __last) {
- if (__pred(*__first, *__i))
- return __first;
- __first = __i;
- }
- }
- return __last;
+ return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
+ return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/clamp.h b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
index b3762b85a0bc..30ddbdce64a9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
@@ -33,7 +33,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_INLINE_VISIBILITY constexpr
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy.h b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
index 5428baa68859..f7535a81547a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_COPY_H
#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/unwrap_range.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
@@ -88,10 +89,11 @@ template <class _InIter, class _Sent, class _OutIter,
&& is_copy_constructible<_Sent>::value
&& is_copy_constructible<_OutIter>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_InIter, _OutIter>
-__copy(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__copy_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
- return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
+pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __range = std::__unwrap_range(__first, __last);
+ auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result));
+ return std::make_pair(
+ std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
}
template <class _InputIterator, class _OutputIterator>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h
index 26b8c4d791fd..c5fa64bc8d75 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h
@@ -20,7 +20,6 @@
#include <__ranges/subrange.h>
#include <__utility/move.h>
#include <__utility/pair.h>
-#include <cstring>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -44,9 +43,10 @@ __copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator _
template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,
__enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
- auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last)));
+ auto __last_iter = _IterOps<_AlgPolicy>::next(__first, std::move(__last));
+ auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), __last_iter));
auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));
- return std::make_pair(__ret.in.base(), __ret.out.base());
+ return std::make_pair(__last_iter, __ret.out.base());
}
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill.h b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
index ec9968fdb8b3..901ba4e68689 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/fill.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
@@ -20,6 +20,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
index 7482a4188dd5..6c5e44efde9b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
@@ -19,6 +19,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
index b968329fc318..2096b0f0c9a5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
@@ -24,7 +24,8 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica
_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
_ForwardIterator2 __first2,
- _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ _ForwardIterator2 __last2,
+ _BinaryPredicate&& __pred) {
for (; __first1 != __last1; ++__first1)
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
if (__pred(*__first1, *__j))
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
index cb662e791872..0890639f4952 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
@@ -54,18 +54,17 @@ public:
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
};
-template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2,
- class _OutputIterator>
-void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
+ class _InputIterator2, class _Sent2, class _OutputIterator>
+void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
+ _InputIterator2 __first2, _Sent2 __last2,
+ _OutputIterator __result, _Compare&& __comp)
{
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
{
- // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `move`.
- _VSTD::move(__first1, __last1, __result);
+ std::__move<_AlgPolicy>(__first1, __last1, __result);
return;
}
@@ -84,13 +83,15 @@ void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
-void
-__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+void __buffered_inplace_merge(
+ _BidirectionalIterator __first,
+ _BidirectionalIterator __middle,
+ _BidirectionalIterator __last,
+ _Compare&& __comp,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff) {
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
if (__len1 <= __len2)
@@ -98,7 +99,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
- std::__half_inplace_merge<_AlgPolicy, _Compare>(__buff, __p, __middle, __last, __first, __comp);
+ std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);
}
else
{
@@ -108,19 +109,22 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi;
typedef __unconstrained_reverse_iterator<value_type*> _Rv;
typedef __invert<_Compare> _Inverted;
- std::__half_inplace_merge<_AlgPolicy, _Inverted>(_Rv(__p), _Rv(__buff),
+ std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff),
_RBi(__middle), _RBi(__first),
_RBi(__last), _Inverted(__comp));
}
}
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
-void
-__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
-{
+void __inplace_merge(
+ _BidirectionalIterator __first,
+ _BidirectionalIterator __middle,
+ _BidirectionalIterator __last,
+ _Compare&& __comp,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff,
+ ptrdiff_t __buff_size) {
using _Ops = _IterOps<_AlgPolicy>;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
@@ -130,7 +134,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
if (__len2 == 0)
return;
if (__len1 <= __buff_size || __len2 <= __buff_size)
- return std::__buffered_inplace_merge<_AlgPolicy, _Compare>
+ return std::__buffered_inplace_merge<_AlgPolicy>
(__first, __middle, __last, __comp, __len1, __len2, __buff);
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
for (; true; ++__first, (void) --__len1)
@@ -158,8 +162,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
__len21 = __len2 / 2;
__m2 = __middle;
_Ops::advance(__m2, __len21);
- // TODO: replace _ClassicAlgPolicy and __identity with _AlgPolicy and projection
- __m1 = std::__upper_bound<_ClassicAlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
+ __m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity());
__len11 = _Ops::distance(__first, __m1);
}
else
@@ -181,15 +184,13 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
// [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
// swap middle two partitions
- // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`.
- __middle = _VSTD::rotate(__m1, __middle, __m2);
+ __middle = std::__rotate<_AlgPolicy>(__m1, __middle, __m2).first;
// __len12 and __len21 now have swapped meanings
// merge smaller range with recursive call and larger with tail recursion elimination
if (__len11 + __len21 < __len12 + __len22)
{
- std::__inplace_merge<_AlgPolicy, _Compare>(
+ std::__inplace_merge<_AlgPolicy>(
__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
__first = __middle;
__middle = __m2;
__len1 = __len12;
@@ -197,9 +198,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
else
{
- std::__inplace_merge<_AlgPolicy, _Compare>(
+ std::__inplace_merge<_AlgPolicy>(
__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
__last = __middle;
__middle = __m1;
__len1 = __len11;
@@ -208,33 +208,40 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
}
}
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>
+_LIBCPP_HIDE_FROM_ABI
void
-inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp)
+__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ _Compare&& __comp)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
- difference_type __len1 = _VSTD::distance(__first, __middle);
- difference_type __len2 = _VSTD::distance(__middle, __last);
+ difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
+ difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
difference_type __buf_size = _VSTD::min(__len1, __len2);
// TODO: Remove the use of std::get_temporary_buffer
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
_LIBCPP_SUPPRESS_DEPRECATED_POP
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__inplace_merge<_ClassicAlgPolicy, _Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
- __buf.first, __buf.second);
+ return std::__inplace_merge<_AlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second);
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
+ _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ std::__inplace_merge<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last), static_cast<_Comp_ref>(__comp));
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
void
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
{
- _VSTD::inplace_merge(__first, __middle, __last,
+ std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last),
__less<typename iterator_traits<_BidirectionalIterator>::value_type>());
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h
index cdd742048412..06a4949e21b5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h
@@ -11,10 +11,16 @@
#define _LIBCPP___ALGORITHM_IS_PERMUTATION_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
+#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,140 +28,211 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
- _BinaryPredicate __pred) {
- // shorten sequences as much as possible by lopping of any equal prefix
- for (; __first1 != __last1; ++__first1, (void)++__first2)
- if (!__pred(*__first1, *__first2))
- break;
- if (__first1 == __last1)
- return true;
+template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class = void>
+struct _ConstTimeDistance : false_type {};
- // __first1 != __last1 && *__first1 != *__first2
- typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
- _D1 __l1 = _VSTD::distance(__first1, __last1);
- if (__l1 == _D1(1))
- return false;
- _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1);
- // For each element in [f1, l1) see if there are the same number of
- // equal elements in [f2, l2)
- for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
+#if _LIBCPP_STD_VER > 17
+
+template <class _Iter1, class _Sent1, class _Iter2, class _Sent2>
+struct _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2, __enable_if_t<
+ sized_sentinel_for<_Sent1, _Iter1> &&
+ sized_sentinel_for<_Sent2, _Iter2>
+>> : true_type {};
+
+#else
+
+template <class _Iter1, class _Iter2>
+struct _ConstTimeDistance<_Iter1, _Iter1, _Iter2, _Iter2, __enable_if_t<
+ is_same<typename iterator_traits<_Iter1>::iterator_category, random_access_iterator_tag>::value &&
+ is_same<typename iterator_traits<_Iter2>::iterator_category, random_access_iterator_tag>::value
+> > : true_type {};
+
+#endif // _LIBCPP_STD_VER > 17
+
+// Internal functions
+
+// For each element in [f1, l1) see if there are the same number of equal elements in [f2, l2)
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
+ using _D1 = __iter_diff_t<_Iter1>;
+
+ for (auto __i = __first1; __i != __last1; ++__i) {
// Have we already counted the number of *__i in [f1, l1)?
- _ForwardIterator1 __match = __first1;
- for (; __match != __i; ++__match)
- if (__pred(*__match, *__i))
+ auto __match = __first1;
+ for (; __match != __i; ++__match) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__match), std::__invoke(__proj1, *__i)))
break;
+ }
+
if (__match == __i) {
// Count number of *__i in [f2, l2)
_D1 __c2 = 0;
- for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
- if (__pred(*__i, *__j))
+ for (auto __j = __first2; __j != __last2; ++__j) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj2, *__j)))
++__c2;
+ }
if (__c2 == 0)
return false;
+
// Count number of *__i in [__i, l1) (we can start with 1)
_D1 __c1 = 1;
- for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
- if (__pred(*__i, *__j))
+ for (auto __j = _IterOps<_AlgPolicy>::next(__i); __j != __last1; ++__j) {
+ if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj1, *__j)))
++__c1;
+ }
if (__c1 != __c2)
return false;
}
}
+
return true;
}
-template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+// 2+1 iterators, predicate. Not used by range algorithms.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2,
+ _BinaryPredicate&& __pred) {
+ // Shorten sequences as much as possible by lopping of any equal prefix.
+ for (; __first1 != __last1; ++__first1, (void)++__first2) {
+ if (!__pred(*__first1, *__first2))
+ break;
+ }
+
+ if (__first1 == __last1)
+ return true;
+
+ // __first1 != __last1 && *__first1 != *__first2
+ using _D1 = __iter_diff_t<_ForwardIterator1>;
+ _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1);
+ if (__l1 == _D1(1))
+ return false;
+ auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __l1);
+
+ return std::__is_permutation_impl<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __identity(), __identity());
}
-#if _LIBCPP_STD_VER > 11
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
- _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
- // shorten sequences as much as possible by lopping of any equal prefix
- for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
- if (!__pred(*__first1, *__first2))
+// 2+2 iterators, predicate, non-constant time `distance`.
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
+ /*_ConstTimeDistance=*/false_type) {
+ // Shorten sequences as much as possible by lopping of any equal prefix.
+ while (__first1 != __last1 && __first2 != __last2) {
+ if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
break;
+ ++__first1;
+ ++__first2;
+ }
+
if (__first1 == __last1)
return __first2 == __last2;
- else if (__first2 == __last2)
+ if (__first2 == __last2) // Second range is shorter
return false;
- typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
- _D1 __l1 = _VSTD::distance(__first1, __last1);
+ using _D1 = __iter_diff_t<_Iter1>;
+ _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1);
- typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
- _D2 __l2 = _VSTD::distance(__first2, __last2);
+ using _D2 = __iter_diff_t<_Iter2>;
+ _D2 __l2 = _IterOps<_AlgPolicy>::distance(__first2, __last2);
if (__l1 != __l2)
return false;
- // For each element in [f1, l1) see if there are the same number of
- // equal elements in [f2, l2)
- for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
- // Have we already counted the number of *__i in [f1, l1)?
- _ForwardIterator1 __match = __first1;
- for (; __match != __i; ++__match)
- if (__pred(*__match, *__i))
- break;
- if (__match == __i) {
- // Count number of *__i in [f2, l2)
- _D1 __c2 = 0;
- for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
- if (__pred(*__i, *__j))
- ++__c2;
- if (__c2 == 0)
- return false;
- // Count number of *__i in [__i, l1) (we can start with 1)
- _D1 __c1 = 1;
- for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
- if (__pred(*__i, *__j))
- ++__c1;
- if (__c1 != __c2)
- return false;
- }
- }
- return true;
+ return std::__is_permutation_impl<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
}
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
- _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
- _BinaryPredicate __pred, random_access_iterator_tag,
- random_access_iterator_tag) {
- if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+// 2+2 iterators, predicate, specialization for constant-time `distance` call.
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
+ /*_ConstTimeDistance=*/true_type) {
+ if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
return false;
- return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
- _BinaryPredicate&>(__first1, __last1, __first2, __pred);
+ return std::__is_permutation<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2,
+ /*_ConstTimeDistance=*/false_type());
+}
+
+// 2+2 iterators, predicate
+template <class _AlgPolicy,
+ class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
+ return std::__is_permutation<_AlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2,
+ _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2>());
}
+// Public interface
+
+// 2+1 iterators, predicate
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
- _ForwardIterator2 __last2, _BinaryPredicate __pred) {
- return _VSTD::__is_permutation<_BinaryPredicate&>(
- __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
+ _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
+ "The predicate has to be callable");
+
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), __pred);
}
+// 2+1 iterators
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ using __v1 = __iter_value_type<_ForwardIterator1>;
+ using __v2 = __iter_value_type<_ForwardIterator2>;
+ return std::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+
+// 2+2 iterators
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2) {
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
+ using __v1 = __iter_value_type<_ForwardIterator1>;
+ using __v2 = __iter_value_type<_ForwardIterator2>;
+
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __equal_to<__v1, __v2>(), __identity(), __identity());
}
-#endif
+
+// 2+2 iterators, predicate
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
+ "The predicate has to be callable");
+
+ return std::__is_permutation<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __identity(), __identity());
+}
+
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h b/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
index 8307d71214e5..af461878737f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
@@ -10,13 +10,18 @@
#define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H
#include <__algorithm/iter_swap.h>
+#include <__algorithm/ranges_iterator_concept.h>
#include <__config>
#include <__iterator/advance.h>
#include <__iterator/distance.h>
+#include <__iterator/incrementable_traits.h>
#include <__iterator/iter_move.h>
#include <__iterator/iter_swap.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__iterator/readable_traits.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <type_traits>
@@ -34,11 +39,22 @@ struct _RangeAlgPolicy {};
template <>
struct _IterOps<_RangeAlgPolicy> {
+
+ template <class _Iter>
+ using __value_type = iter_value_t<_Iter>;
+
+ template <class _Iter>
+ using __iterator_category = ranges::__iterator_concept<_Iter>;
+
+ template <class _Iter>
+ using __difference_type = iter_difference_t<_Iter>;
+
static constexpr auto advance = ranges::advance;
static constexpr auto distance = ranges::distance;
static constexpr auto __iter_move = ranges::iter_move;
static constexpr auto iter_swap = ranges::iter_swap;
static constexpr auto next = ranges::next;
+ static constexpr auto prev = ranges::prev;
static constexpr auto __advance_to = ranges::advance;
};
@@ -49,6 +65,15 @@ struct _ClassicAlgPolicy {};
template <>
struct _IterOps<_ClassicAlgPolicy> {
+ template <class _Iter>
+ using __value_type = typename iterator_traits<_Iter>::value_type;
+
+ template <class _Iter>
+ using __iterator_category = typename iterator_traits<_Iter>::iterator_category;
+
+ template <class _Iter>
+ using __difference_type = typename iterator_traits<_Iter>::difference_type;
+
// advance
template <class _Iter, class _Distance>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -63,24 +88,46 @@ struct _IterOps<_ClassicAlgPolicy> {
return std::distance(__first, __last);
}
- // iter_move
+ template <class _Iter>
+ using __deref_t = decltype(*std::declval<_Iter&>());
+
+ template <class _Iter>
+ using __move_t = decltype(std::move(*std::declval<_Iter&>()));
+
template <class _Iter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
- // Declaring the return type is necessary for C++03, so we basically mirror what `decltype(auto)` would deduce.
- static __enable_if_t<
- is_reference<typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
- typename remove_reference< typename iterator_traits<__uncvref_t<_Iter> >::reference >::type&&>
- __iter_move(_Iter&& __i) {
+ static void __validate_iter_reference() {
+ static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
+ "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
+ "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
+ "and can lead to dangling reference issues at runtime, so we are flagging this.");
+ }
+
+ // iter_move
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
+ // that the C++03 mode doesn't support `decltype(auto)` as the return type.
+ __enable_if_t<
+ is_reference<__deref_t<_Iter> >::value,
+ __move_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
return std::move(*std::forward<_Iter>(__i));
}
template <class _Iter>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
- // Declaring the return type is necessary for C++03, so we basically mirror what `decltype(auto)` would deduce.
- static __enable_if_t<
- !is_reference<typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
- typename iterator_traits<__uncvref_t<_Iter> >::reference>
- __iter_move(_Iter&& __i) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
+ // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
+ // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
+ // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
+ __enable_if_t<
+ !is_reference<__deref_t<_Iter> >::value,
+ __deref_t<_Iter> >
+ __iter_move(_Iter&& __i) {
+ __validate_iter_reference<_Iter>();
+
return *std::forward<_Iter>(__i);
}
@@ -100,11 +147,19 @@ struct _IterOps<_ClassicAlgPolicy> {
template <class _Iter>
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
- __uncvref_t<_Iter> next(_Iter&& __it,
- typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){
+ __uncvref_t<_Iter> next(_Iter&& __it,
+ typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
return std::next(std::forward<_Iter>(__it), __n);
}
+ // prev
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
+ __uncvref_t<_Iter> prev(_Iter&& __iter,
+ typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
+ return std::prev(std::forward<_Iter>(__iter), __n);
+ }
+
template <class _Iter>
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
void __advance_to(_Iter& __first, _Iter __last) {
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h
index bf9dd96756af..0aa67d18ed0a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
+void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
using _CompRef = typename __comp_ref_type<_Compare>::type;
_CompRef __comp_ref = __comp;
@@ -34,7 +34,7 @@ void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
if (__n > 1) {
// start from the first parent, there is no need to consider children
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) {
- std::__sift_down<_AlgPolicy, _CompRef>(__first, __comp_ref, __n, __first + __start);
+ std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start);
}
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h b/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
index 64fc3dfb6a12..6c1d15677667 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
@@ -14,51 +14,91 @@
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__utility/declval.h>
#include <__utility/forward.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace ranges {
-
template <class _Pred, class _Proj>
-_LIBCPP_HIDE_FROM_ABI constexpr static
-decltype(auto) __make_projected_pred(_Pred& __pred, _Proj& __proj) {
- if constexpr (same_as<decay_t<_Proj>, identity> && !is_member_pointer_v<decay_t<_Pred>>) {
- // Avoid creating the lambda and just use the pristine predicate -- for certain algorithms, this would enable
- // optimizations that rely on the type of the predicate.
- return __pred;
+struct _ProjectedPred {
+ _Pred& __pred; // Can be a unary or a binary predicate.
+ _Proj& __proj;
+
+ _LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {}
+
+ template <class _Tp>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_Tp&& __v) const {
+ return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
+ }
- } else {
- return [&](auto&& __x) {
- return std::invoke(__pred, std::invoke(__proj, std::forward<decltype(__x)>(__x)));
- };
+ template <class _T1, class _T2>
+ typename __invoke_of<_Pred&,
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
+ decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))
+ >::type
+ _LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const {
+ return std::__invoke(__pred,
+ std::__invoke(__proj, std::forward<_T1>(__lhs)),
+ std::__invoke(__proj, std::forward<_T2>(__rhs)));
}
-}
-template <class _Comp, class _Proj>
-_LIBCPP_HIDE_FROM_ABI constexpr static
-decltype(auto) __make_projected_comp(_Comp& __comp, _Proj& __proj) {
- if constexpr (same_as<decay_t<_Proj>, identity> && !is_member_pointer_v<decay_t<_Comp>>) {
- // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable
- // optimizations that rely on the type of the comparator.
- return __comp;
+};
- } else {
- return [&](auto&& __lhs, auto&& __rhs) {
- return std::invoke(__comp,
- std::invoke(__proj, std::forward<decltype(__lhs)>(__lhs)),
- std::invoke(__proj, std::forward<decltype(__rhs)>(__rhs)));
- };
- }
+template <class _Pred, class _Proj, class = void>
+struct __can_use_pristine_comp : false_type {};
+
+template <class _Pred, class _Proj>
+struct __can_use_pristine_comp<_Pred, _Proj, __enable_if_t<
+ !is_member_pointer<typename decay<_Pred>::type>::value && (
+#if _LIBCPP_STD_VER > 17
+ is_same<typename decay<_Proj>::type, identity>::value ||
+#endif
+ is_same<typename decay<_Proj>::type, __identity>::value
+ )
+> > : true_type {};
+
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ !__can_use_pristine_comp<_Pred, _Proj>::value,
+ _ProjectedPred<_Pred, _Proj>
+>
+__make_projected(_Pred& __pred, _Proj& __proj) {
+ return _ProjectedPred<_Pred, _Proj>(__pred, __proj);
+}
+
+// Avoid creating the functor and just use the pristine comparator -- for certain algorithms, this would enable
+// optimizations that rely on the type of the comparator. Additionally, this results in less layers of indirection in
+// the call stack when the comparator is invoked, even in an unoptimized build.
+template <class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static
+__enable_if_t<
+ __can_use_pristine_comp<_Pred, _Proj>::value,
+ _Pred&
+>
+__make_projected(_Pred& __pred, _Proj&) {
+ return __pred;
}
+_LIBCPP_END_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
template <class _Comp, class _Proj1, class _Proj2>
_LIBCPP_HIDE_FROM_ABI constexpr static
decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move.h b/contrib/llvm-project/libcxx/include/__algorithm/move.h
index 0b08d31c176e..c090faf6b6dc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/move.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_H
#define _LIBCPP___ALGORITHM_MOVE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/unwrap_iter.h>
#include <__config>
#include <__iterator/iterator_traits.h>
@@ -26,18 +27,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// move
-template <class _InIter, class _Sent, class _OutIter>
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
while (__first != __last) {
- *__result = std::move(*__first);
+ *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
++__first;
++__result;
}
return std::make_pair(std::move(__first), std::move(__result));
}
-template <class _InType,
+template <class _AlgPolicy,
+ class _InType,
class _OutType,
class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
&& is_trivially_move_assignable<_OutType>::value> >
@@ -49,7 +51,7 @@ pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutTyp
&& !is_trivially_copyable<_InType>::value
#endif
)
- return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result);
+ return std::__move_impl<_AlgPolicy, _InType*, _InType*, _OutType*>(__first, __last, __result);
const size_t __n = static_cast<size_t>(__last - __first);
::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
return std::make_pair(__first + __n, __result + __n);
@@ -65,7 +67,8 @@ template <class _Iter>
struct __is_trivially_move_assignable_unwrapped
: __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
-template <class _InIter,
+template <class _AlgPolicy,
+ class _InIter,
class _OutIter,
__enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
typename iterator_traits<_OutIter>::value_type>::value
@@ -81,33 +84,34 @@ __move_impl(reverse_iterator<_InIter> __first,
auto __last_base = std::__unwrap_iter(__last.base());
auto __result_base = std::__unwrap_iter(__result.base());
auto __result_first = __result_base - (__first_base - __last_base);
- std::__move_impl(__last_base, __first_base, __result_first);
+ std::__move_impl<_AlgPolicy>(__last_base, __first_base, __result_first);
return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
}
-template <class _InIter, class _Sent, class _OutIter>
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__enable_if_t<is_copy_constructible<_InIter>::value
&& is_copy_constructible<_Sent>::value
&& is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
__move(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
+ auto __ret = std::__move_impl<_AlgPolicy>(
+ std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
}
-template <class _InIter, class _Sent, class _OutIter>
+template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__enable_if_t<!is_copy_constructible<_InIter>::value
|| !is_copy_constructible<_Sent>::value
|| !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
__move(_InIter __first, _Sent __last, _OutIter __result) {
- return std::__move_impl(std::move(__first), std::move(__last), std::move(__result));
+ return std::__move_impl<_AlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
}
template <class _InputIterator, class _OutputIterator>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
- return std::__move(__first, __last, __result).second;
+ return std::__move<_ClassicAlgPolicy>(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
index a56f6b826ce3..626e250b6d41 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/unwrap_iter.h>
#include <__config>
#include <__utility/move.h>
@@ -21,25 +22,25 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _InputIterator, class _OutputIterator>
+template <class _AlgPolicy, class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_OutputIterator
__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
while (__first != __last)
- *--__result = _VSTD::move(*--__last);
+ *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last);
return __result;
}
-template <class _InputIterator, class _OutputIterator>
+template <class _AlgPolicy, class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_OutputIterator
-__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+__move_backward_impl(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
- return _VSTD::__move_backward_constexpr(__first, __last, __result);
+ return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);
}
-template <class _Tp, class _Up>
+template <class _AlgPolicy, class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
@@ -47,7 +48,7 @@ typename enable_if
is_trivially_move_assignable<_Up>::value,
_Up*
>::type
-__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
+__move_backward_impl(_Tp* __first, _Tp* __last, _Up* __result)
{
const size_t __n = static_cast<size_t>(__last - __first);
if (__n > 0)
@@ -58,22 +59,31 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result)
return __result;
}
-template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+template <class _AlgPolicy, class _BidirectionalIterator1, class _BidirectionalIterator2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_BidirectionalIterator2
-move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
- _BidirectionalIterator2 __result)
+__move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+ _BidirectionalIterator2 __result)
{
if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__move_backward_constexpr(__first, __last, __result);
+ return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);
} else {
return _VSTD::__rewrap_iter(__result,
- _VSTD::__move_backward(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
+ _VSTD::__move_backward_impl<_AlgPolicy>(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result)));
}
}
+template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_BidirectionalIterator2
+move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+ _BidirectionalIterator2 __result)
+{
+ return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
index 05e56f4a17ff..b58dcf4e1a91 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
@@ -11,10 +11,12 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/reverse.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,29 +24,34 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_BidirectionalIterator, bool>
+__next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
{
- _BidirectionalIterator __i = __last;
+ using _Result = pair<_BidirectionalIterator, bool>;
+
+ _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ _BidirectionalIterator __i = __last_iter;
if (__first == __last || __first == --__i)
- return false;
+ return _Result(std::move(__last_iter), false);
+
while (true)
{
_BidirectionalIterator __ip1 = __i;
if (__comp(*--__i, *__ip1))
{
- _BidirectionalIterator __j = __last;
+ _BidirectionalIterator __j = __last_iter;
while (!__comp(*__i, *--__j))
;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
+ _IterOps<_AlgPolicy>::iter_swap(__i, __j);
+ std::__reverse<_AlgPolicy>(__ip1, __last_iter);
+ return _Result(std::move(__last_iter), true);
}
if (__i == __first)
{
- _VSTD::reverse(__first, __last);
- return false;
+ std::__reverse<_AlgPolicy>(__first, __last_iter);
+ return _Result(std::move(__last_iter), false);
}
}
}
@@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ return std::__next_permutation<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second;
}
template <class _BidirectionalIterator>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
index 24016e5cf5a5..dff0cd01f35a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
@@ -31,12 +31,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
_LIBCPP_CONSTEXPR_AFTER_CXX17
_RandomAccessIterator __partial_sort_impl(
- _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare __comp) {
+ _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
if (__first == __middle) {
return _IterOps<_AlgPolicy>::next(__middle, __last);
}
- std::__make_heap<_AlgPolicy, _Compare>(__first, __middle, __comp);
+ std::__make_heap<_AlgPolicy>(__first, __middle, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
_RandomAccessIterator __i = __middle;
@@ -45,11 +45,11 @@ _RandomAccessIterator __partial_sort_impl(
if (__comp(*__i, *__first))
{
_IterOps<_AlgPolicy>::iter_swap(__i, __first);
- std::__sift_down<_AlgPolicy, _Compare>(__first, __comp, __len, __first);
+ std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
}
}
- std::__sort_heap<_AlgPolicy, _Compare>(std::move(__first), std::move(__middle), __comp);
+ std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
return __i;
}
@@ -64,7 +64,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
std::__debug_randomize_range<_AlgPolicy>(__first, __last);
using _Comp_ref = typename __comp_ref_type<_Compare>::type;
- auto __last_iter = std::__partial_sort_impl<_AlgPolicy, _Comp_ref>(__first, __middle, __last, __comp);
+ auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp));
std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
index 3556764e652d..55edf31b0f92 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
@@ -13,10 +13,16 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_heap.h>
+#include <__algorithm/make_projected.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_callable.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,27 +30,33 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _AlgPolicy, class _Compare, class _InputIterator, class _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-__partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+template <class _AlgPolicy, class _Compare,
+ class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
+ class _Proj1, class _Proj2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator>
+__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
+ _RandomAccessIterator __result_first, _Sentinel2 __result_last,
+ _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
{
_RandomAccessIterator __r = __result_first;
+ auto&& __projected_comp = std::__make_projected(__comp, __proj2);
+
if (__r != __result_last)
{
for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
*__r = *__first;
- std::__make_heap<_AlgPolicy, _Compare>(__result_first, __r, __comp);
+ std::__make_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
for (; __first != __last; ++__first)
- if (__comp(*__first, *__result_first))
- {
+ if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) {
*__result_first = *__first;
- std::__sift_down<_AlgPolicy, _Compare>(__result_first, __comp, __len, __result_first);
+ std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first);
}
- std::__sort_heap<_AlgPolicy, _Compare>(__result_first, __r, __comp);
+ std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
}
- return __r;
+
+ return pair<_InputIterator, _RandomAccessIterator>(
+ _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r));
}
template <class _InputIterator, class _RandomAccessIterator, class _Compare>
@@ -53,9 +65,13 @@ _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return std::__partial_sort_copy<_ClassicAlgPolicy, _Comp_ref>(
- __first, __last, __result_first, __result_last, __comp);
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
+ "Comparator has to be callable");
+
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,
+ static_cast<_Comp_ref>(__comp), __identity(), __identity());
+ return __result.second;
}
template <class _InputIterator, class _RandomAccessIterator>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h
index 870af50c133e..44d5d3972605 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h
@@ -38,7 +38,7 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
if (__len > 1) {
value_type __top = _IterOps<_AlgPolicy>::__iter_move(__first); // create a hole at __first
- _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy, _CompRef>(__first, __comp_ref, __len);
+ _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy>(__first, __comp_ref, __len);
--__last;
if (__hole == __last) {
@@ -47,7 +47,7 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
*__hole = _IterOps<_AlgPolicy>::__iter_move(__last);
++__hole;
*__last = std::move(__top);
- std::__sift_up<_AlgPolicy, _CompRef>(__first, __hole, __comp_ref, __hole - __first);
+ std::__sift_up<_AlgPolicy>(__first, __hole, __comp_ref, __hole - __first);
}
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
index 9dbc1dad0124..698506372b6f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
@@ -11,10 +11,12 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/reverse.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -22,29 +24,34 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_BidirectionalIterator, bool>
+__prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
{
- _BidirectionalIterator __i = __last;
+ using _Result = pair<_BidirectionalIterator, bool>;
+
+ _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
+ _BidirectionalIterator __i = __last_iter;
if (__first == __last || __first == --__i)
- return false;
+ return _Result(std::move(__last_iter), false);
+
while (true)
{
_BidirectionalIterator __ip1 = __i;
if (__comp(*__ip1, *--__i))
{
- _BidirectionalIterator __j = __last;
+ _BidirectionalIterator __j = __last_iter;
while (!__comp(*--__j, *__i))
;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
+ _IterOps<_AlgPolicy>::iter_swap(__i, __j);
+ std::__reverse<_AlgPolicy>(__ip1, __last_iter);
+ return _Result(std::move(__last_iter), true);
}
if (__i == __first)
{
- _VSTD::reverse(__first, __last);
- return false;
+ std::__reverse<_AlgPolicy>(__first, __last_iter);
+ return _Result(std::move(__last_iter), false);
}
}
}
@@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
+ using _Comp_ref = typename __comp_ref_type<_Compare>::type;
+ return std::__prev_permutation<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second;
}
template <class _BidirectionalIterator>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
index 716670b76788..72ad51e1a887 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h
new file mode 100644
index 000000000000..bdde97e178a7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_CLAMP_H
+#define _LIBCPP___ALGORITHM_RANGES_CLAMP_H
+
+#include <__assert>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __clamp {
+struct __fn {
+
+ template <class _Type,
+ class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ const _Type& operator()(const _Type& __value,
+ const _Type& __low,
+ const _Type& __high,
+ _Comp __comp = {},
+ _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(!bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))),
+ "Bad bounds passed to std::ranges::clamp");
+
+ if (std::invoke(__comp, std::invoke(__proj, __value), std::invoke(__proj, __low)))
+ return __low;
+ else if (std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __value)))
+ return __high;
+ else
+ return __value;
+ }
+
+};
+} // namespace __clamp
+
+inline namespace __cpo {
+ inline constexpr auto clamp = __clamp::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_inplace_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_inplace_merge.h
index a0867e486c3a..12c90908c210 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_inplace_merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_inplace_merge.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
#include <__algorithm/inplace_merge.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__config>
#include <__functional/identity.h>
@@ -17,6 +18,7 @@
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
#include <__iterator/projected.h>
#include <__iterator/sortable.h>
#include <__ranges/access.h>
@@ -36,28 +38,38 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __inplace_merge {
-struct __fn {
+ struct __fn {
+ template <class _Iter, class _Sent, class _Comp, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
+ auto __last_iter = ranges::next(__middle, __last);
+ std::__inplace_merge<_RangeAlgPolicy>(
+ std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));
+ return __last_iter;
+ }
- template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
- requires sortable<_Iter, _Comp, _Proj>
- _LIBCPP_HIDE_FROM_ABI
- _Iter operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__middle; (void)__last; (void)__comp; (void)__proj;
- return {};
- }
+ template <
+ bidirectional_iterator _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less,
+ class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI _Iter
+ operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
+ }
- template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
- requires sortable<iterator_t<_Range>, _Comp, _Proj>
- _LIBCPP_HIDE_FROM_ABI
- borrowed_iterator_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle,
- _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__middle; (void)__comp; (void)__proj;
- return {};
- }
-
-};
+ template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<
+ iterator_t<_Range>,
+ _Comp,
+ _Proj> _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>
+ operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
+ return __inplace_merge_impl(
+ ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
+ }
+ };
} // namespace __inplace_merge
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h
index a3e86d1a8d72..0bb1dcda0e34 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap.h
@@ -39,7 +39,7 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr
static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
return __result == __last;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h
index bcd33ad404e8..8a751fcc5130 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_heap_until.h
@@ -40,7 +40,7 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr
static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_permutation.h
new file mode 100644
index 000000000000..41e302fe99dc
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_is_permutation.h
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_IS_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
+
+#include <__algorithm/is_permutation.h>
+#include <__algorithm/iterator_operations.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __is_permutation {
+struct __fn {
+
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2,
+ class _Proj1, class _Proj2, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ bool __is_permutation_func_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
+ return std::__is_permutation<_RangeAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
+ }
+
+ template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
+ forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_equivalence_relation<projected<_Iter1, _Proj1>,
+ projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
+ _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ return __is_permutation_func_impl(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
+ __pred, __proj1, __proj2);
+ }
+
+ template <forward_range _Range1,
+ forward_range _Range2,
+ class _Proj1 = identity,
+ class _Proj2 = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ bool operator()(_Range1&& __range1, _Range2&& __range2,
+ _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
+ if (ranges::distance(__range1) != ranges::distance(__range2))
+ return false;
+ }
+
+ return __is_permutation_func_impl(
+ ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2),
+ __pred, __proj1, __proj2);
+ }
+};
+} // namespace __is_permutation
+
+inline namespace __cpo {
+ inline constexpr auto is_permutation = __is_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_make_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_make_heap.h
index 8eabdd12cd2f..b114286a85cc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_make_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_make_heap.h
@@ -45,7 +45,7 @@ struct __fn {
_Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__make_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h
index ad4342d7c989..9e1d4c72fb58 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_MOVE_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/move.h>
#include <__config>
#include <__iterator/concepts.h>
@@ -36,24 +37,12 @@ namespace __move {
struct __fn {
template <class _InIter, class _Sent, class _OutIter>
- requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value
_LIBCPP_HIDE_FROM_ABI constexpr static
move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result));
+ auto __ret = std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
return {std::move(__ret.first), std::move(__ret.second)};
}
- template <class _InIter, class _Sent, class _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr static
- move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
- while (__first != __last) {
- *__result = ranges::iter_move(__first);
- ++__first;
- ++__result;
- }
- return {std::move(__first), std::move(__result)};
- }
-
template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
requires indirectly_movable<_InIter, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_move_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_move_backward.h
index b3dfa7139603..583a6bf29d51 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_move_backward.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_move_backward.h
@@ -40,10 +40,11 @@ struct __fn {
template <class _InIter, class _Sent, class _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr static
move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
- auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)),
+ auto __last_iter = ranges::next(__first, std::move(__last));
+ auto __ret = ranges::move(std::make_reverse_iterator(__last_iter),
std::make_reverse_iterator(__first),
std::make_reverse_iterator(__result));
- return {std::move(__ret.in.base()), std::move(__ret.out.base())};
+ return {std::move(__last_iter), std::move(__ret.out.base())};
}
template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_next_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_next_permutation.h
new file mode 100644
index 000000000000..34c5fee04050
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_next_permutation.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_NEXT_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
+
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/next_permutation.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter>
+using next_permutation_result = in_found_result<_InIter>;
+
+namespace __next_permutation {
+
+struct __fn {
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__next_permutation<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<borrowed_iterator_t<_Range>>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__next_permutation<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+};
+
+} // namespace __next_permutation
+
+inline namespace __cpo {
+constexpr inline auto next_permutation = __next_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_nth_element.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_nth_element.h
index b15eb816b918..ad63bd20fb47 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_nth_element.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_nth_element.h
@@ -44,7 +44,7 @@ struct __fn {
_Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort.h
index 5e82bc6fcc32..020e34925df7 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort.h
@@ -43,7 +43,7 @@ struct __fn {
template <class _Iter, class _Sent, class _Comp, class _Proj>
_LIBCPP_HIDE_FROM_ABI constexpr static
_Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) {
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp);
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort_copy.h
index 55ad2ca4e686..271c347b7aa2 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partial_sort_copy.h
@@ -10,11 +10,11 @@
#define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/partial_sort_copy.h>
#include <__config>
#include <__functional/identity.h>
-#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
@@ -23,7 +23,6 @@
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -52,9 +51,11 @@ struct __fn {
partial_sort_copy_result<_Iter1, _Iter2>
operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result_first, _Sent2 __result_last,
_Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result_first; (void)__result_last; (void)__comp; (void)__proj1; (void)__proj2;
- return {};
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result_first), std::move(__result_last),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
}
template <input_range _Range1, random_access_range _Range2, class _Comp = ranges::less,
@@ -67,9 +68,11 @@ struct __fn {
partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>>
operator()(_Range1&& __range, _Range2&& __result_range, _Comp __comp = {},
_Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
- // TODO: implement
- (void)__range; (void)__result_range; (void)__comp; (void)__proj1; (void)__proj2;
- return {};
+ auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), ranges::begin(__result_range), ranges::end(__result_range),
+ __comp, __proj1, __proj2
+ );
+ return {std::move(__result.first), std::move(__result.second)};
}
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partition.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partition.h
index 60bee699d90e..6a53933f37aa 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_partition.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_partition.h
@@ -44,7 +44,7 @@ struct __fn {
template <class _Iter, class _Sent, class _Proj, class _Pred>
_LIBCPP_HIDE_FROM_ABI static constexpr
subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
- auto&& __projected_pred = ranges::__make_projected_pred(__pred, __proj);
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
auto __result = std::__partition<_RangeAlgPolicy>(
std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_pop_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_pop_heap.h
index 92df6119d34a..fc7554fb0733 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_pop_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_pop_heap.h
@@ -46,7 +46,7 @@ struct __fn {
auto __last_iter = ranges::next(__first, __last);
auto __len = __last_iter - __first;
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__pop_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp, __len);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
new file mode 100644
index 000000000000..58da606d07f7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_prev_permutation.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_PREV_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
+
+#include <__algorithm/in_found_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/make_projected.h>
+#include <__algorithm/prev_permutation.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/sortable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template <class _InIter>
+using prev_permutation_result = in_found_result<_InIter>;
+
+namespace __prev_permutation {
+
+struct __fn {
+
+ template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<_Iter, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+ template <bidirectional_range _Range,
+ class _Comp = ranges::less, class _Proj = identity>
+ requires sortable<iterator_t<_Range>, _Comp, _Proj>
+ _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<borrowed_iterator_t<_Range>>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __result = std::__prev_permutation<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__result.first), std::move(__result.second)};
+ }
+
+};
+
+} // namespace __prev_permutation
+
+inline namespace __cpo {
+constexpr inline auto prev_permutation = __prev_permutation::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_push_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_push_heap.h
index 4c41b00128de..3436b39e12cc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_push_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_push_heap.h
@@ -45,7 +45,7 @@ struct __fn {
_Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
index 16e9009e7ef0..a8144ce0ecbf 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
@@ -10,19 +10,16 @@
#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/remove_copy.h>
+#include <__algorithm/ranges_remove_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -40,32 +37,30 @@ using remove_copy_result = in_out_result<_InIter, _OutIter>;
namespace __remove_copy {
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type,
- class _Proj = identity>
- requires indirectly_copyable<_InIter, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj;
- return {};
- }
-
- template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__value; (void)__proj;
- return {};
- }
-
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Type,
+ class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __val) { return __value == __val; };
+ return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
+ auto __pred = [&](auto&& __val) { return __value == __val; };
+ return ranges::__remove_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
+ }
+ };
} // namespace __remove_copy
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy_if.h
index 4eafe425b8e3..3f56693fa1f2 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy_if.h
@@ -38,33 +38,43 @@ namespace ranges {
template <class _InIter, class _OutIter>
using remove_copy_if_result = in_out_result<_InIter, _OutIter>;
-namespace __remove_copy_if {
-
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter,
- class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
- requires indirectly_copyable<_InIter, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_if_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj;
- return {};
+template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
+_LIBCPP_HIDE_FROM_ABI constexpr in_out_result<_InIter, _OutIter>
+__remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (!std::invoke(__pred, std::invoke(__proj, *__first))) {
+ *__result = *__first;
+ ++__result;
+ }
}
+ return {std::move(__first), std::move(__result)};
+}
- template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
- indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__pred; (void)__proj;
- return {};
- }
+namespace __remove_copy_if {
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<_InIter, _OutIter>
+ operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return ranges::__remove_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
+ }
+ };
} // namespace __remove_copy_if
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
index 19ef635d6f15..7d59dbe7dbed 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
@@ -10,19 +10,16 @@
#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/replace_copy.h>
+#include <__algorithm/ranges_replace_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -40,35 +37,45 @@ using replace_copy_result = in_out_result<_InIter, _OutIter>;
namespace __replace_copy {
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2,
- output_iterator<const _Type2&> _OutIter, class _Proj = identity>
- requires indirectly_copyable<_InIter, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ class _OldType,
+ class _NewType,
+ output_iterator<const _NewType&> _OutIter,
+ class _Proj = identity>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _OldType*>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<_InIter, _OutIter>
+ operator()(_InIter __first,
+ _Sent __last,
+ _OutIter __result,
+ const _OldType& __old_value,
+ const _NewType& __new_value,
_Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
- return {};
- }
-
- template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter,
- class _Proj = identity>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value,
+ auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ return ranges::__replace_copy_if_impl(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _OldType,
+ class _NewType,
+ output_iterator<const _NewType&> _OutIter,
+ class _Proj = identity>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _OldType*>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range,
+ _OutIter __result,
+ const _OldType& __old_value,
+ const _NewType& __new_value,
_Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj;
- return {};
- }
-
-};
+ auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ return ranges::__replace_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
+ }
+ };
} // namespace __replace_copy
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy_if.h
index 2a908e2057af..7602e8a14487 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy_if.h
@@ -10,19 +10,14 @@
#define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
#include <__algorithm/in_out_result.h>
-#include <__algorithm/make_projected.h>
-#include <__algorithm/replace_copy_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
-#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
-#include <__utility/forward.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -38,34 +33,51 @@ namespace ranges {
template <class _InIter, class _OutIter>
using replace_copy_if_result = in_out_result<_InIter, _OutIter>;
-namespace __replace_copy_if {
-
-struct __fn {
-
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter,
- class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
- requires indirectly_copyable<_InIter, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_if_result<_InIter, _OutIter>
- operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value,
- _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
- return {};
+template <class _InIter, class _Sent, class _OutIter, class _Pred, class _Type, class _Proj>
+_LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __replace_copy_if_impl(
+ _InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, const _Type& __new_value, _Proj& __proj) {
+ while (__first != __last) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first)))
+ *__result = __new_value;
+ else
+ *__result = *__first;
+
+ ++__first;
+ ++__result;
}
- template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity,
- indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter>
- _LIBCPP_HIDE_FROM_ABI constexpr
- replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
- operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj;
- return {};
- }
+ return {std::move(__first), std::move(__result)};
+}
+
+namespace __replace_copy_if {
-};
+ struct __fn {
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ class _Type,
+ output_iterator<const _Type&> _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<_InIter, _Proj>> _Pred>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> operator()(
+ _InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {})
+ const {
+ return ranges::__replace_copy_if_impl(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
+ }
+
+ template <input_range _Range,
+ class _Type,
+ output_iterator<const _Type&> _OutIter,
+ class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const {
+ return ranges::__replace_copy_if_impl(
+ ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
+ }
+ };
} // namespace __replace_copy_if
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate.h
new file mode 100644
index 000000000000..1cd69a141fe3
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate.h
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_ROTATE_H
+#define _LIBCPP___ALGORITHM_RANGES_ROTATE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/ranges_iterator_concept.h>
+#include <__algorithm/rotate.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/permutable.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/subrange.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __rotate {
+
+struct __fn {
+
+ template <class _Iter, class _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) {
+ auto __ret = std::__rotate<_RangeAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <permutable _Iter, sentinel_for<_Iter> _Sent>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ subrange<_Iter> operator()(_Iter __first, _Iter __middle, _Sent __last) const {
+ return __rotate_fn_impl(std::move(__first), std::move(__middle), std::move(__last));
+ }
+
+ template <forward_range _Range>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ borrowed_subrange_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle) const {
+ return __rotate_fn_impl(ranges::begin(__range), std::move(__middle), ranges::end(__range));
+ }
+
+};
+
+} // namespace __rotate
+
+inline namespace __cpo {
+ inline constexpr auto rotate = __rotate::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_sample.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sample.h
new file mode 100644
index 000000000000..a8477f803788
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sample.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_SAMPLE_H
+#define _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
+
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/sample.h>
+#include <__algorithm/uniform_random_bit_generator_adaptor.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__random/uniform_random_bit_generator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __sample {
+
+struct __fn {
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen>
+ requires (forward_iterator<_Iter> || random_access_iterator<_OutIter>) &&
+ indirectly_copyable<_Iter, _OutIter> &&
+ uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ _OutIter operator()(_Iter __first, _Sent __last,
+ _OutIter __out_first, iter_difference_t<_Iter> __n, _Gen&& __gen) const {
+ _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
+ return std::__sample<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__out_first), __n, __adapted_gen);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Gen>
+ requires (forward_range<_Range> || random_access_iterator<_OutIter>) &&
+ indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ uniform_random_bit_generator<remove_reference_t<_Gen>>
+ _LIBCPP_HIDE_FROM_ABI
+ _OutIter operator()(_Range&& __range, _OutIter __out_first, range_difference_t<_Range> __n, _Gen&& __gen) const {
+ return (*this)(ranges::begin(__range), ranges::end(__range),
+ std::move(__out_first), __n, std::forward<_Gen>(__gen));
+ }
+
+};
+
+} // namespace __sample
+
+inline namespace __cpo {
+ inline constexpr auto sample = __sample::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_shuffle.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_shuffle.h
index b101a8582eac..9b7f81e489b3 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_shuffle.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_shuffle.h
@@ -11,6 +11,7 @@
#include <__algorithm/iterator_operations.h>
#include <__algorithm/shuffle.h>
+#include <__algorithm/uniform_random_bit_generator_adaptor.h>
#include <__config>
#include <__functional/invoke.h>
#include <__functional/ranges_operations.h>
@@ -32,43 +33,12 @@
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __shuffle {
struct __fn {
- // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given
- // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given
- // generator to meet the uniform random bit generator requirements; these requirements include satisfying
- // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type`
- // typedef (see `[rand.req.urng]`).
- //
- // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping
- // it into an adaptor type that forwards all of its interface and adds the required typedef.
- template <class _Gen>
- class _ClassicGenAdaptor {
- private:
- // The generator is not required to be copyable or movable, so it has to be stored as a reference.
- _Gen& __gen;
-
- public:
- using result_type = invoke_result_t<_Gen&>;
-
- _LIBCPP_HIDE_FROM_ABI
- static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
- _LIBCPP_HIDE_FROM_ABI
- static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
-
- _LIBCPP_HIDE_FROM_ABI
- constexpr auto operator()() const { return __gen(); }
- };
template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
@@ -96,8 +66,6 @@ inline namespace __cpo {
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort.h
index ef14db64295d..c3f3cbff007c 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort.h
@@ -44,7 +44,7 @@ struct __fn {
_Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort_heap.h
index eb6a30dcd3d0..f6e4dcb43ddf 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_sort_heap.h
@@ -45,7 +45,7 @@ struct __fn {
_Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__sort_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_partition.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_partition.h
index 27957db8829f..b20dfa3a8bfc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_partition.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_partition.h
@@ -49,7 +49,7 @@ struct __fn {
_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_pred = ranges::__make_projected_pred(__pred, __proj);
+ auto&& __projected_pred = std::__make_projected(__pred, __proj);
auto __result = std::__stable_partition<_RangeAlgPolicy>(
std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>());
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_sort.h
index de48416a41be..7ecffefc19da 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_stable_sort.h
@@ -44,7 +44,7 @@ struct __fn {
static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
auto __last_iter = ranges::next(__first, __last);
- auto&& __projected_comp = ranges::__make_projected_comp(__comp, __proj);
+ auto&& __projected_comp = std::__make_projected(__comp, __proj);
std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
return __last_iter;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_swap_ranges.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_swap_ranges.h
index 3254e1c60abb..d980fdec2c49 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_swap_ranges.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_swap_ranges.h
@@ -10,6 +10,8 @@
#define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
#include <__algorithm/in_in_result.h>
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/swap_ranges.h>
#include <__config>
#include <__iterator/concepts.h>
#include <__iterator/iter_swap.h>
@@ -38,12 +40,9 @@ struct __fn {
requires indirectly_swappable<_I1, _I2>
_LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const {
- while (__first1 != __last1 && __first2 != __last2) {
- ranges::iter_swap(__first1, __first2);
- ++__first1;
- ++__first2;
- }
- return {_VSTD::move(__first1), _VSTD::move(__first2)};
+ auto __ret = std::__swap_ranges<_RangeAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2));
+ return {std::move(__ret.first), std::move(__ret.second)};
}
template <input_range _R1, input_range _R2>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique.h
index bdf755e9406e..11370aeccd24 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique.h
@@ -9,6 +9,7 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/unique.h>
#include <__config>
@@ -37,28 +38,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
namespace __unique {
-struct __fn {
+ struct __fn {
+ template <
+ permutable _Iter,
+ sentinel_for<_Iter> _Sent,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
+ _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
+ operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
- template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
- indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
- _LIBCPP_HIDE_FROM_ABI constexpr
- subrange<_Iter> operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__comp; (void)__proj;
- return {};
- }
-
- template <forward_range _Range, class _Proj = identity,
- indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
- requires permutable<iterator_t<_Range>>
- _LIBCPP_HIDE_FROM_ABI constexpr
- borrowed_subrange_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__comp; (void)__proj;
- return {};
- }
-
-};
+ template <
+ forward_range _Range,
+ class _Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
+ requires permutable<iterator_t<_Range>>
+ _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
+ operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__unique<_RangeAlgPolicy>(
+ ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+ };
} // namespace __unique
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique_copy.h
index 56361aa8ae2f..8c0b970d043f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_unique_copy.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
#include <__algorithm/in_out_result.h>
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/make_projected.h>
#include <__algorithm/unique_copy.h>
#include <__concepts/same_as.h>
@@ -19,8 +20,8 @@
#include <__functional/ranges_operations.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
-#include <__iterator/readable_traits.h>
#include <__iterator/projected.h>
+#include <__iterator/readable_traits.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
@@ -42,42 +43,68 @@ using unique_copy_result = in_out_result<_InIter, _OutIter>;
namespace __unique_copy {
+template <class _InIter, class _OutIter>
+concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>);
+
struct __fn {
+ template <class _InIter, class _OutIter>
+ static consteval auto __get_algo_tag() {
+ if constexpr (forward_iterator<_InIter>) {
+ return __unique_copy_tags::__reread_from_input_tag{};
+ } else if constexpr (__can_reread_from_output<_InIter, _OutIter>) {
+ return __unique_copy_tags::__reread_from_output_tag{};
+ } else if constexpr (indirectly_copyable_storable<_InIter, _OutIter>) {
+ return __unique_copy_tags::__read_from_tmp_value_tag{};
+ }
+ }
+
+ template <class _InIter, class _OutIter>
+ using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>());
- template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Proj = identity,
+ template <input_iterator _InIter,
+ sentinel_for<_InIter> _Sent,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
indirect_equivalence_relation<projected<_InIter, _Proj>> _Comp = ranges::equal_to>
- requires indirectly_copyable<_InIter, _OutIter> &&
- (forward_iterator<_InIter> ||
- (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
- indirectly_copyable_storable<_InIter, _OutIter>)
- _LIBCPP_HIDE_FROM_ABI constexpr
- unique_copy_result<_InIter, _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter> &&
+ (forward_iterator<_InIter> ||
+ (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<_InIter, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter>
operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__first; (void)__last; (void)__result; (void)__comp; (void)__proj;
- return {};
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ std::move(__first),
+ std::move(__last),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<_InIter, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
}
- template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
+ template <input_range _Range,
+ weakly_incrementable _OutIter,
+ class _Proj = identity,
indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
- requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
- (forward_iterator<iterator_t<_Range>> ||
- (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
- indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
- _LIBCPP_HIDE_FROM_ABI constexpr
- unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
+ (forward_iterator<iterator_t<_Range>> ||
+ (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) ||
+ indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
+ _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
- // TODO: implement
- (void)__range; (void)__result; (void)__comp; (void)__proj;
- return {};
+ auto __ret = std::__unique_copy<_RangeAlgPolicy>(
+ ranges::begin(__range),
+ ranges::end(__range),
+ std::move(__result),
+ std::__make_projected(__comp, __proj),
+ __algo_tag_t<iterator_t<_Range>, _OutIter>());
+ return {std::move(__ret.first), std::move(__ret.second)};
}
-
};
} // namespace __unique_copy
inline namespace __cpo {
- inline constexpr auto unique_copy = __unique_copy::__fn{};
+inline constexpr auto unique_copy = __unique_copy::__fn{};
} // namespace __cpo
} // namespace ranges
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/reverse.h b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
index 0202cd740833..6484c73752ef 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
@@ -10,8 +10,10 @@
#define _LIBCPP___ALGORITHM_REVERSE_H
#include <__algorithm/iter_swap.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -19,28 +21,35 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BidirectionalIterator>
+template <class _AlgPolicy, class _BidirectionalIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
+__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
{
while (__first != __last)
{
if (__first == --__last)
break;
- _VSTD::iter_swap(__first, __last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
++__first;
}
}
-template <class _RandomAccessIterator>
+template <class _AlgPolicy, class _RandomAccessIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
-__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
+__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
{
if (__first != __last)
for (; __first < --__last; ++__first)
- _VSTD::iter_swap(__first, __last);
+ _IterOps<_AlgPolicy>::iter_swap(__first, __last);
+}
+
+template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+void __reverse(_BidirectionalIterator __first, _Sentinel __last) {
+ using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>;
+ std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory());
}
template <class _BidirectionalIterator>
@@ -48,7 +57,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
- _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
+ std::__reverse<_ClassicAlgPolicy>(std::move(__first), std::move(__last));
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/rotate.h b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
index fcf8444a65a0..beb5409d5b88 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
@@ -15,10 +15,8 @@
#include <__algorithm/swap_ranges.h>
#include <__config>
#include <__iterator/iterator_traits.h>
-#include <__iterator/next.h>
-#include <__iterator/prev.h>
#include <__utility/move.h>
-#include <__utility/swap.h>
+#include <__utility/pair.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -32,9 +30,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first);
- // TODO(ranges): pass `_AlgPolicy` to `move`.
- _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ value_type __tmp = _Ops::__iter_move(__first);
+ _ForwardIterator __lm1 = std::__move<_AlgPolicy>(
+ _Ops::next(__first), __last, __first).second;
*__lm1 = _VSTD::move(__tmp);
return __lm1;
}
@@ -44,11 +44,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- // TODO(ranges): pass `_AlgPolicy` to `prev`.
- _BidirectionalIterator __lm1 = _VSTD::prev(__last);
- value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1);
- // TODO(ranges): pass `_AlgPolicy` to `move_backward`.
- _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
+ using _Ops = _IterOps<_AlgPolicy>;
+
+ _BidirectionalIterator __lm1 = _Ops::prev(__last);
+ value_type __tmp = _Ops::__iter_move(__lm1);
+ _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last));
*__first = _VSTD::move(__tmp);
return __fp1;
}
@@ -108,26 +108,26 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ using _Ops = _IterOps<_AlgPolicy>;
const difference_type __m1 = __middle - __first;
- const difference_type __m2 = __last - __middle;
+ const difference_type __m2 = _Ops::distance(__middle, __last);
if (__m1 == __m2)
{
- // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`.
- _VSTD::swap_ranges(__first, __middle, __middle);
+ std::__swap_ranges<_AlgPolicy>(__first, __middle, __middle, __last);
return __middle;
}
const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
- value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p));
+ value_type __t(_Ops::__iter_move(--__p));
_RandomAccessIterator __p1 = __p;
_RandomAccessIterator __p2 = __p1 + __m1;
do
{
- *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2);
+ *__p1 = _Ops::__iter_move(__p2);
__p1 = __p2;
- const difference_type __d = __last - __p2;
+ const difference_type __d = _Ops::distance(__p2, __last);
if (__m1 < __d)
__p2 += __m1;
else
@@ -188,16 +188,23 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra
return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last);
}
-template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory>
+template <class _AlgPolicy, class _Iterator, class _Sentinel>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-_RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle,
- _RandomAccessIterator __last, _IterCategory __iter_category) {
+pair<_Iterator, _Iterator>
+__rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
+ using _Ret = pair<_Iterator, _Iterator>;
+ _Iterator __last_iter = _IterOps<_AlgPolicy>::next(__middle, __last);
+
if (__first == __middle)
- return __last;
+ return _Ret(__last_iter, __last_iter);
if (__middle == __last)
- return __first;
+ return _Ret(std::move(__first), std::move(__last_iter));
+
+ using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_Iterator>;
+ auto __result = std::__rotate_impl<_AlgPolicy>(
+ std::move(__first), std::move(__middle), __last_iter, _IterCategory());
- return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category);
+ return _Ret(std::move(__result), std::move(__last_iter));
}
template <class _ForwardIterator>
@@ -205,8 +212,8 @@ inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
- return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last,
- typename iterator_traits<_ForwardIterator>::iterator_category());
+ return std::__rotate<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__middle), std::move(__last)).first;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sample.h b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
index e04466a08d5a..f403ba612580 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sample.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
@@ -9,12 +9,14 @@
#ifndef _LIBCPP___ALGORITHM_SAMPLE_H
#define _LIBCPP___ALGORITHM_SAMPLE_H
+#include <__algorithm/iterator_operations.h>
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -26,13 +28,14 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
- _UniformRandomNumberGenerator & __g,
+ _UniformRandomNumberGenerator& __g,
input_iterator_tag) {
_Distance __k = 0;
@@ -47,15 +50,16 @@ _SampleIterator __sample(_PopulationIterator __first,
return __output_iter + _VSTD::min(__n, __k);
}
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
_UniformRandomNumberGenerator& __g,
forward_iterator_tag) {
- _Distance __unsampled_sz = _VSTD::distance(__first, __last);
+ _Distance __unsampled_sz = _IterOps<_AlgPolicy>::distance(__first, __last);
for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
_Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
if (__r < __n) {
@@ -66,24 +70,22 @@ _SampleIterator __sample(_PopulationIterator __first,
return __output_iter;
}
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
+template <class _AlgPolicy,
+ class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
+ _PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n, _UniformRandomNumberGenerator& __g) {
- typedef typename iterator_traits<_PopulationIterator>::iterator_category
- _PopCategory;
- typedef typename iterator_traits<_PopulationIterator>::difference_type
- _Difference;
- static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
- __is_cpp17_random_access_iterator<_SampleIterator>::value,
- "SampleIterator must meet the requirements of RandomAccessIterator");
- typedef typename common_type<_Distance, _Difference>::type _CommonType;
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
- return _VSTD::__sample(
- __first, __last, __output_iter, _CommonType(__n),
- __g, _PopCategory());
+
+ using _PopIterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_PopulationIterator>;
+ using _Difference = typename _IterOps<_AlgPolicy>::template __difference_type<_PopulationIterator>;
+ using _CommonType = typename common_type<_Distance, _Difference>::type;
+
+ return std::__sample<_AlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__output_iter), _CommonType(__n),
+ __g, _PopIterCategory());
}
#if _LIBCPP_STD_VER > 14
@@ -93,8 +95,14 @@ inline _LIBCPP_INLINE_VISIBILITY
_SampleIterator sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output_iter,
_Distance __n, _UniformRandomNumberGenerator&& __g) {
- return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
+ static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
+ __is_cpp17_random_access_iterator<_SampleIterator>::value,
+ "SampleIterator must meet the requirements of RandomAccessIterator");
+
+ return std::__sample<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__output_iter), __n, __g);
}
+
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
index be2eb29dd53a..06811239f84f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__sift_down(_RandomAccessIterator __first, _Compare __comp,
+__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{
@@ -79,7 +79,7 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp,
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
-__floyd_sift_down(_RandomAccessIterator __first, _Compare __comp,
+__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
{
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h
index b9f0b2c9690d..7713b766f913 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h
@@ -26,13 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
-void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
+void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
using _CompRef = typename __comp_ref_type<_Compare>::type;
_CompRef __comp_ref = __comp;
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
- std::__pop_heap<_AlgPolicy, _CompRef>(__first, __last, __comp_ref, __n);
+ std::__pop_heap<_AlgPolicy>(__first, __last, __comp_ref, __n);
}
template <class _RandomAccessIterator, class _Compare>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
index e5ad48b2ed51..c7aa3f07a88c 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
@@ -108,7 +108,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first;
// TTTTTTTTFFFFFFFFFF
// |
}
@@ -253,7 +253,7 @@ __first_half_done:
__second_half_done:
// TTTFFFFFTTTTTFFFFF
// f ff m sf l
- return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit);
+ return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first;
// TTTTTTTTFFFFFFFFFF
// |
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
index 6122758bdefe..fb149eeb65dc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
@@ -203,7 +203,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
}
std::__stable_sort<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
std::__stable_sort<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
- std::__inplace_merge<_AlgPolicy, _Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+ std::__inplace_merge<_AlgPolicy>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
}
template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
index 0422265bb4be..0cff519a8da9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
@@ -9,8 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H
#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
+#include <__algorithm/iterator_operations.h>
#include <__config>
-#include <__utility/swap.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -18,12 +20,39 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+// 2+2 iterators: the shorter size will be used.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_ForwardIterator1, _ForwardIterator2>
+__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
+ while (__first1 != __last1 && __first2 != __last2) {
+ _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+
+ return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
+}
+
+// 2+1 iterators: size2 >= size1.
+template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_ForwardIterator1, _ForwardIterator2>
+__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
+ while (__first1 != __last1) {
+ _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
+ ++__first1;
+ ++__first2;
+ }
+
+ return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
+}
+
template <class _ForwardIterator1, class _ForwardIterator2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
- for (; __first1 != __last1; ++__first1, (void)++__first2)
- swap(*__first1, *__first2);
- return __first2;
+ return std::__swap_ranges<_ClassicAlgPolicy>(
+ std::move(__first1), std::move(__last1), std::move(__first2)).second;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h b/contrib/llvm-project/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h
new file mode 100644
index 000000000000..04a67752dd0b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
+#define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Range versions of random algorithms (e.g. `std::shuffle`) are less constrained than their classic counterparts.
+// Range algorithms only require the given generator to satisfy the `std::uniform_random_bit_generator` concept.
+// Classic algorithms require the given generator to meet the uniform random bit generator requirements; these
+// requirements include satisfying `std::uniform_random_bit_generator` and add a requirement for the generator to
+// provide a nested `result_type` typedef (see `[rand.req.urng]`).
+//
+// To be able to reuse classic implementations, make the given generator meet the classic requirements by wrapping
+// it into an adaptor type that forwards all of its interface and adds the required typedef.
+template <class _Gen>
+class _ClassicGenAdaptor {
+private:
+ // The generator is not required to be copyable or movable, so it has to be stored as a reference.
+ _Gen& __gen;
+
+public:
+ using result_type = invoke_result_t<_Gen&>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()() const { return __gen(); }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER > 17
+
+#endif // _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unique.h b/contrib/llvm-project/libcxx/include/__algorithm/unique.h
index 264d727d93c8..1727225a91cd 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/unique.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unique.h
@@ -11,9 +11,11 @@
#include <__algorithm/adjacent_find.h>
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,32 +25,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// unique
+template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 std::pair<_Iter, _Iter>
+__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ __first = std::__adjacent_find(__first, __last, __pred);
+ if (__first != __last) {
+ // ... a a ? ...
+ // f i
+ _Iter __i = __first;
+ for (++__i; ++__i != __last;)
+ if (!__pred(*__first, *__i))
+ *++__first = _IterOps<_AlgPolicy>::__iter_move(__i);
+ ++__first;
+ return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i));
+ }
+ return std::pair<_Iter, _Iter>(__first, __first);
+}
+
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
-{
- __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred);
- if (__first != __last)
- {
- // ... a a ? ...
- // f i
- _ForwardIterator __i = __first;
- for (++__i; ++__i != __last;)
- if (!__pred(*__first, *__i))
- *++__first = _VSTD::move(*__i);
- ++__first;
- }
- return __first;
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
+ return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::unique(__first, __last, __equal_to<__v>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+ return std::unique(__first, __last, __equal_to<__v>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h
index f58517749f51..c7c8d8e9d8fd 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h
@@ -10,8 +10,14 @@
#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
#include <__algorithm/comp.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/is_same.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -19,88 +25,99 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- typename iterator_traits<_InputIterator>::value_type __t(*__first);
+namespace __unique_copy_tags {
+
+struct __reread_from_input_tag {};
+struct __reread_from_output_tag {};
+struct __read_from_tmp_value_tag {};
+
+} // namespace __unique_copy_tags
+
+template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__read_from_tmp_value_tag) {
+ if (__first != __last) {
+ typename _IterOps<_AlgPolicy>::template __value_type<_InputIterator> __t(*__first);
+ *__result = __t;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(__t, *__first)) {
+ __t = *__first;
*__result = __t;
++__result;
- while (++__first != __last)
- {
- if (!__pred(__t, *__first))
- {
- __t = *__first;
- *__result = __t;
- ++__result;
- }
- }
+ }
}
- return __result;
+ }
+ return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__result));
}
-template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- forward_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- *__result = *__i;
+template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
+__unique_copy(_ForwardIterator __first,
+ _Sent __last,
+ _OutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_input_tag) {
+ if (__first != __last) {
+ _ForwardIterator __i = __first;
+ *__result = *__i;
+ ++__result;
+ while (++__first != __last) {
+ if (!__pred(*__i, *__first)) {
+ *__result = *__first;
++__result;
- while (++__first != __last)
- {
- if (!__pred(*__i, *__first))
- {
- *__result = *__first;
- ++__result;
- __i = __first;
- }
- }
+ __i = __first;
+ }
}
- return __result;
+ }
+ return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__result));
}
-template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, forward_iterator_tag)
-{
- if (__first != __last)
- {
- *__result = *__first;
- while (++__first != __last)
- if (!__pred(*__result, *__first))
- *++__result = *__first;
- ++__result;
- }
- return __result;
+template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
+__unique_copy(_InputIterator __first,
+ _Sent __last,
+ _InputAndOutputIterator __result,
+ _BinaryPredicate&& __pred,
+ __unique_copy_tags::__reread_from_output_tag) {
+ if (__first != __last) {
+ *__result = *__first;
+ while (++__first != __last)
+ if (!__pred(*__result, *__first))
+ *++__result = *__first;
+ ++__result;
+ }
+ return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__result));
}
template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
-{
- return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred,
- typename iterator_traits<_InputIterator>::iterator_category(),
- typename iterator_traits<_OutputIterator>::iterator_category());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
+ using __algo_tag = typename conditional<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
+ __unique_copy_tags::__reread_from_input_tag,
+ typename conditional<
+ is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
+ is_same< typename iterator_traits<_InputIterator>::value_type,
+ typename iterator_traits<_OutputIterator>::value_type>::value,
+ __unique_copy_tags::__reread_from_output_tag,
+ __unique_copy_tags::__read_from_tmp_value_tag>::type >::type;
+ return std::__unique_copy<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
+ .second;
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- typedef typename iterator_traits<_InputIterator>::value_type __v;
- return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ typedef typename iterator_traits<_InputIterator>::value_type __v;
+ return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>());
}
-
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h
new file mode 100644
index 000000000000..745906a96e15
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___ALGORITHM_UNWRAP_RANGE_H
+#define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
+
+#include <__algorithm/unwrap_iter.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/next.h>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types.
+// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
+// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+template <class _Iter, class _Sent>
+struct __unwrap_range_impl {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ auto __last = ranges::next(__first, __sent);
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
+ return pair{std::move(__first), std::move(__last)};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter)
+ requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
+ {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
+ requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
+ {
+ return __iter;
+ }
+};
+
+template <class _Iter>
+struct __unwrap_range_impl<_Iter, _Iter> {
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
+ return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+ }
+};
+
+template <class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
+ return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
+}
+
+template <
+ class _Sent,
+ class _Iter,
+ class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))>
+_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
+}
+#else // _LIBCPP_STD_VER > 17
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) {
+ return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
+}
+
+template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
+ return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
+}
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
diff --git a/contrib/llvm-project/libcxx/include/__assert b/contrib/llvm-project/libcxx/include/__assert
index 82db2cf052b5..87556085eabb 100644
--- a/contrib/llvm-project/libcxx/include/__assert
+++ b/contrib/llvm-project/libcxx/include/__assert
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ASSERT
#define _LIBCPP___ASSERT
-#include <__availability>
#include <__config>
+#include <__verbose_abort>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -45,7 +45,7 @@
# define _LIBCPP_ASSERT(expression, message) \
(__builtin_expect(static_cast<bool>(expression), 1) ? \
(void)0 : \
- ::std::__libcpp_assertion_handler("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
+ ::std::__libcpp_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
# define _LIBCPP_ASSERT(expression, message) \
(_LIBCPP_DIAGNOSTIC_PUSH \
@@ -56,11 +56,4 @@
# define _LIBCPP_ASSERT(expression, message) ((void)0)
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ASSERTION_HANDLER _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
-void __libcpp_assertion_handler(const char *__format, ...);
-
-_LIBCPP_END_NAMESPACE_STD
-
#endif // _LIBCPP___ASSERT
diff --git a/contrib/llvm-project/libcxx/include/__availability b/contrib/llvm-project/libcxx/include/__availability
index f9d824509f3d..72ff663334d3 100644
--- a/contrib/llvm-project/libcxx/include/__availability
+++ b/contrib/llvm-project/libcxx/include/__availability
@@ -156,22 +156,21 @@
# define _LIBCPP_AVAILABILITY_FORMAT
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
- // This controls whether the std::__libcpp_assertion_handler default
- // assertion handler is provided by the library.
+ // This controls whether the default verbose termination function is
+ // provided by the library.
//
- // Note that when users provide their own custom assertion handler,
- // it doesn't matter whether the dylib provides a default handler,
- // and the availability markup can actually give a false positive
- // diagnostic (it will think that no handler is provided, when in
- // reality the user has provided their own).
+ // Note that when users provide their own custom function, it doesn't
+ // matter whether the dylib provides a default function, and the
+ // availability markup can actually give a false positive diagnostic
+ // (it will think that no function is provided, when in reality the
+ // user has provided their own).
//
- // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED
- // to the compiler to tell the library to ignore the fact that the
- // default handler isn't available on their deployment target. Note that
- // defining this macro but failing to define a custom assertion handler
- // will lead to a load-time error on back-deployment targets, so it
- // should be avoided.
-# define _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER
+ // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
+ // to the compiler to tell the library not to define its own verbose abort.
+ // Note that defining this macro but failing to define a custom function
+ // will lead to a load-time error on back-deployment targets, so it should
+ // be avoided.
+// # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
#elif defined(__APPLE__)
@@ -272,8 +271,8 @@
__attribute__((unavailable))
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
-# define _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER \
- __attribute__((unavailable))
+# define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
+
#else
// ...New vendors can add availability markup here...
@@ -297,14 +296,4 @@
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
-// Define the special assertion handler availability attribute, which can be silenced by
-// users if they provide their own custom assertion handler. The rest of the code should
-// not use the *_DEFAULT_* macro directly, since that would make it ignore the fact that
-// the user provided a custom handler.
-#if defined(_LIBCPP_AVAILABILITY_CUSTOM_ASSERTION_HANDLER_PROVIDED)
-# define _LIBCPP_AVAILABILITY_ASSERTION_HANDLER /* nothing */
-#else
-# define _LIBCPP_AVAILABILITY_ASSERTION_HANDLER _LIBCPP_AVAILABILITY_DEFAULT_ASSERTION_HANDLER
-#endif
-
#endif // _LIBCPP___AVAILABILITY
diff --git a/contrib/llvm-project/libcxx/include/__bit_reference b/contrib/llvm-project/libcxx/include/__bit_reference
index f54cb6c16f48..60f57d665a1c 100644
--- a/contrib/llvm-project/libcxx/include/__bit_reference
+++ b/contrib/llvm-project/libcxx/include/__bit_reference
@@ -10,10 +10,13 @@
#ifndef _LIBCPP___BIT_REFERENCE
#define _LIBCPP___BIT_REFERENCE
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
#include <__algorithm/min.h>
#include <__bits>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <cstring>
#include <type_traits>
@@ -51,15 +54,15 @@ class __bit_reference
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>;
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference(const __bit_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
- _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
{return !static_cast<bool>(*this);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(bool __x) _NOEXCEPT
{
if (__x)
@@ -70,7 +73,7 @@ public:
}
#if _LIBCPP_STD_VER > 20
- _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
+ _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
if (__x)
*__seg_ |= __mask_;
else
@@ -79,15 +82,15 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
{return operator=(static_cast<bool>(__x));}
- _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
};
@@ -98,7 +101,7 @@ class __bit_reference<_Cp, false>
};
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -108,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
}
template <class _Cp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
{
@@ -118,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
{
@@ -128,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@@ -152,14 +155,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
__bit_const_reference(const __bit_const_reference&) = default;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__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<bool>(*__seg_ & __mask_);}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
@@ -173,12 +176,12 @@ private:
// find
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __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;
+ const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@@ -209,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
@@ -248,7 +251,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, _IsConst>
find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
{
@@ -334,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
// fill_n
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -352,7 +355,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
+ std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -364,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@@ -382,7 +385,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
// do middle whole words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+ // __storage_type is always an unsigned type, so -1 sets all bits
+ std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@@ -394,7 +398,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
{
@@ -410,7 +414,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
// fill
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
{
@@ -420,6 +424,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
// copy
template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@@ -449,9 +454,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
// __first.__ctz_ == 0;
// do middle words
__storage_type __nw = __n / __bits_per_word;
- _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
- _VSTD::__to_address(__first.__seg_),
- __nw * sizeof(__storage_type));
+ std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
__result.__seg_ += __nw;
// do last word
@@ -469,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
}
template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@@ -476,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
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;
+ const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@@ -547,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -559,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
// copy_backward
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -590,9 +594,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
__storage_type __nw = __n / __bits_per_word;
__result.__seg_ -= __nw;
__last.__seg_ -= __nw;
- _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
- _VSTD::__to_address(__last.__seg_),
- __nw * sizeof(__storage_type));
+ std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
// do last word
if (__n > 0)
@@ -608,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
}
template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@@ -694,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
}
template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@@ -901,14 +903,19 @@ struct __bit_array
difference_type __size_;
__storage_type __word_[_Np];
- _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity()
{return static_cast<difference_type>(_Np * __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
- _LIBCPP_INLINE_VISIBILITY iterator begin()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) {
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
+ std::__construct_at(__word_ + __i, 0);
+ }
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
}
- _LIBCPP_INLINE_VISIBILITY iterator end()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
static_cast<unsigned>(__size_ % __bits_per_word));
@@ -916,7 +923,7 @@ struct __bit_array
};
template <class _Cp>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __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;
@@ -967,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
// equal
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 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;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1049,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
}
template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 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;
+ const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@@ -1092,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
}
template <class _Cp, bool _IC1, bool _IC2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
{
@@ -1126,7 +1133,7 @@ private:
unsigned __ctz_;
public:
- _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __seg_(nullptr), __ctz_(0)
#endif
@@ -1137,7 +1144,7 @@ public:
// When _IsConst=true, this is a converting constructor;
// the copy and move constructors are implicitly generated
// and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
@@ -1146,19 +1153,19 @@ public:
// the implicit generation of a defaulted one is deprecated.
// When _IsConst=true, the assignment operators are
// implicitly generated and trivial.
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
__seg_ = __it.__seg_;
__ctz_ = __it.__ctz_;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
::type(__seg_, __storage_type(1) << __ctz_);
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
{
if (__ctz_ != __bits_per_word-1)
++__ctz_;
@@ -1170,14 +1177,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
{
__bit_iterator __tmp = *this;
++(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
{
if (__ctz_ != 0)
--__ctz_;
@@ -1189,14 +1196,14 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
{
__bit_iterator __tmp = *this;
--(*this);
return __tmp;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n)
{
if (__n >= 0)
__seg_ += (__n + __ctz_) / __bits_per_word;
@@ -1208,54 +1215,54 @@ public:
return *this;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n)
{
return *this += -__n;
}
- _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __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
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const
{
__bit_iterator __t(*this);
__t -= __n;
return __t;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
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 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);}
- _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x < __y);}
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
: __seg_(__s), __ctz_(__ctz) {}
@@ -1265,26 +1272,44 @@ private:
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, true>;
template <class _Dp> friend struct __bit_array;
- template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
- template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
- __bit_iterator<_Dp, _IC> __last,
- __bit_iterator<_Dp, false> __result);
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
+ __bit_iterator<_Dp, _IC> __last,
+ __bit_iterator<_Dp, false> __result);
template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
@@ -1294,22 +1319,32 @@ private:
template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
- template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
- __bit_iterator<_Dp, false>,
- __bit_iterator<_Dp, false>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC1>,
- __bit_iterator<_Dp, _IC2>);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
- typename _Dp::size_type);
- template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
- typename _Dp::size_type);
+ template <class _Dp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>,
+ __bit_iterator<_Dp, false>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend bool equal(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+ template <class _Dp, bool _IC>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
__count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
diff --git a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h
index 4109b58d46a9..e6a5ed720f9f 100644
--- a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h
+++ b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h
@@ -13,6 +13,7 @@
#include <__config>
#include <__type_traits/is_primary_template.h>
#include <concepts>
+#include <cstddef>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h
index 254f8c2339e4..0cc64adc0de9 100644
--- a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h
+++ b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h
@@ -14,6 +14,7 @@
#include <__iterator/incrementable_traits.h>
#include <__iterator/readable_traits.h>
#include <concepts>
+#include <cstddef>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -507,6 +508,12 @@ using __iterator_category_type = typename iterator_traits<_Iter>::iterator_categ
template <class _Iter>
using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer;
+template <class _Iter>
+using __iter_diff_t = typename iterator_traits<_Iter>::difference_type;
+
+template<class _InputIterator>
+using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h
index 5c344c2ee310..7b002205f333 100644
--- a/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h
+++ b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h
@@ -70,9 +70,7 @@ public:
typename iterator_traits<_Iter>::iterator_category>;
using pointer = typename iterator_traits<_Iter>::pointer;
#if _LIBCPP_STD_VER > 17
- using iterator_concept = _If<__is_cpp17_random_access_iterator<_Iter>::value,
- random_access_iterator_tag,
- bidirectional_iterator_tag>;
+ using iterator_concept = _If<random_access_iterator<_Iter>, random_access_iterator_tag, bidirectional_iterator_tag>;
using value_type = iter_value_t<_Iter>;
using difference_type = iter_difference_t<_Iter>;
using reference = iter_reference_t<_Iter>;
@@ -365,7 +363,7 @@ class __unconstrained_reverse_iterator {
_Iter __iter_;
public:
- static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value);
+ static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>);
using iterator_type = _Iter;
using iterator_category =
@@ -393,6 +391,14 @@ public:
}
}
+ _LIBCPP_HIDE_FROM_ABI friend constexpr
+ iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)
+ noexcept(is_nothrow_copy_constructible_v<_Iter> &&
+ noexcept(ranges::iter_move(--declval<_Iter&>()))) {
+ auto __tmp = __i.base();
+ return ranges::iter_move(--__tmp);
+ }
+
_LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() {
--__iter_;
return *this;
diff --git a/contrib/llvm-project/libcxx/include/__memory/construct_at.h b/contrib/llvm-project/libcxx/include/__memory/construct_at.h
index bfa20a149d51..f5985b7731fd 100644
--- a/contrib/llvm-project/libcxx/include/__memory/construct_at.h
+++ b/contrib/llvm-project/libcxx/include/__memory/construct_at.h
@@ -42,7 +42,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
#if _LIBCPP_STD_VER > 17
return std::construct_at(__location, std::forward<_Args>(__args)...);
#else
- return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
+ return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
+ ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
#endif
}
diff --git a/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h b/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
index 2549e4be7df1..348f7323a41d 100644
--- a/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
+++ b/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
@@ -12,6 +12,7 @@
#include <__config>
#include <__memory/addressof.h>
+#include <cstddef>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -122,7 +123,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
private:
struct __nat {};
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static pointer pointer_to(typename conditional<is_void<element_type>::value,
__nat, element_type>::type& __r)
{return pointer::pointer_to(__r);}
@@ -171,9 +172,30 @@ _Tp* __to_address(_Tp* __p) _NOEXCEPT {
return __p;
}
+template <class _Pointer, class = void>
+struct _HasToAddress : false_type {};
+
+template <class _Pointer>
+struct _HasToAddress<_Pointer,
+ decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
+> : true_type {};
+
+template <class _Pointer, class = void>
+struct _HasArrow : false_type {};
+
+template <class _Pointer>
+struct _HasArrow<_Pointer,
+ decltype((void)declval<const _Pointer&>().operator->())
+> : true_type {};
+
+template <class _Pointer>
+struct _IsFancyPointer {
+ static const bool value = _HasArrow<_Pointer>::value || _HasToAddress<_Pointer>::value;
+};
+
// enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers
template <class _Pointer, class = __enable_if_t<
- !is_pointer<_Pointer>::value && !is_array<_Pointer>::value && !is_function<_Pointer>::value
+ _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
> >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type
@@ -208,7 +230,7 @@ auto to_address(_Tp *__p) noexcept {
template <class _Pointer>
inline _LIBCPP_INLINE_VISIBILITY constexpr
-auto to_address(const _Pointer& __p) noexcept {
+auto to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {
return _VSTD::__to_address(__p);
}
#endif
diff --git a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
index 72b6890c2225..4f3d4e90cb6e 100644
--- a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
@@ -509,10 +509,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
template <class _Alloc, class _Iter>
class _AllocatorDestroyRangeReverse {
public:
- _LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
: __alloc_(__alloc), __first_(__first), __last_(__last) {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
}
@@ -621,7 +622,7 @@ template <
class _Type = typename iterator_traits<_Iter1>::value_type,
class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
__allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
if (__libcpp_is_constant_evaluated()) {
while (__first1 != __last1) {
diff --git a/contrib/llvm-project/libcxx/include/__ranges/size.h b/contrib/llvm-project/libcxx/include/__ranges/size.h
index 32ca4b854bc3..0e6d295651a3 100644
--- a/contrib/llvm-project/libcxx/include/__ranges/size.h
+++ b/contrib/llvm-project/libcxx/include/__ranges/size.h
@@ -16,6 +16,7 @@
#include <__ranges/access.h>
#include <__utility/auto_cast.h>
#include <concepts>
+#include <cstddef>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/contrib/llvm-project/libcxx/include/__split_buffer b/contrib/llvm-project/libcxx/include/__split_buffer
index f78167466217..4d40732a75cf 100644
--- a/contrib/llvm-project/libcxx/include/__split_buffer
+++ b/contrib/llvm-project/libcxx/include/__split_buffer
@@ -62,107 +62,107 @@ public:
typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
typedef typename add_lvalue_reference<allocator_type>::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_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(__alloc_rr& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(const __alloc_rr& __a);
- __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
- ~__split_buffer();
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
- __split_buffer(__split_buffer&& __c)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
- __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
- __split_buffer& operator=(__split_buffer&& __c)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
!__alloc_traits::propagate_on_container_move_assignment::value);
- _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_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{__destruct_at_end(__begin_);}
- _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
- _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
- _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
- _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
- _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__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);
- void push_front(value_type&& __x);
- void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
template <class... _Args>
- void emplace_back(_Args&&... __args);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
- _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
- _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _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);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
template <class _InputIter>
- __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
- __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
- _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
{__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, false_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, true_type);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{__destruct_at_end(__new_last, false_type());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
- void swap(__split_buffer& __x)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<__alloc_rr>::value);
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
{}
struct _ConstructTransaction {
- explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
: __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
}
- ~_ConstructTransaction() {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
*__dest_ = __pos_;
}
pointer __pos_;
@@ -173,6 +173,7 @@ private:
};
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
bool
__split_buffer<_Tp, _Allocator>::__invariants() const
{
@@ -203,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@@ -219,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
@@ -231,7 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
template <class _Tp, class _Allocator>
template <class _InputIter>
-__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__alloc_rr& __a = this->__alloc();
@@ -254,7 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
-__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
_ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
@@ -265,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
@@ -274,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
@@ -282,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
@@ -291,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
@@ -299,6 +306,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@@ -314,6 +322,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@@ -322,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -329,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -336,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::~__split_buffer()
{
clear();
@@ -344,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __first_(_VSTD::move(__c.__first_)),
@@ -358,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@@ -384,6 +398,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>&
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -404,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
@@ -417,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -433,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -460,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
{
@@ -489,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
{
@@ -519,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
@@ -549,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
{
@@ -580,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
@@ -610,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
diff --git a/contrib/llvm-project/libcxx/include/__verbose_abort b/contrib/llvm-project/libcxx/include/__verbose_abort
new file mode 100644
index 000000000000..3c9cba824ce0
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__verbose_abort
@@ -0,0 +1,51 @@
+// -*- 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___VERBOSE_ABORT
+#define _LIBCPP___VERBOSE_ABORT
+
+#include <__availability>
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+// Provide a default implementation of __libcpp_verbose_abort if we know that neither the built
+// library not the user is providing one. Otherwise, just declare it and use the one from the
+// built library or the one provided by the user.
+//
+// We can't provide a great implementation because it needs to be pretty much
+// dependency-free (this is included everywhere else in the library).
+#if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && !defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
+
+extern "C" void abort();
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline
+void __libcpp_verbose_abort(const char *, ...) {
+ ::abort();
+ __builtin_unreachable(); // never reached, but needed to tell the compiler that the function never returns
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#else
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+void __libcpp_verbose_abort(const char *__format, ...);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
+
+#endif // _LIBCPP___VERBOSE_ABORT
diff --git a/contrib/llvm-project/libcxx/include/algorithm b/contrib/llvm-project/libcxx/include/algorithm
index 197b3b1043bb..69ada038747c 100644
--- a/contrib/llvm-project/libcxx/include/algorithm
+++ b/contrib/llvm-project/libcxx/include/algorithm
@@ -446,6 +446,25 @@ namespace ranges {
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+ template<input_iterator I1, sentinel_for<I1> S1,
+ random_access_iterator I2, sentinel_for<I2> S2,
+ class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
+ constexpr partial_sort_copy_result<I1, I2>
+ partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
+ Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<input_range R1, random_access_range R2, class Comp = ranges::less,
+ class Proj1 = identity, class Proj2 = identity>
+ requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
+ sortable<iterator_t<R2>, Comp, Proj2> &&
+ indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>>
+ constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
+ partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
@@ -574,6 +593,11 @@ namespace ranges {
constexpr borrowed_iterator_t<R>
ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
+ template<class T, class Proj = identity,
+ indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
+ constexpr const T&
+ ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}); // since C++20
+
template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
class Proj1 = identity, class Proj2 = identity,
indirect_strict_weak_order<projected<I1, Proj1>,
@@ -726,6 +750,13 @@ namespace ranges {
constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
ranges::reverse_copy(R&& r, O result); // since C++20
+ template<permutable I, sentinel_for<I> S>
+ constexpr subrange<I> rotate(I first, I middle, S last); // since C++20
+
+ template<forward_range R>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle); // Since C++20
+
template <class _InIter, class _OutIter>
using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
@@ -739,6 +770,18 @@ namespace ranges {
constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
+ requires (forward_iterator<I> || random_access_iterator<O>) &&
+ indirectly_copyable<I, O> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Gen>
+ requires (forward_range<R> || random_access_iterator<O>) &&
+ indirectly_copyable<iterator_t<R>, O> &&
+ uniform_random_bit_generator<remove_reference_t<Gen>>
+ O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // Since C++20
+
template<random_access_iterator I, sentinel_for<I> S, class Gen>
requires permutable<I> &&
uniform_random_bit_generator<remove_reference_t<Gen>>
@@ -750,6 +793,21 @@ namespace ranges {
borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20
template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
+ sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
+ indirect_equivalence_relation<projected<I1, Proj1>,
+ projected<I2, Proj2>> Pred = ranges::equal_to>
+ constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
+ Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<forward_range R1, forward_range R2,
+ class Proj1 = identity, class Proj2 = identity,
+ indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
+ projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
+ constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
+ Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
sentinel_for<I2> S2, class Pred = ranges::equal_to,
class Proj1 = identity, class Proj2 = identity>
requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
@@ -803,7 +861,7 @@ namespace ranges {
set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
Comp comp = {}, Proj1 proj1 = {},
Proj2 proj2 = {}); // since C++20
-
+
template<input_range R1, input_range R2, weakly_incrementable O,
class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
@@ -816,13 +874,13 @@ namespace ranges {
indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
constexpr subrange<I>
equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
-
+
template<forward_range R, class T, class Proj = identity,
indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
ranges::less>
constexpr borrowed_subrange_t<R>
equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
-
+
template<class I1, class I2, class O>
using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
@@ -847,15 +905,154 @@ namespace ranges {
ranges::less>
constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
-
+
template<input_range R1, input_range R2, class Proj1 = identity,
class Proj2 = identity,
indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ borrowed_iterator_t<R>
+ inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
+ Proj proj = {}); // Since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<I, O> &&
+ (forward_iterator<I> ||
+ (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<I, O>)
+ constexpr unique_copy_result<I, O>
+ unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ (forward_iterator<iterator_t<R>> ||
+ (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
+ indirectly_copyable_storable<iterator_t<R>, O>)
+ constexpr unique_copy_result<borrowed_iterator_t<R>, O>
+ unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
+ class Proj = identity>
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr remove_copy_result<I, O>
+ remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class T, class Proj = identity>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ indirect_binary_predicate<ranges::equal_to,
+ projected<iterator_t<R>, Proj>, const T*>
+ constexpr remove_copy_result<borrowed_iterator_t<R>, O>
+ remove_copy(R&& r, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_if_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr remove_copy_if_result<I, O>
+ remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
+ remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using replace_copy_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T1, class T2,
+ output_iterator<const T2&> O, class Proj = identity>
+ requires indirectly_copyable<I, O> &&
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
+ constexpr replace_copy_result<I, O>
+ replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<input_range R, class T1, class T2, output_iterator<const T2&> O,
+ class Proj = identity>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ indirect_binary_predicate<ranges::equal_to,
+ projected<iterator_t<R>, Proj>, const T1*>
+ constexpr replace_copy_result<borrowed_iterator_t<R>, O>
+ replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using replace_copy_if_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr replace_copy_if_result<I, O>
+ replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
+ replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
+ Proj proj = {}); // Since C++20
+
+ template<class I>
+ using prev_permutation_result = in_found_result<I>; // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr ranges::prev_permutation_result<I>
+ ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
+ ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<class I>
+ using next_permutation_result = in_found_result<I>; // Since C++20
+
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ constexpr ranges::next_permutation_result<I>
+ ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20
+
+ template<bidirectional_range R, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
+ ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20
+
}
+template <class InputIterator, class Predicate>
constexpr bool // constexpr in C++20
all_of(InputIterator first, InputIterator last, Predicate pred);
@@ -1587,6 +1784,7 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_all_of.h>
#include <__algorithm/ranges_any_of.h>
#include <__algorithm/ranges_binary_search.h>
+#include <__algorithm/ranges_clamp.h>
#include <__algorithm/ranges_copy.h>
#include <__algorithm/ranges_copy_backward.h>
#include <__algorithm/ranges_copy_if.h>
@@ -1607,9 +1805,11 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_generate.h>
#include <__algorithm/ranges_generate_n.h>
#include <__algorithm/ranges_includes.h>
+#include <__algorithm/ranges_inplace_merge.h>
#include <__algorithm/ranges_is_heap.h>
#include <__algorithm/ranges_is_heap_until.h>
#include <__algorithm/ranges_is_partitioned.h>
+#include <__algorithm/ranges_is_permutation.h>
#include <__algorithm/ranges_is_sorted.h>
#include <__algorithm/ranges_is_sorted_until.h>
#include <__algorithm/ranges_lexicographical_compare.h>
@@ -1625,21 +1825,30 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_mismatch.h>
#include <__algorithm/ranges_move.h>
#include <__algorithm/ranges_move_backward.h>
+#include <__algorithm/ranges_next_permutation.h>
#include <__algorithm/ranges_none_of.h>
#include <__algorithm/ranges_nth_element.h>
#include <__algorithm/ranges_partial_sort.h>
+#include <__algorithm/ranges_partial_sort_copy.h>
#include <__algorithm/ranges_partition.h>
#include <__algorithm/ranges_partition_copy.h>
#include <__algorithm/ranges_partition_point.h>
#include <__algorithm/ranges_pop_heap.h>
+#include <__algorithm/ranges_prev_permutation.h>
#include <__algorithm/ranges_push_heap.h>
#include <__algorithm/ranges_remove.h>
+#include <__algorithm/ranges_remove_copy.h>
+#include <__algorithm/ranges_remove_copy_if.h>
#include <__algorithm/ranges_remove_if.h>
#include <__algorithm/ranges_replace.h>
+#include <__algorithm/ranges_replace_copy.h>
+#include <__algorithm/ranges_replace_copy_if.h>
#include <__algorithm/ranges_replace_if.h>
#include <__algorithm/ranges_reverse.h>
#include <__algorithm/ranges_reverse_copy.h>
+#include <__algorithm/ranges_rotate.h>
#include <__algorithm/ranges_rotate_copy.h>
+#include <__algorithm/ranges_sample.h>
#include <__algorithm/ranges_search.h>
#include <__algorithm/ranges_search_n.h>
#include <__algorithm/ranges_set_difference.h>
@@ -1653,6 +1862,8 @@ template <class BidirectionalIterator, class Compare>
#include <__algorithm/ranges_stable_sort.h>
#include <__algorithm/ranges_swap_ranges.h>
#include <__algorithm/ranges_transform.h>
+#include <__algorithm/ranges_unique.h>
+#include <__algorithm/ranges_unique_copy.h>
#include <__algorithm/ranges_upper_bound.h>
#include <__algorithm/remove.h>
#include <__algorithm/remove_copy.h>
diff --git a/contrib/llvm-project/libcxx/include/format b/contrib/llvm-project/libcxx/include/format
index d2ec8fc23363..6b14570bc627 100644
--- a/contrib/llvm-project/libcxx/include/format
+++ b/contrib/llvm-project/libcxx/include/format
@@ -23,16 +23,23 @@ namespace std {
using format_args = basic_format_args<format_context>;
using wformat_args = basic_format_args<wformat_context>;
- // [format.fmt.string], class template basic-format-string
+ // [format.fmt.string], class template basic_format_string
template<class charT, class... Args>
- struct basic-format-string; // exposition only
+ struct basic_format_string { // since C++23, exposition only before C++23
+ private:
+ basic_string_view<charT> str; // exposition only
+ public:
+ template<class T> consteval basic_format_string(const T& s);
+
+ constexpr basic_string_view<charT> get() const noexcept { return str; }
+ };
template<class... Args>
- using format-string = // exposition only
- basic-format-string<char, type_identity_t<Args>...>;
+ using format_string = // since C++23, exposition only before C++23
+ basic_format_string<char, type_identity_t<Args>...>;
template<class... Args>
- using wformat-string = // exposition only
- basic-format-string<wchar_t, type_identity_t<Args>...>;
+ using wformat_string = // since C++23, exposition only before C++23
+ basic_format_string<wchar_t, type_identity_t<Args>...>;
// [format.functions], formatting functions
template<class... Args>
@@ -233,7 +240,7 @@ private:
};
// Dummy format_context only providing the parts used during constant
-// validation of the basic-format-string.
+// validation of the basic_format_string.
template <class _CharT>
struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
public:
@@ -468,17 +475,21 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
} // namespace __format
template <class _CharT, class... _Args>
-struct _LIBCPP_TEMPLATE_VIS __basic_format_string {
- basic_string_view<_CharT> __str_;
-
+struct _LIBCPP_TEMPLATE_VIS basic_format_string {
template <class _Tp>
requires convertible_to<const _Tp&, basic_string_view<_CharT>>
- consteval __basic_format_string(const _Tp& __str) : __str_{__str} {
+ consteval basic_format_string(const _Tp& __str) : __str_{__str} {
__format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
_Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept {
+ return __str_;
+ }
+
private:
+ basic_string_view<_CharT> __str_;
+
using _Context = __format::__compile_time_basic_format_context<_CharT>;
static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
@@ -510,11 +521,11 @@ private:
};
template <class... _Args>
-using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>;
+using format_string = basic_format_string<char, type_identity_t<_Args>...>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>;
+using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
#endif
template <class _OutIt, class _CharT, class _FormatOutIt>
@@ -555,16 +566,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
template <output_iterator<const char&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
+format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_,
+format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -586,16 +597,16 @@ vformat(wstring_view __fmt, wformat_args __args) {
#endif
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(__format_string_t<_Args...> __fmt,
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(format_string<_Args...> __fmt,
_Args&&... __args) {
- return _VSTD::vformat(__fmt.__str_, _VSTD::make_format_args(__args...));
+ return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
-format(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...));
+format(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
}
#endif
@@ -611,16 +622,16 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it,
template <output_iterator<const char&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...));
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __wformat_string_t<_Args...> __fmt,
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt,
_Args&&... __args) {
- return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...));
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...));
}
#endif
@@ -634,15 +645,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt,
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
+formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
+formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
}
#endif
@@ -686,16 +697,16 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v
template <output_iterator<const char&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
+format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
-format_to(_OutIt __out_it, locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_,
+format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -720,17 +731,17 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
- __format_string_t<_Args...> __fmt,
+ format_string<_Args...> __fmt,
_Args&&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
-format(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_,
+format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -748,18 +759,18 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it,
template <output_iterator<const char&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __format_string_t<_Args...> __fmt,
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, format_string<_Args...> __fmt,
_Args&&... __args) {
- return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
_VSTD::make_format_args(__args...));
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <output_iterator<const wchar_t&> _OutIt, class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
-format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt,
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt,
_Args&&... __args) {
- return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_,
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
_VSTD::make_wformat_args(__args...));
}
#endif
@@ -775,15 +786,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)});
+formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
-formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) {
- return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)});
+formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
}
#endif
diff --git a/contrib/llvm-project/libcxx/include/memory b/contrib/llvm-project/libcxx/include/memory
index 56f8159fbd44..a986d76c8b4e 100644
--- a/contrib/llvm-project/libcxx/include/memory
+++ b/contrib/llvm-project/libcxx/include/memory
@@ -838,6 +838,8 @@ template<size_t N, class T>
*/
+#include <__algorithm/copy.h>
+#include <__algorithm/move.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__memory/addressof.h>
@@ -941,21 +943,31 @@ template <class _Tp, class _Alloc>
struct __temp_value {
typedef allocator_traits<_Alloc> _Traits;
+#ifdef _LIBCPP_CXX03_LANG
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
+#else
+ union { _Tp __v; };
+#endif
_Alloc &__a;
- _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
- _Tp & get() { return *__addr(); }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
+#ifdef _LIBCPP_CXX03_LANG
+ return reinterpret_cast<_Tp*>(std::addressof(__v));
+#else
+ return std::addressof(__v);
+#endif
+ }
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); }
template<class... _Args>
_LIBCPP_NO_CFI
- __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
- _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
- _VSTD::forward<_Args>(__args)...);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+ _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
}
- ~__temp_value() { _Traits::destroy(__a, __addr()); }
- };
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
+};
template<typename _Alloc, typename = void, typename = void>
struct __is_allocator : false_type {};
diff --git a/contrib/llvm-project/libcxx/include/module.modulemap.in b/contrib/llvm-project/libcxx/include/module.modulemap.in
index 98485bcd93ab..83c6384433ce 100644
--- a/contrib/llvm-project/libcxx/include/module.modulemap.in
+++ b/contrib/llvm-project/libcxx/include/module.modulemap.in
@@ -59,7 +59,10 @@ module std [system] {
// FIXME: <stdalign.h> is missing.
// <signal.h> provided by C library.
// <stdarg.h> provided by compiler.
- // <stdbool.h> provided by compiler.
+ module stdbool_h {
+ // <stdbool.h>'s __bool_true_false_are_defined macro requires textual inclusion.
+ textual header "stdbool.h"
+ }
module stddef_h {
// <stddef.h>'s __need_* macros require textual inclusion.
textual header "stddef.h"
@@ -311,6 +314,7 @@ module std [system] {
module ranges_all_of { private header "__algorithm/ranges_all_of.h" }
module ranges_any_of { private header "__algorithm/ranges_any_of.h" }
module ranges_binary_search { private header "__algorithm/ranges_binary_search.h" }
+ module ranges_clamp { private header "__algorithm/ranges_clamp.h" }
module ranges_copy { private header "__algorithm/ranges_copy.h" }
module ranges_copy_backward { private header "__algorithm/ranges_copy_backward.h" }
module ranges_copy_if { private header "__algorithm/ranges_copy_if.h" }
@@ -335,6 +339,7 @@ module std [system] {
module ranges_is_heap { private header "__algorithm/ranges_is_heap.h" }
module ranges_is_heap_until { private header "__algorithm/ranges_is_heap_until.h" }
module ranges_is_partitioned { private header "__algorithm/ranges_is_partitioned.h" }
+ module ranges_is_permutation { private header "__algorithm/ranges_is_permutation.h" }
module ranges_is_sorted { private header "__algorithm/ranges_is_sorted.h" }
module ranges_is_sorted_until { private header "__algorithm/ranges_is_sorted_until.h" }
module ranges_iterator_concept { private header "__algorithm/ranges_iterator_concept.h" }
@@ -351,6 +356,7 @@ module std [system] {
module ranges_mismatch { private header "__algorithm/ranges_mismatch.h" }
module ranges_move { private header "__algorithm/ranges_move.h" }
module ranges_move_backward { private header "__algorithm/ranges_move_backward.h" }
+ module ranges_next_permutation { private header "__algorithm/ranges_next_permutation.h" }
module ranges_none_of { private header "__algorithm/ranges_none_of.h" }
module ranges_nth_element { private header "__algorithm/ranges_nth_element.h" }
module ranges_partial_sort { private header "__algorithm/ranges_partial_sort.h" }
@@ -359,6 +365,7 @@ module std [system] {
module ranges_partition_copy { private header "__algorithm/ranges_partition_copy.h" }
module ranges_partition_point { private header "__algorithm/ranges_partition_point.h" }
module ranges_pop_heap { private header "__algorithm/ranges_pop_heap.h" }
+ module ranges_prev_permutation { private header "__algorithm/ranges_prev_permutation.h" }
module ranges_push_heap { private header "__algorithm/ranges_push_heap.h" }
module ranges_remove { private header "__algorithm/ranges_remove.h" }
module ranges_remove_copy { private header "__algorithm/ranges_remove_copy.h" }
@@ -370,7 +377,9 @@ module std [system] {
module ranges_replace_if { private header "__algorithm/ranges_replace_if.h" }
module ranges_reverse { private header "__algorithm/ranges_reverse.h" }
module ranges_reverse_copy { private header "__algorithm/ranges_reverse_copy.h" }
+ module ranges_rotate { private header "__algorithm/ranges_rotate.h" }
module ranges_rotate_copy { private header "__algorithm/ranges_rotate_copy.h" }
+ module ranges_sample { private header "__algorithm/ranges_sample.h" }
module ranges_search { private header "__algorithm/ranges_search.h" }
module ranges_search_n { private header "__algorithm/ranges_search_n.h" }
module ranges_set_difference { private header "__algorithm/ranges_set_difference.h" }
@@ -384,6 +393,9 @@ module std [system] {
module ranges_stable_sort { private header "__algorithm/ranges_stable_sort.h" }
module ranges_swap_ranges { private header "__algorithm/ranges_swap_ranges.h" }
module ranges_transform { private header "__algorithm/ranges_transform.h" }
+ module uniform_random_bit_generator_adaptor {
+ private header "__algorithm/uniform_random_bit_generator_adaptor.h"
+ }
module ranges_unique { private header "__algorithm/ranges_unique.h" }
module ranges_unique_copy { private header "__algorithm/ranges_unique_copy.h" }
module ranges_upper_bound { private header "__algorithm/ranges_upper_bound.h" }
@@ -419,6 +431,7 @@ module std [system] {
module unique { private header "__algorithm/unique.h" }
module unique_copy { private header "__algorithm/unique_copy.h" }
module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
+ module unwrap_range { private header "__algorithm/unwrap_range.h" }
module upper_bound { private header "__algorithm/upper_bound.h" }
}
}
@@ -1292,6 +1305,7 @@ module std [system] {
module __tree { header "__tree" export * }
module __tuple { private header "__tuple" export * }
module __undef_macros { header "__undef_macros" export * }
+ module __verbose_abort { header "__verbose_abort" export * }
module experimental {
requires cplusplus11
diff --git a/contrib/llvm-project/libcxx/include/vector b/contrib/llvm-project/libcxx/include/vector
index 30030f85e43c..252a0f051ff5 100644
--- a/contrib/llvm-project/libcxx/include/vector
+++ b/contrib/llvm-project/libcxx/include/vector
@@ -360,12 +360,12 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
_VSTD::__debug_db_insert_c(this);
}
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
@@ -375,13 +375,14 @@ public:
{
_VSTD::__debug_db_insert_c(this);
}
- explicit vector(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
#endif
- vector(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x);
template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
@@ -394,6 +395,7 @@ public:
}
template <class _InputIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_InputIterator __first,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
@@ -401,12 +403,14 @@ public:
typename iterator_traits<_InputIterator>::reference>::value,
_InputIterator>::type __last);
template <class _InputIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_ForwardIterator __first,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -414,13 +418,14 @@ public:
typename iterator_traits<_ForwardIterator>::reference>::value,
_ForwardIterator>::type __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
~vector()
{
__annotate_delete();
@@ -433,24 +438,24 @@ public:
}
}
- vector(const vector& __x);
- vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
noexcept;
@@ -458,14 +463,14 @@ public:
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
template <class _InputIterator>
- typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -473,6 +478,7 @@ public:
>::type
assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -483,119 +489,120 @@ public:
>::type
assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const_reference __u);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
{return this->__alloc();}
- _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator cbegin() const _NOEXCEPT
{return begin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator cend() const _NOEXCEPT
{return end();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT
{return static_cast<size_type>(this->__end_ - this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return static_cast<size_type>(__end_cap() - this->__begin_);}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return this->__begin_ == this->__end_;}
- size_type max_size() const _NOEXCEPT;
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
- reference at(size_type __n);
- const_reference at(size_type __n) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
- _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
{
_LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT
{return _VSTD::__to_address(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const value_type* data() const _NOEXCEPT
{return _VSTD::__to_address(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
- _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args);
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void pop_back();
- iterator insert(const_iterator __position, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x);
- iterator insert(const_iterator __position, value_type&& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
- iterator emplace(const_iterator __position, _Args&&... __args);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);
- iterator insert(const_iterator __position, size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
- typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
value_type,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -603,6 +610,7 @@ public:
>::type
insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -614,15 +622,15 @@ public:
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
- iterator erase(const_iterator __first, const_iterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
size_type __old_size = size();
@@ -631,10 +639,10 @@ public:
std::__debug_db_invalidate_all(this);
}
- void resize(size_type __sz);
- void resize(size_type __sz, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
@@ -642,7 +650,7 @@ public:
__is_nothrow_swappable<allocator_type>::value);
#endif
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@@ -661,7 +669,6 @@ private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
-
// Allocate space for __n objects
// throws length_error if __n > max_size()
// throws (probably bad_alloc) if memory run out
@@ -669,7 +676,7 @@ private:
// Precondition: __n > 0
// Postcondition: capacity() >= __n
// Postcondition: size() == 0
- _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
if (__n > max_size())
__throw_length_error();
auto __allocation = std::__allocate_at_least(__alloc(), __n);
@@ -679,46 +686,48 @@ private:
__annotate_new(0);
}
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
- void __construct_at_end(size_type __n);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __construct_at_end(size_type __n, const_reference __x);
template <class _ForwardIterator>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
- void __append(size_type __n);
- void __append(size_type __n, const_reference __x);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
iterator __make_iter(pointer __p) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
- void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
- pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
- void __move_range(pointer __from_s, pointer __from_e, pointer __to);
- void __move_assign(vector& __c, true_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- void __move_assign(vector& __c, false_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{
- __invalidate_iterators_past(__new_last);
+ if (!__libcpp_is_constant_evaluated())
+ __invalidate_iterators_past(__new_last);
size_type __old_size = size();
__base_destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
inline void __push_back_slow_path(_Up&& __x);
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
inline void __emplace_back_slow_path(_Args&&... __args);
// The following functions are no-ops outside of AddressSanitizer mode.
@@ -726,39 +735,40 @@ private:
// may not meet the AddressSanitizer alignment constraints.
// See the documentation for __sanitizer_annotate_contiguous_container for more details.
#ifndef _LIBCPP_HAS_NO_ASAN
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
void __annotate_contiguous_container(const void *__beg, const void *__end,
const void *__old_mid,
const void *__new_mid) const
{
- if (__beg && is_same<allocator_type, __default_allocator_type>::value)
+ if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value)
__sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
}
#else
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_contiguous_container(const void*, const void*, const void*,
const void*) const _NOEXCEPT {}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_new(size_type __current_size) const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + capacity(), data() + __current_size);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_delete() const _NOEXCEPT {
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + capacity());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_increase(size_type __n) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
data() + size(), data() + size() + __n);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __annotate_shrink(size_type __old_size) const _NOEXCEPT
{
__annotate_contiguous_container(data(), data() + capacity(),
@@ -766,13 +776,14 @@ private:
}
struct _ConstructTransaction {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit _ConstructTransaction(vector &__v, size_type __n)
: __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
#ifndef _LIBCPP_HAS_NO_ASAN
__v_.__annotate_increase(__n);
#endif
}
- ~_ConstructTransaction() {
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
__v_.__end_ = __pos_;
#ifndef _LIBCPP_HAS_NO_ASAN
if (__pos_ != __new_end_) {
@@ -791,7 +802,7 @@ private:
};
template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __construct_one_at_end(_Args&& ...__args) {
_ConstructTransaction __tx(*this, 1);
__alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
@@ -799,23 +810,23 @@ private:
++__tx.__pos_;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
allocator_type& __alloc() _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const allocator_type& __alloc() const _NOEXCEPT
{return this->__end_cap_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
pointer& __end_cap() _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
const pointer& __end_cap() const _NOEXCEPT
{return this->__end_cap_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
pointer __soon_to_be_end = this->__end_;
while (__new_last != __soon_to_be_end)
@@ -823,12 +834,12 @@ private:
this->__end_ = __new_last;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __c)
{__copy_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__alloc_traits::propagate_on_container_move_assignment::value ||
@@ -846,7 +857,7 @@ private:
_VSTD::__throw_out_of_range("vector");
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -858,18 +869,18 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const vector&, false_type)
{}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
@@ -894,6 +905,7 @@ vector(_InputIterator, _InputIterator, _Alloc)
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
{
@@ -911,6 +923,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::pointer
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
{
@@ -931,6 +944,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
{
@@ -943,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
@@ -952,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
// Precondition: __new_size > capacity()
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
@@ -971,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@@ -988,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
@@ -1001,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1017,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__append(size_type __n)
{
@@ -1036,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
// Postcondition: size() == size() + __n
// Exception safety: strong.
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
{
@@ -1051,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n)
{
_VSTD::__debug_db_insert_c(this);
@@ -1063,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __end_cap_(nullptr, __a)
{
@@ -1076,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
#endif
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
{
_VSTD::__debug_db_insert_c(this);
@@ -1088,6 +1112,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
template <class _Tp, class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_InputIterator __first,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
@@ -1102,6 +1127,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
template <class _Tp, class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
@@ -1116,6 +1142,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -1134,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
is_constructible<
@@ -1151,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(const vector& __x)
: __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
{
@@ -1164,6 +1193,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
{
@@ -1177,6 +1207,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<alloc
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
@@ -1195,6 +1226,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
: __end_cap_(nullptr, __a)
@@ -1218,6 +1250,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
{
@@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __end_cap_(nullptr, __a)
@@ -1245,6 +1279,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(vector&& __x)
@@ -1256,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
_NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -1270,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
@@ -1284,6 +1321,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
vector<_Tp, _Allocator>::operator=(const vector& __x)
@@ -1298,7 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
template <class _Tp, class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1313,6 +1351,7 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1350,6 +1389,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
{
@@ -1372,6 +1412,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::begin() _NOEXCEPT
@@ -1380,6 +1421,7 @@ vector<_Tp, _Allocator>::begin() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::begin() const _NOEXCEPT
@@ -1388,6 +1430,7 @@ vector<_Tp, _Allocator>::begin() const _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::end() _NOEXCEPT
@@ -1396,6 +1439,7 @@ vector<_Tp, _Allocator>::end() _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_iterator
vector<_Tp, _Allocator>::end() const _NOEXCEPT
@@ -1404,6 +1448,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
@@ -1413,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
@@ -1422,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::reference
vector<_Tp, _Allocator>::at(size_type __n)
{
@@ -1431,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::const_reference
vector<_Tp, _Allocator>::at(size_type __n) const
{
@@ -1440,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::reserve(size_type __n)
{
@@ -1454,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@@ -1477,6 +1527,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
template <class _Tp, class _Allocator>
template <class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
{
@@ -1489,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(const_reference __x)
@@ -1502,6 +1554,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::push_back(value_type&& __x)
@@ -1516,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
{
@@ -1529,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
#if _LIBCPP_STD_VER > 14
typename vector<_Tp, _Allocator>::reference
@@ -1549,6 +1604,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
vector<_Tp, _Allocator>::pop_back()
@@ -1558,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back()
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __position)
@@ -1569,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
difference_type __ps = __position - cbegin();
pointer __p = this->__begin_ + __ps;
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
- this->__invalidate_iterators_past(__p-1);
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
iterator __r = iterator(this, __p);
return __r;
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -1587,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
pointer __p = this->__begin_ + (__first - begin());
if (__first != __last) {
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
- this->__invalidate_iterators_past(__p - 1);
+ if (!__libcpp_is_constant_evaluated())
+ this->__invalidate_iterators_past(__p - 1);
}
iterator __r = iterator(this, __p);
return __r;
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
{
@@ -1613,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
{
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
"vector::insert(iterator, x) called with an iterator not referring to this vector");
pointer __p = this->__begin_ + (__position - begin());
- if (this->__end_ < this->__end_cap())
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
{
if (__p == this->__end_)
{
@@ -1645,6 +1708,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
{
@@ -1675,6 +1739,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
{
@@ -1705,6 +1770,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<_Tp, _Allocator>::iterator
vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
{
@@ -1713,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
pointer __p = this->__begin_ + (__position - begin());
if (__n > 0)
{
- if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+ // We can't compare unrelated pointers inside constant expressions
+ if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
{
size_type __old_n = __n;
pointer __old_last = this->__end_;
@@ -1745,7 +1812,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
template <class _Tp, class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
is_constructible<
_Tp,
typename iterator_traits<_InputIterator>::reference>::value,
@@ -1793,6 +1860,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1841,6 +1909,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::resize(size_type __sz)
{
@@ -1852,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
{
@@ -1863,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<_Tp, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
@@ -1885,6 +1956,7 @@ vector<_Tp, _Allocator>::swap(vector& __x)
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
bool
vector<_Tp, _Allocator>::__invariants() const
{
@@ -2007,81 +2079,81 @@ public:
typedef __bit_const_reference<vector> const_reference;
#endif
private:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type& __cap() _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const size_type& __cap() const _NOEXCEPT
{return __cap_alloc_.first();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__storage_allocator& __alloc() _NOEXCEPT
{return __cap_alloc_.second();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const __storage_allocator& __alloc() const _NOEXCEPT
{return __cap_alloc_.second();}
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
{return __n * __bits_per_word;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
{return (__n - 1) / __bits_per_word + 1;}
public:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
- ~vector();
- explicit vector(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
- explicit vector(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
#endif
- vector(size_type __n, const value_type& __v);
- vector(size_type __n, const value_type& __v, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _InputIterator>
- vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
template <class _ForwardIterator>
- vector(_ForwardIterator __first, _ForwardIterator __last,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
template <class _ForwardIterator>
- vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
- vector(const vector& __v);
- vector(const vector& __v, const allocator_type& __a);
- vector& operator=(const vector& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);
#ifndef _LIBCPP_CXX03_LANG
- vector(initializer_list<value_type> __il);
- vector(initializer_list<value_type> __il, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // !_LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
noexcept;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
@@ -2089,93 +2161,93 @@ public:
typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
- assign(_InputIterator __first, _InputIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
- assign(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last);
- void assign(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(this->__alloc());}
- size_type max_size() const _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type capacity() const _NOEXCEPT
{return __internal_cap_to_external(__cap());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type size() const _NOEXCEPT
{return __size_;}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool empty() const _NOEXCEPT
{return __size_ == 0;}
- void reserve(size_type __n);
- void shrink_to_fit() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator begin() _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator begin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator end() _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator end() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rbegin() const _NOEXCEPT
{return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reverse_iterator rend() _NOEXCEPT
{return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator rend() const _NOEXCEPT
{return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cbegin() const _NOEXCEPT
{return __make_iter(0);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator cend() const _NOEXCEPT
{return __make_iter(__size_);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crbegin() const _NOEXCEPT
{return rbegin();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reverse_iterator crend() const _NOEXCEPT
{return rend();}
- _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);}
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);}
reference at(size_type __n);
const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
- _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);}
- void push_back(const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x);
#if _LIBCPP_STD_VER > 11
template <class... _Args>
#if _LIBCPP_STD_VER > 14
- _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args)
#else
_LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
#endif
@@ -2187,54 +2259,54 @@ public:
}
#endif
- _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;}
#if _LIBCPP_STD_VER > 11
template <class... _Args>
- _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator __position, _Args&&... __args)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)
{ return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }
#endif
- iterator insert(const_iterator __position, const value_type& __x);
- iterator insert(const_iterator __position, size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
template <class _InputIterator>
typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
iterator
>::type
- insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
iterator
>::type
- insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif
- _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
- iterator erase(const_iterator __first, const_iterator __last);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void clear() _NOEXCEPT {__size_ = 0;}
- void swap(vector&)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
- static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
- void resize(size_type __sz, value_type __x = false);
- void flip() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;
- bool __invariants() const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
private:
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
@@ -2254,52 +2326,56 @@ private:
// Precondition: __n > 0
// Postcondition: capacity() >= __n
// Postcondition: size() == 0
- _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) {
if (__n > max_size())
__throw_length_error();
auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
__begin_ = __allocation.ptr;
__size_ = 0;
__cap() = __allocation.count;
+ if (__libcpp_is_constant_evaluated()) {
+ for (size_type __i = 0; __i != __cap(); ++__i)
+ std::__construct_at(std::__to_address(__begin_) + __i);
+ }
}
- void __vdeallocate() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static size_type __align_it(size_type __new_size) _NOEXCEPT
{return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}
- _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
- _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x);
template <class _ForwardIterator>
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
void
>::type
- __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
- void __append(size_type __n, const_reference __x);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
reference __make_ref(size_type __pos) _NOEXCEPT
{return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_reference __make_ref(size_type __pos) const _NOEXCEPT {
return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
__storage_type(1) << __pos % __bits_per_word);
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator __make_iter(size_type __pos) _NOEXCEPT
{return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
const_iterator __make_iter(size_type __pos) const _NOEXCEPT
{return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
{return begin() + (__p - cbegin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector& __v)
{__copy_assign_alloc(__v, integral_constant<bool,
__storage_traits::propagate_on_container_copy_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector& __c, true_type)
{
if (__alloc() != __c.__alloc())
@@ -2307,33 +2383,33 @@ private:
__alloc() = __c.__alloc();
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __copy_assign_alloc(const vector&, false_type)
{}
- void __move_assign(vector& __c, false_type);
- void __move_assign(vector& __c, true_type)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector& __c)
_NOEXCEPT_(
!__storage_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__storage_traits::propagate_on_container_move_assignment::value>());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void __move_assign_alloc(vector&, false_type)
_NOEXCEPT
{}
- size_t __hash_code() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
friend class __bit_const_reference<vector>;
@@ -2344,7 +2420,7 @@ private:
};
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
@@ -2357,6 +2433,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::max_size() const _NOEXCEPT
{
@@ -2369,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
// Precondition: __new_size > capacity()
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::size_type
vector<bool, _Allocator>::__recommend(size_type __new_size) const
{
@@ -2387,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
{
@@ -2405,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2425,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
@@ -2435,7 +2513,7 @@ vector<bool, _Allocator>::vector()
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
@@ -2449,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n)
: __begin_(nullptr),
__size_(0),
@@ -2463,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n)
#if _LIBCPP_STD_VER > 11
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2477,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
#endif
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
: __begin_(nullptr),
__size_(0),
@@ -2490,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2504,6 +2586,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
@@ -2530,6 +2613,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
: __begin_(nullptr),
@@ -2556,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
@@ -2572,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
: __begin_(nullptr),
@@ -2589,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
: __begin_(nullptr),
__size_(0),
@@ -2603,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2619,6 +2707,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::~vector()
{
if (__begin_ != nullptr)
@@ -2627,6 +2716,7 @@ vector<bool, _Allocator>::~vector()
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const vector& __v)
: __begin_(nullptr),
__size_(0),
@@ -2640,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
: __begin_(nullptr),
__size_(0),
@@ -2653,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(const vector& __v)
{
@@ -2674,7 +2766,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
@@ -2689,6 +2781,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
: __begin_(nullptr),
__size_(0),
@@ -2710,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
vector<bool, _Allocator>&
vector<bool, _Allocator>::operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -2721,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
{
if (__alloc() != __c.__alloc())
@@ -2731,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
@@ -2745,7 +2838,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
{
__size_ = 0;
@@ -2768,7 +2861,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
template <class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
void
>::type
vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2780,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2803,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::reserve(size_type __n)
{
if (__n > capacity())
@@ -2819,7 +2913,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
{
if (__external_cap_to_internal(size()) > __cap())
@@ -2857,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::push_back(const value_type& __x)
{
if (this->__size_ == this->capacity())
@@ -2867,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
{
iterator __r;
@@ -2892,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
}
template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
{
iterator __r;
@@ -2919,7 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
template <class _Allocator>
template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
typename vector<bool, _Allocator>::iterator
>::type
vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -2961,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
template <class _Allocator>
template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2994,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
}
template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __position)
{
@@ -3005,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position)
}
template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
typename vector<bool, _Allocator>::iterator
vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
{
@@ -3016,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::swap(vector& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
@@ -3033,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
{
size_type __cs = size();
@@ -3062,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
}
template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
vector<bool, _Allocator>::flip() _NOEXCEPT
{
// do middle whole words
@@ -3081,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
}
template <class _Allocator>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
vector<bool, _Allocator>::__invariants() const
{
if (this->__begin_ == nullptr)
@@ -3100,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const
}
template <class _Allocator>
-size_t
+_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t
vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
{
size_t __h = 0;
@@ -3122,12 +3218,13 @@ template <class _Allocator>
struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
: public __unary_function<vector<bool, _Allocator>, size_t>
{
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
{return __vec.__hash_code();}
};
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3137,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3145,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3153,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3161,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3169,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3177,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
}
template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
@@ -3187,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
auto __old_size = __c.size();
@@ -3195,6 +3299,7 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
}
template <class _Tp, class _Allocator, class _Predicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
auto __old_size = __c.size();
diff --git a/contrib/llvm-project/libcxx/include/version b/contrib/llvm-project/libcxx/include/version
index 1df51fa1cb86..8ffb1747eb27 100644
--- a/contrib/llvm-project/libcxx/include/version
+++ b/contrib/llvm-project/libcxx/include/version
@@ -331,8 +331,8 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_erase_if 202002L
# undef __cpp_lib_execution
// # define __cpp_lib_execution 201902L
-# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)
-// # define __cpp_lib_format 202106L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+# define __cpp_lib_format 202106L
# endif
# define __cpp_lib_generic_unordered_lookup 201811L
# define __cpp_lib_int_pow2 202002L
@@ -351,7 +351,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_list_remove_return_type 201806L
# define __cpp_lib_math_constants 201907L
// # define __cpp_lib_polymorphic_allocator 201902L
-// # define __cpp_lib_ranges 201811L
+# if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+# define __cpp_lib_ranges 201811L
+# endif
# define __cpp_lib_remove_cvref 201711L
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
# define __cpp_lib_semaphore 201907L
diff --git a/contrib/llvm-project/libcxx/src/include/sso_allocator.h b/contrib/llvm-project/libcxx/src/include/sso_allocator.h
index 2baf599c5c24..6a682fc43f86 100644
--- a/contrib/llvm-project/libcxx/src/include/sso_allocator.h
+++ b/contrib/llvm-project/libcxx/src/include/sso_allocator.h
@@ -41,6 +41,11 @@ public:
typedef _Tp* pointer;
typedef _Tp value_type;
+ template <class U>
+ struct rebind {
+ using other = __sso_allocator<U, _Np>;
+ };
+
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
diff --git a/contrib/llvm-project/libcxx/src/assert.cpp b/contrib/llvm-project/libcxx/src/verbose_abort.cpp
index c218645f1771..a9fba5e3c007 100644
--- a/contrib/llvm-project/libcxx/src/assert.cpp
+++ b/contrib/llvm-project/libcxx/src/verbose_abort.cpp
@@ -6,17 +6,21 @@
//
//===----------------------------------------------------------------------===//
-#include <__assert>
#include <__config>
+#include <__verbose_abort>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#ifdef __BIONIC__
# include <android/api-level.h>
-# include <syslog.h>
+# if __ANDROID_API__ >= 21
+# include <syslog.h>
extern "C" void android_set_abort_message(const char* msg);
-#endif
+# else
+# include <assert.h>
+# endif // __ANDROID_API__ >= 21
+#endif // __BIONIC__
#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
# include <CrashReporterClient.h>
@@ -25,7 +29,7 @@ extern "C" void android_set_abort_message(const char* msg);
_LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_WEAK
-void __libcpp_assertion_handler(char const* format, ...) {
+void __libcpp_verbose_abort(char const* format, ...) {
// Write message to stderr. We do this before formatting into a
// buffer so that we still get some information out if that fails.
{
@@ -48,14 +52,22 @@ void __libcpp_assertion_handler(char const* format, ...) {
vasprintf(&buffer, format, list);
CRSetCrashLogMessage(buffer);
#elif defined(__BIONIC__)
- // Show error in tombstone.
vasprintf(&buffer, format, list);
+
+# if __ANDROID_API__ >= 21
+ // Show error in tombstone.
android_set_abort_message(buffer);
// Show error in logcat.
openlog("libc++", 0, 0);
syslog(LOG_CRIT, "%s", buffer);
closelog();
+# else
+ // The good error reporting wasn't available in Android until L. Since we're
+ // about to abort anyway, just call __assert2, which will log _somewhere_
+ // (tombstone and/or logcat) in older releases.
+ __assert2(__FILE__, __LINE__, __func__, buffer);
+# endif // __ANDROID_API__ >= 21
#endif
va_end(list);
diff --git a/contrib/llvm-project/lld/COFF/Driver.cpp b/contrib/llvm-project/lld/COFF/Driver.cpp
index 155e4ca6ee3f..680f89b79b95 100644
--- a/contrib/llvm-project/lld/COFF/Driver.cpp
+++ b/contrib/llvm-project/lld/COFF/Driver.cpp
@@ -372,6 +372,14 @@ void LinkerDriver::parseDirectives(InputFile *file) {
for (StringRef inc : directives.includes)
addUndefined(inc);
+ // Handle /exclude-symbols: in bulk.
+ for (StringRef e : directives.excludes) {
+ SmallVector<StringRef, 2> vec;
+ e.split(vec, ',');
+ for (StringRef sym : vec)
+ excludedSymbols.insert(mangle(sym));
+ }
+
// https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-160
for (auto *arg : directives.args) {
switch (arg->getOption().getID()) {
@@ -1306,12 +1314,19 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
return;
}
- AutoExporter exporter;
+ AutoExporter exporter(excludedSymbols);
for (auto *arg : args.filtered(OPT_wholearchive_file))
if (Optional<StringRef> path = doFindFile(arg->getValue()))
exporter.addWholeArchive(*path);
+ for (auto *arg : args.filtered(OPT_exclude_symbols)) {
+ SmallVector<StringRef, 2> vec;
+ StringRef(arg->getValue()).split(vec, ',');
+ for (StringRef sym : vec)
+ exporter.addExcludedSymbol(mangle(sym));
+ }
+
ctx.symtab.forEachSymbol([&](Symbol *s) {
auto *def = dyn_cast<Defined>(s);
if (!exporter.shouldExport(ctx, def))
diff --git a/contrib/llvm-project/lld/COFF/Driver.h b/contrib/llvm-project/lld/COFF/Driver.h
index 162517340e80..129a3d9c7317 100644
--- a/contrib/llvm-project/lld/COFF/Driver.h
+++ b/contrib/llvm-project/lld/COFF/Driver.h
@@ -54,6 +54,7 @@ extern COFFOptTable optTable;
struct ParsedDirectives {
std::vector<StringRef> exports;
std::vector<StringRef> includes;
+ std::vector<StringRef> excludes;
llvm::opt::InputArgList args;
};
@@ -159,7 +160,8 @@ private:
std::vector<StringRef> filePaths;
std::vector<MemoryBufferRef> resources;
- llvm::StringSet<> directivesExports;
+ llvm::DenseSet<StringRef> directivesExports;
+ llvm::DenseSet<StringRef> excludedSymbols;
COFFLinkerContext &ctx;
diff --git a/contrib/llvm-project/lld/COFF/DriverUtils.cpp b/contrib/llvm-project/lld/COFF/DriverUtils.cpp
index 29a2d0165839..cdfe8587f3fa 100644
--- a/contrib/llvm-project/lld/COFF/DriverUtils.cpp
+++ b/contrib/llvm-project/lld/COFF/DriverUtils.cpp
@@ -909,6 +909,9 @@ ParsedDirectives ArgParser::parseDirectives(StringRef s) {
else if (tok.startswith_insensitive("/include:") ||
tok.startswith_insensitive("-include:"))
result.includes.push_back(tok.substr(strlen("/include:")));
+ else if (tok.startswith_insensitive("/exclude-symbols:") ||
+ tok.startswith_insensitive("-exclude-symbols:"))
+ result.excludes.push_back(tok.substr(strlen("/exclude-symbols:")));
else {
// Copy substrings that are not valid C strings. The tokenizer may have
// already copied quoted arguments for us, so those do not need to be
diff --git a/contrib/llvm-project/lld/COFF/MinGW.cpp b/contrib/llvm-project/lld/COFF/MinGW.cpp
index 7a3a3853572f..0689e44cc363 100644
--- a/contrib/llvm-project/lld/COFF/MinGW.cpp
+++ b/contrib/llvm-project/lld/COFF/MinGW.cpp
@@ -23,7 +23,9 @@ using namespace llvm::COFF;
using namespace lld;
using namespace lld::coff;
-AutoExporter::AutoExporter() {
+AutoExporter::AutoExporter(
+ const llvm::DenseSet<StringRef> &manualExcludeSymbols)
+ : manualExcludeSymbols(manualExcludeSymbols) {
excludeLibs = {
"libgcc",
"libgcc_s",
@@ -122,6 +124,10 @@ void AutoExporter::addWholeArchive(StringRef path) {
excludeLibs.erase(libName);
}
+void AutoExporter::addExcludedSymbol(StringRef symbol) {
+ excludeSymbols.insert(symbol);
+}
+
bool AutoExporter::shouldExport(const COFFLinkerContext &ctx,
Defined *sym) const {
if (!sym || !sym->getChunk())
@@ -131,7 +137,7 @@ bool AutoExporter::shouldExport(const COFFLinkerContext &ctx,
// disallow import symbols.
if (!isa<DefinedRegular>(sym) && !isa<DefinedCommon>(sym))
return false;
- if (excludeSymbols.count(sym->getName()))
+ if (excludeSymbols.count(sym->getName()) || manualExcludeSymbols.count(sym->getName()))
return false;
for (StringRef prefix : excludeSymbolPrefixes.keys())
diff --git a/contrib/llvm-project/lld/COFF/MinGW.h b/contrib/llvm-project/lld/COFF/MinGW.h
index 8f9343784fa0..5f2bbe4e9920 100644
--- a/contrib/llvm-project/lld/COFF/MinGW.h
+++ b/contrib/llvm-project/lld/COFF/MinGW.h
@@ -13,6 +13,7 @@
#include "Symbols.h"
#include "lld/Common/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Option/ArgList.h"
#include <vector>
@@ -25,9 +26,10 @@ class COFFLinkerContext;
// symbols for MinGW.
class AutoExporter {
public:
- AutoExporter();
+ AutoExporter(const llvm::DenseSet<StringRef> &manualExcludeSymbols);
void addWholeArchive(StringRef path);
+ void addExcludedSymbol(StringRef symbol);
llvm::StringSet<> excludeSymbols;
llvm::StringSet<> excludeSymbolPrefixes;
@@ -35,6 +37,8 @@ public:
llvm::StringSet<> excludeLibs;
llvm::StringSet<> excludeObjects;
+ const llvm::DenseSet<StringRef> &manualExcludeSymbols;
+
bool shouldExport(const COFFLinkerContext &ctx, Defined *sym) const;
};
diff --git a/contrib/llvm-project/lld/COFF/Options.td b/contrib/llvm-project/lld/COFF/Options.td
index 5135f4ea34af..c728279ef5cc 100644
--- a/contrib/llvm-project/lld/COFF/Options.td
+++ b/contrib/llvm-project/lld/COFF/Options.td
@@ -45,6 +45,8 @@ def diasdkdir : P<"diasdkdir", "Set the location of the DIA SDK">;
def entry : P<"entry", "Name of entry point symbol">;
def errorlimit : P<"errorlimit",
"Maximum number of errors to emit before stopping (0 = no limit)">;
+def exclude_symbols : P<"exclude-symbols", "Exclude symbols from automatic export">,
+ MetaVarName<"<symbol[,symbol,...]>">;
def export : P<"export", "Export a function">;
// No help text because /failifmismatch is not intended to be used by the user.
def failifmismatch : P<"failifmismatch", "">;
diff --git a/contrib/llvm-project/lld/COFF/PDB.cpp b/contrib/llvm-project/lld/COFF/PDB.cpp
index 87b6bb55d610..2da63ab4e59a 100644
--- a/contrib/llvm-project/lld/COFF/PDB.cpp
+++ b/contrib/llvm-project/lld/COFF/PDB.cpp
@@ -811,6 +811,10 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) {
// Unclear what this is for.
break;
+ case DebugSubsectionKind::XfgHashType:
+ case DebugSubsectionKind::XfgHashVirtual:
+ break;
+
default:
warn("ignoring unknown debug$S subsection kind 0x" +
utohexstr(uint32_t(ss.kind())) + " in file " + toString(&file));
diff --git a/contrib/llvm-project/lld/ELF/Arch/AArch64.cpp b/contrib/llvm-project/lld/ELF/Arch/AArch64.cpp
index 1949169d6447..b23684819a23 100644
--- a/contrib/llvm-project/lld/ELF/Arch/AArch64.cpp
+++ b/contrib/llvm-project/lld/ELF/Arch/AArch64.cpp
@@ -873,8 +873,8 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym,
}
static TargetInfo *getTargetInfo() {
- if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI |
- GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
+ if ((config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ||
+ config->zPacPlt) {
static AArch64BtiPac t;
return &t;
}
diff --git a/contrib/llvm-project/lld/ELF/Config.h b/contrib/llvm-project/lld/ELF/Config.h
index 39723f092784..af976e39147d 100644
--- a/contrib/llvm-project/lld/ELF/Config.h
+++ b/contrib/llvm-project/lld/ELF/Config.h
@@ -290,6 +290,7 @@ struct Configuration {
StringRef thinLTOJobs;
unsigned timeTraceGranularity;
int32_t splitStackAdjustSize;
+ StringRef packageMetadata;
// The following config options do not directly correspond to any
// particular command line options.
diff --git a/contrib/llvm-project/lld/ELF/Driver.cpp b/contrib/llvm-project/lld/ELF/Driver.cpp
index 6c0fd3139e87..296fb4220012 100644
--- a/contrib/llvm-project/lld/ELF/Driver.cpp
+++ b/contrib/llvm-project/lld/ELF/Driver.cpp
@@ -590,11 +590,6 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
if (errorCount())
return;
- // The Target instance handles target-specific stuff, such as applying
- // relocations or writing a PLT section. It also contains target-dependent
- // values such as a default image base address.
- target = getTarget();
-
link(args);
}
@@ -1150,6 +1145,7 @@ static void readConfigs(opt::InputArgList &args) {
config->optimize = args::getInteger(args, OPT_O, 1);
config->orphanHandling = getOrphanHandling(args);
config->outputFile = args.getLastArgValue(OPT_o);
+ config->packageMetadata = args.getLastArgValue(OPT_package_metadata);
config->pie = args.hasFlag(OPT_pie, OPT_no_pie, false);
config->printIcfSections =
args.hasFlag(OPT_print_icf_sections, OPT_no_print_icf_sections, false);
diff --git a/contrib/llvm-project/lld/ELF/Options.td b/contrib/llvm-project/lld/ELF/Options.td
index 80c0ff9fe1b8..d9266e595887 100644
--- a/contrib/llvm-project/lld/ELF/Options.td
+++ b/contrib/llvm-project/lld/ELF/Options.td
@@ -503,6 +503,8 @@ def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"<option>">,
def visual_studio_diagnostics_format : FF<"vs-diagnostics">,
HelpText<"Format diagnostics for Visual Studio compatibility">;
+def package_metadata: JJ<"package-metadata=">, HelpText<"Emit package metadata note">;
+
// Aliases
def: Separate<["-"], "f">, Alias<auxiliary>, HelpText<"Alias for --auxiliary">;
def: F<"call_shared">, Alias<Bdynamic>, HelpText<"Alias for --Bdynamic">;
diff --git a/contrib/llvm-project/lld/ELF/Relocations.cpp b/contrib/llvm-project/lld/ELF/Relocations.cpp
index e54e1ebd41bb..53af34ef2085 100644
--- a/contrib/llvm-project/lld/ELF/Relocations.cpp
+++ b/contrib/llvm-project/lld/ELF/Relocations.cpp
@@ -1705,7 +1705,8 @@ static bool mergeCmp(const InputSection *a, const InputSection *b) {
if (a->outSecOff < b->outSecOff)
return true;
- if (a->outSecOff == b->outSecOff) {
+ // FIXME dyn_cast<ThunkSection> is non-null for any SyntheticSection.
+ if (a->outSecOff == b->outSecOff && a != b) {
auto *ta = dyn_cast<ThunkSection>(a);
auto *tb = dyn_cast<ThunkSection>(b);
diff --git a/contrib/llvm-project/lld/ELF/SyntheticSections.cpp b/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
index 919afc7a6e0e..b359c2e7bcea 100644
--- a/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
+++ b/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
@@ -712,6 +712,9 @@ bool GotSection::isNeeded() const {
}
void GotSection::writeTo(uint8_t *buf) {
+ // On PPC64 .got may be needed but empty. Skip the write.
+ if (size == 0)
+ return;
target->writeGotHeader(buf);
relocateAlloc(buf, buf + size);
}
@@ -3884,6 +3887,20 @@ size_t MemtagAndroidNote::getSize() const {
/*descsz=*/sizeof(uint32_t);
}
+void PackageMetadataNote::writeTo(uint8_t *buf) {
+ write32(buf, 4);
+ write32(buf + 4, config->packageMetadata.size() + 1);
+ write32(buf + 8, FDO_PACKAGING_METADATA);
+ memcpy(buf + 12, "FDO", 4);
+ memcpy(buf + 16, config->packageMetadata.data(),
+ config->packageMetadata.size());
+}
+
+size_t PackageMetadataNote::getSize() const {
+ return sizeof(llvm::ELF::Elf64_Nhdr) + 4 +
+ alignTo(config->packageMetadata.size() + 1, 4);
+}
+
InStruct elf::in;
std::vector<Partition> elf::partitions;
diff --git a/contrib/llvm-project/lld/ELF/SyntheticSections.h b/contrib/llvm-project/lld/ELF/SyntheticSections.h
index 9e95d3f3f65a..987c0461ec07 100644
--- a/contrib/llvm-project/lld/ELF/SyntheticSections.h
+++ b/contrib/llvm-project/lld/ELF/SyntheticSections.h
@@ -1199,6 +1199,15 @@ public:
size_t getSize() const override;
};
+class PackageMetadataNote : public SyntheticSection {
+public:
+ PackageMetadataNote()
+ : SyntheticSection(llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOTE,
+ /*alignment=*/4, ".note.package") {}
+ void writeTo(uint8_t *buf) override;
+ size_t getSize() const override;
+};
+
InputSection *createInterpSection();
MergeInputSection *createCommentSection();
template <class ELFT> void splitSections();
@@ -1230,6 +1239,7 @@ struct Partition {
std::unique_ptr<GnuHashTableSection> gnuHashTab;
std::unique_ptr<HashTableSection> hashTab;
std::unique_ptr<MemtagAndroidNote> memtagAndroidNote;
+ std::unique_ptr<PackageMetadataNote> packageMetadataNote;
std::unique_ptr<RelocationBaseSection> relaDyn;
std::unique_ptr<RelrBaseSection> relrDyn;
std::unique_ptr<VersionDefinitionSection> verDef;
diff --git a/contrib/llvm-project/lld/ELF/Writer.cpp b/contrib/llvm-project/lld/ELF/Writer.cpp
index c9345d812270..ad80d4344e36 100644
--- a/contrib/llvm-project/lld/ELF/Writer.cpp
+++ b/contrib/llvm-project/lld/ELF/Writer.cpp
@@ -425,6 +425,11 @@ template <class ELFT> void elf::createSyntheticSections() {
part.armExidx = std::make_unique<ARMExidxSyntheticSection>();
add(*part.armExidx);
}
+
+ if (!config->packageMetadata.empty()) {
+ part.packageMetadataNote = std::make_unique<PackageMetadataNote>();
+ add(*part.packageMetadataNote);
+ }
}
if (partitions.size() != 1) {
diff --git a/contrib/llvm-project/lld/MachO/Arch/ARM64.cpp b/contrib/llvm-project/lld/MachO/Arch/ARM64.cpp
index 46e935aa1fd1..c05fe8da8ca6 100644
--- a/contrib/llvm-project/lld/MachO/Arch/ARM64.cpp
+++ b/contrib/llvm-project/lld/MachO/Arch/ARM64.cpp
@@ -444,7 +444,7 @@ void OptimizationHintContext::applyAdrpLdr(const OptimizationHint &hint) {
Optional<PerformedReloc> rel2 = findReloc(hint.offset0 + hint.delta[0]);
if (!rel1 || !rel2)
return;
- if (ldr.offset != (rel1->referentVA & 0xfff))
+ if (ldr.offset != static_cast<int64_t>(rel1->referentVA & 0xfff))
return;
ldr.offset = rel1->referentVA - rel2->rel.offset - isec->getVA();
if (!isLiteralLdrEligible(ldr))
diff --git a/contrib/llvm-project/lld/MachO/DriverUtils.cpp b/contrib/llvm-project/lld/MachO/DriverUtils.cpp
index d8e474d15cfd..b91a43552443 100644
--- a/contrib/llvm-project/lld/MachO/DriverUtils.cpp
+++ b/contrib/llvm-project/lld/MachO/DriverUtils.cpp
@@ -211,7 +211,7 @@ DylibFile *macho::loadDylib(MemoryBufferRef mbref, DylibFile *umbrella,
DylibFile *&file = loadedDylibs[path];
if (file) {
if (explicitlyLinked)
- file->explicitlyLinked = explicitlyLinked;
+ file->setExplicitlyLinked();
return file;
}
diff --git a/contrib/llvm-project/lld/MachO/EhFrame.cpp b/contrib/llvm-project/lld/MachO/EhFrame.cpp
index 50d8accc0596..55a85f316cdd 100644
--- a/contrib/llvm-project/lld/MachO/EhFrame.cpp
+++ b/contrib/llvm-project/lld/MachO/EhFrame.cpp
@@ -58,17 +58,17 @@ uint32_t EhReader::readU32(size_t *off) const {
return v;
}
-uint64_t EhReader::readPointer(size_t *off) const {
- if (*off + wordSize > data.size())
+uint64_t EhReader::readPointer(size_t *off, uint8_t size) const {
+ if (*off + size > data.size())
failOn(*off, "unexpected end of CIE/FDE");
uint64_t v;
- if (wordSize == 8)
+ if (size == 8)
v = read64le(data.data() + *off);
else {
- assert(wordSize == 4);
+ assert(size == 4);
v = read32le(data.data() + *off);
}
- *off += wordSize;
+ *off += size;
return v;
}
diff --git a/contrib/llvm-project/lld/MachO/EhFrame.h b/contrib/llvm-project/lld/MachO/EhFrame.h
index c8269b941bcf..609a3bb8b1fe 100644
--- a/contrib/llvm-project/lld/MachO/EhFrame.h
+++ b/contrib/llvm-project/lld/MachO/EhFrame.h
@@ -55,9 +55,8 @@ namespace macho {
class EhReader {
public:
- EhReader(const ObjFile *file, ArrayRef<uint8_t> data, size_t dataOff,
- size_t wordSize)
- : file(file), data(data), dataOff(dataOff), wordSize(wordSize) {}
+ EhReader(const ObjFile *file, ArrayRef<uint8_t> data, size_t dataOff)
+ : file(file), data(data), dataOff(dataOff) {}
size_t size() const { return data.size(); }
// Read and validate the length field.
uint64_t readLength(size_t *off) const;
@@ -65,7 +64,7 @@ public:
void skipValidLength(size_t *off) const;
uint8_t readByte(size_t *off) const;
uint32_t readU32(size_t *off) const;
- uint64_t readPointer(size_t *off) const;
+ uint64_t readPointer(size_t *off, uint8_t size) const;
StringRef readString(size_t *off) const;
void skipLeb128(size_t *off) const;
void failOn(size_t errOff, const Twine &msg) const;
@@ -76,7 +75,6 @@ private:
// The offset of the data array within its section. Used only for error
// reporting.
const size_t dataOff;
- size_t wordSize;
};
// The EH frame format, when emitted by llvm-mc, consists of a number of
diff --git a/contrib/llvm-project/lld/MachO/InputFiles.cpp b/contrib/llvm-project/lld/MachO/InputFiles.cpp
index b463d7817594..fd0e4ec8834c 100644
--- a/contrib/llvm-project/lld/MachO/InputFiles.cpp
+++ b/contrib/llvm-project/lld/MachO/InputFiles.cpp
@@ -385,7 +385,7 @@ void ObjFile::parseSections(ArrayRef<SectionHeader> sectionHeaders) {
}
void ObjFile::splitEhFrames(ArrayRef<uint8_t> data, Section &ehFrameSection) {
- EhReader reader(this, data, /*dataOff=*/0, target->wordSize);
+ EhReader reader(this, data, /*dataOff=*/0);
size_t off = 0;
while (off < reader.size()) {
uint64_t frameOff = off;
@@ -1290,10 +1290,25 @@ void ObjFile::registerCompactUnwind(Section &compactUnwindSection) {
struct CIE {
macho::Symbol *personalitySymbol = nullptr;
- bool fdesHaveLsda = false;
bool fdesHaveAug = false;
+ uint8_t lsdaPtrSize = 0; // 0 => no LSDA
+ uint8_t funcPtrSize = 0;
};
+static uint8_t pointerEncodingToSize(uint8_t enc) {
+ switch (enc & 0xf) {
+ case dwarf::DW_EH_PE_absptr:
+ return target->wordSize;
+ case dwarf::DW_EH_PE_sdata4:
+ return 4;
+ case dwarf::DW_EH_PE_sdata8:
+ // ld64 doesn't actually support sdata8, but this seems simple enough...
+ return 8;
+ default:
+ return 0;
+ };
+}
+
static CIE parseCIE(const InputSection *isec, const EhReader &reader,
size_t off) {
// Handling the full generality of possible DWARF encodings would be a major
@@ -1301,8 +1316,6 @@ static CIE parseCIE(const InputSection *isec, const EhReader &reader,
// DWARF and handle just that.
constexpr uint8_t expectedPersonalityEnc =
dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_sdata4;
- constexpr uint8_t expectedPointerEnc =
- dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_absptr;
CIE cie;
uint8_t version = reader.readByte(&off);
@@ -1329,16 +1342,17 @@ static CIE parseCIE(const InputSection *isec, const EhReader &reader,
break;
}
case 'L': {
- cie.fdesHaveLsda = true;
uint8_t lsdaEnc = reader.readByte(&off);
- if (lsdaEnc != expectedPointerEnc)
+ cie.lsdaPtrSize = pointerEncodingToSize(lsdaEnc);
+ if (cie.lsdaPtrSize == 0)
reader.failOn(off, "unexpected LSDA encoding 0x" +
Twine::utohexstr(lsdaEnc));
break;
}
case 'R': {
uint8_t pointerEnc = reader.readByte(&off);
- if (pointerEnc != expectedPointerEnc)
+ cie.funcPtrSize = pointerEncodingToSize(pointerEnc);
+ if (cie.funcPtrSize == 0 || !(pointerEnc & dwarf::DW_EH_PE_pcrel))
reader.failOn(off, "unexpected pointer encoding 0x" +
Twine::utohexstr(pointerEnc));
break;
@@ -1468,7 +1482,7 @@ void ObjFile::registerEhFrames(Section &ehFrameSection) {
else if (isec->symbols[0]->value != 0)
fatal("found symbol at unexpected offset in __eh_frame");
- EhReader reader(this, isec->data, subsec.offset, target->wordSize);
+ EhReader reader(this, isec->data, subsec.offset);
size_t dataOff = 0; // Offset from the start of the EH frame.
reader.skipValidLength(&dataOff); // readLength() already validated this.
// cieOffOff is the offset from the start of the EH frame to the cieOff
@@ -1507,20 +1521,20 @@ void ObjFile::registerEhFrames(Section &ehFrameSection) {
continue;
}
+ assert(cieMap.count(cieIsec));
+ const CIE &cie = cieMap[cieIsec];
// Offset of the function address within the EH frame.
const size_t funcAddrOff = dataOff;
- uint64_t funcAddr = reader.readPointer(&dataOff) + ehFrameSection.addr +
- isecOff + funcAddrOff;
- uint32_t funcLength = reader.readPointer(&dataOff);
+ uint64_t funcAddr = reader.readPointer(&dataOff, cie.funcPtrSize) +
+ ehFrameSection.addr + isecOff + funcAddrOff;
+ uint32_t funcLength = reader.readPointer(&dataOff, cie.funcPtrSize);
size_t lsdaAddrOff = 0; // Offset of the LSDA address within the EH frame.
- assert(cieMap.count(cieIsec));
- const CIE &cie = cieMap[cieIsec];
Optional<uint64_t> lsdaAddrOpt;
if (cie.fdesHaveAug) {
reader.skipLeb128(&dataOff);
lsdaAddrOff = dataOff;
- if (cie.fdesHaveLsda) {
- uint64_t lsdaOff = reader.readPointer(&dataOff);
+ if (cie.lsdaPtrSize != 0) {
+ uint64_t lsdaOff = reader.readPointer(&dataOff, cie.lsdaPtrSize);
if (lsdaOff != 0) // FIXME possible to test this?
lsdaAddrOpt = ehFrameSection.addr + isecOff + lsdaAddrOff + lsdaOff;
}
@@ -1944,6 +1958,14 @@ DylibFile::DylibFile(const InterfaceFile &interface, DylibFile *umbrella,
}
}
+DylibFile::DylibFile(DylibFile *umbrella)
+ : InputFile(DylibKind, MemoryBufferRef{}), refState(RefState::Unreferenced),
+ explicitlyLinked(false), isBundleLoader(false) {
+ if (umbrella == nullptr)
+ umbrella = this;
+ this->umbrella = umbrella;
+}
+
void DylibFile::parseReexports(const InterfaceFile &interface) {
const InterfaceFile *topLevel =
interface.getParent() == nullptr ? &interface : interface.getParent();
@@ -1955,6 +1977,39 @@ void DylibFile::parseReexports(const InterfaceFile &interface) {
}
}
+bool DylibFile::isExplicitlyLinked() const {
+ if (!explicitlyLinked)
+ return false;
+
+ // If this dylib was explicitly linked, but at least one of the symbols
+ // of the synthetic dylibs it created via $ld$previous symbols is
+ // referenced, then that synthetic dylib fulfils the explicit linkedness
+ // and we can deadstrip this dylib if it's unreferenced.
+ for (const auto *dylib : extraDylibs)
+ if (dylib->isReferenced())
+ return false;
+
+ return true;
+}
+
+DylibFile *DylibFile::getSyntheticDylib(StringRef installName,
+ uint32_t currentVersion,
+ uint32_t compatVersion) {
+ for (DylibFile *dylib : extraDylibs)
+ if (dylib->installName == installName) {
+ // FIXME: Check what to do if different $ld$previous symbols
+ // request the same dylib, but with different versions.
+ return dylib;
+ }
+
+ auto *dylib = make<DylibFile>(umbrella == this ? nullptr : umbrella);
+ dylib->installName = saver().save(installName);
+ dylib->currentVersion = currentVersion;
+ dylib->compatibilityVersion = compatVersion;
+ extraDylibs.push_back(dylib);
+ return dylib;
+}
+
// $ld$ symbols modify the properties/behavior of the library (e.g. its install
// name, compatibility version or hide/add symbols) for specific target
// versions.
@@ -1990,10 +2045,9 @@ void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) {
std::tie(platformStr, name) = name.split('$');
std::tie(startVersion, name) = name.split('$');
std::tie(endVersion, name) = name.split('$');
- std::tie(symbolName, rest) = name.split('$');
- // TODO: ld64 contains some logic for non-empty symbolName as well.
- if (!symbolName.empty())
- return;
+ std::tie(symbolName, rest) = name.rsplit('$');
+
+ // FIXME: Does this do the right thing for zippered files?
unsigned platform;
if (platformStr.getAsInteger(10, platform) ||
platform != static_cast<unsigned>(config->platform()))
@@ -2014,8 +2068,9 @@ void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) {
config->platformInfo.minimum >= end)
return;
- this->installName = saver().save(installName);
-
+ // Initialized to compatibilityVersion for the symbolName branch below.
+ uint32_t newCompatibilityVersion = compatibilityVersion;
+ uint32_t newCurrentVersionForSymbol = currentVersion;
if (!compatVersion.empty()) {
VersionTuple cVersion;
if (cVersion.tryParse(compatVersion)) {
@@ -2023,8 +2078,27 @@ void DylibFile::handleLDPreviousSymbol(StringRef name, StringRef originalName) {
"' ignored");
return;
}
- compatibilityVersion = encodeVersion(cVersion);
+ newCompatibilityVersion = encodeVersion(cVersion);
+ newCurrentVersionForSymbol = newCompatibilityVersion;
+ }
+
+ if (!symbolName.empty()) {
+ // A $ld$previous$ symbol with symbol name adds a symbol with that name to
+ // a dylib with given name and version.
+ auto *dylib = getSyntheticDylib(installName, newCurrentVersionForSymbol,
+ newCompatibilityVersion);
+
+ // Just adding the symbol to the symtab works because dylibs contain their
+ // symbols in alphabetical order, guaranteeing $ld$ symbols to precede
+ // normal symbols.
+ dylib->symbols.push_back(symtab->addDylib(
+ saver().save(symbolName), dylib, /*isWeakDef=*/false, /*isTlv=*/false));
+ return;
}
+
+ // A $ld$previous$ symbol without symbol name modifies the dylib it's in.
+ this->installName = saver().save(installName);
+ this->compatibilityVersion = newCompatibilityVersion;
}
void DylibFile::handleLDInstallNameSymbol(StringRef name,
diff --git a/contrib/llvm-project/lld/MachO/InputFiles.h b/contrib/llvm-project/lld/MachO/InputFiles.h
index ea6802814e4c..89172922a0a7 100644
--- a/contrib/llvm-project/lld/MachO/InputFiles.h
+++ b/contrib/llvm-project/lld/MachO/InputFiles.h
@@ -219,10 +219,13 @@ public:
explicit DylibFile(const llvm::MachO::InterfaceFile &interface,
DylibFile *umbrella, bool isBundleLoader,
bool explicitlyLinked);
+ explicit DylibFile(DylibFile *umbrella);
void parseLoadCommands(MemoryBufferRef mb);
void parseReexports(const llvm::MachO::InterfaceFile &interface);
bool isReferenced() const { return numReferencedSymbols > 0; }
+ bool isExplicitlyLinked() const;
+ void setExplicitlyLinked() { explicitlyLinked = true; }
static bool classof(const InputFile *f) { return f->kind() == DylibKind; }
@@ -239,14 +242,26 @@ public:
bool forceNeeded = false;
bool forceWeakImport = false;
bool deadStrippable = false;
- bool explicitlyLinked = false;
+
+private:
+ bool explicitlyLinked = false; // Access via isExplicitlyLinked().
+
+public:
// An executable can be used as a bundle loader that will load the output
// file being linked, and that contains symbols referenced, but not
// implemented in the bundle. When used like this, it is very similar
// to a dylib, so we've used the same class to represent it.
bool isBundleLoader;
+ // Synthetic Dylib objects created by $ld$previous symbols in this dylib.
+ // Usually empty. These synthetic dylibs won't have synthetic dylibs
+ // themselves.
+ SmallVector<DylibFile *, 2> extraDylibs;
+
private:
+ DylibFile *getSyntheticDylib(StringRef installName, uint32_t currentVersion,
+ uint32_t compatVersion);
+
bool handleLDSymbol(StringRef originalName);
void handleLDPreviousSymbol(StringRef name, StringRef originalName);
void handleLDInstallNameSymbol(StringRef name, StringRef originalName);
diff --git a/contrib/llvm-project/lld/MachO/UnwindInfoSection.cpp b/contrib/llvm-project/lld/MachO/UnwindInfoSection.cpp
index 322057947a3d..c3f563d5572b 100644
--- a/contrib/llvm-project/lld/MachO/UnwindInfoSection.cpp
+++ b/contrib/llvm-project/lld/MachO/UnwindInfoSection.cpp
@@ -401,8 +401,12 @@ static bool canFoldEncoding(compact_unwind_encoding_t encoding) {
// of the unwind info's unwind address, two functions that have identical
// unwind info can't be folded if it's using this encoding since both
// entries need unique addresses.
- static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
- static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
+ static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_MASK) ==
+ static_cast<uint32_t>(UNWIND_X86_MODE_MASK),
+ "");
+ static_assert(static_cast<uint32_t>(UNWIND_X86_64_MODE_STACK_IND) ==
+ static_cast<uint32_t>(UNWIND_X86_MODE_STACK_IND),
+ "");
if ((target->cpuType == CPU_TYPE_X86_64 || target->cpuType == CPU_TYPE_X86) &&
(encoding & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_STACK_IND) {
// FIXME: Consider passing in the two function addresses and getting
diff --git a/contrib/llvm-project/lld/MachO/Writer.cpp b/contrib/llvm-project/lld/MachO/Writer.cpp
index 7fad9f5564ce..3c44a60f4be2 100644
--- a/contrib/llvm-project/lld/MachO/Writer.cpp
+++ b/contrib/llvm-project/lld/MachO/Writer.cpp
@@ -780,70 +780,80 @@ template <class LP> void Writer::createLoadCommands() {
if (config->outputType == MH_EXECUTE)
in.header->addLoadCommand(make<LCMain>());
+ // See ld64's OutputFile::buildDylibOrdinalMapping for the corresponding
+ // library ordinal computation code in ld64.
int64_t dylibOrdinal = 1;
DenseMap<StringRef, int64_t> ordinalForInstallName;
+
+ std::vector<DylibFile *> dylibFiles;
for (InputFile *file : inputFiles) {
- if (auto *dylibFile = dyn_cast<DylibFile>(file)) {
- if (dylibFile->isBundleLoader) {
- dylibFile->ordinal = BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE;
- // Shortcut since bundle-loader does not re-export the symbols.
+ if (auto *dylibFile = dyn_cast<DylibFile>(file))
+ dylibFiles.push_back(dylibFile);
+ }
+ for (size_t i = 0; i < dylibFiles.size(); ++i)
+ dylibFiles.insert(dylibFiles.end(), dylibFiles[i]->extraDylibs.begin(),
+ dylibFiles[i]->extraDylibs.end());
- dylibFile->reexport = false;
- continue;
- }
+ for (DylibFile *dylibFile : dylibFiles) {
+ if (dylibFile->isBundleLoader) {
+ dylibFile->ordinal = BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE;
+ // Shortcut since bundle-loader does not re-export the symbols.
- // Don't emit load commands for a dylib that is not referenced if:
- // - it was added implicitly (via a reexport, an LC_LOAD_DYLINKER --
- // if it's on the linker command line, it's explicit)
- // - or it's marked MH_DEAD_STRIPPABLE_DYLIB
- // - or the flag -dead_strip_dylibs is used
- // FIXME: `isReferenced()` is currently computed before dead code
- // stripping, so references from dead code keep a dylib alive. This
- // matches ld64, but it's something we should do better.
- if (!dylibFile->isReferenced() && !dylibFile->forceNeeded &&
- (!dylibFile->explicitlyLinked || dylibFile->deadStrippable ||
- config->deadStripDylibs))
- continue;
+ dylibFile->reexport = false;
+ continue;
+ }
- // Several DylibFiles can have the same installName. Only emit a single
- // load command for that installName and give all these DylibFiles the
- // same ordinal.
- // This can happen in several cases:
- // - a new framework could change its installName to an older
- // framework name via an $ld$ symbol depending on platform_version
- // - symlinks (for example, libpthread.tbd is a symlink to libSystem.tbd;
- // Foo.framework/Foo.tbd is usually a symlink to
- // Foo.framework/Versions/Current/Foo.tbd, where
- // Foo.framework/Versions/Current is usually a symlink to
- // Foo.framework/Versions/A)
- // - a framework can be linked both explicitly on the linker
- // command line and implicitly as a reexport from a different
- // framework. The re-export will usually point to the tbd file
- // in Foo.framework/Versions/A/Foo.tbd, while the explicit link will
- // usually find Foo.framework/Foo.tbd. These are usually symlinks,
- // but in a --reproduce archive they will be identical but distinct
- // files.
- // In the first case, *semantically distinct* DylibFiles will have the
- // same installName.
- int64_t &ordinal = ordinalForInstallName[dylibFile->installName];
- if (ordinal) {
- dylibFile->ordinal = ordinal;
- continue;
- }
+ // Don't emit load commands for a dylib that is not referenced if:
+ // - it was added implicitly (via a reexport, an LC_LOAD_DYLINKER --
+ // if it's on the linker command line, it's explicit)
+ // - or it's marked MH_DEAD_STRIPPABLE_DYLIB
+ // - or the flag -dead_strip_dylibs is used
+ // FIXME: `isReferenced()` is currently computed before dead code
+ // stripping, so references from dead code keep a dylib alive. This
+ // matches ld64, but it's something we should do better.
+ if (!dylibFile->isReferenced() && !dylibFile->forceNeeded &&
+ (!dylibFile->isExplicitlyLinked() || dylibFile->deadStrippable ||
+ config->deadStripDylibs))
+ continue;
- ordinal = dylibFile->ordinal = dylibOrdinal++;
- LoadCommandType lcType =
- dylibFile->forceWeakImport || dylibFile->refState == RefState::Weak
- ? LC_LOAD_WEAK_DYLIB
- : LC_LOAD_DYLIB;
- in.header->addLoadCommand(make<LCDylib>(lcType, dylibFile->installName,
- dylibFile->compatibilityVersion,
- dylibFile->currentVersion));
-
- if (dylibFile->reexport)
- in.header->addLoadCommand(
- make<LCDylib>(LC_REEXPORT_DYLIB, dylibFile->installName));
+ // Several DylibFiles can have the same installName. Only emit a single
+ // load command for that installName and give all these DylibFiles the
+ // same ordinal.
+ // This can happen in several cases:
+ // - a new framework could change its installName to an older
+ // framework name via an $ld$ symbol depending on platform_version
+ // - symlinks (for example, libpthread.tbd is a symlink to libSystem.tbd;
+ // Foo.framework/Foo.tbd is usually a symlink to
+ // Foo.framework/Versions/Current/Foo.tbd, where
+ // Foo.framework/Versions/Current is usually a symlink to
+ // Foo.framework/Versions/A)
+ // - a framework can be linked both explicitly on the linker
+ // command line and implicitly as a reexport from a different
+ // framework. The re-export will usually point to the tbd file
+ // in Foo.framework/Versions/A/Foo.tbd, while the explicit link will
+ // usually find Foo.framework/Foo.tbd. These are usually symlinks,
+ // but in a --reproduce archive they will be identical but distinct
+ // files.
+ // In the first case, *semantically distinct* DylibFiles will have the
+ // same installName.
+ int64_t &ordinal = ordinalForInstallName[dylibFile->installName];
+ if (ordinal) {
+ dylibFile->ordinal = ordinal;
+ continue;
}
+
+ ordinal = dylibFile->ordinal = dylibOrdinal++;
+ LoadCommandType lcType =
+ dylibFile->forceWeakImport || dylibFile->refState == RefState::Weak
+ ? LC_LOAD_WEAK_DYLIB
+ : LC_LOAD_DYLIB;
+ in.header->addLoadCommand(make<LCDylib>(lcType, dylibFile->installName,
+ dylibFile->compatibilityVersion,
+ dylibFile->currentVersion));
+
+ if (dylibFile->reexport)
+ in.header->addLoadCommand(
+ make<LCDylib>(LC_REEXPORT_DYLIB, dylibFile->installName));
}
if (functionStartsSection)
diff --git a/contrib/llvm-project/lld/docs/ReleaseNotes.rst b/contrib/llvm-project/lld/docs/ReleaseNotes.rst
index 936d800cabc3..5819d67d3297 100644
--- a/contrib/llvm-project/lld/docs/ReleaseNotes.rst
+++ b/contrib/llvm-project/lld/docs/ReleaseNotes.rst
@@ -25,18 +25,43 @@ Non-comprehensive list of changes in this release
ELF Improvements
----------------
+* ``--package-metadata=`` has been added to create package metadata notes
+ (`D131439 <https://reviews.llvm.org/D131439>`_)
* ``-z pack-relative-relocs`` is now available to support ``DT_RELR`` for glibc 2.36+.
(`D120701 <https://reviews.llvm.org/D120701>`_)
* ``--no-fortran-common`` (pre 12.0.0 behavior) is now the default.
+* ``--load-pass-plugin`` has been added to load a new pass manager plugin.
+ (`D120490 <https://reviews.llvm.org/D120490>`_)
+* ``--android-memtag-{mode=,stack,heap}`` have been added to synthesize SHT_NOTE for memory tags on Android.
+ (`D119384 <https://reviews.llvm.org/D119384>`_)
* ``FORCE_LLD_DIAGNOSTICS_CRASH`` environment variable is now available to force LLD to crash.
(`D128195 <https://reviews.llvm.org/D128195>`_)
+* ``--wrap`` semantics have been refined.
+ (`rG7288b85cc80f1ce5509aeea860e6b4232cd3ca01 <https://reviews.llvm.org/rG7288b85cc80f1ce5509aeea860e6b4232cd3ca01>`_)
+ (`D118756 <https://reviews.llvm.org/D118756>`_)
+ (`D124056 <https://reviews.llvm.org/D124056>`_)
+* ``--build-id={md5,sha1}`` are now implemented with truncated BLAKE3.
+ (`D121531 <https://reviews.llvm.org/D121531>`_)
+* ``--emit-relocs``: ``.rel[a].eh_frame`` relocation offsets are now adjusted.
+ (`D122459 <https://reviews.llvm.org/D122459>`_)
+* ``--emit-relocs``: fixed missing ``STT_SECTION`` when the first input section is synthetic.
+ (`D122463 <https://reviews.llvm.org/D122463>`_)
+* ``(TYPE=<value>)`` can now be used in linker scripts.
+ (`D118840 <https://reviews.llvm.org/D118840>`_)
+* Local symbol initialization is now performed in parallel.
+ (`D119909 <https://reviews.llvm.org/D119909>`_)
+ (`D120626 <https://reviews.llvm.org/D120626>`_)
Breaking changes
----------------
+* Archives are now parsed as ``--start-lib`` object files. If a member is neither
+ an ELF relocatable object file nor an LLVM bitcode file, ld.lld will give a warning.
+ (`D119074 <https://reviews.llvm.org/D119074>`_)
* The GNU ld incompatible ``--no-define-common`` has been removed.
* The obscure ``-dc``/``-dp`` options have been removed.
+ (`D119108 <https://reviews.llvm.org/D119108>`_)
* ``-d`` is now ignored.
* If a prevailing COMDAT group defines STB_WEAK symbol, having a STB_GLOBAL symbol in a non-prevailing group is now rejected with a diagnostic.
(`D120626 <https://reviews.llvm.org/D120626>`_)
@@ -60,7 +85,13 @@ COFF Improvements
MinGW Improvements
------------------
-* ...
+* The ``--disable-reloc-section`` option is now supported.
+ (`D127478 <https://reviews.llvm.org/D127478>`_)
+* The ``--exclude-symbols`` option is now supported.
+ (`D130118 <https://reviews.llvm.org/D130118>`_)
+
+* Support for an entirely new object file directive, ``-exclude-symbols:``,
+ has been implemented. (`D130120 <https://reviews.llvm.org/D130120>`_)
MachO Improvements
------------------
@@ -71,6 +102,117 @@ MachO Improvements
(`D129540 <https://reviews.llvm.org/D129540>`_,
`D122258 <https://reviews.llvm.org/D122258>`_)
+New flags
+#########
+
+* ``-load_hidden`` and ``-hidden-l`` are now supported.
+ (`D130473 <https://reviews.llvm.org/D130473>`_,
+ `D130529 <https://reviews.llvm.org/D130529>`_)
+* ``-alias`` is now supported. (`D129938 <https://reviews.llvm.org/D129938>`_)
+* ``-no_exported_symbols`` and ``-exported_symbols_list <empty file>`` are now
+ supported. (`D127562 <https://reviews.llvm.org/D127562>`_)
+* ``-w`` -- to suppress warnings -- is now supported.
+ (`D127564 <https://reviews.llvm.org/D127564>`_)
+* ``-non_global_symbols_strip_list``, ``-non_global_symbols_no_strip_list``, and
+ ``-x`` are now supported. (`D126046 <https://reviews.llvm.org/D126046>`_)
+* ``--icf=safe`` is now supported.
+ (`D128938 <https://reviews.llvm.org/D128938>`_,
+ `D123752 <https://reviews.llvm.org/D123752>`_)
+* ``-why_live`` is now supported.
+ (`D120377 <https://reviews.llvm.org/D120377>`_)
+* ``-pagezero_size`` is now supported.
+ (`D118724 <https://reviews.llvm.org/D118724>`_)
+
+Improvements
+############
+
+* Linker optimization hints are now supported.
+ (`D129427 <https://reviews.llvm.org/D129427>`_,
+ `D129059 <https://reviews.llvm.org/D129059>`_,
+ `D128942 <https://reviews.llvm.org/D128942>`_,
+ `D128093 <https://reviews.llvm.org/D128093>`_)
+* Rebase opcodes are now encoded more compactly.
+ (`D130180 <https://reviews.llvm.org/D130180>`_,
+ `D128798 <https://reviews.llvm.org/D128798>`_)
+* C-strings are now aligned more compactly.
+ (`D121342 <https://reviews.llvm.org/D121342>`_)
+* ``--deduplicate-literals`` (and ``--icf={safe,all}``) now fold the
+ ``__cfstring`` section.
+ (`D130134 <https://reviews.llvm.org/D130134>`_,
+ `D120137 <https://reviews.llvm.org/D120137>`_)
+* ICF now folds the ``__objc_classrefs`` section.
+ (`D121053 <https://reviews.llvm.org/D121053>`_)
+* ICF now folds functions with identical LSDAs.
+ (`D129830 <https://reviews.llvm.org/D129830>`_)
+* STABS entries for folded functions are now omitted.
+ (`D123252 <https://reviews.llvm.org/D123252>`_)
+* ``__objc_imageinfo`` sections are now folded.
+ (`D130125 <https://reviews.llvm.org/D130125>`_)
+* Dylibs with ``LC_DYLD_EXPORTS_TRIE`` can now be read.
+ (`D129430 <https://reviews.llvm.org/D129430>`_)
+* Writing zippered dylibs is now supported.
+ (`D124887 <https://reviews.llvm.org/D124887>`_)
+* C-string literals are now included in the mapfile.
+ (`D118077 <https://reviews.llvm.org/D118077>`_)
+* Symbol names in several more diagnostics are now demangled.
+ (`D130490 <https://reviews.llvm.org/D130490>`_,
+ `D127110 <https://reviews.llvm.org/D127110>`_,
+ `D125732 <https://reviews.llvm.org/D125732>`_)
+* Source information is now included in symbol error messages.
+ (`D128425 <https://reviews.llvm.org/D128425>`_,
+ `D128184 <https://reviews.llvm.org/D128184>`_)
+* Numerous other improvements were made to diagnostic messages.
+ (`D127753 <https://reviews.llvm.org/D127753>`_,
+ `D127696 <https://reviews.llvm.org/D127696>`_,
+ `D127670 <https://reviews.llvm.org/D127670>`_,
+ `D118903 <https://reviews.llvm.org/D118903>`_,
+ `D118798 <https://reviews.llvm.org/D118798>`_)
+* Many performance and memory improvements were made.
+ (`D130000 <https://reviews.llvm.org/D130000>`_,
+ `D128298 <https://reviews.llvm.org/D128298>`_,
+ `D128290 <https://reviews.llvm.org/D128290>`_,
+ `D126800 <https://reviews.llvm.org/D126800>`_,
+ `D126785 <https://reviews.llvm.org/D126785>`_,
+ `D121052 <https://reviews.llvm.org/D121052>`_)
+* Order files and call graph sorting can now be used together.
+ (`D117354 <https://reviews.llvm.org/D117354>`_)
+* Give LTO more precise symbol resolutions, which allows optimizations to be
+ more effective.
+ (`D119506 <https://reviews.llvm.org/D119506>`_,
+ `D119372 <https://reviews.llvm.org/D119372>`_,
+ `D119767 <https://reviews.llvm.org/D119767>`_)
+* Added partial support for linking object files built with DTrace probes.
+ (`D129062 <https://reviews.llvm.org/D129062>`_)
+
+Fixes
+#####
+
+* Programs using Swift linked with the 14.0 SDK but an older deployment target
+ no longer crash at startup when running on older iOS versions. This is because
+ we now correctly support ``$ld$previous`` symbols that contain an explicit
+ symbol name. (`D130725 <https://reviews.llvm.org/D130725>`_)
+* Match ld64's behavior when an archive is specified both via
+ ``LC_LINKER_OPTION`` and via the command line.
+ (`D129556 <https://reviews.llvm.org/D129556>`_)
+* ``-ObjC`` now correctly loads archives with Swift sections.
+ (`D125250 <https://reviews.llvm.org/D125250>`_)
+* ``-lto_object_path`` now accepts a filename (instead of just a directory
+ name.) (`D129705 <https://reviews.llvm.org/D129705>`_)
+* The ``LC_UUID`` hash now includes the output file's name.
+ (`D122843 <https://reviews.llvm.org/D122843>`_)
+* ``-flat_namespace`` now correctly makes all extern symbols in a dylib
+ interposable. (`D119294 <https://reviews.llvm.org/D119294>`_)
+* Fixed compact unwind output when linking on 32-bit hosts.
+ (`D129363 <https://reviews.llvm.org/D129363>`_)
+* Exporting private symbols no longer triggers an assertion.
+ (`D124143 <https://reviews.llvm.org/D124143>`_)
+* MacOS-only ``.tbd`` files are now supported when targeting Catalyst.
+ (`D124336 <https://reviews.llvm.org/D124336>`_)
+* Thunk symbols now have local visibility, avoiding false duplicate symbol
+ errors. (`D122624 <https://reviews.llvm.org/D122624>`_)
+* Fixed handling of relocatable object files within frameworks.
+ (`D114841 <https://reviews.llvm.org/D114841>`_)
+
WebAssembly Improvements
------------------------
diff --git a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
index 4c57be44dc9c..cc354636987c 100644
--- a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
+++ b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp
@@ -599,6 +599,7 @@ const char *Instruction::GetNameForInstructionControlFlowKind(
case eInstructionControlFlowKindFarJump:
return "far jump";
}
+ llvm_unreachable("Fully covered switch above!");
}
void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size,
diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 6ea6d2361eba..102b069ac722 100644
--- a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1440,6 +1440,10 @@ public:
/// to a stack reload.
unsigned getGISelRematGlobalCost() const;
+ /// \returns the lower bound of a trip count to decide on vectorization
+ /// while tail-folding.
+ unsigned getMinTripCountTailFoldingThreshold() const;
+
/// \returns True if the target supports scalable vectors.
bool supportsScalableVectors() const;
@@ -1830,6 +1834,7 @@ public:
ReductionFlags) const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
virtual unsigned getGISelRematGlobalCost() const = 0;
+ virtual unsigned getMinTripCountTailFoldingThreshold() const = 0;
virtual bool enableScalableVectorization() const = 0;
virtual bool supportsScalableVectors() const = 0;
virtual bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
@@ -2453,6 +2458,10 @@ public:
return Impl.getGISelRematGlobalCost();
}
+ unsigned getMinTripCountTailFoldingThreshold() const override {
+ return Impl.getMinTripCountTailFoldingThreshold();
+ }
+
bool supportsScalableVectors() const override {
return Impl.supportsScalableVectors();
}
diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 1a75cb35549e..da1f53aa33cb 100644
--- a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -803,6 +803,8 @@ public:
unsigned getGISelRematGlobalCost() const { return 1; }
+ unsigned getMinTripCountTailFoldingThreshold() const { return 0; }
+
bool supportsScalableVectors() const { return false; }
bool enableScalableVectorization() const { return false; }
diff --git a/contrib/llvm-project/llvm/include/llvm/BinaryFormat/ELF.h b/contrib/llvm-project/llvm/include/llvm/BinaryFormat/ELF.h
index a0bb50db8c54..99e7a9868c29 100644
--- a/contrib/llvm-project/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/contrib/llvm-project/llvm/include/llvm/BinaryFormat/ELF.h
@@ -1597,6 +1597,7 @@ enum {
NT_GNU_BUILD_ID = 3,
NT_GNU_GOLD_VERSION = 4,
NT_GNU_PROPERTY_TYPE_0 = 5,
+ FDO_PACKAGING_METADATA = 0xcafe1a7e,
};
// Android note types.
diff --git a/contrib/llvm-project/llvm/include/llvm/CodeGen/ISDOpcodes.h b/contrib/llvm-project/llvm/include/llvm/CodeGen/ISDOpcodes.h
index e90730140406..b7f6de40266e 100644
--- a/contrib/llvm-project/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/contrib/llvm-project/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -1486,6 +1486,11 @@ inline unsigned getUnorderedFlavor(CondCode Cond) {
/// SetCC operation.
CondCode getSetCCInverse(CondCode Operation, EVT Type);
+inline bool isExtOpcode(unsigned Opcode) {
+ return Opcode == ISD::ANY_EXTEND || Opcode == ISD::ZERO_EXTEND ||
+ Opcode == ISD::SIGN_EXTEND;
+}
+
namespace GlobalISel {
/// Return the operation corresponding to !(X op Y), where 'op' is a valid
/// SetCC operation. The U bit of the condition code has different meanings
diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeView.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
index d4cb6ae7a28e..b7a3e1561a07 100644
--- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
+++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
@@ -330,6 +330,9 @@ enum class DebugSubsectionKind : uint32_t {
MergedAssemblyInput = 0xfc,
CoffSymbolRVA = 0xfd,
+
+ XfgHashType = 0xff,
+ XfgHashVirtual = 0x100,
};
/// Equivalent to CV_ptrtype_e.
diff --git a/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h b/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
index 37fe5a98b093..549a6c096510 100644
--- a/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
+++ b/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h
@@ -66,7 +66,10 @@ private:
static llvm::orc::shared::CWrapperFunctionResult
releaseWrapper(const char *ArgData, size_t ArgSize);
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
std::atomic<int> SharedMemoryCount{0};
+#endif
+
std::mutex Mutex;
ReservationMap Reservations;
AllocationMap Allocations;
diff --git a/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h b/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h
index cfb951178da6..99175d796974 100644
--- a/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h
+++ b/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h
@@ -19,4 +19,7 @@
extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerJITLoaderGDBWrapper(const char *Data, uint64_t Size);
+extern "C" llvm::orc::shared::CWrapperFunctionResult
+llvm_orc_registerJITLoaderGDBAllocAction(const char *Data, size_t Size);
+
#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_JITLOADERGDB_H
diff --git a/contrib/llvm-project/llvm/include/llvm/IR/Type.h b/contrib/llvm-project/llvm/include/llvm/IR/Type.h
index 51263c6b8fcc..a7f22324571b 100644
--- a/contrib/llvm-project/llvm/include/llvm/IR/Type.h
+++ b/contrib/llvm-project/llvm/include/llvm/IR/Type.h
@@ -144,6 +144,11 @@ public:
/// Return true if this is 'bfloat', a 16-bit bfloat type.
bool isBFloatTy() const { return getTypeID() == BFloatTyID; }
+ /// Return true if this is a 16-bit float type.
+ bool is16bitFPTy() const {
+ return getTypeID() == BFloatTyID || getTypeID() == HalfTyID;
+ }
+
/// Return true if this is 'float', a 32-bit IEEE fp type.
bool isFloatTy() const { return getTypeID() == FloatTyID; }
diff --git a/contrib/llvm-project/llvm/include/llvm/Support/ErrorHandling.h b/contrib/llvm-project/llvm/include/llvm/Support/ErrorHandling.h
index 004b3b7868fb..9c8e3448f3a0 100644
--- a/contrib/llvm-project/llvm/include/llvm/Support/ErrorHandling.h
+++ b/contrib/llvm-project/llvm/include/llvm/Support/ErrorHandling.h
@@ -147,7 +147,11 @@ llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr,
#elif LLVM_UNREACHABLE_OPTIMIZE
#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
#else
-#define llvm_unreachable(msg) LLVM_BUILTIN_TRAP, LLVM_BUILTIN_UNREACHABLE
+#define llvm_unreachable(msg) \
+ do { \
+ LLVM_BUILTIN_TRAP; \
+ LLVM_BUILTIN_UNREACHABLE; \
+ } while (false)
#endif
#endif
diff --git a/contrib/llvm-project/llvm/include/llvm/Support/Host.h b/contrib/llvm-project/llvm/include/llvm/Support/Host.h
index f683371ad1d3..369d6745db5a 100644
--- a/contrib/llvm-project/llvm/include/llvm/Support/Host.h
+++ b/contrib/llvm-project/llvm/include/llvm/Support/Host.h
@@ -65,6 +65,7 @@ namespace sys {
StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent);
+ StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent);
StringRef getHostCPUNameForBPF();
/// Helper functions to extract CPU details from CPUID on x86.
diff --git a/contrib/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp b/contrib/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp
index aa4da27be4e5..ae927dae74f7 100644
--- a/contrib/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/contrib/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp
@@ -3120,7 +3120,7 @@ static Constant *ConstantFoldFixedVectorCall(
}
return ConstantVector::get(NCs);
}
- break;
+ return nullptr;
}
case Intrinsic::get_active_lane_mask: {
auto *Op0 = dyn_cast<ConstantInt>(Operands[0]);
@@ -3139,7 +3139,7 @@ static Constant *ConstantFoldFixedVectorCall(
}
return ConstantVector::get(NCs);
}
- break;
+ return nullptr;
}
default:
break;
diff --git a/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp b/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp
index cfa6e3a97626..143f03ccac39 100644
--- a/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1108,6 +1108,10 @@ unsigned TargetTransformInfo::getGISelRematGlobalCost() const {
return TTIImpl->getGISelRematGlobalCost();
}
+unsigned TargetTransformInfo::getMinTripCountTailFoldingThreshold() const {
+ return TTIImpl->getMinTripCountTailFoldingThreshold();
+}
+
bool TargetTransformInfo::supportsScalableVectors() const {
return TTIImpl->supportsScalableVectors();
}
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp
index 96131dc2983e..e5cd46268600 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -750,7 +750,7 @@ void ScheduleDAGMI::moveInstruction(
}
bool ScheduleDAGMI::checkSchedLimit() {
-#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG)
if (NumInstrsScheduled == MISchedCutoff && MISchedCutoff != ~0U) {
CurrentTop = CurrentBottom;
return false;
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 654879115ff9..8d465b9520de 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6353,6 +6353,24 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
}
}
+ if (N0.getOpcode() == ISD::EXTRACT_SUBVECTOR && N0.hasOneUse() && N1C &&
+ ISD::isExtOpcode(N0.getOperand(0).getOpcode())) {
+ SDValue Ext = N0.getOperand(0);
+ EVT ExtVT = Ext->getValueType(0);
+ SDValue Extendee = Ext->getOperand(0);
+
+ unsigned ScalarWidth = Extendee.getValueType().getScalarSizeInBits();
+ if (N1C->getAPIntValue().isMask(ScalarWidth)) {
+ // (and (extract_subvector (zext|anyext|sext v) _) iN_mask)
+ // => (extract_subvector (iN_zeroext v))
+ SDValue ZeroExtExtendee =
+ DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), ExtVT, Extendee);
+
+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(N), VT, ZeroExtExtendee,
+ N0.getOperand(1));
+ }
+ }
+
// fold (and (masked_gather x)) -> (zext_masked_gather x)
if (auto *GN0 = dyn_cast<MaskedGatherSDNode>(N0)) {
EVT MemVT = GN0->getMemoryVT();
@@ -7301,12 +7319,14 @@ static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
unsigned MaskLoBits = 0;
if (IsRotate && isPowerOf2_64(EltSize)) {
unsigned Bits = Log2_64(EltSize);
- APInt DemandedBits =
- APInt::getLowBitsSet(Neg.getScalarValueSizeInBits(), Bits);
- if (SDValue Inner =
- TLI.SimplifyMultipleUseDemandedBits(Neg, DemandedBits, DAG)) {
- Neg = Inner;
- MaskLoBits = Bits;
+ unsigned NegBits = Neg.getScalarValueSizeInBits();
+ if (NegBits >= Bits) {
+ APInt DemandedBits = APInt::getLowBitsSet(NegBits, Bits);
+ if (SDValue Inner =
+ TLI.SimplifyMultipleUseDemandedBits(Neg, DemandedBits, DAG)) {
+ Neg = Inner;
+ MaskLoBits = Bits;
+ }
}
}
@@ -7322,11 +7342,13 @@ static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
// affect Mask's demanded bits, just replace Pos with Pos'. These operations
// are redundant for the purpose of the equality.
if (MaskLoBits) {
- APInt DemandedBits =
- APInt::getLowBitsSet(Pos.getScalarValueSizeInBits(), MaskLoBits);
- if (SDValue Inner =
- TLI.SimplifyMultipleUseDemandedBits(Pos, DemandedBits, DAG)) {
- Pos = Inner;
+ unsigned PosBits = Pos.getScalarValueSizeInBits();
+ if (PosBits >= MaskLoBits) {
+ APInt DemandedBits = APInt::getLowBitsSet(PosBits, MaskLoBits);
+ if (SDValue Inner =
+ TLI.SimplifyMultipleUseDemandedBits(Pos, DemandedBits, DAG)) {
+ Pos = Inner;
+ }
}
}
@@ -22707,6 +22729,7 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
SDLoc DL(N);
EVT IntVT = VT.changeVectorElementTypeToInteger();
EVT IntSVT = VT.getVectorElementType().changeTypeToInteger();
+ IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT);
SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT);
SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT);
SmallVector<SDValue, 16> AndMask(NumElts, DAG.getUNDEF(IntSVT));
diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
index a167d45982a9..9c05d585831a 100644
--- a/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
+++ b/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
@@ -66,6 +66,8 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
RETURN_CASE(DebugSubsectionKind, MergedAssemblyInput,
"merged assembly input");
RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA, "coff symbol rva");
+ RETURN_CASE(DebugSubsectionKind, XfgHashType, "xfg hash type");
+ RETURN_CASE(DebugSubsectionKind, XfgHashVirtual, "xfg hash virtual");
}
} else {
switch (Kind) {
@@ -89,6 +91,11 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
"DEBUG_S_MERGED_ASSEMBLYINPUT");
RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA,
"DEBUG_S_COFF_SYMBOL_RVA");
+ RETURN_CASE(DebugSubsectionKind, XfgHashType,
+ "DEBUG_S_XFGHASH_TYPE");
+ RETURN_CASE(DebugSubsectionKind, XfgHashVirtual,
+ "DEBUG_S_XFGHASH_VIRTUAL");
+
}
}
return formatUnknownEnum(Kind);
diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
index 3f75012f5cf9..4afcf95e9e8e 100644
--- a/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
+++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
@@ -24,6 +24,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/ValueHandle.h"
+#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolSize.h"
#include "llvm/Support/Debug.h"
diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
index ca3f64b8a409..ee92e5191b50 100644
--- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
+++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
@@ -11,7 +11,7 @@
#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
#include "llvm/Support/WindowsError.h"
-#if defined(LLVM_ON_UNIX)
+#if defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
@@ -173,20 +173,30 @@ InProcessMemoryMapper::~InProcessMemoryMapper() {
SharedMemoryMapper::SharedMemoryMapper(ExecutorProcessControl &EPC,
SymbolAddrs SAs, size_t PageSize)
- : EPC(EPC), SAs(SAs), PageSize(PageSize) {}
+ : EPC(EPC), SAs(SAs), PageSize(PageSize) {
+#if (!defined(LLVM_ON_UNIX) || defined(__ANDROID__)) && !defined(_WIN32)
+ llvm_unreachable("SharedMemoryMapper is not supported on this platform yet");
+#endif
+}
Expected<std::unique_ptr<SharedMemoryMapper>>
SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) {
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
auto PageSize = sys::Process::getPageSize();
if (!PageSize)
return PageSize.takeError();
return std::make_unique<SharedMemoryMapper>(EPC, SAs, *PageSize);
+#else
+ return make_error<StringError>(
+ "SharedMemoryMapper is not supported on this platform yet",
+ inconvertibleErrorCode());
+#endif
}
void SharedMemoryMapper::reserve(size_t NumBytes,
OnReservedFunction OnReserved) {
-#if defined(LLVM_ON_UNIX) || defined(_WIN32)
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
EPC.callSPSWrapperAsync<
rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>(
@@ -334,7 +344,7 @@ void SharedMemoryMapper::deinitialize(
void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> Bases,
OnReleasedFunction OnReleased) {
-#if defined(LLVM_ON_UNIX) || defined(_WIN32)
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
Error Err = Error::success();
{
@@ -351,8 +361,8 @@ void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> Bases,
#elif defined(_WIN32)
if (!UnmapViewOfFile(Reservations[Base].LocalAddr))
- joinErrors(std::move(Err),
- errorCodeToError(mapWindowsError(GetLastError())));
+ Err = joinErrors(std::move(Err),
+ errorCodeToError(mapWindowsError(GetLastError())));
#endif
diff --git a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
index 6c9f099061ae..caa191cea899 100644
--- a/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
+++ b/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
@@ -52,7 +52,7 @@ namespace rt_bootstrap {
Expected<std::pair<ExecutorAddr, std::string>>
ExecutorSharedMemoryMapperService::reserve(uint64_t Size) {
-#if defined(LLVM_ON_UNIX) || defined(_WIN32)
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
#if defined(LLVM_ON_UNIX)
@@ -125,7 +125,7 @@ ExecutorSharedMemoryMapperService::reserve(uint64_t Size) {
Expected<ExecutorAddr> ExecutorSharedMemoryMapperService::initialize(
ExecutorAddr Reservation, tpctypes::SharedMemoryFinalizeRequest &FR) {
-#if defined(LLVM_ON_UNIX) || defined(_WIN32)
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
ExecutorAddr MinAddr(~0ULL);
@@ -207,7 +207,7 @@ Error ExecutorSharedMemoryMapperService::deinitialize(
Error ExecutorSharedMemoryMapperService::release(
const std::vector<ExecutorAddr> &Bases) {
-#if defined(LLVM_ON_UNIX) || defined(_WIN32)
+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
Error Err = Error::success();
for (auto Base : Bases) {
@@ -241,6 +241,7 @@ Error ExecutorSharedMemoryMapperService::release(
errno, std::generic_category())));
#elif defined(_WIN32)
+ (void)Size;
if (!UnmapViewOfFile(Base.toPtr<void *>()))
Err = joinErrors(std::move(Err),
diff --git a/contrib/llvm-project/llvm/lib/Support/Host.cpp b/contrib/llvm-project/llvm/lib/Support/Host.cpp
index 08e3a27e0173..c97f273b0739 100644
--- a/contrib/llvm-project/llvm/lib/Support/Host.cpp
+++ b/contrib/llvm-project/llvm/lib/Support/Host.cpp
@@ -47,6 +47,9 @@
#ifdef _AIX
#include <sys/systemcfg.h>
#endif
+#if defined(__sun__) && defined(__svr4__)
+#include <kstat.h>
+#endif
#define DEBUG_TYPE "host-detection"
@@ -1413,6 +1416,111 @@ StringRef sys::getHostCPUName() {
#endif
#endif
}
+#elif defined(__sparc__)
+#if defined(__linux__)
+StringRef sys::detail::getHostCPUNameForSPARC(StringRef ProcCpuinfoContent) {
+ SmallVector<StringRef> Lines;
+ ProcCpuinfoContent.split(Lines, "\n");
+
+ // Look for cpu line to determine cpu name
+ StringRef Cpu;
+ for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
+ if (Lines[I].startswith("cpu")) {
+ Cpu = Lines[I].substr(5).ltrim("\t :");
+ break;
+ }
+ }
+
+ return StringSwitch<const char *>(Cpu)
+ .StartsWith("SuperSparc", "supersparc")
+ .StartsWith("HyperSparc", "hypersparc")
+ .StartsWith("SpitFire", "ultrasparc")
+ .StartsWith("BlackBird", "ultrasparc")
+ .StartsWith("Sabre", " ultrasparc")
+ .StartsWith("Hummingbird", "ultrasparc")
+ .StartsWith("Cheetah", "ultrasparc3")
+ .StartsWith("Jalapeno", "ultrasparc3")
+ .StartsWith("Jaguar", "ultrasparc3")
+ .StartsWith("Panther", "ultrasparc3")
+ .StartsWith("Serrano", "ultrasparc3")
+ .StartsWith("UltraSparc T1", "niagara")
+ .StartsWith("UltraSparc T2", "niagara2")
+ .StartsWith("UltraSparc T3", "niagara3")
+ .StartsWith("UltraSparc T4", "niagara4")
+ .StartsWith("UltraSparc T5", "niagara4")
+ .StartsWith("LEON", "leon3")
+ // niagara7/m8 not supported by LLVM yet.
+ .StartsWith("SPARC-M7", "niagara4" /* "niagara7" */)
+ .StartsWith("SPARC-S7", "niagara4" /* "niagara7" */)
+ .StartsWith("SPARC-M8", "niagara4" /* "m8" */)
+ .Default("generic");
+}
+#endif
+
+StringRef sys::getHostCPUName() {
+#if defined(__linux__)
+ std::unique_ptr<llvm::MemoryBuffer> P = getProcCpuinfoContent();
+ StringRef Content = P ? P->getBuffer() : "";
+ return detail::getHostCPUNameForSPARC(Content);
+#elif defined(__sun__) && defined(__svr4__)
+ char *buf = NULL;
+ kstat_ctl_t *kc;
+ kstat_t *ksp;
+ kstat_named_t *brand = NULL;
+
+ kc = kstat_open();
+ if (kc != NULL) {
+ ksp = kstat_lookup(kc, const_cast<char *>("cpu_info"), -1, NULL);
+ if (ksp != NULL && kstat_read(kc, ksp, NULL) != -1 &&
+ ksp->ks_type == KSTAT_TYPE_NAMED)
+ brand =
+ (kstat_named_t *)kstat_data_lookup(ksp, const_cast<char *>("brand"));
+ if (brand != NULL && brand->data_type == KSTAT_DATA_STRING)
+ buf = KSTAT_NAMED_STR_PTR(brand);
+ }
+ kstat_close(kc);
+
+ return StringSwitch<const char *>(buf)
+ .Case("TMS390S10", "supersparc") // Texas Instruments microSPARC I
+ .Case("TMS390Z50", "supersparc") // Texas Instruments SuperSPARC I
+ .Case("TMS390Z55",
+ "supersparc") // Texas Instruments SuperSPARC I with SuperCache
+ .Case("MB86904", "supersparc") // Fujitsu microSPARC II
+ .Case("MB86907", "supersparc") // Fujitsu TurboSPARC
+ .Case("RT623", "hypersparc") // Ross hyperSPARC
+ .Case("RT625", "hypersparc")
+ .Case("RT626", "hypersparc")
+ .Case("UltraSPARC-I", "ultrasparc")
+ .Case("UltraSPARC-II", "ultrasparc")
+ .Case("UltraSPARC-IIe", "ultrasparc")
+ .Case("UltraSPARC-IIi", "ultrasparc")
+ .Case("SPARC64-III", "ultrasparc")
+ .Case("SPARC64-IV", "ultrasparc")
+ .Case("UltraSPARC-III", "ultrasparc3")
+ .Case("UltraSPARC-III+", "ultrasparc3")
+ .Case("UltraSPARC-IIIi", "ultrasparc3")
+ .Case("UltraSPARC-IIIi+", "ultrasparc3")
+ .Case("UltraSPARC-IV", "ultrasparc3")
+ .Case("UltraSPARC-IV+", "ultrasparc3")
+ .Case("SPARC64-V", "ultrasparc3")
+ .Case("SPARC64-VI", "ultrasparc3")
+ .Case("SPARC64-VII", "ultrasparc3")
+ .Case("UltraSPARC-T1", "niagara")
+ .Case("UltraSPARC-T2", "niagara2")
+ .Case("UltraSPARC-T2", "niagara2")
+ .Case("UltraSPARC-T2+", "niagara2")
+ .Case("SPARC-T3", "niagara3")
+ .Case("SPARC-T4", "niagara4")
+ .Case("SPARC-T5", "niagara4")
+ // niagara7/m8 not supported by LLVM yet.
+ .Case("SPARC-M7", "niagara4" /* "niagara7" */)
+ .Case("SPARC-S7", "niagara4" /* "niagara7" */)
+ .Case("SPARC-M8", "niagara4" /* "m8" */)
+ .Default("generic");
+#else
+ return "generic";
+#endif
+}
#else
StringRef sys::getHostCPUName() { return "generic"; }
namespace llvm {
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 72f0fc94940c..c28216048d7c 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -886,7 +886,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
setTargetDAGCombine({ISD::ANY_EXTEND, ISD::ZERO_EXTEND, ISD::SIGN_EXTEND,
ISD::VECTOR_SPLICE, ISD::SIGN_EXTEND_INREG,
ISD::CONCAT_VECTORS, ISD::EXTRACT_SUBVECTOR,
- ISD::INSERT_SUBVECTOR, ISD::STORE});
+ ISD::INSERT_SUBVECTOR, ISD::STORE, ISD::BUILD_VECTOR});
if (Subtarget->supportsAddressTopByteIgnored())
setTargetDAGCombine(ISD::LOAD);
@@ -15988,6 +15988,49 @@ static SDValue performVectorAddSubExtCombine(SDNode *N, SelectionDAG &DAG) {
return SDValue();
}
+static SDValue performBuildVectorCombine(SDNode *N,
+ TargetLowering::DAGCombinerInfo &DCI,
+ SelectionDAG &DAG) {
+ SDLoc DL(N);
+
+ // A build vector of two extracted elements is equivalent to an
+ // extract subvector where the inner vector is any-extended to the
+ // extract_vector_elt VT.
+ // (build_vector (extract_elt_iXX_to_i32 vec Idx+0)
+ // (extract_elt_iXX_to_i32 vec Idx+1))
+ // => (extract_subvector (anyext_iXX_to_i32 vec) Idx)
+
+ // For now, only consider the v2i32 case, which arises as a result of
+ // legalization.
+ if (N->getValueType(0) != MVT::v2i32)
+ return SDValue();
+
+ SDValue Elt0 = N->getOperand(0), Elt1 = N->getOperand(1);
+ // Reminder, EXTRACT_VECTOR_ELT has the effect of any-extending to its VT.
+ if (Elt0->getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
+ Elt1->getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
+ // Constant index.
+ isa<ConstantSDNode>(Elt0->getOperand(1)) &&
+ isa<ConstantSDNode>(Elt1->getOperand(1)) &&
+ // Both EXTRACT_VECTOR_ELT from same vector...
+ Elt0->getOperand(0) == Elt1->getOperand(0) &&
+ // ... and contiguous. First element's index +1 == second element's index.
+ Elt0->getConstantOperandVal(1) + 1 == Elt1->getConstantOperandVal(1)) {
+ SDValue VecToExtend = Elt0->getOperand(0);
+ EVT ExtVT = VecToExtend.getValueType().changeVectorElementType(MVT::i32);
+ if (!DAG.getTargetLoweringInfo().isTypeLegal(ExtVT))
+ return SDValue();
+
+ SDValue SubvectorIdx = DAG.getVectorIdxConstant(Elt0->getConstantOperandVal(1), DL);
+
+ SDValue Ext = DAG.getNode(ISD::ANY_EXTEND, DL, ExtVT, VecToExtend);
+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, MVT::v2i32, Ext,
+ SubvectorIdx);
+ }
+
+ return SDValue();
+}
+
static SDValue performAddSubCombine(SDNode *N,
TargetLowering::DAGCombinerInfo &DCI,
SelectionDAG &DAG) {
@@ -19457,6 +19500,8 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode *N,
case ISD::ADD:
case ISD::SUB:
return performAddSubCombine(N, DCI, DAG);
+ case ISD::BUILD_VECTOR:
+ return performBuildVectorCombine(N, DCI, DAG);
case AArch64ISD::ANDS:
return performFlagSettingCombine(N, DCI, ISD::AND);
case AArch64ISD::ADC:
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index 2231f8705998..0c5eadeffcdb 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -334,6 +334,10 @@ public:
return 2;
}
+ unsigned getMinTripCountTailFoldingThreshold() const {
+ return ST->hasSVE() ? 5 : 0;
+ }
+
PredicationStyle emitGetActiveLaneMask() const {
if (ST->hasSVE())
return PredicationStyle::DataAndControlFlow;
diff --git a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index d3617b87a851..380d3621e745 100644
--- a/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -662,8 +662,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
getActionDefinitionsBuilder(G_CTTZ_ZERO_UNDEF).lower();
- // TODO: Handle vector types.
getActionDefinitionsBuilder(G_CTTZ)
+ .lowerIf(isVector(0))
.clampScalar(0, s32, s64)
.scalarSameSizeAs(1, 0)
.customFor({s32, s64});
diff --git a/contrib/llvm-project/llvm/lib/Target/ARM/ARM.td b/contrib/llvm-project/llvm/lib/Target/ARM/ARM.td
index 73970b9c74c5..71388bc4efa4 100644
--- a/contrib/llvm-project/llvm/lib/Target/ARM/ARM.td
+++ b/contrib/llvm-project/llvm/lib/Target/ARM/ARM.td
@@ -556,6 +556,15 @@ def FeatureAAPCSFrameChainLeaf : SubtargetFeature<"aapcs-frame-chain-leaf",
"for leaf functions",
[FeatureAAPCSFrameChain]>;
+// Assume that lock-free 32-bit atomics are available, even if the target
+// and operating system combination would not usually provide them. The user
+// is responsible for providing any necessary __sync implementations. Code
+// built with this feature is not ABI-compatible with code built without this
+// feature, if atomic variables are exposed across the ABI boundary.
+def FeatureAtomics32 : SubtargetFeature<
+ "atomics-32", "HasForced32BitAtomics", "true",
+ "Assume that lock-free 32-bit atomics are available">;
+
//===----------------------------------------------------------------------===//
// ARM architecture class
//
diff --git a/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 743cca9ff71f..4c24d7020932 100644
--- a/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -1370,7 +1370,8 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
// instructions. (ARMv6 doesn't have dmb, but it has an equivalent
// encoding; see ARMISD::MEMBARRIER_MCR.)
setMaxAtomicSizeInBitsSupported(64);
- } else if (Subtarget->isMClass() && Subtarget->hasV8MBaselineOps()) {
+ } else if ((Subtarget->isMClass() && Subtarget->hasV8MBaselineOps()) ||
+ Subtarget->hasForced32BitAtomics()) {
// Cortex-M (besides Cortex-M0) have 32-bit atomics.
setMaxAtomicSizeInBitsSupported(32);
} else {
diff --git a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCFastISel.cpp
index 5c7f0619161c..7b1b9456080e 100644
--- a/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCFastISel.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCFastISel.cpp
@@ -831,7 +831,7 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2,
// FIXME: Operands are not in canonical order at -O0, so an immediate
// operand in position 1 is a lost opportunity for now. We are
// similar to ARM in this regard.
- long Imm = 0;
+ int64_t Imm = 0;
bool UseImm = false;
const bool HasSPE = Subtarget->hasSPE();
@@ -841,7 +841,8 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2,
if (SrcVT == MVT::i64 || SrcVT == MVT::i32 || SrcVT == MVT::i16 ||
SrcVT == MVT::i8 || SrcVT == MVT::i1) {
const APInt &CIVal = ConstInt->getValue();
- Imm = (IsZExt) ? (long)CIVal.getZExtValue() : (long)CIVal.getSExtValue();
+ Imm = (IsZExt) ? (int64_t)CIVal.getZExtValue() :
+ (int64_t)CIVal.getSExtValue();
if ((IsZExt && isUInt<16>(Imm)) || (!IsZExt && isInt<16>(Imm)))
UseImm = true;
}
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index baa19e81e436..d0ca325e9c14 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -8199,7 +8199,13 @@ static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG,
if (!isIntEqualitySetCC(Cond))
return SDValue();
- const APInt &C1 = cast<ConstantSDNode>(N1)->getAPIntValue();
+ // Don't do this if the sign bit is provably zero, it will be turned back into
+ // an AND.
+ APInt SignMask = APInt::getOneBitSet(64, 31);
+ if (DAG.MaskedValueIsZero(N0.getOperand(0), SignMask))
+ return SDValue();
+
+ const APInt &C1 = N1C->getAPIntValue();
SDLoc dl(N);
// If the constant is larger than 2^32 - 1 it is impossible for both sides
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index fc0a983f6542..5d9bd2f67558 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -1022,16 +1022,10 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info, const MachineInstr &M
return;
}
- // Two cases involving an AVL resulting from a previous vsetvli.
- // 1) If the AVL is the result of a previous vsetvli which has the
- // same AVL and VLMAX as our current state, we can reuse the AVL
- // from the current state for the new one. This allows us to
- // generate 'vsetvli x0, x0, vtype" or possible skip the transition
- // entirely.
- // 2) If AVL is defined by a vsetvli with the same VLMAX, we can
- // replace the AVL operand with the AVL of the defining vsetvli.
- // We avoid general register AVLs to avoid extending live ranges
- // without being sure we can kill the original source reg entirely.
+ // If AVL is defined by a vsetvli with the same VLMAX, we can
+ // replace the AVL operand with the AVL of the defining vsetvli.
+ // We avoid general register AVLs to avoid extending live ranges
+ // without being sure we can kill the original source reg entirely.
if (!Info.hasAVLReg() || !Info.getAVLReg().isVirtual())
return;
MachineInstr *DefMI = MRI->getVRegDef(Info.getAVLReg());
@@ -1039,17 +1033,6 @@ void RISCVInsertVSETVLI::transferBefore(VSETVLIInfo &Info, const MachineInstr &M
return;
VSETVLIInfo DefInfo = getInfoForVSETVLI(*DefMI);
- // case 1
- if (PrevInfo.isValid() && !PrevInfo.isUnknown() &&
- DefInfo.hasSameAVL(PrevInfo) &&
- DefInfo.hasSameVLMAX(PrevInfo)) {
- if (PrevInfo.hasAVLImm())
- Info.setAVLImm(PrevInfo.getAVLImm());
- else
- Info.setAVLReg(PrevInfo.getAVLReg());
- return;
- }
- // case 2
if (DefInfo.hasSameVLMAX(Info) &&
(DefInfo.hasAVLImm() || DefInfo.getAVLReg() == RISCV::X0)) {
if (DefInfo.hasAVLImm())
diff --git a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
index b080ab7e138c..7d0fc4e8a8c6 100644
--- a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -419,7 +419,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
setTruncStoreAction(VT, MVT::bf16, Expand);
setOperationAction(ISD::BF16_TO_FP, VT, Expand);
- setOperationAction(ISD::FP_TO_BF16, VT, Expand);
+ setOperationAction(ISD::FP_TO_BF16, VT, Custom);
}
setOperationAction(ISD::PARITY, MVT::i8, Custom);
@@ -2494,6 +2494,10 @@ MVT X86TargetLowering::getRegisterTypeForCallingConv(LLVMContext &Context,
!Subtarget.hasX87())
return MVT::i32;
+ if (VT.isVector() && VT.getVectorElementType() == MVT::bf16)
+ return getRegisterTypeForCallingConv(Context, CC,
+ VT.changeVectorElementTypeToInteger());
+
return TargetLowering::getRegisterTypeForCallingConv(Context, CC, VT);
}
@@ -2525,6 +2529,10 @@ unsigned X86TargetLowering::getNumRegistersForCallingConv(LLVMContext &Context,
return 3;
}
+ if (VT.isVector() && VT.getVectorElementType() == MVT::bf16)
+ return getNumRegistersForCallingConv(Context, CC,
+ VT.changeVectorElementTypeToInteger());
+
return TargetLowering::getNumRegistersForCallingConv(Context, CC, VT);
}
@@ -2733,6 +2741,40 @@ unsigned X86TargetLowering::getJumpTableEncoding() const {
return TargetLowering::getJumpTableEncoding();
}
+bool X86TargetLowering::splitValueIntoRegisterParts(
+ SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
+ unsigned NumParts, MVT PartVT, Optional<CallingConv::ID> CC) const {
+ bool IsABIRegCopy = CC.has_value();
+ EVT ValueVT = Val.getValueType();
+ if (IsABIRegCopy && ValueVT == MVT::bf16 && PartVT == MVT::f32) {
+ unsigned ValueBits = ValueVT.getSizeInBits();
+ unsigned PartBits = PartVT.getSizeInBits();
+ Val = DAG.getNode(ISD::BITCAST, DL, MVT::getIntegerVT(ValueBits), Val);
+ Val = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::getIntegerVT(PartBits), Val);
+ Val = DAG.getNode(ISD::BITCAST, DL, PartVT, Val);
+ Parts[0] = Val;
+ return true;
+ }
+ return false;
+}
+
+SDValue X86TargetLowering::joinRegisterPartsIntoValue(
+ SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts,
+ MVT PartVT, EVT ValueVT, Optional<CallingConv::ID> CC) const {
+ bool IsABIRegCopy = CC.has_value();
+ if (IsABIRegCopy && ValueVT == MVT::bf16 && PartVT == MVT::f32) {
+ unsigned ValueBits = ValueVT.getSizeInBits();
+ unsigned PartBits = PartVT.getSizeInBits();
+ SDValue Val = Parts[0];
+
+ Val = DAG.getNode(ISD::BITCAST, DL, MVT::getIntegerVT(PartBits), Val);
+ Val = DAG.getNode(ISD::TRUNCATE, DL, MVT::getIntegerVT(ValueBits), Val);
+ Val = DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
+ return Val;
+ }
+ return SDValue();
+}
+
bool X86TargetLowering::useSoftFloat() const {
return Subtarget.useSoftFloat();
}
@@ -19304,44 +19346,6 @@ static bool canonicalizeShuffleMaskWithCommute(ArrayRef<int> Mask) {
return false;
}
-static bool canCombineAsMaskOperation(SDValue V1, SDValue V2,
- const X86Subtarget &Subtarget) {
- if (!Subtarget.hasAVX512())
- return false;
-
- MVT VT = V1.getSimpleValueType().getScalarType();
- if ((VT == MVT::i16 || VT == MVT::i8) && !Subtarget.hasBWI())
- return false;
-
- // i8 is better to be widen to i16, because there is PBLENDW for vXi16
- // when the vector bit size is 128 or 256.
- if (VT == MVT::i8 && V1.getSimpleValueType().getSizeInBits() < 512)
- return false;
-
- auto HasMaskOperation = [&](SDValue V) {
- // TODO: Currently we only check limited opcode. We probably extend
- // it to all binary operation by checking TLI.isBinOp().
- switch (V->getOpcode()) {
- default:
- return false;
- case ISD::ADD:
- case ISD::SUB:
- case ISD::AND:
- case ISD::XOR:
- break;
- }
- if (!V->hasOneUse())
- return false;
-
- return true;
- };
-
- if (HasMaskOperation(V1) || HasMaskOperation(V2))
- return true;
-
- return false;
-}
-
// Forward declaration.
static SDValue canonicalizeShuffleMaskWithHorizOp(
MutableArrayRef<SDValue> Ops, MutableArrayRef<int> Mask,
@@ -19417,7 +19421,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, const X86Subtarget &Subtarget,
// integers to handle flipping the low and high halves of AVX 256-bit vectors.
SmallVector<int, 16> WidenedMask;
if (VT.getScalarSizeInBits() < 64 && !Is1BitVector &&
- !canCombineAsMaskOperation(V1, V2, Subtarget) &&
canWidenShuffleElements(OrigMask, Zeroable, V2IsZero, WidenedMask)) {
// Shuffle mask widening should not interfere with a broadcast opportunity
// by obfuscating the operands with bitcasts.
@@ -23058,6 +23061,18 @@ static SDValue LowerFP_TO_FP16(SDValue Op, SelectionDAG &DAG) {
return Res;
}
+SDValue X86TargetLowering::LowerFP_TO_BF16(SDValue Op,
+ SelectionDAG &DAG) const {
+ SDLoc DL(Op);
+ MakeLibCallOptions CallOptions;
+ RTLIB::Libcall LC =
+ RTLIB::getFPROUND(Op.getOperand(0).getValueType(), MVT::bf16);
+ SDValue Res =
+ makeLibCall(DAG, LC, MVT::f32, Op.getOperand(0), CallOptions, DL).first;
+ return DAG.getNode(ISD::TRUNCATE, DL, MVT::i16,
+ DAG.getBitcast(MVT::i32, Res));
+}
+
/// Depending on uarch and/or optimizing for size, we might prefer to use a
/// vector operation in place of the typical scalar operation.
static SDValue lowerAddSubToHorizontalOp(SDValue Op, SelectionDAG &DAG,
@@ -32250,6 +32265,7 @@ SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
case ISD::STRICT_FP16_TO_FP: return LowerFP16_TO_FP(Op, DAG);
case ISD::FP_TO_FP16:
case ISD::STRICT_FP_TO_FP16: return LowerFP_TO_FP16(Op, DAG);
+ case ISD::FP_TO_BF16: return LowerFP_TO_BF16(Op, DAG);
case ISD::LOAD: return LowerLoad(Op, Subtarget, DAG);
case ISD::STORE: return LowerStore(Op, Subtarget, DAG);
case ISD::FADD:
diff --git a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.h b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.h
index 85e5d0ba4c34..18fb2dbe8d71 100644
--- a/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.h
+++ b/contrib/llvm-project/llvm/lib/Target/X86/X86ISelLowering.h
@@ -1598,6 +1598,7 @@ namespace llvm {
SDValue lowerFaddFsub(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
+ SDValue LowerFP_TO_BF16(SDValue Op, SelectionDAG &DAG) const;
SDValue
LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
@@ -1621,6 +1622,17 @@ namespace llvm {
MachineBasicBlock *Entry,
const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
+ bool
+ splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val,
+ SDValue *Parts, unsigned NumParts, MVT PartVT,
+ Optional<CallingConv::ID> CC) const override;
+
+ SDValue
+ joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL,
+ const SDValue *Parts, unsigned NumParts,
+ MVT PartVT, EVT ValueVT,
+ Optional<CallingConv::ID> CC) const override;
+
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
diff --git a/contrib/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/contrib/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 83252fec3ea8..59d5d88a126c 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -9899,6 +9899,15 @@ struct AAPotentialValuesImpl : AAPotentialValues {
struct ItemInfo {
AA::ValueAndContext I;
AA::ValueScope S;
+
+ bool operator==(const ItemInfo &II) const {
+ return II.I == I && II.S == S;
+ };
+ bool operator<(const ItemInfo &II) const {
+ if (I == II.I)
+ return S < II.S;
+ return I < II.I;
+ };
};
bool recurseForValue(Attributor &A, const IRPosition &IRP, AA::ValueScope S) {
@@ -10271,7 +10280,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
SmallMapVector<const Function *, LivenessInfo, 4> LivenessAAs;
Value *InitialV = &getAssociatedValue();
- SmallSet<AA::ValueAndContext, 16> Visited;
+ SmallSet<ItemInfo, 16> Visited;
SmallVector<ItemInfo, 16> Worklist;
Worklist.push_back({{*InitialV, getCtxI()}, AA::AnyScope});
@@ -10285,7 +10294,7 @@ struct AAPotentialValuesFloating : AAPotentialValuesImpl {
// Check if we should process the current value. To prevent endless
// recursion keep a record of the values we followed!
- if (!Visited.insert(II.I).second)
+ if (!Visited.insert(II).second)
continue;
// Make sure we limit the compile time for complex expressions.
diff --git a/contrib/llvm-project/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/contrib/llvm-project/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index ef2384faa273..0b42fc151991 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -499,6 +499,18 @@ struct OMPInformationCache : public InformationCache {
}
#include "llvm/Frontend/OpenMP/OMPKinds.def"
+ // Remove the `noinline` attribute from `__kmpc`, `_OMP::` and `omp_`
+ // functions, except if `optnone` is present.
+ if (isOpenMPDevice(M)) {
+ for (Function &F : M) {
+ for (StringRef Prefix : {"__kmpc", "_ZN4_OMP", "omp_"})
+ if (F.hasFnAttribute(Attribute::NoInline) &&
+ F.getName().startswith(Prefix) &&
+ !F.hasFnAttribute(Attribute::OptimizeNone))
+ F.removeFnAttr(Attribute::NoInline);
+ }
+ }
+
// TODO: We should attach the attributes defined in OMPKinds.def.
}
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
index 926427450682..c9ff94dc9744 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp
@@ -57,11 +57,15 @@ static bool shouldConvertToRelLookupTable(Module &M, GlobalVariable &GV) {
return false;
ConstantArray *Array = dyn_cast<ConstantArray>(GV.getInitializer());
- // If values are not pointers, do not generate a relative lookup table.
- if (!Array || !Array->getType()->getElementType()->isPointerTy())
+ if (!Array)
return false;
+ // If values are not 64-bit pointers, do not generate a relative lookup table.
const DataLayout &DL = M.getDataLayout();
+ Type *ElemType = Array->getType()->getElementType();
+ if (!ElemType->isPointerTy() || DL.getPointerTypeSizeInBits(ElemType) != 64)
+ return false;
+
for (const Use &Op : Array->operands()) {
Constant *ConstOp = cast<Constant>(&Op);
GlobalValue *GVOp;
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 238b074089aa..91bc7dbad1d0 100644
--- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10109,8 +10109,19 @@ bool LoopVectorizePass::processLoop(Loop *L) {
if (Hints.getForce() == LoopVectorizeHints::FK_Enabled)
LLVM_DEBUG(dbgs() << " But vectorizing was explicitly forced.\n");
else {
- LLVM_DEBUG(dbgs() << "\n");
- SEL = CM_ScalarEpilogueNotAllowedLowTripLoop;
+ if (*ExpectedTC > TTI->getMinTripCountTailFoldingThreshold()) {
+ LLVM_DEBUG(dbgs() << "\n");
+ SEL = CM_ScalarEpilogueNotAllowedLowTripLoop;
+ } else {
+ LLVM_DEBUG(dbgs() << " But the target considers the trip count too "
+ "small to consider vectorizing.\n");
+ reportVectorizationFailure(
+ "The trip count is below the minial threshold value.",
+ "loop trip count is too low, avoiding vectorization",
+ "LowTripCount", ORE, L);
+ Hints.emitRemarkWithHints();
+ return false;
+ }
}
}
diff --git a/contrib/llvm-project/llvm/tools/lli/lli.cpp b/contrib/llvm-project/llvm/tools/lli/lli.cpp
index 42bea1a6487f..3fd2a618bf1a 100644
--- a/contrib/llvm-project/llvm/tools/lli/lli.cpp
+++ b/contrib/llvm-project/llvm/tools/lli/lli.cpp
@@ -291,7 +291,8 @@ namespace {
LLVM_ATTRIBUTE_USED void linkComponents() {
errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper
<< (void *)&llvm_orc_deregisterEHFrameSectionWrapper
- << (void *)&llvm_orc_registerJITLoaderGDBWrapper;
+ << (void *)&llvm_orc_registerJITLoaderGDBWrapper
+ << (void *)&llvm_orc_registerJITLoaderGDBAllocAction;
}
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp b/contrib/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
index 1d4a8e9cd398..4ffc5cf337a2 100644
--- a/contrib/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/contrib/llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -68,9 +68,9 @@ static StringRef ToolName;
static StringRef Stem;
static void printRanLibHelp(StringRef ToolName) {
- outs() << "OVERVIEW: LLVM Ranlib\n\n"
- << "This program generates an index to speed access to archives\n\n"
- << "USAGE: " + ToolName + " <archive-file>\n\n"
+ outs() << "OVERVIEW: LLVM ranlib\n\n"
+ << "Generate an index for archives\n\n"
+ << "USAGE: " + ToolName + " archive...\n\n"
<< "OPTIONS:\n"
<< " -h --help - Display available options\n"
<< " -v --version - Display the version of this program\n"
@@ -1125,8 +1125,7 @@ static void performOperation(ArchiveOperation Operation,
llvm_unreachable("Unknown operation.");
}
-static int performOperation(ArchiveOperation Operation,
- std::vector<NewArchiveMember> *NewMembers) {
+static int performOperation(ArchiveOperation Operation) {
// Create or open the archive object.
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(
ArchiveName, /*IsText=*/false, /*RequiresNullTerminator=*/false);
@@ -1145,7 +1144,7 @@ static int performOperation(ArchiveOperation Operation,
if (Archive->isThin())
CompareFullPath = true;
performOperation(Operation, Archive.get(), std::move(Buf.get()),
- NewMembers);
+ /*NewMembers=*/nullptr);
return 0;
}
@@ -1160,7 +1159,7 @@ static int performOperation(ArchiveOperation Operation,
}
}
- performOperation(Operation, nullptr, nullptr, NewMembers);
+ performOperation(Operation, nullptr, nullptr, /*NewMembers=*/nullptr);
return 0;
}
@@ -1403,12 +1402,11 @@ static int ar_main(int argc, char **argv) {
Options += *ArgIt + 1;
}
- ArchiveOperation Operation = parseCommandLine();
- return performOperation(Operation, nullptr);
+ return performOperation(parseCommandLine());
}
static int ranlib_main(int argc, char **argv) {
- bool ArchiveSpecified = false;
+ std::vector<StringRef> Archives;
for (int i = 1; i < argc; ++i) {
StringRef arg(argv[i]);
if (handleGenericOption(arg)) {
@@ -1433,16 +1431,17 @@ static int ranlib_main(int argc, char **argv) {
arg = arg.drop_front(1);
}
} else {
- if (ArchiveSpecified)
- fail("exactly one archive should be specified");
- ArchiveSpecified = true;
- ArchiveName = arg.str();
+ Archives.push_back(arg);
}
}
- if (!ArchiveSpecified) {
- badUsage("an archive name must be specified");
+
+ for (StringRef Archive : Archives) {
+ ArchiveName = Archive.str();
+ performOperation(CreateSymTab);
}
- return performOperation(CreateSymTab, nullptr);
+ if (Archives.empty())
+ badUsage("an archive name must be specified");
+ return 0;
}
int llvm_ar_main(int argc, char **argv) {
diff --git a/contrib/llvm-project/openmp/runtime/src/kmp_dispatch.cpp b/contrib/llvm-project/openmp/runtime/src/kmp_dispatch.cpp
index e7d28c6587b1..c8c8ff8065fc 100644
--- a/contrib/llvm-project/openmp/runtime/src/kmp_dispatch.cpp
+++ b/contrib/llvm-project/openmp/runtime/src/kmp_dispatch.cpp
@@ -1979,7 +1979,7 @@ int __kmp_dispatch_next_algorithm(int gtid,
// TODO: implement count
#else
#define OMPT_LOOP_END // no-op
-#define OMPT_LOOP_DISPATCH // no-op
+#define OMPT_LOOP_DISPATCH(lb, ub, st, status) // no-op
#endif
#if KMP_STATS_ENABLED
diff --git a/lib/clang/include/VCSVersion.inc b/lib/clang/include/VCSVersion.inc
index 571ed75d3dc9..4756d002a956 100644
--- a/lib/clang/include/VCSVersion.inc
+++ b/lib/clang/include/VCSVersion.inc
@@ -1,10 +1,10 @@
// $FreeBSD$
-#define LLVM_REVISION "llvmorg-15-init-17826-g1f8ae9d7e7e4"
+#define LLVM_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d"
#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
-#define CLANG_REVISION "llvmorg-15-init-17826-g1f8ae9d7e7e4"
+#define CLANG_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d"
#define CLANG_REPOSITORY "https://github.com/llvm/llvm-project.git"
-#define LLDB_REVISION "llvmorg-15-init-17826-g1f8ae9d7e7e4"
+#define LLDB_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d"
#define LLDB_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc
index 6e25b65b845e..eaf7ae8ff492 100644
--- a/lib/clang/include/lld/Common/Version.inc
+++ b/lib/clang/include/lld/Common/Version.inc
@@ -1,4 +1,4 @@
// Local identifier in __FreeBSD_version style
#define LLD_FREEBSD_VERSION 1400005
-#define LLD_VERSION_STRING "15.0.0 (FreeBSD llvmorg-15-init-17826-g1f8ae9d7e7e4-" __XSTRING(LLD_FREEBSD_VERSION) ")"
+#define LLD_VERSION_STRING "15.0.0 (FreeBSD llvmorg-15.0.0-rc2-40-gfbd2950d8d0d-" __XSTRING(LLD_FREEBSD_VERSION) ")"
diff --git a/lib/clang/include/llvm/Support/VCSRevision.h b/lib/clang/include/llvm/Support/VCSRevision.h
index 1405a0d08395..8fd2403121b2 100644
--- a/lib/clang/include/llvm/Support/VCSRevision.h
+++ b/lib/clang/include/llvm/Support/VCSRevision.h
@@ -1,3 +1,3 @@
/* $FreeBSD$ */
-#define LLVM_REVISION "llvmorg-15-init-17826-g1f8ae9d7e7e4"
+#define LLVM_REVISION "llvmorg-15.0.0-rc2-40-gfbd2950d8d0d"
#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile
index 9020bda31574..01fe0705d954 100644
--- a/lib/clang/libllvm/Makefile
+++ b/lib/clang/libllvm/Makefile
@@ -25,6 +25,8 @@ CFLAGS+= -I${LLVM_SRCS}/lib/Target/${arch}
CFLAGS+= -I${LLVM_SRCS}/lib/ObjCopy
+TARGET_ARCH?= ${MACHINE_ARCH}
+
.if ${TARGET_ARCH} != "amd64"
CFLAGS+= -DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 \
-DBLAKE3_NO_SSE2
@@ -496,7 +498,7 @@ SRCS_MIN+= DebugInfo/CodeView/RecordSerialization.cpp
SRCS_MIN+= DebugInfo/CodeView/SimpleTypeSerializer.cpp
SRCS_EXT+= DebugInfo/CodeView/StringsAndChecksums.cpp
SRCS_MIN+= DebugInfo/CodeView/SymbolDumper.cpp
-SRCS_EXT+= DebugInfo/CodeView/SymbolRecordHelpers.cpp
+SRCS_MIN+= DebugInfo/CodeView/SymbolRecordHelpers.cpp
SRCS_MIN+= DebugInfo/CodeView/SymbolRecordMapping.cpp
SRCS_EXT+= DebugInfo/CodeView/SymbolSerializer.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeDumpVisitor.cpp
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index 9d059ea39319..540118e4038f 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -18,7 +18,6 @@ SHLIB_LDSCRIPT= libc++.ldscript
SRCS+= algorithm.cpp
SRCS+= any.cpp
-SRCS+= assert.cpp
SRCS+= atomic.cpp
SRCS+= barrier.cpp
SRCS+= bind.cpp
@@ -63,6 +62,7 @@ SRCS+= utility.cpp
SRCS+= valarray.cpp
SRCS+= variant.cpp
SRCS+= vector.cpp
+SRCS+= verbose_abort.cpp
CXXRT_SRCS+= auxhelper.cc
CXXRT_SRCS+= dynamic_cast.cc
@@ -118,6 +118,7 @@ STD_HEADERS+= __threading_support
STD_HEADERS+= __tree
STD_HEADERS+= __tuple
STD_HEADERS+= __undef_macros
+STD_HEADERS+= __verbose_abort
STD_HEADERS+= algorithm
STD_HEADERS+= any
STD_HEADERS+= array
@@ -329,6 +330,7 @@ ALG_HEADERS+= ranges_adjacent_find.h
ALG_HEADERS+= ranges_all_of.h
ALG_HEADERS+= ranges_any_of.h
ALG_HEADERS+= ranges_binary_search.h
+ALG_HEADERS+= ranges_clamp.h
ALG_HEADERS+= ranges_copy.h
ALG_HEADERS+= ranges_copy_backward.h
ALG_HEADERS+= ranges_copy_if.h
@@ -353,6 +355,7 @@ ALG_HEADERS+= ranges_inplace_merge.h
ALG_HEADERS+= ranges_is_heap.h
ALG_HEADERS+= ranges_is_heap_until.h
ALG_HEADERS+= ranges_is_partitioned.h
+ALG_HEADERS+= ranges_is_permutation.h
ALG_HEADERS+= ranges_is_sorted.h
ALG_HEADERS+= ranges_is_sorted_until.h
ALG_HEADERS+= ranges_iterator_concept.h
@@ -369,6 +372,7 @@ ALG_HEADERS+= ranges_minmax_element.h
ALG_HEADERS+= ranges_mismatch.h
ALG_HEADERS+= ranges_move.h
ALG_HEADERS+= ranges_move_backward.h
+ALG_HEADERS+= ranges_next_permutation.h
ALG_HEADERS+= ranges_none_of.h
ALG_HEADERS+= ranges_nth_element.h
ALG_HEADERS+= ranges_partial_sort.h
@@ -377,6 +381,7 @@ ALG_HEADERS+= ranges_partition.h
ALG_HEADERS+= ranges_partition_copy.h
ALG_HEADERS+= ranges_partition_point.h
ALG_HEADERS+= ranges_pop_heap.h
+ALG_HEADERS+= ranges_prev_permutation.h
ALG_HEADERS+= ranges_push_heap.h
ALG_HEADERS+= ranges_remove.h
ALG_HEADERS+= ranges_remove_copy.h
@@ -388,7 +393,9 @@ ALG_HEADERS+= ranges_replace_copy_if.h
ALG_HEADERS+= ranges_replace_if.h
ALG_HEADERS+= ranges_reverse.h
ALG_HEADERS+= ranges_reverse_copy.h
+ALG_HEADERS+= ranges_rotate.h
ALG_HEADERS+= ranges_rotate_copy.h
+ALG_HEADERS+= ranges_sample.h
ALG_HEADERS+= ranges_search.h
ALG_HEADERS+= ranges_search_n.h
ALG_HEADERS+= ranges_set_difference.h
@@ -434,9 +441,11 @@ ALG_HEADERS+= stable_partition.h
ALG_HEADERS+= stable_sort.h
ALG_HEADERS+= swap_ranges.h
ALG_HEADERS+= transform.h
+ALG_HEADERS+= uniform_random_bit_generator_adaptor.h
ALG_HEADERS+= unique.h
ALG_HEADERS+= unique_copy.h
ALG_HEADERS+= unwrap_iter.h
+ALG_HEADERS+= unwrap_range.h
ALG_HEADERS+= upper_bound.h
.for hdr in ${ALG_HEADERS}
ALG+= ${HDRDIR}/__algorithm/${hdr}
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 9b33c7b82125..2b84b0be94b8 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -46,8 +46,13 @@ CWARNEXTRA?= -Wno-error=tautological-compare -Wno-error=empty-body \
CWARNEXTRA+= -Wno-error=shift-negative-value
CWARNEXTRA+= -Wno-address-of-packed-member
.if ${COMPILER_VERSION} >= 150000
+# Clang 15 has much more aggressive diagnostics about inconsistently declared
+# array parameters, K&R prototypes, mismatched prototypes, and unused-but-set
+# variables. Make these non-fatal for the time being.
CWARNEXTRA+= -Wno-error=array-parameter
CWARNEXTRA+= -Wno-error=deprecated-non-prototype
+CWARNEXTRA+= -Wno-error=strict-protoypes
+CWARNEXTRA+= -Wno-error=unused-but-set-variable
.endif
.endif # clang