Skip to content

Commit 36ab596

Browse files
Merge pull request swiftlang#63391 from apple/QuietMisdreavus/factory-init-sgf
don't print the "not inherited" mark in SGF declarations
2 parents 000664b + 1f9575d commit 36ab596

File tree

8 files changed

+27
-1
lines changed

8 files changed

+27
-1
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ struct PrintOptions {
318318
/// Suppress emitting @available(*, noasync)
319319
bool SuppressNoAsyncAvailabilityAttr = false;
320320

321+
/// Whether to print the \c{/*not inherited*/} comment on factory initializers.
322+
bool PrintFactoryInitializerComment = true;
323+
321324
/// How to print opaque return types.
322325
enum class OpaqueReturnTypePrintingMode {
323326
/// 'some P1 & P2'.

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4373,7 +4373,9 @@ void PrintAST::visitConstructorDecl(ConstructorDecl *decl) {
43734373
"unexpected convenience initializer");
43744374
}
43754375
} else if (decl->getInitKind() == CtorInitializerKind::Factory) {
4376-
Printer << "/*not inherited*/ ";
4376+
if (Options.PrintFactoryInitializerComment) {
4377+
Printer << "/*not inherited*/ ";
4378+
}
43774379
}
43784380

43794381
printContextIfNeeded(decl);

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ PrintOptions SymbolGraph::getDeclarationFragmentsPrintOptions() const {
6767
Opts.PrintGenericRequirements = true;
6868
Opts.PrintInherited = false;
6969
Opts.ExplodeEnumCaseDecls = true;
70+
Opts.PrintFactoryInitializerComment = false;
7071

7172
Opts.ExclusiveAttrList.clear();
7273

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-symbolgraph-extract -sdk %clang-importer-sdk -module-name FactoryInit -F %S/Inputs/FactoryInit -output-dir %t -pretty-print -v
3+
4+
// REQUIRES: objc_interop
5+
6+
// RUN: %FileCheck %s --input-file %t/FactoryInit.symbols.json
7+
8+
// CHECK-NOT: not inherited

test/SymbolGraph/ClangImporter/Inputs/FactoryInit/FactoryInit.framework/FactoryInit

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import Foundation;
2+
3+
__attribute__((swift_name("SomeClass")))
4+
@interface IAMSomeClass : NSObject
5+
@end
6+
7+
__attribute__((swift_name("SomeClass.init(value:)")))
8+
IAMSomeClass * _Nonnull MakeIAMSomeClass(double x);

test/SymbolGraph/ClangImporter/Inputs/FactoryInit/FactoryInit.framework/Modules/FactoryInit.swiftmodule/.keep

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework module FactoryInit {
2+
header "FactoryInit.h"
3+
export *
4+
}

0 commit comments

Comments
 (0)