Skip to content

Commit 44c1bf7

Browse files
authored
Merge pull request #79364 from rintaro/astgen-declcontextdiff
[ASTGen] Adopt '-dump-ast-format default-with-decl-contexts' in tests
2 parents 515221c + 74f5f1d commit 44c1bf7

File tree

12 files changed

+74
-69
lines changed

12 files changed

+74
-69
lines changed

lib/AST/DeclContext.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "swift/AST/AccessScope.h"
1717
#include "swift/AST/AvailabilityInference.h"
1818
#include "swift/AST/ClangModuleLoader.h"
19+
#include "swift/AST/DiagnosticsSema.h"
1920
#include "swift/AST/Expr.h"
2021
#include "swift/AST/FileUnit.h"
2122
#include "swift/AST/GenericEnvironment.h"
@@ -25,8 +26,8 @@
2526
#include "swift/AST/ParseRequests.h"
2627
#include "swift/AST/SourceFile.h"
2728
#include "swift/AST/TypeCheckRequests.h"
29+
#include "swift/AST/TypeRepr.h"
2830
#include "swift/AST/Types.h"
29-
#include "swift/AST/DiagnosticsSema.h"
3031
#include "swift/Basic/Assertions.h"
3132
#include "swift/Basic/SourceManager.h"
3233
#include "swift/Basic/Statistic.h"
@@ -802,10 +803,17 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
802803
OS << " name=" << cast<GenericTypeDecl>(this)->getName();
803804
break;
804805

805-
case DeclContextKind::ExtensionDecl:
806-
OS << " line=" << getLineNumber(cast<ExtensionDecl>(this));
807-
OS << " base=" << cast<ExtensionDecl>(this)->getExtendedType();
806+
case DeclContextKind::ExtensionDecl: {
807+
auto *ED = cast<ExtensionDecl>(this);
808+
OS << " line=" << getLineNumber(ED);
809+
OS << " base=";
810+
if (ED->hasBeenBound()) {
811+
OS << ED->getExtendedType();
812+
} else {
813+
ED->getExtendedTypeRepr()->print(OS);
814+
}
808815
break;
816+
}
809817

810818
case DeclContextKind::TopLevelCodeDecl:
811819
OS << " line=" << getLineNumber(cast<TopLevelCodeDecl>(this));
@@ -817,7 +825,12 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
817825

818826
case DeclContextKind::AbstractFunctionDecl: {
819827
auto *AFD = cast<AbstractFunctionDecl>(this);
820-
OS << " name=" << AFD->getName();
828+
OS << " name=";
829+
if (auto *AD = dyn_cast<AccessorDecl>(AFD)) {
830+
OS << accessorKindName(AD->getAccessorKind());
831+
} else {
832+
OS << AFD->getName();
833+
}
821834
if (AFD->hasInterfaceType())
822835
OS << " : " << AFD->getInterfaceType();
823836
else

test/ASTGen/attrs.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking \
2+
3+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking \
34
// RUN: -enable-experimental-feature SymbolLinkageMarkers \
45
// RUN: -enable-experimental-feature ABIAttribute \
56
// RUN: -enable-experimental-feature Extern \
67
// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext \
78
// RUN: -enable-experimental-move-only \
8-
// RUN: -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
9+
// RUN: -enable-experimental-feature ParserASTGen \
10+
// RUN: | %sanitize-address > %t/astgen.ast
911

10-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking \
12+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking \
1113
// RUN: -enable-experimental-feature SymbolLinkageMarkers \
1214
// RUN: -enable-experimental-feature ABIAttribute \
1315
// RUN: -enable-experimental-feature Extern \
1416
// RUN: -enable-experimental-feature NonIsolatedAsyncInheritsIsolationFromContext \
15-
// RUN: -enable-experimental-move-only > %t/cpp-parser.ast.raw
16-
17-
// Filter out any addresses in the dump, since they can differ.
18-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
19-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
17+
// RUN: -enable-experimental-move-only \
18+
// RUN: | %sanitize-address > %t/cpp-parser.ast
2019

2120
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
2221

test/ASTGen/attrs_objc.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -dump-parse -import-objc-header %S/Inputs/objc_decls.h -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
3-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -dump-parse -import-objc-header %S/Inputs/objc_decls.h > %t/cpp-parser.ast.raw
4-
5-
// Filter out any addresses in the dump, since they can differ.
6-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
2+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s %dump-parse -import-objc-header %S/Inputs/objc_decls.h -enable-experimental-feature ParserASTGen \
3+
// RUN: | %sanitize-address > %t/astgen.ast
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s %dump-parse -import-objc-header %S/Inputs/objc_decls.h \
5+
// RUN: | %sanitize-address > %t/cpp-parser.ast
86

97
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
108
// RUN: %target-typecheck-verify-swift %clang-importer-sdk -import-objc-header %S/Inputs/objc_decls.h -enable-experimental-feature ParserASTGen

test/ASTGen/availability.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99
// RUN: -define-availability '_myProject 2.5:macOS 52.5' \
1010
// RUN: )
1111

12-
// RUN: %target-swift-frontend %s "${COMPILER_ARGS[@]}" -dump-parse \
12+
// RUN: %target-swift-frontend-dump-parse "${COMPILER_ARGS[@]}" \
1313
// RUN: -enable-experimental-feature ParserASTGen \
14-
// RUN: > %t/astgen.ast.raw
14+
// RUN: | %sanitize-address > %t/astgen.ast
1515

16-
// RUN: %target-swift-frontend %s "${COMPILER_ARGS[@]}" -dump-parse \
17-
// RUN: > %t/cpp-parser.ast.raw
18-
19-
// Filter out any addresses in the dump, since they can differ.
20-
// RUN: sed -E 's#0x[0-9a-fA-F]+#<ADDR>#g' %t/astgen.ast.raw > %t/astgen.ast
21-
// RUN: sed -E 's#0x[0-9a-fA-F]+#<ADDR>#g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
16+
// RUN: %target-swift-frontend-dump-parse "${COMPILER_ARGS[@]}" \
17+
// RUN: | %sanitize-address > %t/cpp-parser.ast
2218

2319
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
2420

test/ASTGen/decls.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11

22
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ParserASTGen -enable-experimental-feature ValueGenerics > %t/astgen.ast.raw
4-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ValueGenerics > %t/cpp-parser.ast.raw
5-
6-
// Filter out any addresses in the dump, since they can differ.
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
8-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
3+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ValueGenerics -enable-experimental-feature ParserASTGen \
4+
// RUN: | %sanitize-address > %t/astgen.ast
5+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ValueGenerics \
6+
// RUN: | %sanitize-address > %t/cpp-parser.ast
97

108
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
119

test/ASTGen/do_expr.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-feature DoExpressions -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
4-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-feature DoExpressions > %t/cpp-parser.ast.raw
5-
6-
// Filter out any addresses in the dump, since they can differ.
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
8-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
3+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-feature DoExpressions -enable-experimental-feature ParserASTGen \
4+
// RUN: | %sanitize-address > %t/astgen.ast
5+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-feature DoExpressions \
6+
// RUN: | %sanitize-address > %t/cpp-parser.ast
97

108
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
119

test/ASTGen/exprs.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
21
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend %s -dump-parse -target %target-swift-5.1-abi-triple -enable-experimental-move-only -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
4-
// RUN: %target-swift-frontend %s -dump-parse -target %target-swift-5.1-abi-triple -enable-experimental-move-only > %t/cpp-parser.ast.raw
5-
6-
// Filter out any addresses in the dump, since they can differ.
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
8-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
2+
// RUN: %target-swift-frontend-dump-parse -target %target-swift-5.1-abi-triple -enable-experimental-move-only -enable-experimental-feature ParserASTGen \
3+
// RUN: | %sanitize-address > %t/astgen.ast
4+
// RUN: %target-swift-frontend-dump-parse -target %target-swift-5.1-abi-triple -enable-experimental-move-only \
5+
// RUN: | %sanitize-address > %t/cpp-parser.ast
96

107
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
118

test/ASTGen/keypath.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// should end up with the same type-checked AST.
99

1010
// RUN: %empty-directory(%t)
11-
// RUN: %target-swift-frontend %s -dump-ast -enable-experimental-feature ParserASTGen -verify > %t/astgen.ast.raw
12-
// RUN: not %target-swift-frontend %s -dump-ast > %t/cpp-parser.ast.raw
13-
14-
// Filter out any addresses in the dump, since they can differ.
15-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
16-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
11+
// RUN: %target-swift-frontend-dump-ast -enable-experimental-feature ParserASTGen -verify \
12+
// RUN: | %sanitize-address > %t/astgen.ast
13+
// RUN: not %target-swift-frontend-dump-ast \
14+
// RUN: | %sanitize-address > %t/cpp-parser.ast
1715

1816
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
1917

test/ASTGen/lit.local.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
config.substitutions.insert(0, ('%target-swift-frontend-dump-parse', '%target-swift-frontend %dump-parse %s') )
3+
config.substitutions.insert(0, ('%target-swift-frontend-dump-ast', '%target-swift-frontend %dump-ast %s') )
4+
config.substitutions.append( ('%dump-parse', '-dump-parse -dump-ast-format default-with-decl-contexts') )
5+
config.substitutions.append( ('%dump-ast', '-dump-ast -dump-ast-format default-with-decl-contexts') )
6+
config.substitutions.append( ('%sanitize-address', '%s %s/sanitize-address.py' % (config.python, config.swift_utils)) )

test/ASTGen/regex.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -dump-parse -enable-bare-slash-regex -disable-availability-checking -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
3-
// RUN: %target-swift-frontend %s -dump-parse -enable-bare-slash-regex -disable-availability-checking > %t/cpp-parser.ast.raw
4-
5-
// Filter out any addresses in the dump, since they can differ.
6-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
2+
// RUN: %target-swift-frontend-dump-parse -enable-bare-slash-regex -disable-availability-checking -enable-experimental-feature ParserASTGen \
3+
// RUN: | %sanitize-address > %t/astgen.ast
4+
// RUN: %target-swift-frontend-dump-parse -enable-bare-slash-regex -disable-availability-checking \
5+
// RUN: | %sanitize-address > %t/cpp-parser.ast
86

97
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
108

test/ASTGen/stmts.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ThenStatements -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
3-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ThenStatements > %t/cpp-parser.ast.raw
4-
5-
// Filter out any addresses in the dump, since they can differ.
6-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
2+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ThenStatements -enable-experimental-feature ParserASTGen \
3+
// RUN: | %sanitize-address > %t/astgen.ast
4+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ThenStatements \
5+
// RUN: | %sanitize-address > %t/cpp-parser.ast
86

97
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
108

test/ASTGen/top_level.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ParserASTGen > %t/astgen.ast.raw
3-
// RUN: %target-swift-frontend %s -dump-parse -disable-availability-checking -enable-experimental-move-only > %t/cpp-parser.ast.raw
42

5-
// Filter out any addresses in the dump, since they can differ.
6-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/cpp-parser.ast.raw > %t/cpp-parser.ast
7-
// RUN: sed -E 's#0x[0-9a-fA-F]+##g' %t/astgen.ast.raw > %t/astgen.ast
3+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature ParserASTGen \
4+
// RUN: | %sanitize-address > %t/astgen.ast
5+
// RUN: %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only \
6+
// RUN: | %sanitize-address > %t/cpp-parser.ast
87

98
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
109

10+
// RUN: not %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -parse-as-library -enable-experimental-feature ParserASTGen \
11+
// RUN: | %sanitize-address > %t/astgen.library.ast
12+
// RUN: not %target-swift-frontend-dump-parse -disable-availability-checking -enable-experimental-move-only -parse-as-library \
13+
// RUN: | %sanitize-address > %t/cpp-parser.library.ast
14+
15+
// RUN: %diff -u %t/astgen.library.ast %t/cpp-parser.library.ast
16+
1117
// REQUIRES: swift_feature_ParserASTGen
1218

1319
// rdar://116686158

0 commit comments

Comments
 (0)