Skip to content

Commit e57f70b

Browse files
authored
[Debugging] Add DebugDescriptionMacro experimental feature (swiftlang#73107)
This removes the leading underscore from the macro.
1 parent d6a4a35 commit e57f70b

19 files changed

+43
-34
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ EXPERIMENTAL_FEATURE(CImplementation, true)
385385
// Enable @sensitive attribute.
386386
EXPERIMENTAL_FEATURE(Sensitive, true)
387387

388+
// Enable the stdlib @DebugDescription macro.
389+
EXPERIMENTAL_FEATURE(DebugDescriptionMacro, true)
390+
388391
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
389392
#undef EXPERIMENTAL_FEATURE
390393
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,8 @@ static bool usesFeatureSensitive(Decl *decl) {
710710
return decl->getAttrs().hasAttribute<SensitiveAttr>();
711711
}
712712

713+
UNINTERESTING_FEATURE(DebugDescriptionMacro)
714+
713715
// ----------------------------------------------------------------------------
714716
// MARK: - FeatureSet
715717
// ----------------------------------------------------------------------------

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15381538
Opts.DisableDynamicActorIsolation |=
15391539
Args.hasArg(OPT_disable_dynamic_actor_isolation);
15401540

1541+
// @DebugDescription uses @_section and @_used attributes.
1542+
if (Opts.hasFeature(Feature::DebugDescriptionMacro))
1543+
Opts.enableFeature(Feature::SymbolLinkageMarkers);
1544+
15411545
#if SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
15421546
/// Enable round trip parsing via the new swift parser unless it is disabled
15431547
/// explicitly. The new Swift parser can have mismatches with C++ parser -

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ endif()
329329

330330
list(APPEND swift_stdlib_compile_flags "-external-plugin-path"
331331
"${swift_lib_dir}/swift/host/plugins#${swift_bin_dir}/swift-plugin-server")
332-
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "SymbolLinkageMarkers")
332+
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "DebugDescriptionMacro")
333333

334334
set(swift_core_incorporate_object_libraries)
335335
list(APPEND swift_core_incorporate_object_libraries swiftRuntime)

stdlib/public/core/DebuggerSupport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SwiftShims
1414

1515
// Macros are disabled when Swift is built without swift-syntax.
16-
#if $Macros && hasAttribute(attached)
16+
#if $Macros && $DebugDescriptionMacro && hasAttribute(attached)
1717

1818
/// Converts description definitions to a debugger Type Summary.
1919
///
@@ -65,10 +65,10 @@ import SwiftShims
6565
/// logic and computed properties are not supported.
6666
/// * Overloaded string interpolation cannot be used.
6767
@attached(memberAttribute)
68-
public macro _DebugDescription() =
68+
public macro DebugDescription() =
6969
#externalMacro(module: "SwiftMacros", type: "DebugDescriptionMacro")
7070

71-
/// Internal-only macro. See `@_DebugDescription`.
71+
/// Internal-only macro. See `@DebugDescription`.
7272
@attached(peer, names: named(_lldb_summary))
7373
public macro _DebugDescriptionProperty(_ debugIdentifier: String, _ computedProperties: [String]) =
7474
#externalMacro(module: "SwiftMacros", type: "_DebugDescriptionPropertyMacro")

stdlib/public/core/ObjectIdentifier+DebugDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#if !$Embedded
14-
@_DebugDescription
14+
@DebugDescription
1515
extension ObjectIdentifier {
1616
var _debugDescription: String {
1717
return "ObjectIdentifier(\(_value))"

test/Macros/DebugDescription/error_complex_implementation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -verify -plugin-path %swift-plugin-dir
55

6-
@_DebugDescription
6+
@DebugDescription
77
struct MyStruct {
88
var flag: Bool
99

test/Macros/DebugDescription/error_computed_properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -verify -plugin-path %swift-plugin-dir
55

6-
@_DebugDescription
6+
@DebugDescription
77
struct MyStruct {
88
var name: String { "thirty" }
99

test/Macros/DebugDescription/error_custom_interpolation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ extension DefaultStringInterpolation {
88
fileprivate func appendInterpolation<A, B>(_ a: A, _ b: B) {}
99
}
1010

11-
@_DebugDescription
11+
@DebugDescription
1212
struct MyStruct1 {
1313
// expected-error @+1 {{unsupported custom string interpolation expression}}
1414
var debugDescription: String { "\(custom: 30)" }
1515
}
1616

17-
@_DebugDescription
17+
@DebugDescription
1818
struct MyStruct2 {
1919
// expected-error @+1 {{unsupported custom string interpolation expression}}
2020
var debugDescription: String { "\(30, true)" }

test/Macros/DebugDescription/error_interpolation_expression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -verify -plugin-path %swift-plugin-dir
55

6-
@_DebugDescription
6+
@DebugDescription
77
struct MyStruct {
88
// expected-error @+1 {{only references to stored properties are allowed}}
99
var debugDescription: String { "\(1)" }

0 commit comments

Comments
 (0)