diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-08-22 18:15:50 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-08-22 18:15:50 +0000 |
commit | 4dc5573acc0d2e7c59d8bac2543eb25cb4b32984 (patch) | |
tree | 79d7d47df40888fc8802d0f98f1dee747a10ff25 /clang/lib/Lex/Preprocessor.cpp | |
parent | 15ee5ba6e75759f5ca3d58f941fb6f8023741491 (diff) | |
download | bcm5719-llvm-4dc5573acc0d2e7c59d8bac2543eb25cb4b32984.tar.gz bcm5719-llvm-4dc5573acc0d2e7c59d8bac2543eb25cb4b32984.zip |
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/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 6579319cb3f..3abd0c76d0f 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -563,7 +563,7 @@ void Preprocessor::EnterMainSourceFile() { // Lookup and save the FileID for the through header. If it isn't found // in the search path, it's a fatal error. const DirectoryLookup *CurDir; - const FileEntry *File = LookupFile( + Optional<FileEntryRef> File = LookupFile( SourceLocation(), PPOpts->PCHThroughHeader, /*isAngled=*/false, /*FromDir=*/nullptr, /*FromFile=*/nullptr, CurDir, /*SearchPath=*/nullptr, /*RelativePath=*/nullptr, @@ -575,7 +575,7 @@ void Preprocessor::EnterMainSourceFile() { return; } setPCHThroughHeaderFileID( - SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User)); + SourceMgr.createFileID(*File, SourceLocation(), SrcMgr::C_User)); } // Skip tokens from the Predefines and if needed the main file. |