Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -35,6 +35,7 @@ #include "clang/Serialization/GlobalModuleIndex.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/CrashRecoveryContext.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" @@ -50,6 +51,8 @@ #include #include +#define DEBUG_TYPE "module-compilerinstance" + using namespace clang; CompilerInstance::CompilerInstance( @@ -924,6 +927,7 @@ SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName) { + DEBUG(llvm::dbgs() << "In compileModuleImpl: " << ModuleFileName << '\n';); ModuleMap &ModMap = ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap(); @@ -1451,6 +1455,9 @@ std::string ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module); + DEBUG(llvm::dbgs() << "In loadModule: " << ModuleName + << " we find the Module then ModuleFileName " + << ModuleFileName << '\n';); if (ModuleFileName.empty()) { if (Module->HasIncompatibleModuleFile) { // We tried and failed to load a module file for this module. Fall Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -49,6 +49,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Compression.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -60,6 +61,8 @@ #include #include +#define DEBUG_TYPE "module-astreader" + using namespace clang; using namespace clang::serialization; using namespace clang::serialization::reader; @@ -364,6 +367,8 @@ if (Complain) Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror=" + Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str(); + DEBUG(llvm::dbgs() << "In checkDiagnosticGroupMappings: DiagID " + << Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str() << '\n';); return true; } } @@ -390,6 +395,9 @@ if (StoredDiags.getSuppressSystemWarnings()) { if (Complain) Diags.Report(diag::err_pch_diagopt_mismatch) << "-Wsystem-headers"; + DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: suppress system warnings" + << ": IsSystem " + << IsSystem << '\n';); return true; } } @@ -397,6 +405,9 @@ if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) { if (Complain) Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror"; + DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: warnings as errors" + << ": IsSystem " + << IsSystem << '\n';); return true; } @@ -404,6 +415,9 @@ !StoredDiags.getEnableAllWarnings()) { if (Complain) Diags.Report(diag::err_pch_diagopt_mismatch) << "-Weverything -Werror"; + DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: enable all warnings" + << ": IsSystem " + << IsSystem << '\n';); return true; } @@ -411,6 +425,9 @@ !isExtHandlingFromDiagsError(StoredDiags)) { if (Complain) Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors"; + DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: pedantic-errors" + << ": IsSystem " + << IsSystem << '\n';); return true; } @@ -2138,8 +2155,12 @@ case DIAGNOSTIC_OPTIONS: { bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0; if (!AllowCompatibleConfigurationMismatch && - ParseDiagnosticOptions(Record, Complain, Listener)) + ParseDiagnosticOptions(Record, Complain, Listener)) { + DEBUG(llvm::dbgs() << "In ReadOptionsBlock: we return OutOfDate" + << ": client " + << ClientLoadCapabilities << '\n';); return OutOfDate; + } break; } @@ -2218,8 +2239,12 @@ for (unsigned I = 0; I < N; ++I) { InputFile IF = getInputFile(F, I+1, Complain); - if (!IF.getFile() || IF.isOutOfDate()) + if (!IF.getFile() || IF.isOutOfDate()) { + DEBUG(llvm::dbgs() << "In ReadControlBlock: we return OutOfDate" + << ": " << F.FileName << " client " + << ClientLoadCapabilities << '\n';); return OutOfDate; + } } } @@ -2280,8 +2305,12 @@ // If we can't load the module, exit early since we likely // will rebuild the module anyway. The stream may be in the // middle of a block. - if (Result != Success) + if (Result != Success) { + DEBUG(llvm::dbgs() << "In ReadControlBlock: ReadOptionsBlock returns " << Result + << ": " << F.FileName << " client " + << ClientLoadCapabilities << '\n';); return Result; + } } else if (Stream.SkipBlock()) { Error("malformed block record in AST file"); return Failure; @@ -2377,7 +2406,12 @@ case Failure: return Failure; // If we have to ignore the dependency, we'll have to ignore this too. case Missing: - case OutOfDate: return OutOfDate; + case OutOfDate: { + DEBUG(llvm::dbgs() << "In ReadControlBlock: ReadASTCore returns " << Result + << ": " << F.FileName << " client " + << ClientLoadCapabilities << '\n';); + return OutOfDate; + } case VersionMismatch: return VersionMismatch; case ConfigurationMismatch: return ConfigurationMismatch; case HadErrors: return HadErrors; @@ -2424,6 +2458,10 @@ if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) Diag(diag::err_imported_module_relocated) << F.ModuleName << Blob << M->Directory->getName(); + DEBUG(llvm::dbgs() << "In ReadControlBlock: due to module " + << "directory, we return OutOfDate: " + << F.FileName << " client " + << ClientLoadCapabilities << '\n';); return OutOfDate; } } @@ -2436,8 +2474,12 @@ case MODULE_MAP_FILE: if (ASTReadResult Result = - ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities)) + ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities)) { + DEBUG(llvm::dbgs() << "In ReadControlBlock: ReadModuleMapFileBlock returns " << Result + << ": " << F.FileName << " client " + << ClientLoadCapabilities << '\n';); return Result; + } break; case INPUT_FILE_OFFSETS: @@ -3485,6 +3527,9 @@ // Defer any pending actions until we get to the end of reading the AST file. Deserializing AnASTFile(this); + DEBUG(llvm::dbgs() << "In ReadAST: " << FileName << " client " + << ClientLoadCapabilities << '\n';); + // Bump the generation number. unsigned PreviousGeneration = incrementGeneration(Context); @@ -3514,6 +3559,9 @@ // to be out-of-date. Just remove it. GlobalIndex.reset(); ModuleMgr.setGlobalIndex(nullptr); + DEBUG(llvm::dbgs() << "In ReadAST: ReadASTCore returns " << ReadResult + << ": " << FileName << " client " + << ClientLoadCapabilities << '\n';); return ReadResult; } case Success: @@ -3529,13 +3577,21 @@ ModuleFile &F = *M->Mod; // Read the AST block. - if (ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities)) + if (ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities)) { + DEBUG(llvm::dbgs() << "In ReadAST: ReadASTBlock returns " << Result + << ": " << FileName << " client " + << ClientLoadCapabilities << '\n';); return Result; + } // Read the extension blocks. while (!SkipCursorToBlock(F.Stream, EXTENSION_BLOCK_ID)) { - if (ASTReadResult Result = ReadExtensionBlock(F)) + if (ASTReadResult Result = ReadExtensionBlock(F)) { + DEBUG(llvm::dbgs() << "In ReadAST: ReadExtensionBlock returns " << Result + << ": " << FileName << " client " + << ClientLoadCapabilities << '\n';); return Result; + } } // Once read, set the ModuleFile bit base offset and update the size in @@ -3761,8 +3817,12 @@ case ModuleManager::OutOfDate: // We couldn't load the module file because it is out-of-date. If the // client can handle out-of-date, return it. - if (ClientLoadCapabilities & ARR_OutOfDate) + if (ClientLoadCapabilities & ARR_OutOfDate) { + DEBUG(llvm::dbgs() << "In ReadASTCore: addModule returns " << AddResult + << ": " << FileName << " client " + << ClientLoadCapabilities << '\n';); return OutOfDate; + } // Otherwise, return an error. Diag(diag::err_module_file_out_of_date) << moduleKindForDiagnostic(Type) @@ -3824,13 +3884,21 @@ if (Result != OutOfDate || (ClientLoadCapabilities & ARR_OutOfDate) == 0) Diag(diag::err_module_file_not_module) << FileName; + DEBUG(llvm::dbgs() << "In ReadASTCore: ReadControlBlock returns Success but module " + << "name is empty : " << FileName << " client " + << ClientLoadCapabilities << '\n';); return Result; } break; case Failure: return Failure; case Missing: return Missing; - case OutOfDate: return OutOfDate; + case OutOfDate: { + DEBUG(llvm::dbgs() << "In ReadASTCore: ReadControlBlock returns OutOfDate" + << ": " << FileName << " client " + << ClientLoadCapabilities << '\n';); + return OutOfDate; + } case VersionMismatch: return VersionMismatch; case ConfigurationMismatch: return ConfigurationMismatch; case HadErrors: return HadErrors; @@ -4596,6 +4664,9 @@ else if (CurrentModule->getUmbrellaDir().Entry != Umbrella) { if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) Error("mismatched umbrella directories in submodule"); + DEBUG(llvm::dbgs() << "In ReadSubmoduleBlock: we return OutOfDate" + << ": " << F.FileName << " client " + << ClientLoadCapabilities << '\n';); return OutOfDate; } } Index: lib/Serialization/ASTWriter.cpp =================================================================== --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -51,6 +51,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Bitcode/BitstreamWriter.h" #include "llvm/Support/Compression.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -62,6 +63,8 @@ #include #include +#define DEBUG_TYPE "module-astwriter" + using namespace clang; using namespace clang::serialization; @@ -4113,6 +4116,7 @@ uint64_t ASTWriter::WriteAST(Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors) { + DEBUG(llvm::dbgs() << "In WriteAST: " << OutputFile << '\n';); WritingAST = true; ASTHasCompilerErrors = hasErrors; Index: lib/Serialization/ModuleManager.cpp =================================================================== --- lib/Serialization/ModuleManager.cpp +++ lib/Serialization/ModuleManager.cpp @@ -16,6 +16,7 @@ #include "clang/Lex/ModuleMap.h" #include "clang/Serialization/GlobalModuleIndex.h" #include "clang/Serialization/ModuleManager.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -25,6 +26,8 @@ #include "llvm/Support/GraphWriter.h" #endif +#define DEBUG_TYPE "module-manager" + using namespace clang; using namespace serialization; @@ -76,6 +79,8 @@ } if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) { ErrorStr = "module file out of date"; + DEBUG(llvm::dbgs() << "In addModule: size or modtime mismatch " + << FileName << '\n';); return OutOfDate; } @@ -169,6 +174,8 @@ assert(ImportedBy); delete ModuleEntry; } + DEBUG(llvm::dbgs() << "In addModule: signature mismatch " + << FileName << '\n';); return OutOfDate; } }