Skip to content

Commit 18fc42d

Browse files
authored
Merge pull request #17527 from DougGregor/swift-api-dump-fixes
2 parents 8ea96e9 + 8082d39 commit 18fc42d

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

test/IDE/print_module_missing.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Make sure we emit some kind of error message when we cannot find the module
2+
// to print.
3+
4+
// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=NoSuchModule -source-filename=%s 2> %t.err
5+
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING < %t.err
6+
7+
// RUN: not %target-swift-ide-test -print-module -print-interface -no-empty-line-between-members -module-to-print=Swift.NoSuchSubModule -source-filename=%s 2> %t.suberr
8+
// RUN: %FileCheck %s -check-prefix=CHECK-MISSING-SUBMODULE < %t.suberr
9+
10+
// CHECK-MISSING: 'NoSuchModule'
11+
// CHECK-MISSING-SUBMODULE: 'Swift.NoSuchSubModule'

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
18541854
// Get the (sub)module to print.
18551855
auto *M = getModuleByFullName(Context, ModuleToPrint);
18561856
if (!M) {
1857+
llvm::errs() << "error: could not find module '" << ModuleToPrint
1858+
<< "'\n";
18571859
ExitCode = 1;
18581860
continue;
18591861
}
@@ -1873,6 +1875,8 @@ static int doPrintModules(const CompilerInvocation &InitInvok,
18731875
if (ModuleName.size() > 1) {
18741876
M = getModuleByFullName(Context, ModuleName[0]);
18751877
if (!M) {
1878+
llvm::errs() << "error: could not find module '" << ModuleName[0]
1879+
<< "'\n";
18761880
ExitCode = 1;
18771881
continue;
18781882
}

utils/swift-api-dump.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
# (Objective-)C APIs, any API notes added on top of those APIs, and the
66
# Clang importer itself. One can execute it to dump the API of a given
77
# module within a particular SDK, e.g., UIKit from the iOS SDK as seen in
8-
# Swift 3 compatibility mode:
8+
# Swift 4 compatibility mode:
99
#
10-
# /path/to/bin/dir/swift-api-dump.py -swift-version 3 -o output-dir \
10+
# /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir \
1111
# -m UIKit -s iphoneos
1212
#
1313
# The "-m" argument can be omitted, in which case the script will collect
1414
# all of the frameworks in the named SDK(s) and dump their APIs.
1515
#
1616
# One can supply multiple SDKs, written as a list. For example, to
1717
# dump the API for all frameworks across macOS, iOS, watchOS, and tvOS,
18-
# in Swift 4, use:
18+
# in Swift 4.2, use:
1919
#
20-
# /path/to/bin/dir/swift-api-dump.py -swift-version 4 -o output-dir \
20+
# /path/to/bin/dir/swift-api-dump.py -swift-version 4.2 -o output-dir \
2121
# -s macosx iphoneos watchos appletvos
2222
#
2323

@@ -102,7 +102,7 @@ def create_parser():
102102
parser.add_argument('--enable-infer-import-as-member', action='store_true',
103103
help='Infer when a global could be imported as a ' +
104104
'member.')
105-
parser.add_argument('-swift-version', type=int, metavar='N',
105+
parser.add_argument('-swift-version', metavar='N',
106106
help='the Swift version to use')
107107
parser.add_argument('-show-overlay', action='store_true',
108108
help='Show overlay API in addition to Objective-C ' +
@@ -326,7 +326,7 @@ def main():
326326
if args.enable_infer_import_as_member:
327327
extra_args = extra_args + ['-enable-infer-import-as-member']
328328
if args.swift_version:
329-
extra_args = extra_args + ['-swift-version', '%d' % args.swift_version]
329+
extra_args = extra_args + ['-swift-version', '%s' % args.swift_version]
330330

331331
# Create a .swift file we can feed into swift-ide-test
332332
subprocess.call(['touch', source_filename])

0 commit comments

Comments
 (0)