[all-commits] [llvm/llvm-project] e3e739: [Clang] [Diagnostics] Simplify filenames that cont...

Sirraide via All-commits all-commits at lists.llvm.org
Mon Jul 7 16:02:41 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e3e7393c4681f31cd3820fdda2831a3e004a48f5
      https://github.com/llvm/llvm-project/commit/e3e7393c4681f31cd3820fdda2831a3e004a48f5
  Author: Sirraide <aeternalmail at gmail.com>
  Date:   2025-07-08 (Tue, 08 Jul 2025)

  Changed paths:
    M clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
    M clang/include/clang/Basic/SourceManager.h
    M clang/lib/Basic/SourceManager.cpp
    M clang/lib/Frontend/SARIFDiagnostic.cpp
    M clang/lib/Frontend/TextDiagnostic.cpp
    M clang/test/Frontend/absolute-paths.c
    A clang/test/Frontend/simplify-paths.c

  Log Message:
  -----------
  [Clang] [Diagnostics] Simplify filenames that contain '..' (#143520)

This can significantly shorten file paths to standard library headers,
e.g. on my system, `<ranges>` is currently printed as
```console
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/ranges
```
but with this change, we instead print
```console
/usr/include/c++/15/ranges
```

This is of course just a heuristic; there are paths that would get longer
as a result of this, so we use whichever path ends up being shorter.

@AaronBallman pointed out that this might be problematic for network
file systems since path resolution might take a while, so this is enabled 
only for paths that are part of a local filesystem—though not on Windows
since there we noticed that the check itself is slow.

The file names are cached in `SourceManager`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list