Skip to content

Commit aa70113

Browse files
committed
Merge remote-tracking branch 'apple/master'
2 parents 2992de7 + 3d43231 commit aa70113

File tree

7 files changed

+52
-11
lines changed

7 files changed

+52
-11
lines changed

lib/Markup/Markup.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "swift/Markup/LineList.h"
1717
#include "swift/Markup/Markup.h"
1818
#include "cmark.h"
19-
#include "node.h"
2019

2120
using namespace llvm;
2221
using namespace markup;
@@ -60,15 +59,7 @@ StringRef getLiteralContent(MarkupContext &MC, LineList &LL, cmark_node *Node) {
6059
// its parent.
6160
auto Literal = cmark_node_get_literal(Node);
6261
assert(Literal != nullptr);
63-
size_t Length = 0;
64-
switch (cmark_node_get_type(Node)) {
65-
case CMARK_NODE_CODE_BLOCK:
66-
Length = Node->as.code.literal.len;
67-
break;
68-
default:
69-
Length = Node->as.literal.len;
70-
}
71-
return MC.allocateCopy(StringRef(Literal, Length));
62+
return MC.allocateCopy(StringRef(Literal));
7263
}
7364

7465
ParseResult<MarkupASTNode>

stdlib/public/core/Misc.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ func _typeName(type: Any.Type, qualified: Bool = true) -> String {
8383
input: UnsafeBufferPointer(start: stringPtr, count: count))
8484
}
8585

86+
@warn_unused_result
87+
@_silgen_name("swift_stdlib_demangleName")
88+
func _stdlib_demangleNameImpl(
89+
mangledName: UnsafePointer<UInt8>,
90+
_ mangledNameLength: UInt,
91+
_ demangledName: UnsafeMutablePointer<String>)
92+
93+
// NB: This function is not used directly in the Swift codebase, but is
94+
// exported for Xcode support. Please coordinate before changing.
95+
@warn_unused_result
96+
public // @testable
97+
func _stdlib_demangleName(mangledName: String) -> String {
98+
let mangledNameUTF8 = Array(mangledName.utf8)
99+
return mangledNameUTF8.withUnsafeBufferPointer {
100+
(mangledNameUTF8) in
101+
let (_, demangledName) = _withUninitializedString {
102+
_stdlib_demangleNameImpl(
103+
mangledNameUTF8.baseAddress, UInt(mangledNameUTF8.endIndex),
104+
$0)
105+
}
106+
return demangledName
107+
}
108+
}
109+
86110
/// Returns `floor(log(x))`. This equals to the position of the most
87111
/// significant non-zero bit, or 63 - number-of-zeros before it.
88112
///

stdlib/public/core/String.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import SwiftShims
102102
/// any sequence of mutating operations causes elements to be copied
103103
/// into unique, contiguous storage which may cost `O(N)` time and
104104
/// space, where `N` is the length of the string representation (or
105-
/// more, if the underlying `NSString` is has unusual performance
105+
/// more, if the underlying `NSString` has unusual performance
106106
/// characteristics).
107107
public struct String {
108108
/// An empty `String`.

stdlib/public/runtime/Reflection.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,3 +1264,17 @@ static Mirror ObjC_getMirrorForSuperclass(Class sup,
12641264
T->vw_destroy(value);
12651265
return MirrorReturn(result);
12661266
}
1267+
1268+
// NB: This function is not used directly in the Swift codebase, but is
1269+
// exported for Xcode support. Please coordinate before changing.
1270+
extern "C" void swift_stdlib_demangleName(const char *mangledName,
1271+
size_t mangledNameLength,
1272+
String *demangledName) {
1273+
auto options = Demangle::DemangleOptions();
1274+
options.DisplayDebuggerGeneratedModule = false;
1275+
auto result =
1276+
Demangle::demangleSymbolAsString(mangledName,
1277+
mangledNameLength,
1278+
options);
1279+
new (demangledName) String(result.data(), result.size());
1280+
}

test/1_stdlib/Runtime.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,16 @@ Runtime.test("typeName") {
665665
expectEqual("protocol<>.Protocol", _typeName(a.dynamicType))
666666
}
667667

668+
Runtime.test("demangleName") {
669+
expectEqual("", _stdlib_demangleName(""))
670+
expectEqual("abc", _stdlib_demangleName("abc"))
671+
expectEqual("\0", _stdlib_demangleName("\0"))
672+
expectEqual("Swift.Double", _stdlib_demangleName("_TtSd"))
673+
expectEqual("x.a : x.Foo<x.Foo<x.Foo<Swift.Int, Swift.Int>, x.Foo<Swift.Int, Swift.Int>>, x.Foo<x.Foo<Swift.Int, Swift.Int>, x.Foo<Swift.Int, Swift.Int>>>",
674+
_stdlib_demangleName("_Tv1x1aGCS_3FooGS0_GS0_SiSi_GS0_SiSi__GS0_GS0_SiSi_GS0_SiSi___"))
675+
expectEqual("Foobar", _stdlib_demangleName("_TtC13__lldb_expr_46Foobar"))
676+
}
677+
668678
Runtime.test("_stdlib_atomicCompareExchangeStrongPtr") {
669679
typealias IntPtr = UnsafeMutablePointer<Int>
670680
var origP1 = IntPtr(bitPattern: 0x10101010)

test/Driver/environment.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// FIXME: This is failing on some of Apple's internal CI.
2+
// FIXME: <rdar://problem/23771412> Fix test/Driver/{environment.swift,options-interpreter.swift}
23
// REQUIRES: disabled
34

45
// RUN: %swift_driver -target x86_64-apple-macosx10.9 -L/foo/ -driver-use-frontend-path %S/Inputs/print-var.sh %s DYLD_LIBRARY_PATH | FileCheck %s

test/Driver/options-interpreter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// FIXME: This is failing on some of Apple's internal CI.
2+
// FIXME: <rdar://problem/23771412> Fix test/Driver/{environment.swift,options-interpreter.swift}
23
// REQUIRES: disabled
34

45
// RUN: not %swift_driver -deprecated-integrated-repl -emit-module 2>&1 | FileCheck -check-prefix=IMMEDIATE_NO_MODULE %s

0 commit comments

Comments
 (0)