[analyzer] Use getFileName and do not use realpath names (#126039)

The real paths resolves symlinks and makes the tests fail when the
filesystem is a symlink tree over a content-addressable storage (our
internal environment).
This commit is contained in:
Utkarsh Saxena 2025-02-06 11:15:20 +01:00 committed by GitHub
parent 8c2b4aa5a0
commit 112490ce04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -299,7 +299,8 @@ std::string timeTraceName(const BugReportEquivClass &EQ) {
return ("Flushing EQC " + BT.getDescription()).str();
}
llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) {
llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ,
const SourceManager &SM) {
// Must be called only when constructing non-bogus TimeTraceScope
assert(llvm::timeTraceProfilerEnabled());
@ -309,9 +310,7 @@ llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) {
const BugReport *R = BugReports.front().get();
const auto &BT = R->getBugType();
auto Loc = R->getLocation().asLocation();
std::string File = "";
if (const auto *Entry = Loc.getFileEntry())
File = Entry->tryGetRealPathName().str();
std::string File = SM.getFilename(Loc).str();
return {BT.getCheckerName().str(), std::move(File),
static_cast<int>(Loc.getLineNumber())};
}
@ -3150,8 +3149,9 @@ BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass(
}
void BugReporter::FlushReport(BugReportEquivClass &EQ) {
llvm::TimeTraceScope TCS{timeTraceName(EQ),
[&EQ]() { return timeTraceMetadata(EQ); }};
llvm::TimeTraceScope TCS{timeTraceName(EQ), [&]() {
return timeTraceMetadata(EQ, getSourceManager());
}};
SmallVector<BugReport*, 10> bugReports;
BugReport *report = findReportInEquivalenceClass(EQ, bugReports);
if (!report)