[PATCH] D65907: Introduce FileEntryRef and use it when handling includes to report correct dependencies when the FileManager is reused across invocations

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 14:29:55 PDT 2019


arphaman created this revision.
arphaman added reviewers: rsmith, bruno, Bigcheese, jkorous, harlanhaskins.
Herald added subscribers: dexonsmith, mgorny.
Herald added a project: clang.

This patch introduces a parallel API to FileManager's `getFile`: `getFileEntryRef`, which returns a reference to the `FileEntry`, and the name that was used to access the file.

The new API is adopted only in the HeaderSearch and Preprocessor for include file lookup, so that the accessed path can be propagated to SourceManager's `FileInfo`. SourceManager's `FileInfo` now can report this accessed path, using the new `getName` method. This API is then adopted in the dependency collector, which now correctly reports dependencies when a file is included both using a symlink and a real path in the case when the FileManager is reused across multiple Preprocessor invocations.

Note that this patch does not fix all dependency collector issues, as the same problem is still present in other cases when dependencies are obtained using `FileSkipped`, `InclusionDirective`, and `HasInclude`. This will be fixed in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65907

Files:
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/DependencyScannerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65907.213997.patch
Type: text/x-patch
Size: 68258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190807/d6f8bb9c/attachment-0001.bin>


More information about the cfe-commits mailing list