diff options
author | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-03-21 17:53:59 +0000 |
commit | 9cedb8bb69b89b0f0c529937247a6a80cabdbaec (patch) | |
tree | c978f0e9ec1ab92dc8123783f30b08a7fd1e2a39 /contrib/llvm/tools/clang/lib/Basic/FileManager.cpp | |
parent | 03fdc2934eb61c44c049a02b02aa974cfdd8a0eb (diff) | |
download | FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.zip FreeBSD-src-9cedb8bb69b89b0f0c529937247a6a80cabdbaec.tar.gz |
MFC 261991:
Upgrade our copy of llvm/clang to 3.4 release. This version supports
all of the features in the current working draft of the upcoming C++
standard, provisionally named C++1y.
The code generator's performance is greatly increased, and the loop
auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The
PowerPC backend has made several major improvements to code generation
quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ
backends have all seen major feature work.
Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.4/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html>
MFC 262121 (by emaste):
Update lldb for clang/llvm 3.4 import
This commit largely restores the lldb source to the upstream r196259
snapshot with the addition of threaded inferior support and a few bug
fixes.
Specific upstream lldb revisions restored include:
SVN git
181387 779e6ac
181703 7bef4e2
182099 b31044e
182650 f2dcf35
182683 0d91b80
183862 15c1774
183929 99447a6
184177 0b2934b
184948 4dc3761
184954 007e7bc
186990 eebd175
Sponsored by: DARPA, AFRL
MFC 262186 (by emaste):
Fix mismerge in r262121
A break statement was lost in the merge. The error had no functional
impact, but restore it to reduce the diff against upstream.
MFC 262303:
Pull in r197521 from upstream clang trunk (by rdivacky):
Use the integrated assembler by default on FreeBSD/ppc and ppc64.
Requested by: jhibbits
MFC 262611:
Pull in r196874 from upstream llvm trunk:
Fix a crash that occurs when PWD is invalid.
MCJIT needs to be able to run in hostile environments, even when PWD
is invalid. There's no need to crash MCJIT in this case.
The obvious fix is to simply leave MCContext's CompilationDir empty
when PWD can't be determined. This way, MCJIT clients,
and other clients that link with LLVM don't need a valid working directory.
If we do want to guarantee valid CompilationDir, that should be done
only for clients of getCompilationDir(). This is as simple as checking
for an empty string.
The only current use of getCompilationDir is EmitGenDwarfInfo, which
won't conceivably run with an invalid working dir. However, in the
purely hypothetically and untestable case that this happens, the
AT_comp_dir will be omitted from the compilation_unit DIE.
This should help fix assertions occurring with ports-mgmt/tinderbox,
when it is using jails, and sometimes invalidates clang's current
working directory.
Reported by: decke
MFC 262809:
Pull in r203007 from upstream clang trunk:
Don't produce an alias between destructors with different calling conventions.
Fixes pr19007.
(Please note that is an LLVM PR identifier, not a FreeBSD one.)
This should fix Firefox and/or libxul crashes (due to problems with
regparm/stdcall calling conventions) on i386.
Reported by: multiple users on freebsd-current
PR: bin/187103
MFC 263048:
Repair recognition of "CC" as an alias for the C++ compiler, since it
was silently broken by upstream for a Windows-specific use-case.
Apparently some versions of CMake still rely on this archaic feature...
Reported by: rakuco
MFC 263049:
Garbage collect the old way of adding the libstdc++ include directories
in clang's InitHeaderSearch.cpp. This has been superseded by David
Chisnall's commit in r255321.
Moreover, if libc++ is used, the libstdc++ include directories should
not be in the search path at all. These directories are now only used
if you pass -stdlib=libstdc++.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/FileManager.cpp | 149 |
1 files changed, 41 insertions, 108 deletions
diff --git a/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp b/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp index 9cc5902..af9b266 100644 --- a/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/FileManager.cpp @@ -63,91 +63,16 @@ FileEntry::~FileEntry() { if (FD != -1) ::close(FD); } -bool FileEntry::isNamedPipe() const { - return S_ISFIFO(FileMode); -} - -//===----------------------------------------------------------------------===// -// Windows. -//===----------------------------------------------------------------------===// - -#ifdef LLVM_ON_WIN32 - -namespace { - static std::string GetFullPath(const char *relPath) { - char *absPathStrPtr = _fullpath(NULL, relPath, 0); - assert(absPathStrPtr && "_fullpath() returned NULL!"); - - std::string absPath(absPathStrPtr); - - free(absPathStrPtr); - return absPath; - } -} - -class FileManager::UniqueDirContainer { - /// UniqueDirs - Cache from full path to existing directories/files. - /// - llvm::StringMap<DirectoryEntry> UniqueDirs; - -public: - /// getDirectory - Return an existing DirectoryEntry with the given - /// name if there is already one; otherwise create and return a - /// default-constructed DirectoryEntry. - DirectoryEntry &getDirectory(const char *Name, - const struct stat & /*StatBuf*/) { - std::string FullPath(GetFullPath(Name)); - return UniqueDirs.GetOrCreateValue(FullPath).getValue(); - } - - size_t size() const { return UniqueDirs.size(); } -}; - -class FileManager::UniqueFileContainer { - /// UniqueFiles - Cache from full path to existing directories/files. - /// - llvm::StringMap<FileEntry, llvm::BumpPtrAllocator> UniqueFiles; - -public: - /// getFile - Return an existing FileEntry with the given name if - /// there is already one; otherwise create and return a - /// default-constructed FileEntry. - FileEntry &getFile(const char *Name, const struct stat & /*StatBuf*/) { - std::string FullPath(GetFullPath(Name)); - - // Lowercase string because Windows filesystem is case insensitive. - FullPath = StringRef(FullPath).lower(); - return UniqueFiles.GetOrCreateValue(FullPath).getValue(); - } - - size_t size() const { return UniqueFiles.size(); } - - void erase(const FileEntry *Entry) { - std::string FullPath(GetFullPath(Entry->getName())); - - // Lowercase string because Windows filesystem is case insensitive. - FullPath = StringRef(FullPath).lower(); - UniqueFiles.erase(FullPath); - } -}; - -//===----------------------------------------------------------------------===// -// Unix-like Systems. -//===----------------------------------------------------------------------===// - -#else - class FileManager::UniqueDirContainer { /// UniqueDirs - Cache from ID's to existing directories/files. - std::map<std::pair<dev_t, ino_t>, DirectoryEntry> UniqueDirs; + std::map<llvm::sys::fs::UniqueID, DirectoryEntry> UniqueDirs; public: /// getDirectory - Return an existing DirectoryEntry with the given /// ID's if there is already one; otherwise create and return a /// default-constructed DirectoryEntry. - DirectoryEntry &getDirectory(const char * /*Name*/, - const struct stat &StatBuf) { - return UniqueDirs[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)]; + DirectoryEntry &getDirectory(const llvm::sys::fs::UniqueID &UniqueID) { + return UniqueDirs[UniqueID]; } size_t size() const { return UniqueDirs.size(); } @@ -161,12 +86,10 @@ public: /// getFile - Return an existing FileEntry with the given ID's if /// there is already one; otherwise create and return a /// default-constructed FileEntry. - FileEntry &getFile(const char * /*Name*/, const struct stat &StatBuf) { - return - const_cast<FileEntry&>( - *UniqueFiles.insert(FileEntry(StatBuf.st_dev, - StatBuf.st_ino, - StatBuf.st_mode)).first); + FileEntry &getFile(llvm::sys::fs::UniqueID UniqueID, bool IsNamedPipe, + bool InPCH) { + return const_cast<FileEntry &>( + *UniqueFiles.insert(FileEntry(UniqueID, IsNamedPipe, InPCH)).first); } size_t size() const { return UniqueFiles.size(); } @@ -174,8 +97,6 @@ public: void erase(const FileEntry *Entry) { UniqueFiles.erase(*Entry); } }; -#endif - //===----------------------------------------------------------------------===// // Common logic. //===----------------------------------------------------------------------===// @@ -292,6 +213,16 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName, DirName != llvm::sys::path::root_path(DirName) && llvm::sys::path::is_separator(DirName.back())) DirName = DirName.substr(0, DirName.size()-1); +#ifdef LLVM_ON_WIN32 + // Fixing a problem with "clang C:test.c" on Windows. + // Stat("C:") does not recognize "C:" as a valid directory + std::string DirNameStr; + if (DirName.size() > 1 && DirName.back() == ':' && + DirName.equals_lower(llvm::sys::path::root_name(DirName))) { + DirNameStr = DirName.str() + '.'; + DirName = DirNameStr; + } +#endif ++NumDirLookups; llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt = @@ -313,8 +244,8 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName, const char *InterndDirName = NamedDirEnt.getKeyData(); // Check to see if the directory exists. - struct stat StatBuf; - if (getStatValue(InterndDirName, StatBuf, false, 0/*directory lookup*/)) { + FileData Data; + if (getStatValue(InterndDirName, Data, false, 0 /*directory lookup*/)) { // There's no real directory at the given path. if (!CacheFailure) SeenDirEntries.erase(DirName); @@ -325,7 +256,8 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName, // same inode (this occurs on Unix-like systems when one dir is // symlinked to another, for example) or the same path (on // Windows). - DirectoryEntry &UDE = UniqueRealDirs.getDirectory(InterndDirName, StatBuf); + DirectoryEntry &UDE = + UniqueRealDirs.getDirectory(Data.UniqueID); NamedDirEnt.setValue(&UDE); if (!UDE.getName()) { @@ -378,8 +310,8 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, // Nope, there isn't. Check to see if the file exists. int FileDescriptor = -1; - struct stat StatBuf; - if (getStatValue(InterndFileName, StatBuf, true, + FileData Data; + if (getStatValue(InterndFileName, Data, true, openFile ? &FileDescriptor : 0)) { // There's no real file at the given path. if (!CacheFailure) @@ -395,7 +327,8 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, // It exists. See if we have already opened a file with the same inode. // This occurs when one dir is symlinked to another, for example. - FileEntry &UFE = UniqueRealFiles.getFile(InterndFileName, StatBuf); + FileEntry &UFE = + UniqueRealFiles.getFile(Data.UniqueID, Data.IsNamedPipe, Data.InPCH); NamedFileEnt.setValue(&UFE); if (UFE.getName()) { // Already have an entry with this inode, return it. @@ -410,8 +343,8 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, // FIXME: Change the name to be a char* that points back to the // 'SeenFileEntries' key. UFE.Name = InterndFileName; - UFE.Size = StatBuf.st_size; - UFE.ModTime = StatBuf.st_mtime; + UFE.Size = Data.Size; + UFE.ModTime = Data.ModTime; UFE.Dir = DirInfo; UFE.UID = NextFileUID++; UFE.FD = FileDescriptor; @@ -448,12 +381,12 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size, "The directory of a virtual file should already be in the cache."); // Check to see if the file exists. If so, drop the virtual file - struct stat StatBuf; + FileData Data; const char *InterndFileName = NamedFileEnt.getKeyData(); - if (getStatValue(InterndFileName, StatBuf, true, 0) == 0) { - StatBuf.st_size = Size; - StatBuf.st_mtime = ModificationTime; - UFE = &UniqueRealFiles.getFile(InterndFileName, StatBuf); + if (getStatValue(InterndFileName, Data, true, 0) == 0) { + Data.Size = Size; + Data.ModTime = ModificationTime; + UFE = &UniqueRealFiles.getFile(Data.UniqueID, Data.IsNamedPipe, Data.InPCH); NamedFileEnt.setValue(UFE); @@ -562,27 +495,27 @@ getBufferForFile(StringRef Filename, std::string *ErrorStr) { /// if the path points to a virtual file or does not exist, or returns /// false if it's an existent real file. If FileDescriptor is NULL, /// do directory look-up instead of file look-up. -bool FileManager::getStatValue(const char *Path, struct stat &StatBuf, - bool isFile, int *FileDescriptor) { +bool FileManager::getStatValue(const char *Path, FileData &Data, bool isFile, + int *FileDescriptor) { // FIXME: FileSystemOpts shouldn't be passed in here, all paths should be // absolute! if (FileSystemOpts.WorkingDir.empty()) - return FileSystemStatCache::get(Path, StatBuf, isFile, FileDescriptor, + return FileSystemStatCache::get(Path, Data, isFile, FileDescriptor, StatCache.get()); SmallString<128> FilePath(Path); FixupRelativePath(FilePath); - return FileSystemStatCache::get(FilePath.c_str(), StatBuf, - isFile, FileDescriptor, StatCache.get()); + return FileSystemStatCache::get(FilePath.c_str(), Data, isFile, + FileDescriptor, StatCache.get()); } -bool FileManager::getNoncachedStatValue(StringRef Path, - struct stat &StatBuf) { +bool FileManager::getNoncachedStatValue(StringRef Path, + llvm::sys::fs::file_status &Result) { SmallString<128> FilePath(Path); FixupRelativePath(FilePath); - return ::stat(FilePath.c_str(), &StatBuf) != 0; + return llvm::sys::fs::status(FilePath.c_str(), Result); } void FileManager::invalidateCache(const FileEntry *Entry) { @@ -610,7 +543,7 @@ void FileManager::GetUniqueIDMapping( UIDToFiles[FE->getValue()->getUID()] = FE->getValue(); // Map virtual file entries - for (SmallVector<FileEntry*, 4>::const_iterator + for (SmallVectorImpl<FileEntry *>::const_iterator VFE = VirtualFileEntries.begin(), VFEEnd = VirtualFileEntries.end(); VFE != VFEEnd; ++VFE) if (*VFE && *VFE != NON_EXISTENT_FILE) |