Re: r283856 - Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)
This breaks MSVC 2013 builds: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/30238/steps/run%20tests/logs/stdio FAILED: tools/clang/lib/Frontend/CMakeFiles/clangFrontend.dir/CacheTokens.cpp.obj ... C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(63) : error C2620: '`anonymous-namespace'::PTHEntryKeyVariant::Path' : illegal union member; type 'llvm::StringRef' has a user-defined constructor or non-trivial default constructor C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(71) : error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member initialization: 'Path' is not a base or member C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(74) : error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member initialization: 'Path' is not a base or member C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(80) : error C2065: 'Path' : undeclared identifier On Tue, Oct 11, 2016 at 12:31 AM, Mehdi Amini via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: mehdi_amini > Date: Tue Oct 11 02:31:29 2016 > New Revision: 283856 > > URL: http://llvm.org/viewvc/llvm-project?rev=283856=rev > Log: > Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC) > > 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/CacheTokens.cpp > cfe/trunk/lib/Lex/HeaderSearch.cpp > cfe/trunk/lib/Lex/PTHLexer.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=283856=283855=283856=diff > > == > --- cfe/trunk/include/clang/Basic/FileManager.h (original) > +++ cfe/trunk/include/clang/Basic/FileManager.h Tue Oct 11 02:31:29 2016 > @@ -38,11 +38,10 @@ class FileSystemStatCache; > /// \brief Cached information about one directory (either on disk or in > /// the virtual file system). > class DirectoryEntry { > - const char *Name; // Name of the directory. > + StringRef Name; // Name of the directory. >friend class FileManager; > public: > - DirectoryEntry() : Name(nullptr) {} > - const char *getName() const { return Name; } > + StringRef getName() const { return Name; } > }; > > /// \brief Cached information about one file (either on disk > @@ -165,7 +164,7 @@ class FileManager : public RefCountedBas >// Caching. >std::unique_ptr StatCache; > > - bool getStatValue(const char *Path, FileData , bool isFile, > + bool getStatValue(StringRef Path, FileData , 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=283856=283855=283856=diff > > == > --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original) > +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Oct 11 > 02:31:29 2016 > @@ -68,7 +68,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(const char *Path, FileData , bool isFile, > + static bool get(StringRef Path, FileData , bool isFile, >std::unique_ptr *F, FileSystemStatCache > *Cache, >vfs::FileSystem ); > > @@ -92,11 +92,11 @@ protected: >// FIXME: The pointer here is a non-owning/optional reference to the >// unique_ptr. Optionalmight be nicer, but >// Optional needs some work to support references so this isn't > possible yet. > - virtual LookupResult getStat(const char *Path, FileData , bool > isFile, > + virtual LookupResult getStat(StringRef Path, FileData , bool > isFile, > std::unique_ptr *F, > vfs::FileSystem ) = 0; > > - LookupResult statChained(const char *Path, FileData , bool isFile, > + LookupResult statChained(StringRef Path, FileData , bool isFile, > std::unique_ptr *F, vfs::FileSystem > ) { > if (FileSystemStatCache *Next = getNextStatCache()) >return Next->getStat(Path, Data, isFile, F, FS); > @@ -121,7 +121,7 @@ public: >iterator begin() const { return StatCalls.begin(); } >iterator end() const { return StatCalls.end(); } > > - LookupResult getStat(const char *Path, FileData , bool isFile, > +
r283856 - Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)
Author: mehdi_amini Date: Tue Oct 11 02:31:29 2016 New Revision: 283856 URL: http://llvm.org/viewvc/llvm-project?rev=283856=rev Log: Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC) 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/CacheTokens.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Lex/PTHLexer.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=283856=283855=283856=diff == --- cfe/trunk/include/clang/Basic/FileManager.h (original) +++ cfe/trunk/include/clang/Basic/FileManager.h Tue Oct 11 02:31:29 2016 @@ -38,11 +38,10 @@ class FileSystemStatCache; /// \brief Cached information about one directory (either on disk or in /// the virtual file system). class DirectoryEntry { - const char *Name; // Name of the directory. + StringRef Name; // Name of the directory. friend class FileManager; public: - DirectoryEntry() : Name(nullptr) {} - const char *getName() const { return Name; } + StringRef getName() const { return Name; } }; /// \brief Cached information about one file (either on disk @@ -165,7 +164,7 @@ class FileManager : public RefCountedBas // Caching. std::unique_ptr StatCache; - bool getStatValue(const char *Path, FileData , bool isFile, + bool getStatValue(StringRef Path, FileData , 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=283856=283855=283856=diff == --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original) +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Oct 11 02:31:29 2016 @@ -68,7 +68,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(const char *Path, FileData , bool isFile, + static bool get(StringRef Path, FileData , bool isFile, std::unique_ptr *F, FileSystemStatCache *Cache, vfs::FileSystem ); @@ -92,11 +92,11 @@ protected: // FIXME: The pointer here is a non-owning/optional reference to the // unique_ptr. Optionalmight be nicer, but // Optional needs some work to support references so this isn't possible yet. - virtual LookupResult getStat(const char *Path, FileData , bool isFile, + virtual LookupResult getStat(StringRef Path, FileData , bool isFile, std::unique_ptr *F, vfs::FileSystem ) = 0; - LookupResult statChained(const char *Path, FileData , bool isFile, + LookupResult statChained(StringRef Path, FileData , bool isFile, std::unique_ptr *F, vfs::FileSystem ) { if (FileSystemStatCache *Next = getNextStatCache()) return Next->getStat(Path, Data, isFile, F, FS); @@ -121,7 +121,7 @@ public: iterator begin() const { return StatCalls.begin(); } iterator end() const { return StatCalls.end(); } - LookupResult getStat(const char *Path, FileData , bool isFile, + LookupResult getStat(StringRef Path, FileData , bool isFile, std::unique_ptr *F, vfs::FileSystem ) override; }; Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=283856=283855=283856=diff == --- cfe/trunk/lib/Basic/FileManager.cpp (original) +++ cfe/trunk/lib/Basic/FileManager.cpp Tue Oct 11 02:31:29 2016 @@ -140,7 +140,7 @@ void FileManager::addAncestorsAsVirtualD // Add the virtual directory to the cache. auto UDE = llvm::make_unique(); - UDE->Name = NamedDirEnt.first().data(); + UDE->Name = NamedDirEnt.first(); NamedDirEnt.second = UDE.get(); VirtualDirectoryEntries.push_back(std::move(UDE)); @@ -185,7 +185,7 @@ const DirectoryEntry *FileManager::getDi // Get the null-terminated directory name as stored as the key of the // SeenDirEntries map. - const char *InterndDirName = NamedDirEnt.first().data(); + StringRef InterndDirName = NamedDirEnt.first(); // Check to see if the directory exists. FileData Data; @@ -203,7 +203,7 @@ const DirectoryEntry *FileManager::getDi DirectoryEntry = UniqueRealDirs[Data.UniqueID];