aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2019-08-22 18:15:50 +0000
committerAlex Lorenz <arphaman@gmail.com>2019-08-22 18:15:50 +0000
commit4dc5573acc0d2e7c59d8bac2543eb25cb4b32984 (patch)
tree79d7d47df40888fc8802d0f98f1dee747a10ff25 /clang/lib/Lex/HeaderMap.cpp
parent15ee5ba6e75759f5ca3d58f941fb6f8023741491 (diff)
downloadllvm-4dc5573acc0d2e7c59d8bac2543eb25cb4b32984.zip
llvm-4dc5573acc0d2e7c59d8bac2543eb25cb4b32984.tar.gz
llvm-4dc5573acc0d2e7c59d8bac2543eb25cb4b32984.tar.bz2
Introduce FileEntryRef and use it when handling includes to report correct dependencies
when the FileManager is reused across invocations This commit 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. In the case of a VFS with 'use-external-names', the FileEntyRef contains the external name of the file, not the filename that was used to access it. 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 follow-up commits. Differential Revision: https://reviews.llvm.org/D65907 llvm-svn: 369680
Diffstat (limited to 'clang/lib/Lex/HeaderMap.cpp')
-rw-r--r--clang/lib/Lex/HeaderMap.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index 7a46faf..1c7fb1a 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -196,17 +196,17 @@ LLVM_DUMP_METHOD void HeaderMapImpl::dump() const {
/// LookupFile - Check to see if the specified relative filename is located in
/// this HeaderMap. If so, open it and return its FileEntry.
-const FileEntry *HeaderMap::LookupFile(
- StringRef Filename, FileManager &FM) const {
+Optional<FileEntryRef> HeaderMap::LookupFile(StringRef Filename,
+ FileManager &FM) const {
SmallString<1024> Path;
StringRef Dest = HeaderMapImpl::lookupFilename(Filename, Path);
if (Dest.empty())
- return nullptr;
+ return None;
- if (auto File = FM.getFile(Dest))
+ if (auto File = FM.getFileRef(Dest))
return *File;
- return nullptr;
+ return None;
}
StringRef HeaderMapImpl::lookupFilename(StringRef Filename,