Skip to content

Commit 6f46362

Browse files
committed
[Stats] Improve stats tracing readability a little.
1 parent 677491f commit 6f46362

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/AST/Decl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5677,6 +5677,10 @@ struct DeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
56775677
const Decl *D = static_cast<const Decl *>(Entity);
56785678
if (auto const *VD = dyn_cast<const ValueDecl>(D)) {
56795679
VD->getFullName().print(OS, false);
5680+
} else {
5681+
OS << "<"
5682+
<< Decl::getDescriptiveKindName(D->getDescriptiveKind())
5683+
<< ">";
56805684
}
56815685
}
56825686
void traceLoc(const void *Entity, SourceManager *SM,

lib/ClangImporter/ImportDecl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8604,17 +8604,20 @@ struct ClangDeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
86048604
const clang::Decl *CD = static_cast<const clang::Decl *>(Entity);
86058605
if (auto const *ND = dyn_cast<const clang::NamedDecl>(CD)) {
86068606
ND->printName(OS);
8607+
} else {
8608+
OS << "<unnamed-clang-decl>";
86078609
}
86088610
}
86098611

8610-
static inline void printClangShortLoc(raw_ostream &OS,
8612+
static inline bool printClangShortLoc(raw_ostream &OS,
86118613
clang::SourceManager *CSM,
86128614
clang::SourceLocation L) {
86138615
if (!L.isValid() || !L.isFileID())
8614-
return;
8616+
return false;
86158617
auto PLoc = CSM->getPresumedLoc(L);
86168618
OS << llvm::sys::path::filename(PLoc.getFilename()) << ':' << PLoc.getLine()
86178619
<< ':' << PLoc.getColumn();
8620+
return true;
86188621
}
86198622

86208623
void traceLoc(const void *Entity, SourceManager *SM,
@@ -8624,8 +8627,8 @@ struct ClangDeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
86248627
if (CSM) {
86258628
const clang::Decl *CD = static_cast<const clang::Decl *>(Entity);
86268629
auto Range = CD->getSourceRange();
8627-
printClangShortLoc(OS, CSM, Range.getBegin());
8628-
OS << '-';
8630+
if (printClangShortLoc(OS, CSM, Range.getBegin()))
8631+
OS << '-';
86298632
printClangShortLoc(OS, CSM, Range.getEnd());
86308633
}
86318634
}

0 commit comments

Comments
 (0)