Skip to content

Commit 97c0acc

Browse files
committed
Use whichever path ends up being shorter
1 parent 15c0a79 commit 97c0acc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clang/lib/Frontend/TextDiagnostic.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,12 @@ void TextDiagnostic::emitFilename(StringRef Filename, const SourceManager &SM) {
774774
#else
775775
CacheEntry = SM.getFileManager().getCanonicalName(*File);
776776
#endif
777+
778+
// In some cases, the resolved path may actually end up being longer (e.g.
779+
// if it was originally a relative path), so just retain whichever one
780+
// ends up being shorter.
781+
if (!DiagOpts.AbsolutePath && CacheEntry.size() > Filename.size())
782+
CacheEntry = Filename;
777783
}
778784
Filename = CacheEntry;
779785
}

0 commit comments

Comments
 (0)