Skip to content

Commit 4ccf315

Browse files
authored
[Debugging] Add DebugDescriptionMacro experimental feature (#73070)
This removes the leading underscore from the macro.
1 parent a5f9e25 commit 4ccf315

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
@@ -376,6 +376,9 @@ EXPERIMENTAL_FEATURE(ObjCImplementation, true)
376376
// Enable @implementation on @_cdecl functions.
377377
EXPERIMENTAL_FEATURE(CImplementation, true)
378378

379+
// Enable the stdlib @DebugDescription macro.
380+
EXPERIMENTAL_FEATURE(DebugDescriptionMacro, false)
381+
379382
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
380383
#undef EXPERIMENTAL_FEATURE
381384
#undef UPCOMING_FEATURE

lib/AST/FeatureSet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ UNINTERESTING_FEATURE(IsolatedAny2)
686686
UNINTERESTING_FEATURE(ObjCImplementation)
687687
UNINTERESTING_FEATURE(CImplementation)
688688

689+
UNINTERESTING_FEATURE(DebugDescriptionMacro)
690+
689691
// ----------------------------------------------------------------------------
690692
// MARK: - FeatureSet
691693
// ----------------------------------------------------------------------------

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15131513
}
15141514
}
15151515

1516+
// @DebugDescription uses @_section and @_used attributes.
1517+
if (Opts.hasFeature(Feature::DebugDescriptionMacro))
1518+
Opts.enableFeature(Feature::SymbolLinkageMarkers);
1519+
15161520
#if SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
15171521
/// Enable round trip parsing via the new swift parser unless it is disabled
15181522
/// 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
@@ -328,7 +328,7 @@ endif()
328328

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

333333
set(swift_core_incorporate_object_libraries)
334334
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)