mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE] Fix sort predicate in printCodeCompletionLookedupTypeNames
This wasn't a strict weak ordering, and it turns out violating that is undefined behavior which can result in buffer overruns.
This commit is contained in:
@@ -1379,7 +1379,7 @@ printCodeCompletionLookedupTypeNames(ArrayRef<NullTerminatedStringRef> names,
|
|||||||
sortedNames.append(names.begin(), names.end());
|
sortedNames.append(names.begin(), names.end());
|
||||||
llvm::sort(sortedNames,
|
llvm::sort(sortedNames,
|
||||||
[](NullTerminatedStringRef a, NullTerminatedStringRef b) {
|
[](NullTerminatedStringRef a, NullTerminatedStringRef b) {
|
||||||
return a.compare(b) <= 0;
|
return a.compare(b) < 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
OS << "LookedupTypeNames: [";
|
OS << "LookedupTypeNames: [";
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// {"kind":"complete","signature":"void std::__1::__introsort<std::__1::_ClassicAlgPolicy, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, swift::NullTerminatedStringRef*, false>(swift::NullTerminatedStringRef*, swift::NullTerminatedStringRef*, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, std::__1::iterator_traits<swift::NullTerminatedStringRef*>::difference_type, bool)"}
|
||||||
|
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
|
||||||
|
{
|
||||||
|
$1 == [$1 ]#^^#
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
// {"kind":"complete","signature":"void std::__1::__introsort<std::__1::_ClassicAlgPolicy, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, swift::NullTerminatedStringRef*, false>(swift::NullTerminatedStringRef*, swift::NullTerminatedStringRef*, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, std::__1::iterator_traits<swift::NullTerminatedStringRef*>::difference_type, bool)","useGuardMalloc":true}
|
// {"kind":"complete","signature":"void std::__1::__introsort<std::__1::_ClassicAlgPolicy, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, swift::NullTerminatedStringRef*, false>(swift::NullTerminatedStringRef*, swift::NullTerminatedStringRef*, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, std::__1::iterator_traits<swift::NullTerminatedStringRef*>::difference_type, bool)"}
|
||||||
// RUN: env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib not --crash %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
|
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
|
||||||
// REQUIRES: OS=macosx
|
|
||||||
// REQUIRES: no_asan
|
|
||||||
// REQUIRES: target-same-as-host
|
|
||||||
struct a<each b: Collection
|
struct a<each b: Collection
|
||||||
{
|
{
|
||||||
c: (repeat each b.Index
|
c: (repeat each b.Index
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// {"kind":"complete","signature":"void std::__1::__introsort<std::__1::_ClassicAlgPolicy, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, swift::NullTerminatedStringRef*, false>(swift::NullTerminatedStringRef*, swift::NullTerminatedStringRef*, printCodeCompletionLookedupTypeNames(llvm::ArrayRef<swift::NullTerminatedStringRef>, llvm::raw_ostream&)::$_0&, std::__1::iterator_traits<swift::NullTerminatedStringRef*>::difference_type, bool)"}
|
||||||
|
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
|
||||||
|
(.1.a - a)#^^#
|
||||||
Reference in New Issue
Block a user