Skip to content

Commit 7c794aa

Browse files
committed
DO NOT MERGE: debug CI failure
1 parent 6707b6d commit 7c794aa

File tree

6 files changed

+40
-10
lines changed

6 files changed

+40
-10
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,9 +2290,13 @@ ClangImporter::Implementation::lookupModule(StringRef moduleName) {
22902290
return loadFromMM();
22912291
}
22922292

2293+
#define DEBUG_TYPE "foo"
22932294
ModuleDecl *ClangImporter::Implementation::loadModuleClang(
22942295
SourceLoc importLoc, ImportPath::Module path) {
22952296
auto realModuleName = SwiftContext.getRealModuleName(path.front().Item).str();
2297+
LLVM_DEBUG(llvm::dbgs() << "loadModuleClang '";
2298+
path.print(llvm::dbgs());
2299+
llvm::dbgs() << "'\n");
22962300

22972301
// Convert the Swift import path over to a Clang import path.
22982302
SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4>
@@ -2331,9 +2335,19 @@ ModuleDecl *ClangImporter::Implementation::loadModuleClang(
23312335
}
23322336

23332337
clang::SourceLocation clangImportLoc = getNextIncludeLoc();
2338+
LLVM_DEBUG(
2339+
llvm::dbgs() << "loading clang module '";
2340+
llvm::interleave(path, [](auto IdInfoPair) { llvm::dbgs() << IdInfoPair.first->getName(); },
2341+
[]() { llvm::dbgs() << "."; });
2342+
llvm::dbgs() << "'\n");
23342343
clang::ModuleLoadResult result =
23352344
Instance->loadModule(clangImportLoc, path, visibility,
23362345
/*IsInclusionDirective=*/false);
2346+
LLVM_DEBUG(
2347+
llvm::dbgs() << "loaded clang module '";
2348+
llvm::interleave(path, [](auto IdInfoPair) { llvm::dbgs() << IdInfoPair.first->getName(); },
2349+
[]() { llvm::dbgs() << "."; });
2350+
llvm::dbgs() << "'\n");
23372351

23382352
if (!preservedIndexStorePathOption.empty()) {
23392353
// Restore the -index-store-path option.
@@ -2395,9 +2409,10 @@ ClangImporter::loadModule(SourceLoc importLoc,
23952409
}
23962410

23972411
ModuleDecl *ClangImporter::Implementation::loadModule(
2398-
SourceLoc importLoc, ImportPath::Module path) {
2412+
SourceLoc importLoc, ImportPath::Module path, const std::string caller) {
23992413
ModuleDecl *MD = nullptr;
24002414
ASTContext &ctx = getNameImporter().getContext();
2415+
LLVM_DEBUG(llvm::dbgs() << "loadModule called from " << caller << "\n");
24012416

24022417
// `CxxStdlib` is the only accepted spelling of the C++ stdlib module name.
24032418
if (path.front().Item.is("std") ||
@@ -2419,6 +2434,7 @@ ModuleDecl *ClangImporter::Implementation::loadModule(
24192434
ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
24202435
const clang::Module *clangModule, SourceLoc importLoc) {
24212436
assert(clangModule);
2437+
LLVM_DEBUG(llvm::dbgs() << "finishLoadingClangModule\n");
24222438

24232439
// Bump the generation count.
24242440
bumpGeneration();
@@ -2464,6 +2480,7 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
24642480
SwiftContext.addLoadedModule(result);
24652481
}
24662482

2483+
LLVM_DEBUG(llvm::dbgs() << "finished loading clang module\n");
24672484
return result;
24682485
}
24692486

lib/ClangImporter/ImporterImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
882882
public:
883883
/// Load a module using either method.
884884
ModuleDecl *loadModule(SourceLoc importLoc,
885-
ImportPath::Module path);
885+
ImportPath::Module path, const std::string caller = __func__);
886886

887887
void recordImplicitUnwrapForDecl(ValueDecl *decl, bool isIUO) {
888888
if (!isIUO)

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3054,9 +3054,10 @@ ModuleDecl *ModuleFile::getModule(ModuleID MID) {
30543054
}
30553055

30563056
ModuleDecl *ModuleFile::getModule(ImportPath::Module name,
3057-
bool allowLoading) {
3057+
bool allowLoading, const std::string caller) {
30583058
if (name.empty() || name.front().Item.empty())
30593059
return getContext().TheBuiltinModule;
3060+
DEBUG_WITH_TYPE("foo", llvm::dbgs() << "getModule called from " << caller << "\n");
30603061

30613062
// FIXME: duplicated from ImportResolver::getModule
30623063
Identifier parentName = FileContext->getParentModule()->getName();

lib/Serialization/DeserializationErrors.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,19 +725,31 @@ class InavalidAvailabilityDomainError
725725
}
726726
};
727727

728+
#define DEBUG_TYPE "foo"
729+
728730
class PrettyStackTraceModuleFile : public llvm::PrettyStackTraceEntry {
729731
const char *Action;
730732
const ModuleFile &MF;
733+
const std::string caller;
731734
public:
732-
explicit PrettyStackTraceModuleFile(const char *action, ModuleFile &module)
733-
: Action(action), MF(module) {}
734-
explicit PrettyStackTraceModuleFile(ModuleFile &module)
735-
: PrettyStackTraceModuleFile("While reading from", module) {}
735+
explicit PrettyStackTraceModuleFile(const char *action, ModuleFile &module, std::string c = __func__)
736+
: Action(action), MF(module), caller(c) {
737+
LLVM_DEBUG(llvm::dbgs() << "start module read of ";
738+
MF.outputDiagnosticInfo(llvm::dbgs());
739+
llvm::dbgs() << " (called from " << c << ")\n");
740+
}
741+
explicit PrettyStackTraceModuleFile(ModuleFile &module, std::string caller = __func__)
742+
: PrettyStackTraceModuleFile("While reading from", module, caller) {}
736743

744+
~PrettyStackTraceModuleFile() {
745+
LLVM_DEBUG(llvm::dbgs() << "finish module read of ";
746+
MF.outputDiagnosticInfo(llvm::dbgs());
747+
llvm::dbgs() << " (called from " << caller << ")\n");
748+
}
737749
void print(raw_ostream &os) const override {
738750
os << Action << " ";
739751
MF.outputDiagnosticInfo(os);
740-
os << "\n";
752+
os << " (called from " << caller << ")\n";
741753
}
742754
};
743755

lib/Serialization/ModuleFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ class ModuleFile
10581058
///
10591059
/// If the name matches the name of the current module, a shadowed module
10601060
/// is loaded instead.
1061-
ModuleDecl *getModule(ImportPath::Module name, bool allowLoading = false);
1061+
ModuleDecl *getModule(ImportPath::Module name, bool allowLoading = false, std::string caller = __func__);
10621062

10631063
/// Returns the generic signature for the given ID.
10641064
GenericSignature getGenericSignature(serialization::GenericSignatureID ID);

test/Interop/Cxx/stdlib/std-span-interface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %S/Inputs -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=StdSpan -source-filename=x -enable-experimental-cxx-interop -Xcc -std=c++20 -module-cache-path %t > %t/interface.swift
2+
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -Xllvm -debug-only=foo -I %S/Inputs -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=StdSpan -source-filename=x -enable-experimental-cxx-interop -Xcc -std=c++20 -module-cache-path %t > %t/interface.swift
33
// RUN: %FileCheck %s < %t/interface.swift
44

55
// Make sure we trigger typechecking and SIL diagnostics

0 commit comments

Comments
 (0)