manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.
This is a patch I applied internally to debug out-of-date issues. In general is
this the right way to add debugging messages in clang frontend?
https://reviews.llvm.org/D22638
Files:
lib/Frontend/CompilerInstance.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
lib/Serialization/ModuleManager.cpp
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;
}
}
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 , const std::string ,
Module *WritingModule, StringRef isysroot,
bool hasErrors) {
+ DEBUG(llvm::dbgs() << "In WriteAST: " << OutputFile << '\n';);
WritingAST = true;
ASTHasCompilerErrors = hasErrors;
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,27 +395,39 @@
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;
}
}
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;
}
if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
!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;
}
if (isExtHandlingFromDiagsError(Diags) &&
!isExtHandlingFromDiagsError(StoredDiags)) {
if (Complain)
Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors";
+DEBUG(llvm::dbgs()