Skip to content

Commit 112490c

Browse files
authored
[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).
1 parent 8c2b4aa commit 112490c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/lib/StaticAnalyzer/Core/BugReporter.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ std::string timeTraceName(const BugReportEquivClass &EQ) {
299299
return ("Flushing EQC " + BT.getDescription()).str();
300300
}
301301

302-
llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) {
302+
llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ,
303+
const SourceManager &SM) {
303304
// Must be called only when constructing non-bogus TimeTraceScope
304305
assert(llvm::timeTraceProfilerEnabled());
305306

@@ -309,9 +310,7 @@ llvm::TimeTraceMetadata timeTraceMetadata(const BugReportEquivClass &EQ) {
309310
const BugReport *R = BugReports.front().get();
310311
const auto &BT = R->getBugType();
311312
auto Loc = R->getLocation().asLocation();
312-
std::string File = "";
313-
if (const auto *Entry = Loc.getFileEntry())
314-
File = Entry->tryGetRealPathName().str();
313+
std::string File = SM.getFilename(Loc).str();
315314
return {BT.getCheckerName().str(), std::move(File),
316315
static_cast<int>(Loc.getLineNumber())};
317316
}
@@ -3150,8 +3149,9 @@ BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass(
31503149
}
31513150

31523151
void BugReporter::FlushReport(BugReportEquivClass &EQ) {
3153-
llvm::TimeTraceScope TCS{timeTraceName(EQ),
3154-
[&EQ]() { return timeTraceMetadata(EQ); }};
3152+
llvm::TimeTraceScope TCS{timeTraceName(EQ), [&]() {
3153+
return timeTraceMetadata(EQ, getSourceManager());
3154+
}};
31553155
SmallVector<BugReport*, 10> bugReports;
31563156
BugReport *report = findReportInEquivalenceClass(EQ, bugReports);
31573157
if (!report)

0 commit comments

Comments
 (0)