r355368 - Replace clang::FileData with llvm::vfs::Status
Author: harlanhaskins Date: Mon Mar 4 18:27:12 2019 New Revision: 355368 URL: http://llvm.org/viewvc/llvm-project?rev=355368&view=rev Log: Replace clang::FileData with llvm::vfs::Status Summary: FileData was only ever used as a container for the values in llvm::vfs::Status, so they might as well be consolidated. The `InPCH` member was also always set to false, and unused. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58924 Modified: cfe/trunk/include/clang/Basic/FileManager.h cfe/trunk/include/clang/Basic/FileSystemStatCache.h cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Basic/FileSystemStatCache.cpp cfe/trunk/lib/Frontend/TextDiagnostic.cpp cfe/trunk/unittests/Basic/FileManagerTest.cpp Modified: cfe/trunk/include/clang/Basic/FileManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=355368&r1=355367&r2=355368&view=diff == --- cfe/trunk/include/clang/Basic/FileManager.h (original) +++ cfe/trunk/include/clang/Basic/FileManager.h Mon Mar 4 18:27:12 2019 @@ -67,7 +67,6 @@ class FileEntry { unsigned UID; // A unique (small) ID for the file. llvm::sys::fs::UniqueID UniqueID; bool IsNamedPipe; - bool InPCH; bool IsValid; // Is this \c FileEntry initialized and valid? /// The open file, if it is owned by the \p FileEntry. @@ -75,7 +74,7 @@ class FileEntry { public: FileEntry() - : UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false) + : UniqueID(0, 0), IsNamedPipe(false), IsValid(false) {} FileEntry(const FileEntry &) = delete; @@ -87,7 +86,6 @@ public: off_t getSize() const { return Size; } unsigned getUID() const { return UID; } const llvm::sys::fs::UniqueID &getUniqueID() const { return UniqueID; } - bool isInPCH() const { return InPCH; } time_t getModificationTime() const { return ModTime; } /// Return the directory the file lives in. @@ -108,8 +106,6 @@ public: bool isOpenForTests() const { return File != nullptr; } }; -struct FileData; - /// Implements support for file system lookup, file system caching, /// and directory search management. /// @@ -168,7 +164,7 @@ class FileManager : public RefCountedBas // Caching. std::unique_ptr StatCache; - bool getStatValue(StringRef Path, FileData &Data, bool isFile, + bool getStatValue(StringRef Path, llvm::vfs::Status &Status, bool isFile, std::unique_ptr *F); /// Add all ancestors of the given path (pointing to either a file Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=355368&r1=355367&r2=355368&view=diff == --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original) +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Mon Mar 4 18:27:12 2019 @@ -19,40 +19,15 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include #include #include #include #include -namespace llvm { - -namespace vfs { - -class File; -class FileSystem; - -} // namespace vfs -} // namespace llvm - namespace clang { -// FIXME: should probably replace this with vfs::Status -struct FileData { - std::string Name; - uint64_t Size = 0; - time_t ModTime = 0; - llvm::sys::fs::UniqueID UniqueID; - bool IsDirectory = false; - bool IsNamedPipe = false; - bool InPCH = false; - - // FIXME: remove this when files support multiple names - bool IsVFSMapped = false; - - FileData() = default; -}; - /// Abstract interface for introducing a FileManager cache for 'stat' /// system calls, which is used by precompiled and pretokenized headers to /// improve performance. @@ -80,7 +55,7 @@ public: /// success for directories (not files). On a successful file lookup, the /// implementation can optionally fill in \p F with a valid \p File object and /// the client guarantees that it will close it. - static bool get(StringRef Path, FileData &Data, bool isFile, + static bool get(StringRef Path, llvm::vfs::Status &Status, bool isFile, std::unique_ptr *F, FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS); @@ -88,7 +63,8 @@ protected: // FIXME: The pointer here is a non-owning/optional reference to the // unique_ptr. Optional&> might be nicer, but // Optional needs some work to support references so this isn't possible yet. - virtual LookupResult getStat(StringRef Path, FileData &Data, bool isFile, + virtual LookupResult getStat(StringRef Path, llvm::vfs::Status &Status, + bool isFile, std::unique_ptr *F,
r358509 - [FileSystemStatCache] Return std::error_code from stat cache methods
Author: harlanhaskins Date: Tue Apr 16 10:34:26 2019 New Revision: 358509 URL: http://llvm.org/viewvc/llvm-project?rev=358509&view=rev Log: [FileSystemStatCache] Return std::error_code from stat cache methods Summary: Previously, we would return true/false signifying if the cache/lookup succeeded or failed. Instead, provide clients with the underlying error that was thrown while attempting to look up in the cache. Since clang::FileManager doesn't make use of this information, it discards the error that's received and casts away to bool. This change is NFC. Reviewers: benlangmuir, arphaman Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60735 Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Basic/FileSystemStatCache.cpp Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=358509&r1=358508&r2=358509&view=diff == --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original) +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Apr 16 10:34:26 2019 @@ -37,14 +37,6 @@ class FileSystemStatCache { public: virtual ~FileSystemStatCache() = default; - enum LookupResult { -/// We know the file exists and its cached stat data. -CacheExists, - -/// We know that the file doesn't exist. -CacheMissing - }; - /// Get the 'stat' information for the specified path, using the cache /// to accelerate it if possible. /// @@ -55,18 +47,19 @@ public: /// success for directories (not files). On a successful file lookup, the /// implementation can optionally fill in \p F with a valid \p File object and /// the client guarantees that it will close it. - static bool get(StringRef Path, llvm::vfs::Status &Status, bool isFile, - std::unique_ptr *F, - FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS); + static std::error_code + get(StringRef Path, llvm::vfs::Status &Status, bool isFile, + std::unique_ptr *F, + FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS); protected: // FIXME: The pointer here is a non-owning/optional reference to the // unique_ptr. Optional&> might be nicer, but // Optional needs some work to support references so this isn't possible yet. - virtual LookupResult getStat(StringRef Path, llvm::vfs::Status &Status, - bool isFile, - std::unique_ptr *F, - llvm::vfs::FileSystem &FS) = 0; + virtual std::error_code getStat(StringRef Path, llvm::vfs::Status &Status, + bool isFile, + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) = 0; }; /// A stat "cache" that can be used by FileManager to keep @@ -84,9 +77,10 @@ public: iterator begin() const { return StatCalls.begin(); } iterator end() const { return StatCalls.end(); } - LookupResult getStat(StringRef Path, llvm::vfs::Status &Status, bool isFile, - std::unique_ptr *F, - llvm::vfs::FileSystem &FS) override; + std::error_code getStat(StringRef Path, llvm::vfs::Status &Status, + bool isFile, + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override; }; } // namespace clang Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=358509&r1=358508&r2=358509&view=diff == --- cfe/trunk/lib/Basic/FileManager.cpp (original) +++ cfe/trunk/lib/Basic/FileManager.cpp Tue Apr 16 10:34:26 2019 @@ -429,13 +429,14 @@ bool FileManager::getStatValue(StringRef // FIXME: FileSystemOpts shouldn't be passed in here, all paths should be // absolute! if (FileSystemOpts.WorkingDir.empty()) -return FileSystemStatCache::get(Path, Status, isFile, F,StatCache.get(), *FS); +return bool(FileSystemStatCache::get(Path, Status, isFile, F, + StatCache.get(), *FS)); SmallString<128> FilePath(Path); FixupRelativePath(FilePath); - return FileSystemStatCache::get(FilePath.c_str(), Status, isFile, F, - StatCache.get(), *FS); + return bool(FileSystemStatCache::get(FilePath.c_str(), Status, isFile, F, + StatCache.get(), *FS)); } bool FileManager::getNoncachedStatValue(StringRef Path, Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=358509&r1=358508&r2=358509&view=diff =
r358511 - [FileSystemStatCache] Update test for new FileSystemStatCache API
Author: harlanhaskins Date: Tue Apr 16 11:00:43 2019 New Revision: 358511 URL: http://llvm.org/viewvc/llvm-project?rev=358511&view=rev Log: [FileSystemStatCache] Update test for new FileSystemStatCache API Summary: Update this test to return std::error_code instead of LookupResult. Reviewers: arphaman Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60786 Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=358511&r1=358510&r2=358511&view=diff == --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original) +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Tue Apr 16 11:00:43 2019 @@ -57,9 +57,10 @@ public: } // Implement FileSystemStatCache::getStat(). - LookupResult getStat(StringRef Path, llvm::vfs::Status &Status, bool isFile, - std::unique_ptr *F, - llvm::vfs::FileSystem &FS) override { + std::error_code getStat(StringRef Path, llvm::vfs::Status &Status, + bool isFile, + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override { #ifndef _WIN32 SmallString<128> NormalizedPath(Path); llvm::sys::path::native(NormalizedPath); @@ -68,10 +69,10 @@ public: if (StatCalls.count(Path) != 0) { Status = StatCalls[Path]; - return CacheExists; + return std::error_code(); } -return CacheMissing; // This means the file/directory doesn't exist. +return std::make_error_code(std::errc::no_such_file_or_directory); } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r367615 - [clang] Adopt llvm::ErrorOr in FileManager methods
Author: harlanhaskins Date: Thu Aug 1 14:31:49 2019 New Revision: 367615 URL: http://llvm.org/viewvc/llvm-project?rev=367615&view=rev Log: [clang] Adopt llvm::ErrorOr in FileManager methods Previously, the FileManager would use NULL returns to signify whether a file existed, but that doesn’t cover permissions issues or anything else that might occur while trying to stat or read a file. Instead, convert getFile and getDirectory into returning llvm::ErrorOr Signed-off-by: Harlan Haskins Modified: cfe/trunk/include/clang/Basic/FileManager.h cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/unittests/Basic/FileManagerTest.cpp Modified: cfe/trunk/include/clang/Basic/FileManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=367615&r1=367614&r2=367615&view=diff == --- cfe/trunk/include/clang/Basic/FileManager.h (original) +++ cfe/trunk/include/clang/Basic/FileManager.h Thu Aug 1 14:31:49 2019 @@ -132,20 +132,24 @@ class FileManager : public RefCountedBas SmallVector, 4> VirtualFileEntries; /// A cache that maps paths to directory entries (either real or - /// virtual) we have looked up + /// virtual) we have looked up, or an error that occurred when we looked up + /// the directory. /// /// The actual Entries for real directories/files are /// owned by UniqueRealDirs/UniqueRealFiles above, while the Entries /// for virtual directories/files are owned by /// VirtualDirectoryEntries/VirtualFileEntries above. /// - llvm::StringMap SeenDirEntries; + llvm::StringMap, llvm::BumpPtrAllocator> + SeenDirEntries; /// A cache that maps paths to file entries (either real or - /// virtual) we have looked up. + /// virtual) we have looked up, or an error that occurred when we looked up + /// the file. /// /// \see SeenDirEntries - llvm::StringMap SeenFileEntries; + llvm::StringMap, llvm::BumpPtrAllocator> + SeenFileEntries; /// The canonical names of directories. llvm::DenseMap CanonicalDirNames; @@ -164,8 +168,9 @@ class FileManager : public RefCountedBas // Caching. std::unique_ptr StatCache; - bool getStatValue(StringRef Path, llvm::vfs::Status &Status, bool isFile, -std::unique_ptr *F); + std::error_code getStatValue(StringRef Path, llvm::vfs::Status &Status, + bool isFile, + std::unique_ptr *F); /// Add all ancestors of the given path (pointing to either a file /// or a directory) as virtual directories. @@ -198,24 +203,27 @@ public: /// Lookup, cache, and verify the specified directory (real or /// virtual). /// - /// This returns NULL if the directory doesn't exist. + /// This returns a \c std::error_code if there was an error reading the + /// directory. If there is no error, the DirectoryEntry is guaranteed to be + /// non-NULL. /// /// \param CacheFailure If true and the file does not exist, we'll cache /// the failure to find this file. - const DirectoryEntry *getDirectory(StringRef DirName, - bool CacheFailure = true); + llvm::ErrorOr + getDirectory(StringRef DirName, bool CacheFailure = true); /// Lookup, cache, and verify the specified file (real or /// virtual). /// - /// This returns NULL if the file doesn't exist. + /// This returns a \c std::error_code if there was an error loading the file. + /// If there is no error, the FileEntry is guaranteed to be non-NULL. /// /// \param OpenFile if true and the file exists, it will be opened. /// /// \param CacheFailure If true and the file does not exist, we'll cache /// the failure to find this file. - const FileEntry *getFile(StringRef Filename, bool OpenFile = false, - bool CacheFailure = true); + llvm::ErrorOr + getFile(StringRef Filename, bool OpenFile = false, bool CacheFailure = true); /// Returns the current file system options FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } @@ -243,8 +251,9 @@ public: /// If the path is relative, it will be resolved against the WorkingDir of the /// FileManager's FileSystemOptions. /// - /// \returns false on success, true on error. - bool getNoncachedStatValue(StringRef Path, llvm::vfs::Status &Result); + /// \returns a \c std::error_code describing an error, if there was one + std::error_code getNoncachedStatValue(StringRef Path, +llvm::vfs::Status &Result); /// Remove the real file \p Entry from the cache. void invalidateCache(const FileEntry *Entry); Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=367615&r1=367614&r2=367615&view=diff == --- cfe/trunk/lib/Basic/FileManager.cp
r367616 - [clang] Adopt new FileManager error-returning APIs
Author: harlanhaskins Date: Thu Aug 1 14:31:56 2019 New Revision: 367616 URL: http://llvm.org/viewvc/llvm-project?rev=367616&view=rev Log: [clang] Adopt new FileManager error-returning APIs Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods. Signed-off-by: Harlan Haskins Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp cfe/trunk/lib/ARCMigrate/ObjCMT.cpp cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/Basic/Module.cpp cfe/trunk/lib/Basic/SourceManager.cpp cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/lib/Frontend/InitHeaderSearch.cpp cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp cfe/trunk/lib/Frontend/TextDiagnostic.cpp cfe/trunk/lib/Lex/HeaderMap.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Lex/ModuleMap.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PPLexerChange.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp cfe/trunk/lib/Serialization/ModuleManager.cpp cfe/trunk/lib/Tooling/Core/Replacement.cpp cfe/trunk/lib/Tooling/Refactoring.cpp cfe/trunk/tools/clang-format/ClangFormat.cpp cfe/trunk/tools/clang-import-test/clang-import-test.cpp cfe/trunk/tools/clang-refactor/ClangRefactor.cpp cfe/trunk/tools/clang-refactor/TestSupport.cpp cfe/trunk/tools/clang-rename/ClangRename.cpp cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/Indexing.cpp cfe/trunk/unittests/Basic/FileManagerTest.cpp cfe/trunk/unittests/Lex/HeaderSearchTest.cpp cfe/trunk/unittests/Lex/PPCallbacksTest.cpp cfe/trunk/unittests/Tooling/RefactoringTest.cpp cfe/trunk/unittests/Tooling/RewriterTestContext.h Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=367616&r1=367615&r2=367616&view=diff == --- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original) +++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Thu Aug 1 14:31:56 2019 @@ -78,26 +78,26 @@ bool FileRemapper::initFromFile(StringRe Diag); StringRef toFilename = lines[idx+2]; -const FileEntry *origFE = FileMgr->getFile(fromFilename); +llvm::ErrorOr origFE = FileMgr->getFile(fromFilename); if (!origFE) { if (ignoreIfFilesChanged) continue; return report("File does not exist: " + fromFilename, Diag); } -const FileEntry *newFE = FileMgr->getFile(toFilename); +llvm::ErrorOr newFE = FileMgr->getFile(toFilename); if (!newFE) { if (ignoreIfFilesChanged) continue; return report("File does not exist: " + toFilename, Diag); } -if ((uint64_t)origFE->getModificationTime() != timeModified) { +if ((uint64_t)(*origFE)->getModificationTime() != timeModified) { if (ignoreIfFilesChanged) continue; return report("File was modified: " + fromFilename, Diag); } -pairs.push_back(std::make_pair(origFE, newFE)); +pairs.push_back(std::make_pair(*origFE, *newFE)); } for (unsigned i = 0, e = pairs.size(); i != e; ++i) @@ -152,9 +152,11 @@ bool FileRemapper::flushToFile(StringRef newOut.write(mem->getBufferStart(), mem->getBufferSize()); newOut.close(); - const FileEntry *newE = FileMgr->getFile(tempPath); - remap(origFE, newE); - infoOut << newE->getName() << '\n'; + auto newE = FileMgr->getFile(tempPath); + if (newE) { +remap(origFE, *newE); +infoOut << (*newE)->getName() << '\n'; + } } } @@ -224,7 +226,9 @@ void FileRemapper::remap(const FileEntry } const FileEntry *FileRemapper::getOriginalFile(StringRef filePath) { - const FileEntry *file = FileMgr->getFile(filePath); + const FileEntry *file = nullptr; + if (auto fileOrErr = FileMgr->getFile(filePath)) +file = *fileOrErr; // If we are updating a file that overridden an original file, // actually update the original file. llvm::DenseMap::iterator Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=367616&r1=367615&r2=367616&view=diff == --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original) +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Aug 1 14:31:56 2019 @@ -2141,10 +2141,11 @@ private: StringRef Val = ValueString->getValue(ValueStorage); if (Key == "file") { -const FileEntry *FE = FileMgr.getFile(Val); -if (!FE) +auto FE = FileMgr.getFile(Val); +if (FE) + Entry.File = *FE; +else
[clang-tools-extra] r367617 - [clang-tools-extra] Adopt FileManager's error-returning APIs
Author: harlanhaskins Date: Thu Aug 1 14:32:01 2019 New Revision: 367617 URL: http://llvm.org/viewvc/llvm-project?rev=367617&view=rev Log: [clang-tools-extra] Adopt FileManager's error-returning APIs The FileManager has been updated to return llvm::ErrorOr from getFile and getDirectory, this commit updates all the callers of those APIs from clang. Modified: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp clang-tools-extra/trunk/clang-change-namespace/tool/ClangChangeNamespace.cpp clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/clang-move/Move.cpp clang-tools-extra/trunk/clang-move/tool/ClangMove.cpp clang-tools-extra/trunk/clang-reorder-fields/tool/ClangReorderFields.cpp clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/SourceCode.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Modified: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=367617&r1=367616&r2=367617&view=diff == --- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp (original) +++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp Thu Aug 1 14:32:01 2019 @@ -151,13 +151,13 @@ groupReplacements(const TUReplacements & auto AddToGroup = [&](const tooling::Replacement &R, bool FromDiag) { // Use the file manager to deduplicate paths. FileEntries are // automatically canonicalized. -if (const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath())) { +if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) { if (FromDiag) { -auto &Replaces = DiagReplacements[Entry]; +auto &Replaces = DiagReplacements[*Entry]; if (!Replaces.insert(R).second) return; } - GroupedReplacements[Entry].push_back(R); + GroupedReplacements[*Entry].push_back(R); } else if (Warned.insert(R.getFilePath()).second) { errs() << "Described file '" << R.getFilePath() << "' doesn't exist. Ignoring...\n"; Modified: clang-tools-extra/trunk/clang-change-namespace/tool/ClangChangeNamespace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-change-namespace/tool/ClangChangeNamespace.cpp?rev=367617&r1=367616&r2=367617&view=diff == --- clang-tools-extra/trunk/clang-change-namespace/tool/ClangChangeNamespace.cpp (original) +++ clang-tools-extra/trunk/clang-change-namespace/tool/ClangChangeNamespace.cpp Thu Aug 1 14:32:01 2019 @@ -147,8 +147,8 @@ int main(int argc, const char **argv) { for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) { OS << " {\n"; OS << "\"FilePath\": \"" << *I << "\",\n"; -const auto *Entry = FileMgr.getFile(*I); -auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User); +const auto Entry = FileMgr.getFile(*I); +auto ID = Sources.getOrCreateFileID(*Entry, SrcMgr::C_User); std::string Content; llvm::raw_string_ostream ContentStream(Content); Rewrite.getEditBuffer(ID).write(ContentStream); @@ -165,9 +165,9 @@ int main(int argc, const char **argv) { } for (const auto &File : ChangedFiles) { -const auto *Entry = FileMgr.getFile(File); +const auto Entry = FileMgr.getFile(File); -auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User); +auto ID = Sources.getOrCreateFileID(*Entry, SrcMgr::C_User); outs() << "== " << File << " ==\n"; Rewrite.getEditBuffer(ID).write(llvm::outs()); outs() << "\n\n"; Modified: clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp?rev=367617&r1=367616&r2=367617&view=diff == --- clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/clang-include-fixer/IncludeFixer.cpp Thu Aug 1 14:32:01 2019 @@ -306,8 +306,7 @@ std::string IncludeFixerSemaSource::mini // Get the FileEntry for the include. StringRef StrippedInclude = Include.trim("\"<>"); - const FileEntry *Entry = - SourceManager.getFileManager().getFile(StrippedInclude); + auto Entry = SourceManager.getFileManager().getFile(StrippedInclude); // If the file doesn't exist return the path from the database. // FIXME: This should nev
r367620 - Fix use-after-move in ClangBasicTests
Author: harlanhaskins Date: Thu Aug 1 14:50:16 2019 New Revision: 367620 URL: http://llvm.org/viewvc/llvm-project?rev=367620&view=rev Log: Fix use-after-move in ClangBasicTests Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=367620&r1=367619&r2=367620&view=diff == --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original) +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Aug 1 14:50:16 2019 @@ -212,6 +212,7 @@ TEST_F(FileManagerTest, getFileReturnsEr auto statCache = llvm::make_unique(); statCache->InjectDirectory(".", 41); statCache->InjectFile("foo.cpp", 42); + statCache->InjectDirectory("MyDirectory", 49); manager.setStatCache(std::move(statCache)); // Create a virtual bar.cpp file. @@ -221,7 +222,6 @@ TEST_F(FileManagerTest, getFileReturnsEr ASSERT_FALSE(file); ASSERT_EQ(file.getError(), std::errc::no_such_file_or_directory); - statCache->InjectDirectory("MyDirectory", 49); auto readingDirAsFile = manager.getFile("MyDirectory"); ASSERT_FALSE(readingDirAsFile); ASSERT_EQ(readingDirAsFile.getError(), std::errc::is_a_directory); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r367622 - Fix Windows branch of FileManagerTest changes
Author: harlanhaskins Date: Thu Aug 1 14:58:56 2019 New Revision: 367622 URL: http://llvm.org/viewvc/llvm-project?rev=367622&view=rev Log: Fix Windows branch of FileManagerTest changes Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=367622&r1=367621&r2=367622&view=diff == --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original) +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Aug 1 14:58:56 2019 @@ -163,7 +163,7 @@ TEST_F(FileManagerTest, getFileReturnsVa file = manager.getFile(FileName); ASSERT_TRUE(file); - dir = file->getDir(); + dir = (*file)->getDir(); ASSERT_TRUE(dir != NULL); EXPECT_EQ(DirName, dir->getName()); #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits