|
@@ -129,20 +129,20 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) {
|
|
if (DirName.empty())
|
|
if (DirName.empty())
|
|
return;
|
|
return;
|
|
|
|
|
|
- llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
|
|
|
|
- SeenDirEntries.GetOrCreateValue(DirName);
|
|
|
|
|
|
+ auto &NamedDirEnt =
|
|
|
|
+ *SeenDirEntries.insert(std::make_pair(DirName, nullptr)).first;
|
|
|
|
|
|
// When caching a virtual directory, we always cache its ancestors
|
|
// When caching a virtual directory, we always cache its ancestors
|
|
// at the same time. Therefore, if DirName is already in the cache,
|
|
// at the same time. Therefore, if DirName is already in the cache,
|
|
// we don't need to recurse as its ancestors must also already be in
|
|
// we don't need to recurse as its ancestors must also already be in
|
|
// the cache.
|
|
// the cache.
|
|
- if (NamedDirEnt.getValue())
|
|
|
|
|
|
+ if (NamedDirEnt.second)
|
|
return;
|
|
return;
|
|
|
|
|
|
// Add the virtual directory to the cache.
|
|
// Add the virtual directory to the cache.
|
|
DirectoryEntry *UDE = new DirectoryEntry;
|
|
DirectoryEntry *UDE = new DirectoryEntry;
|
|
- UDE->Name = NamedDirEnt.getKeyData();
|
|
|
|
- NamedDirEnt.setValue(UDE);
|
|
|
|
|
|
+ UDE->Name = NamedDirEnt.first().data();
|
|
|
|
+ NamedDirEnt.second = UDE;
|
|
VirtualDirectoryEntries.push_back(UDE);
|
|
VirtualDirectoryEntries.push_back(UDE);
|
|
|
|
|
|
// Recursively add the other ancestors.
|
|
// Recursively add the other ancestors.
|
|
@@ -170,23 +170,23 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
|
|
#endif
|
|
#endif
|
|
|
|
|
|
++NumDirLookups;
|
|
++NumDirLookups;
|
|
- llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
|
|
|
|
- SeenDirEntries.GetOrCreateValue(DirName);
|
|
|
|
|
|
+ auto &NamedDirEnt =
|
|
|
|
+ *SeenDirEntries.insert(std::make_pair(DirName, nullptr)).first;
|
|
|
|
|
|
// See if there was already an entry in the map. Note that the map
|
|
// See if there was already an entry in the map. Note that the map
|
|
// contains both virtual and real directories.
|
|
// contains both virtual and real directories.
|
|
- if (NamedDirEnt.getValue())
|
|
|
|
- return NamedDirEnt.getValue() == NON_EXISTENT_DIR ? nullptr
|
|
|
|
- : NamedDirEnt.getValue();
|
|
|
|
|
|
+ if (NamedDirEnt.second)
|
|
|
|
+ return NamedDirEnt.second == NON_EXISTENT_DIR ? nullptr
|
|
|
|
+ : NamedDirEnt.second;
|
|
|
|
|
|
++NumDirCacheMisses;
|
|
++NumDirCacheMisses;
|
|
|
|
|
|
// By default, initialize it to invalid.
|
|
// By default, initialize it to invalid.
|
|
- NamedDirEnt.setValue(NON_EXISTENT_DIR);
|
|
|
|
|
|
+ NamedDirEnt.second = NON_EXISTENT_DIR;
|
|
|
|
|
|
// Get the null-terminated directory name as stored as the key of the
|
|
// Get the null-terminated directory name as stored as the key of the
|
|
// SeenDirEntries map.
|
|
// SeenDirEntries map.
|
|
- const char *InterndDirName = NamedDirEnt.getKeyData();
|
|
|
|
|
|
+ const char *InterndDirName = NamedDirEnt.first().data();
|
|
|
|
|
|
// Check to see if the directory exists.
|
|
// Check to see if the directory exists.
|
|
FileData Data;
|
|
FileData Data;
|
|
@@ -203,7 +203,7 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
|
|
// Windows).
|
|
// Windows).
|
|
DirectoryEntry &UDE = UniqueRealDirs[Data.UniqueID];
|
|
DirectoryEntry &UDE = UniqueRealDirs[Data.UniqueID];
|
|
|
|
|
|
- NamedDirEnt.setValue(&UDE);
|
|
|
|
|
|
+ NamedDirEnt.second = &UDE;
|
|
if (!UDE.getName()) {
|
|
if (!UDE.getName()) {
|
|
// We don't have this directory yet, add it. We use the string
|
|
// We don't have this directory yet, add it. We use the string
|
|
// key from the SeenDirEntries map as the string.
|
|
// key from the SeenDirEntries map as the string.
|
|
@@ -218,22 +218,22 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
|
|
++NumFileLookups;
|
|
++NumFileLookups;
|
|
|
|
|
|
// See if there is already an entry in the map.
|
|
// See if there is already an entry in the map.
|
|
- llvm::StringMapEntry<FileEntry *> &NamedFileEnt =
|
|
|
|
- SeenFileEntries.GetOrCreateValue(Filename);
|
|
|
|
|
|
+ auto &NamedFileEnt =
|
|
|
|
+ *SeenFileEntries.insert(std::make_pair(Filename, nullptr)).first;
|
|
|
|
|
|
// See if there is already an entry in the map.
|
|
// See if there is already an entry in the map.
|
|
- if (NamedFileEnt.getValue())
|
|
|
|
- return NamedFileEnt.getValue() == NON_EXISTENT_FILE
|
|
|
|
- ? nullptr : NamedFileEnt.getValue();
|
|
|
|
|
|
+ if (NamedFileEnt.second)
|
|
|
|
+ return NamedFileEnt.second == NON_EXISTENT_FILE ? nullptr
|
|
|
|
+ : NamedFileEnt.second;
|
|
|
|
|
|
++NumFileCacheMisses;
|
|
++NumFileCacheMisses;
|
|
|
|
|
|
// By default, initialize it to invalid.
|
|
// By default, initialize it to invalid.
|
|
- NamedFileEnt.setValue(NON_EXISTENT_FILE);
|
|
|
|
|
|
+ NamedFileEnt.second = NON_EXISTENT_FILE;
|
|
|
|
|
|
// Get the null-terminated file name as stored as the key of the
|
|
// Get the null-terminated file name as stored as the key of the
|
|
// SeenFileEntries map.
|
|
// SeenFileEntries map.
|
|
- const char *InterndFileName = NamedFileEnt.getKeyData();
|
|
|
|
|
|
+ const char *InterndFileName = NamedFileEnt.first().data();
|
|
|
|
|
|
// Look up the directory for the file. When looking up something like
|
|
// Look up the directory for the file. When looking up something like
|
|
// sys/foo.h we'll discover all of the search directories that have a 'sys'
|
|
// sys/foo.h we'll discover all of the search directories that have a 'sys'
|
|
@@ -269,18 +269,19 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
|
|
// This occurs when one dir is symlinked to another, for example.
|
|
// This occurs when one dir is symlinked to another, for example.
|
|
FileEntry &UFE = UniqueRealFiles[Data.UniqueID];
|
|
FileEntry &UFE = UniqueRealFiles[Data.UniqueID];
|
|
|
|
|
|
- NamedFileEnt.setValue(&UFE);
|
|
|
|
|
|
+ NamedFileEnt.second = &UFE;
|
|
|
|
|
|
// If the name returned by getStatValue is different than Filename, re-intern
|
|
// If the name returned by getStatValue is different than Filename, re-intern
|
|
// the name.
|
|
// the name.
|
|
if (Data.Name != Filename) {
|
|
if (Data.Name != Filename) {
|
|
- auto &NamedFileEnt = SeenFileEntries.GetOrCreateValue(Data.Name);
|
|
|
|
- if (!NamedFileEnt.getValue())
|
|
|
|
- NamedFileEnt.setValue(&UFE);
|
|
|
|
|
|
+ auto &NamedFileEnt =
|
|
|
|
+ *SeenFileEntries.insert(std::make_pair(Data.Name, nullptr)).first;
|
|
|
|
+ if (!NamedFileEnt.second)
|
|
|
|
+ NamedFileEnt.second = &UFE;
|
|
else
|
|
else
|
|
- assert(NamedFileEnt.getValue() == &UFE &&
|
|
|
|
|
|
+ assert(NamedFileEnt.second == &UFE &&
|
|
"filename from getStatValue() refers to wrong file");
|
|
"filename from getStatValue() refers to wrong file");
|
|
- InterndFileName = NamedFileEnt.getKeyData();
|
|
|
|
|
|
+ InterndFileName = NamedFileEnt.first().data();
|
|
}
|
|
}
|
|
|
|
|
|
if (UFE.isValid()) { // Already have an entry with this inode, return it.
|
|
if (UFE.isValid()) { // Already have an entry with this inode, return it.
|
|
@@ -324,17 +325,17 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
|
|
++NumFileLookups;
|
|
++NumFileLookups;
|
|
|
|
|
|
// See if there is already an entry in the map.
|
|
// See if there is already an entry in the map.
|
|
- llvm::StringMapEntry<FileEntry *> &NamedFileEnt =
|
|
|
|
- SeenFileEntries.GetOrCreateValue(Filename);
|
|
|
|
|
|
+ auto &NamedFileEnt =
|
|
|
|
+ *SeenFileEntries.insert(std::make_pair(Filename, nullptr)).first;
|
|
|
|
|
|
// See if there is already an entry in the map.
|
|
// See if there is already an entry in the map.
|
|
- if (NamedFileEnt.getValue() && NamedFileEnt.getValue() != NON_EXISTENT_FILE)
|
|
|
|
- return NamedFileEnt.getValue();
|
|
|
|
|
|
+ if (NamedFileEnt.second && NamedFileEnt.second != NON_EXISTENT_FILE)
|
|
|
|
+ return NamedFileEnt.second;
|
|
|
|
|
|
++NumFileCacheMisses;
|
|
++NumFileCacheMisses;
|
|
|
|
|
|
// By default, initialize it to invalid.
|
|
// By default, initialize it to invalid.
|
|
- NamedFileEnt.setValue(NON_EXISTENT_FILE);
|
|
|
|
|
|
+ NamedFileEnt.second = NON_EXISTENT_FILE;
|
|
|
|
|
|
addAncestorsAsVirtualDirs(Filename);
|
|
addAncestorsAsVirtualDirs(Filename);
|
|
FileEntry *UFE = nullptr;
|
|
FileEntry *UFE = nullptr;
|
|
@@ -349,13 +350,13 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
|
|
|
|
|
|
// Check to see if the file exists. If so, drop the virtual file
|
|
// Check to see if the file exists. If so, drop the virtual file
|
|
FileData Data;
|
|
FileData Data;
|
|
- const char *InterndFileName = NamedFileEnt.getKeyData();
|
|
|
|
|
|
+ const char *InterndFileName = NamedFileEnt.first().data();
|
|
if (getStatValue(InterndFileName, Data, true, nullptr) == 0) {
|
|
if (getStatValue(InterndFileName, Data, true, nullptr) == 0) {
|
|
Data.Size = Size;
|
|
Data.Size = Size;
|
|
Data.ModTime = ModificationTime;
|
|
Data.ModTime = ModificationTime;
|
|
UFE = &UniqueRealFiles[Data.UniqueID];
|
|
UFE = &UniqueRealFiles[Data.UniqueID];
|
|
|
|
|
|
- NamedFileEnt.setValue(UFE);
|
|
|
|
|
|
+ NamedFileEnt.second = UFE;
|
|
|
|
|
|
// If we had already opened this file, close it now so we don't
|
|
// If we had already opened this file, close it now so we don't
|
|
// leak the descriptor. We're not going to use the file
|
|
// leak the descriptor. We're not going to use the file
|
|
@@ -375,7 +376,7 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
|
|
if (!UFE) {
|
|
if (!UFE) {
|
|
UFE = new FileEntry();
|
|
UFE = new FileEntry();
|
|
VirtualFileEntries.push_back(UFE);
|
|
VirtualFileEntries.push_back(UFE);
|
|
- NamedFileEnt.setValue(UFE);
|
|
|
|
|
|
+ NamedFileEnt.second = UFE;
|
|
}
|
|
}
|
|
|
|
|
|
UFE->Name = InterndFileName;
|
|
UFE->Name = InterndFileName;
|