Skip to content

Commit 6e74363

Browse files
authored
Merge pull request #41017 from franklinsch/access-control-attributes
[5.6] [SymbolGraphGen] don't emit access control attributes in declarations
2 parents 17dc994 + 06fd251 commit 6e74363

File tree

8 files changed

+35
-25
lines changed

8 files changed

+35
-25
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ PrintOptions SymbolGraph::getDeclarationFragmentsPrintOptions() const {
9999
ExcludeAttrs.insert(std::make_pair("DAK_Postfix", DAK_Postfix));
100100
ExcludeAttrs.insert(std::make_pair("DAK_Infix", DAK_Infix));
101101

102+
// In "emit modules separately" jobs, access modifiers show up as attributes,
103+
// but we don't want them to be printed in declarations
104+
ExcludeAttrs.insert(std::make_pair("DAK_AccessControl", DAK_AccessControl));
105+
102106
for (const auto &Entry : ExcludeAttrs) {
103107
Opts.ExcludeAttrList.push_back(Entry.getValue());
104108
}

test/SourceKit/CursorInfo/cursor_symbol_graph.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,6 @@ enum MyEnum {
182182
// CHECKY: "symbols": [
183183
// CHECKY: {
184184
// CHECKY: "accessLevel": "private",
185-
// CHECKY: "declarationFragments": [
186-
// CHECKY: {
187-
// CHECKY: "kind": "keyword",
188-
// CHECKY: "spelling": "private"
189-
// CHECKY: },
190-
// CHECKY: {
191-
// CHECKY: "kind": "text",
192-
// CHECKY: "spelling": " "
193-
// CHECKY: },
194185
// CHECKY: {
195186
// CHECKY: "kind": "keyword",
196187
// CHECKY: "spelling": "var"

test/SourceKit/CursorInfo/cursor_symbol_graph_referenced.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,6 @@ extension Parent {
237237
// PRIVATE: "declarationFragments": [
238238
// PRIVATE-NEXT: {
239239
// PRIVATE-NEXT: "kind": "keyword",
240-
// PRIVATE-NEXT: "spelling": "private"
241-
// PRIVATE-NEXT: },
242-
// PRIVATE-NEXT: {
243-
// PRIVATE-NEXT: "kind": "text",
244-
// PRIVATE-NEXT: "spelling": " "
245-
// PRIVATE-NEXT: },
246-
// PRIVATE-NEXT: {
247-
// PRIVATE-NEXT: "kind": "keyword",
248240
// PRIVATE-NEXT: "spelling": "func"
249241
// PRIVATE-NEXT: },
250242
// PRIVATE-NEXT: {
@@ -302,14 +294,6 @@ extension Parent {
302294
// SPI: "declarationFragments": [
303295
// SPI-NEXT: {
304296
// SPI-NEXT: "kind": "keyword",
305-
// SPI-NEXT: "spelling": "internal"
306-
// SPI-NEXT: },
307-
// SPI-NEXT: {
308-
// SPI-NEXT: "kind": "text",
309-
// SPI-NEXT: "spelling": " "
310-
// SPI-NEXT: },
311-
// SPI-NEXT: {
312-
// SPI-NEXT: "kind": "keyword",
313297
// SPI-NEXT: "spelling": "func"
314298
// SPI-NEXT: },
315299
// SPI-NEXT: {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module-path %t/EmitWhileBuilding.framework/Modules/EmitWhileBuilding.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name EmitWhileBuilding -disable-objc-attr-requires-foundation-module %s -emit-symbol-graph -emit-symbol-graph-dir %t
4+
// RUN: %{python} -m json.tool %t/EmitWhileBuilding.symbols.json %t/EmitWhileBuilding.formatted.symbols.json
5+
// RUN: %FileCheck %s --input-file %t/EmitWhileBuilding.formatted.symbols.json
6+
7+
// REQUIRES: objc_interop
8+
9+
import Foundation
10+
11+
public enum SwiftEnum {}
12+
13+
// CHECK: "declarationFragments": [
14+
// CHECK-NEXT: {
15+
// CHECK-NEXT: "kind": "keyword",
16+
// CHECK-NEXT: "spelling": "enum"
17+
// CHECK-NEXT: },
18+
// CHECK-NEXT: {
19+
// CHECK-NEXT: "kind": "text",
20+
// CHECK-NEXT: "spelling": " "
21+
// CHECK-NEXT: },
22+
// CHECK-NEXT: {
23+
// CHECK-NEXT: "kind": "identifier",
24+
// CHECK-NEXT: "spelling": "SwiftEnum"
25+
// CHECK-NEXT: }
26+
// CHECK-NEXT: ],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
double testVariable = 1.0;

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

Whitespace-only changes.

test/SymbolGraph/ClangImporter/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework/ObjcProperty

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

0 commit comments

Comments
 (0)