[all-commits] [llvm/llvm-project] 874a5d: [clang] Processing real directories added as virtu...

Ivan Murashko via All-commits all-commits at lists.llvm.org
Tue May 21 23:47:32 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 874a5dab419240af0a02a3fc70accd926105aa31
      https://github.com/llvm/llvm-project/commit/874a5dab419240af0a02a3fc70accd926105aa31
  Author: Ivan Murashko <ivan.murashko at gmail.com>
  Date:   2024-05-22 (Wed, 22 May 2024)

  Changed paths:
    M clang/include/clang/Basic/FileManager.h
    M clang/lib/Basic/FileManager.cpp
    A clang/test/Modules/implicit-module-remap.cpp

  Log Message:
  -----------
  [clang] Processing real directories added as virtual ones (#91645)

The `FileManager` might create a virtual directory that can be used
later as a search path. This is the case when we use remapping, as
demonstrated in the suggested LIT test.

We might encounter a 'false cache miss' and add the same directory
twice into `FileManager::SeenDirEntries` if the added record is a real
directory that is present on a disk:
- Once as a virtual directory 
- And once as a real one

This isn't a problem if the added directories have the same name, as in
this case, we will get a cache hit. However, it could lead to
compilation errors if the directory names are different but point to the
same folder. For example, one might use an absolute name and another a
relative one. For instance, the **implicit-module-remap.cpp** LIT test
will fail with the following message:
```
/.../implicit-module-remap.cpp.tmp/test.cpp:1:2: fatal error: module 'a' 
was built in directory '/.../implicit-module-remap.cpp.tmp' but now 
resides in directory '.'
    1 | #include "a.h"
      |  ^
1 error generated.
```

The suggested fix checks if the added virtual directory is present on
the disk and handles it as a real one if that is the case.



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