jansvoboda11 created this revision. jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman. jansvoboda11 added a project: clang. jansvoboda11 requested review of this revision.
This patch normalizes paths in `DependencyScanningWorkerFilesystem` so that lookup of ignored files and cached file entries works correctly on Windows (where `/` and `\` are equivalent). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D106064 Files: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -128,11 +128,11 @@ // Add any filenames that were explicity passed in the build settings and // that might be opened, as we want to ensure we don't run source // minimization on them. - DepFS->IgnoredFiles.clear(); + DepFS->clearIgnoredFiles(); for (const auto &Entry : CI.getHeaderSearchOpts().UserEntries) - DepFS->IgnoredFiles.insert(Entry.Path); + DepFS->ignoreFile(Entry.Path); for (const auto &Entry : CI.getHeaderSearchOpts().VFSOverlayFiles) - DepFS->IgnoredFiles.insert(Entry); + DepFS->ignoreFile(Entry); // Support for virtual file system overlays on top of the caching // filesystem. Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -149,9 +149,18 @@ return shouldMinimize(Filename); // Only cache stat failures on source files. } +void DependencyScanningWorkerFilesystem::ignoreFile(StringRef RawFilename) { + llvm::SmallString<256> Filename; + llvm::sys::path::native(RawFilename, Filename); + IgnoredFiles.insert(Filename); +} + llvm::ErrorOr<const CachedFileSystemEntry *> DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry( - const StringRef Filename) { + const StringRef RawFilename) { + llvm::SmallString<256> Filename; + llvm::sys::path::native(RawFilename, Filename); + if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) { return Entry; } Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h =================================================================== --- clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h +++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h @@ -153,8 +153,8 @@ llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> openFileForRead(const Twine &Path) override; - /// The set of files that should not be minimized. - llvm::StringSet<> IgnoredFiles; + void clearIgnoredFiles() { IgnoredFiles.clear(); } + void ignoreFile(StringRef Filename); private: void setCachedEntry(StringRef Filename, const CachedFileSystemEntry *Entry) { @@ -179,6 +179,8 @@ /// excluded conditional directive skip mappings that are used by the /// currently active preprocessor. ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings; + /// The set of files that should not be minimized. + llvm::StringSet<> IgnoredFiles; }; } // end namespace dependencies
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -128,11 +128,11 @@ // Add any filenames that were explicity passed in the build settings and // that might be opened, as we want to ensure we don't run source // minimization on them. - DepFS->IgnoredFiles.clear(); + DepFS->clearIgnoredFiles(); for (const auto &Entry : CI.getHeaderSearchOpts().UserEntries) - DepFS->IgnoredFiles.insert(Entry.Path); + DepFS->ignoreFile(Entry.Path); for (const auto &Entry : CI.getHeaderSearchOpts().VFSOverlayFiles) - DepFS->IgnoredFiles.insert(Entry); + DepFS->ignoreFile(Entry); // Support for virtual file system overlays on top of the caching // filesystem. Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -149,9 +149,18 @@ return shouldMinimize(Filename); // Only cache stat failures on source files. } +void DependencyScanningWorkerFilesystem::ignoreFile(StringRef RawFilename) { + llvm::SmallString<256> Filename; + llvm::sys::path::native(RawFilename, Filename); + IgnoredFiles.insert(Filename); +} + llvm::ErrorOr<const CachedFileSystemEntry *> DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry( - const StringRef Filename) { + const StringRef RawFilename) { + llvm::SmallString<256> Filename; + llvm::sys::path::native(RawFilename, Filename); + if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) { return Entry; } Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h =================================================================== --- clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h +++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h @@ -153,8 +153,8 @@ llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> openFileForRead(const Twine &Path) override; - /// The set of files that should not be minimized. - llvm::StringSet<> IgnoredFiles; + void clearIgnoredFiles() { IgnoredFiles.clear(); } + void ignoreFile(StringRef Filename); private: void setCachedEntry(StringRef Filename, const CachedFileSystemEntry *Entry) { @@ -179,6 +179,8 @@ /// excluded conditional directive skip mappings that are used by the /// currently active preprocessor. ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings; + /// The set of files that should not be minimized. + llvm::StringSet<> IgnoredFiles; }; } // end namespace dependencies
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits