Skip to content

Commit ab57715

Browse files
committed
[Index] Remark on indexing system modules and use it in tests
1 parent 32c359f commit ab57715

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ ERROR(error_index_failed_status_check,none,
255255
"failed file status check: %0", (StringRef))
256256
ERROR(error_index_inputs_more_than_outputs,none,
257257
"index output filenames do not match input source files", ())
258+
REMARK(remark_indexing_system_module,none,
259+
"indexing system module at %0"
260+
"%select{|; skipping because of a broken swiftinterface}1",
261+
(StringRef, bool))
258262

259263
ERROR(error_wrong_number_of_arguments,none,
260264
"wrong number of '%0' arguments (expected %1, got %2)",

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ namespace swift {
216216

217217
/// Emit a remark after loading a module.
218218
bool EnableModuleLoadingRemarks = false;
219+
220+
/// Emit a remark when indexing a system module.
221+
bool EnableIndexingSystemModuleRemarks = false;
219222

220223
/// Emit a remark on early exit in explicit interface build
221224
bool EnableSkipExplicitInterfaceModuleBuildRemarks = false;

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ def remark_loading_module : Flag<["-"], "Rmodule-loading">,
343343
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
344344
HelpText<"Emit a remark and file path of each loaded module">;
345345

346+
def remark_indexing_system_module : Flag<["-"], "Rindexing-system-module">,
347+
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
348+
HelpText<"Emit a remark when indexing a system module">;
349+
346350
def remark_skip_explicit_interface_build : Flag<["-"], "Rskip-explicit-interface-build">,
347351
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
348352
HelpText<"Emit a remark if an explicit module interface invocation has an early exit because the expected output is up-to-date">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
822822

823823
Opts.EnableModuleLoadingRemarks = Args.hasArg(OPT_remark_loading_module);
824824

825+
Opts.EnableIndexingSystemModuleRemarks = Args.hasArg(OPT_remark_indexing_system_module);
826+
825827
Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg(OPT_remark_skip_explicit_interface_build);
826828

827829
llvm::Triple Target = Opts.Target;

lib/Index/IndexRecord.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ emitDataForSwiftSerializedModule(ModuleDecl *module,
530530
}
531531
}
532532

533+
if (module->getASTContext().LangOpts.EnableIndexingSystemModuleRemarks) {
534+
diags.diagnose(SourceLoc(),
535+
diag::remark_indexing_system_module,
536+
filename, skipIndexingModule);
537+
}
538+
533539
// FIXME: Would be useful for testing if swift had clang's -Rremark system so
534540
// we could output a remark here that we are going to create index data for
535541
// a module file.

test/Index/index_system_modules_swiftinterfaces.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@
4242
// RUN: %empty-directory(%t/idx)
4343
// RUN: %empty-directory(%t/modulecache)
4444
// RUN: echo "breaking_the_swifinterface" >> %t/SDK/Frameworks/SystemModule.framework/Modules/SystemModule.swiftmodule/%module-target-triple.swiftinterface
45+
4546
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
4647
// RUN: -index-system-modules \
4748
// RUN: -index-store-path %t/idx \
4849
// RUN: -index-ignore-stdlib \
4950
// RUN: -sdk %t/SDK \
5051
// RUN: -Fsystem %t/SDK/Frameworks \
5152
// RUN: -module-cache-path %t/modulecache \
53+
// RUN: -Rindexing-system-module \
5254
// RUN: %t/Client.swift \
53-
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD --allow-empty %s
55+
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD %s
5456

5557
/// We don't expect so see the swiftinterface error for indexing
58+
// BROKEN-BUILD: indexing system module {{.*}} skipping
5659
// BROKEN-BUILD-NOT: error
5760
// BROKEN-BUILD-NOT: breaking_the_swifinterface
5861

@@ -63,6 +66,18 @@
6366
// RUN: c-index-test core -print-record %t/idx | %FileCheck -check-prefix=BROKEN-RECORD %s
6467
// BROKEN-RECORD-NOT: function/Swift | systemFunc()
6568

69+
// RUN: %target-swift-frontend -typecheck -parse-stdlib \
70+
// RUN: -index-system-modules \
71+
// RUN: -index-store-path %t/idx \
72+
// RUN: -index-ignore-stdlib \
73+
// RUN: -sdk %t/SDK \
74+
// RUN: -Fsystem %t/SDK/Frameworks \
75+
// RUN: -module-cache-path %t/modulecache \
76+
// RUN: -Rindexing-system-module \
77+
// RUN: %t/Client.swift \
78+
// RUN: 2>&1 | %FileCheck -check-prefix=BROKEN-BUILD-2 --allow-empty %s
79+
// BROKEN-BUILD-2-NOT: indexing system module
80+
6681
//--- SecretModule.swift
6782
public struct SecretType {}
6883

0 commit comments

Comments
 (0)