<div dir="ltr">This breaks MSVC 2013 builds:<div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/30238/steps/run%20tests/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-windows/builds/30238/steps/run%20tests/logs/stdio</a><br></div><div><br></div><div>FAILED: tools/clang/lib/Frontend/CMakeFiles/clangFrontend.dir/CacheTokens.cpp.obj </div><div>...</div><div>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<br></div><div>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</div><div>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</div><div>C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(80) : error C2065: 'Path' : undeclared identifier</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 11, 2016 at 12:31 AM, Mehdi Amini via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br>
Date: Tue Oct 11 02:31:29 2016<br>
New Revision: 283856<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=283856&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=283856&view=rev</a><br>
Log:<br>
Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/<wbr>FileManager.h<br>
cfe/trunk/include/clang/Basic/<wbr>FileSystemStatCache.h<br>
cfe/trunk/lib/Basic/<wbr>FileManager.cpp<br>
cfe/trunk/lib/Basic/<wbr>FileSystemStatCache.cpp<br>
cfe/trunk/lib/Frontend/<wbr>CacheTokens.cpp<br>
cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp<br>
cfe/trunk/lib/Lex/PTHLexer.cpp<br>
cfe/trunk/unittests/Basic/<wbr>FileManagerTest.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>FileManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/FileManager.h?rev=<wbr>283856&r1=283855&r2=283856&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>FileManager.h (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>FileManager.h Tue Oct 11 02:31:29 2016<br>
@@ -38,11 +38,10 @@ class FileSystemStatCache;<br>
/// \brief Cached information about one directory (either on disk or in<br>
/// the virtual file system).<br>
class DirectoryEntry {<br>
- const char *Name; // Name of the directory.<br>
+ StringRef Name; // Name of the directory.<br>
friend class FileManager;<br>
public:<br>
- DirectoryEntry() : Name(nullptr) {}<br>
- const char *getName() const { return Name; }<br>
+ StringRef getName() const { return Name; }<br>
};<br>
<br>
/// \brief Cached information about one file (either on disk<br>
@@ -165,7 +164,7 @@ class FileManager : public RefCountedBas<br>
// Caching.<br>
std::unique_ptr<<wbr>FileSystemStatCache> StatCache;<br>
<br>
- bool getStatValue(const char *Path, FileData &Data, bool isFile,<br>
+ bool getStatValue(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F);<br>
<br>
/// Add all ancestors of the given path (pointing to either a file<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>FileSystemStatCache.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/<wbr>FileSystemStatCache.h?rev=<wbr>283856&r1=283855&r2=283856&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>FileSystemStatCache.h (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>FileSystemStatCache.h Tue Oct 11 02:31:29 2016<br>
@@ -68,7 +68,7 @@ public:<br>
/// success for directories (not files). On a successful file lookup, the<br>
/// implementation can optionally fill in \p F with a valid \p File object and<br>
/// the client guarantees that it will close it.<br>
- static bool get(const char *Path, FileData &Data, bool isFile,<br>
+ static bool get(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F, FileSystemStatCache *Cache,<br>
vfs::FileSystem &FS);<br>
<br>
@@ -92,11 +92,11 @@ protected:<br>
// FIXME: The pointer here is a non-owning/optional reference to the<br>
// unique_ptr. Optional<unique_ptr<vfs::File><wbr>&> might be nicer, but<br>
// Optional needs some work to support references so this isn't possible yet.<br>
- virtual LookupResult getStat(const char *Path, FileData &Data, bool isFile,<br>
+ virtual LookupResult getStat(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
vfs::FileSystem &FS) = 0;<br>
<br>
- LookupResult statChained(const char *Path, FileData &Data, bool isFile,<br>
+ LookupResult statChained(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {<br>
if (FileSystemStatCache *Next = getNextStatCache())<br>
return Next->getStat(Path, Data, isFile, F, FS);<br>
@@ -121,7 +121,7 @@ public:<br>
iterator begin() const { return StatCalls.begin(); }<br>
iterator end() const { return StatCalls.end(); }<br>
<br>
- LookupResult getStat(const char *Path, FileData &Data, bool isFile,<br>
+ LookupResult getStat(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
vfs::FileSystem &FS) override;<br>
};<br>
<br>
Modified: cfe/trunk/lib/Basic/<wbr>FileManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Basic/<wbr>FileManager.cpp?rev=283856&r1=<wbr>283855&r2=283856&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Basic/<wbr>FileManager.cpp (original)<br>
+++ cfe/trunk/lib/Basic/<wbr>FileManager.cpp Tue Oct 11 02:31:29 2016<br>
@@ -140,7 +140,7 @@ void FileManager::<wbr>addAncestorsAsVirtualD<br>
<br>
// Add the virtual directory to the cache.<br>
auto UDE = llvm::make_unique<<wbr>DirectoryEntry>();<br>
- UDE->Name = NamedDirEnt.first().data();<br>
+ UDE->Name = NamedDirEnt.first();<br>
NamedDirEnt.second = UDE.get();<br>
VirtualDirectoryEntries.push_<wbr>back(std::move(UDE));<br>
<br>
@@ -185,7 +185,7 @@ const DirectoryEntry *FileManager::getDi<br>
<br>
// Get the null-terminated directory name as stored as the key of the<br>
// SeenDirEntries map.<br>
- const char *InterndDirName = NamedDirEnt.first().data();<br>
+ StringRef InterndDirName = NamedDirEnt.first();<br>
<br>
// Check to see if the directory exists.<br>
FileData Data;<br>
@@ -203,7 +203,7 @@ const DirectoryEntry *FileManager::getDi<br>
DirectoryEntry &UDE = UniqueRealDirs[Data.UniqueID];<br>
<br>
NamedDirEnt.second = &UDE;<br>
- if (!UDE.getName()) {<br>
+ if (UDE.getName().empty()) {<br>
// We don't have this directory yet, add it. We use the string<br>
// key from the SeenDirEntries map as the string.<br>
UDE.Name = InterndDirName;<br>
@@ -232,7 +232,7 @@ const FileEntry *FileManager::getFile(St<br>
<br>
// Get the null-terminated file name as stored as the key of the<br>
// SeenFileEntries map.<br>
- const char *InterndFileName = NamedFileEnt.first().data();<br>
+ StringRef InterndFileName = NamedFileEnt.first();<br>
<br>
// Look up the directory for the file. When looking up something like<br>
// sys/foo.h we'll discover all of the search directories that have a 'sys'<br>
@@ -463,7 +463,7 @@ FileManager::getBufferForFile(<wbr>StringRef<br>
/// if the path points to a virtual file or does not exist, or returns<br>
/// false if it's an existent real file. If FileDescriptor is NULL,<br>
/// do directory look-up instead of file look-up.<br>
-bool FileManager::getStatValue(<wbr>const char *Path, FileData &Data, bool isFile,<br>
+bool FileManager::getStatValue(<wbr>StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F) {<br>
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be<br>
// absolute!<br>
@@ -535,7 +535,7 @@ StringRef FileManager::getCanonicalName(<br>
<br>
#ifdef LLVM_ON_UNIX<br>
char CanonicalNameBuf[PATH_MAX];<br>
- if (realpath(Dir->getName(), CanonicalNameBuf))<br>
+ if (realpath(Dir->getName().str()<wbr>.c_str(), CanonicalNameBuf))<br>
CanonicalName = StringRef(CanonicalNameBuf).<wbr>copy(CanonicalNameStorage);<br>
#else<br>
SmallString<256> CanonicalNameBuf(<wbr>CanonicalName);<br>
<br>
Modified: cfe/trunk/lib/Basic/<wbr>FileSystemStatCache.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Basic/<wbr>FileSystemStatCache.cpp?rev=<wbr>283856&r1=283855&r2=283856&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Basic/<wbr>FileSystemStatCache.cpp (original)<br>
+++ cfe/trunk/lib/Basic/<wbr>FileSystemStatCache.cpp Tue Oct 11 02:31:29 2016<br>
@@ -40,7 +40,7 @@ static void copyStatusToFileData(const v<br>
/// success for directories (not files). On a successful file lookup, the<br>
/// implementation can optionally fill in FileDescriptor with a valid<br>
/// descriptor and the client guarantees that it will close it.<br>
-bool FileSystemStatCache::get(const char *Path, FileData &Data, bool isFile,<br>
+bool FileSystemStatCache::get(<wbr>StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
FileSystemStatCache *Cache, vfs::FileSystem &FS) {<br>
LookupResult R;<br>
@@ -107,7 +107,7 @@ bool FileSystemStatCache::get(const char<br>
}<br>
<br>
MemorizeStatCalls::<wbr>LookupResult<br>
-MemorizeStatCalls::getStat(<wbr>const char *Path, FileData &Data, bool isFile,<br>
+MemorizeStatCalls::getStat(<wbr>StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {<br>
LookupResult Result = statChained(Path, Data, isFile, F, FS);<br>
<br>
<br>
Modified: cfe/trunk/lib/Frontend/<wbr>CacheTokens.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CacheTokens.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Frontend/CacheTokens.cpp?rev=<wbr>283856&r1=283855&r2=283856&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Frontend/<wbr>CacheTokens.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/<wbr>CacheTokens.cpp Tue Oct 11 02:31:29 2016<br>
@@ -58,18 +58,21 @@ public:<br>
<br>
<br>
class PTHEntryKeyVariant {<br>
- union { const FileEntry* FE; const char* Path; };<br>
+ union {<br>
+ const FileEntry *FE;<br>
+ StringRef Path;<br>
+ };<br>
enum { IsFE = 0x1, IsDE = 0x2, IsNoExist = 0x0 } Kind;<br>
FileData *Data;<br>
<br>
public:<br>
PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(nullptr) {}<br>
<br>
- PTHEntryKeyVariant(FileData *Data, const char *path)<br>
- : Path(path), Kind(IsDE), Data(new FileData(*Data)) {}<br>
+ PTHEntryKeyVariant(FileData *Data, StringRef Path)<br>
+ : Path(Path), Kind(IsDE), Data(new FileData(*Data)) {}<br>
<br>
- explicit PTHEntryKeyVariant(const char *path)<br>
- : Path(path), Kind(IsNoExist), Data(nullptr) {}<br>
+ explicit PTHEntryKeyVariant(StringRef Path)<br>
+ : Path(Path), Kind(IsNoExist), Data(nullptr) {}<br>
<br>
bool isFile() const { return Kind == IsFE; }<br>
<br>
@@ -549,7 +552,7 @@ public:<br>
StatListener(PTHMap &pm) : PM(pm) {}<br>
~StatListener() override {}<br>
<br>
- LookupResult getStat(const char *Path, FileData &Data, bool isFile,<br>
+ LookupResult getStat(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
vfs::FileSystem &FS) override {<br>
LookupResult Result = statChained(Path, Data, isFile, F, FS);<br>
<br>
Modified: cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp?rev=283856&<wbr>r1=283855&r2=283856&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp (original)<br>
+++ cfe/trunk/lib/Lex/<wbr>HeaderSearch.cpp Tue Oct 11 02:31:29 2016<br>
@@ -1461,7 +1461,7 @@ std::string HeaderSearch::suggestPathToF<br>
if (!SearchDirs[I].isNormalDir())<br>
continue;<br>
<br>
- const char *Dir = SearchDirs[I].getDir()-><wbr>getName();<br>
+ StringRef Dir = SearchDirs[I].getDir()-><wbr>getName();<br>
for (auto NI = llvm::sys::path::begin(Name),<br>
NE = llvm::sys::path::end(Name),<br>
DI = llvm::sys::path::begin(Dir),<br>
<br>
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Lex/<wbr>PTHLexer.cpp?rev=283856&r1=<wbr>283855&r2=283856&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Tue Oct 11 02:31:29 2016<br>
@@ -644,10 +644,10 @@ public:<br>
<br>
class PTHStatLookupTrait : public PTHFileLookupCommonTrait {<br>
public:<br>
- typedef const char* external_key_type; // const char*<br>
+ typedef StringRef external_key_type; // const char*<br>
typedef PTHStatData data_type;<br>
<br>
- static internal_key_type GetInternalKey(const char *path) {<br>
+ static internal_key_type GetInternalKey(StringRef path) {<br>
// The key 'kind' doesn't matter here because it is ignored in EqualKey.<br>
return std::make_pair((unsigned char) 0x0, path);<br>
}<br>
@@ -694,7 +694,7 @@ public:<br>
: Cache(FL.getNumBuckets(), FL.getNumEntries(), FL.getBuckets(),<br>
FL.getBase()) {}<br>
<br>
- LookupResult getStat(const char *Path, FileData &Data, bool isFile,<br>
+ LookupResult getStat(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
vfs::FileSystem &FS) override {<br>
// Do the lookup for the file's data in the PTH file.<br>
<br>
Modified: cfe/trunk/unittests/Basic/<wbr>FileManagerTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=283856&r1=283855&r2=283856&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/unittests/<wbr>Basic/FileManagerTest.cpp?rev=<wbr>283856&r1=283855&r2=283856&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/unittests/Basic/<wbr>FileManagerTest.cpp (original)<br>
+++ cfe/trunk/unittests/Basic/<wbr>FileManagerTest.cpp Tue Oct 11 02:31:29 2016<br>
@@ -52,7 +52,7 @@ public:<br>
}<br>
<br>
// Implement FileSystemStatCache::getStat()<wbr>.<br>
- LookupResult getStat(const char *Path, FileData &Data, bool isFile,<br>
+ LookupResult getStat(StringRef Path, FileData &Data, bool isFile,<br>
std::unique_ptr<vfs::File> *F,<br>
vfs::FileSystem &FS) override {<br>
if (StatCalls.count(Path) != 0) {<br>
@@ -82,14 +82,14 @@ TEST_F(FileManagerTest, getVirtualFileSe<br>
<br>
const DirectoryEntry *dir = file->getDir();<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ(".", dir->getName());<br>
+ EXPECT_EQ(".", dir->getName());<br>
<br>
file = manager.getVirtualFile("x/y/z.<wbr>cpp", 42, 0);<br>
ASSERT_TRUE(file != nullptr);<br>
<br>
dir = file->getDir();<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ("x/y", dir->getName());<br>
+ EXPECT_EQ("x/y", dir->getName());<br>
}<br>
<br>
// Before any virtual file is added, no virtual directory exists.<br>
@@ -115,11 +115,11 @@ TEST_F(FileManagerTest, getVirtualFileCr<br>
<br>
const DirectoryEntry *dir = manager.getDirectory("virtual/<wbr>dir");<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ("virtual/dir", dir->getName());<br>
+ EXPECT_EQ("virtual/dir", dir->getName());<br>
<br>
dir = manager.getDirectory("virtual"<wbr>);<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ("virtual", dir->getName());<br>
+ EXPECT_EQ("virtual", dir->getName());<br>
}<br>
<br>
// getFile() returns non-NULL if a real file exists at the given path.<br>
@@ -144,7 +144,7 @@ TEST_F(FileManagerTest, getFileReturnsVa<br>
<br>
const DirectoryEntry *dir = file->getDir();<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ("/tmp", dir->getName());<br>
+ EXPECT_EQ("/tmp", dir->getName());<br>
<br>
#ifdef LLVM_ON_WIN32<br>
file = manager.getFile(FileName);<br>
@@ -152,7 +152,7 @@ TEST_F(FileManagerTest, getFileReturnsVa<br>
<br>
dir = file->getDir();<br>
ASSERT_TRUE(dir != NULL);<br>
- EXPECT_STREQ(DirName, dir->getName());<br>
+ EXPECT_EQ(DirName, dir->getName());<br>
#endif<br>
}<br>
<br>
@@ -168,7 +168,7 @@ TEST_F(FileManagerTest, getFileReturnsVa<br>
<br>
const DirectoryEntry *dir = file->getDir();<br>
ASSERT_TRUE(dir != nullptr);<br>
- EXPECT_STREQ("virtual/dir", dir->getName());<br>
+ EXPECT_EQ("virtual/dir", dir->getName());<br>
}<br>
<br>
// getFile() returns different FileEntries for different paths when<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>