diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 23:48:03 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 23:48:03 +0000 |
commit | 1b8d44f59bc7b8453c03186dc9f72e1a55da605f (patch) | |
tree | e0f70ff93543109248ff9f03aa6b3340ccd54c14 | |
parent | 09e0d5c1bb206571b28c280632ca1476ae800570 (diff) | |
download | bcm5719-llvm-1b8d44f59bc7b8453c03186dc9f72e1a55da605f.tar.gz bcm5719-llvm-1b8d44f59bc7b8453c03186dc9f72e1a55da605f.zip |
Revert "Honour 'use-external-names' in FileManager"
Revert r202442, which broke the buildbots.
llvm-svn: 202443
-rw-r--r-- | clang/include/clang/Basic/FileManager.h | 7 | ||||
-rw-r--r-- | clang/include/clang/Basic/FileSystemStatCache.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Basic/VirtualFileSystem.h | 2 | ||||
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Basic/FileSystemStatCache.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 37 | ||||
-rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 1 | ||||
-rw-r--r-- | clang/test/VFS/Inputs/external-names.h | 4 | ||||
-rw-r--r-- | clang/test/VFS/Inputs/use-external-names.yaml | 7 | ||||
-rw-r--r-- | clang/test/VFS/external-names.c | 35 | ||||
-rw-r--r-- | clang/unittests/Basic/FileManagerTest.cpp | 1 |
11 files changed, 13 insertions, 86 deletions
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index ddf78c86def..b5b7231e13c 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -59,7 +59,7 @@ public: /// If the 'File' member is valid, then this FileEntry has an open file /// descriptor for the file. class FileEntry { - std::string Name; // Name of the file. + const char *Name; // Name of the file. off_t Size; // File size in bytes. time_t ModTime; // Modification time of file. const DirectoryEntry *Dir; // Directory file lives in. @@ -81,7 +81,8 @@ class FileEntry { public: FileEntry() - : UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false) + : Name(0), UniqueID(0, 0), IsNamedPipe(false), InPCH(false), + IsValid(false) {} // FIXME: this is here to allow putting FileEntry in std::map. Once we have @@ -91,7 +92,7 @@ public: assert(!isValid() && "Cannot copy an initialized FileEntry"); } - const char *getName() const { return Name.c_str(); } + const char *getName() const { return Name; } bool isValid() const { return IsValid; } off_t getSize() const { return Size; } unsigned getUID() const { return UID; } diff --git a/clang/include/clang/Basic/FileSystemStatCache.h b/clang/include/clang/Basic/FileSystemStatCache.h index 7ed0acc7a8c..913e41e4ca8 100644 --- a/clang/include/clang/Basic/FileSystemStatCache.h +++ b/clang/include/clang/Basic/FileSystemStatCache.h @@ -29,9 +29,7 @@ class File; class FileSystem; } -// FIXME: should probably replace this with vfs::Status struct FileData { - std::string Name; uint64_t Size; time_t ModTime; llvm::sys::fs::UniqueID UniqueID; diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/clang/include/clang/Basic/VirtualFileSystem.h index 8f144da917f..bd568120b25 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/clang/include/clang/Basic/VirtualFileSystem.h @@ -90,8 +90,6 @@ public: bool RequiresNullTerminator = true) = 0; /// \brief Closes the file. virtual llvm::error_code close() = 0; - /// \brief Sets the name to use for this file. - virtual void setName(StringRef Name) = 0; }; /// \brief The virtual file system interface. diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 5784f31843f..f7e566b9779 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -282,7 +282,7 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, } // Otherwise, we don't have this file yet, add it. - UFE.Name = Data.Name; + UFE.Name = InterndFileName; UFE.Size = Data.Size; UFE.ModTime = Data.ModTime; UFE.Dir = DirInfo; diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp index e50dc1b5ed0..b225facbad9 100644 --- a/clang/lib/Basic/FileSystemStatCache.cpp +++ b/clang/lib/Basic/FileSystemStatCache.cpp @@ -32,7 +32,6 @@ void FileSystemStatCache::anchor() { } static void copyStatusToFileData(const vfs::Status &Status, FileData &Data) { - Data.Name = Status.getName(); Data.Size = Status.getSize(); Data.ModTime = Status.getLastModificationTime().toEpochTime(); Data.UniqueID = Status.getUniqueID(); diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index d4845e6f363..f6d88c1860d 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -83,7 +83,6 @@ error_code FileSystem::getBufferForFile(const llvm::Twine &Name, /// \brief Wrapper around a raw file descriptor. class RealFile : public File { int FD; - Status S; friend class RealFileSystem; RealFile(int FD) : FD(FD) { assert(FD >= 0 && "Invalid or inactive file descriptor"); @@ -96,21 +95,15 @@ public: int64_t FileSize = -1, bool RequiresNullTerminator = true) LLVM_OVERRIDE; error_code close() LLVM_OVERRIDE; - void setName(StringRef Name) LLVM_OVERRIDE; }; RealFile::~RealFile() { close(); } ErrorOr<Status> RealFile::status() { assert(FD != -1 && "cannot stat closed file"); - if (!S.isStatusKnown()) { - file_status RealStatus; - if (error_code EC = sys::fs::status(FD, RealStatus)) - return EC; - Status NewS(RealStatus); - NewS.setName(S.getName()); - S = llvm_move(NewS); - } - return S; + file_status RealStatus; + if (error_code EC = sys::fs::status(FD, RealStatus)) + return EC; + return Status(RealStatus); } error_code RealFile::getBuffer(const Twine &Name, @@ -138,10 +131,6 @@ error_code RealFile::close() { return error_code::success(); } -void RealFile::setName(StringRef Name) { - S.setName(Name); -} - /// \brief The file system according to your operating system. class RealFileSystem : public FileSystem { public: @@ -165,7 +154,6 @@ error_code RealFileSystem::openFileForRead(const Twine &Name, if (error_code EC = sys::fs::openFileForRead(Name, FD)) return EC; Result.reset(new RealFile(FD)); - Result->setName(Name.str()); return error_code::success(); } @@ -279,10 +267,7 @@ public: UseName(UseName) {} StringRef getExternalContentsPath() const { return ExternalContentsPath; } /// \brief whether to use the external path as the name for this file. - bool useExternalName(bool GlobalUseExternalName) const { - return UseName == NK_NotSet ? GlobalUseExternalName - : (UseName == NK_External); - } + NameKind useName() const { return UseName; } static bool classof(const Entry *E) { return E->getKind() == EK_File; } }; @@ -785,7 +770,8 @@ ErrorOr<Status> VFSFromYAML::status(const Twine &Path) { if (FileEntry *F = dyn_cast<FileEntry>(*Result)) { ErrorOr<Status> S = ExternalFS->status(F->getExternalContentsPath()); assert(!S || S->getName() == F->getExternalContentsPath()); - if (S && !F->useExternalName(UseExternalNames)) + if (S && (F->useName() == FileEntry::NK_Virtual || + (F->useName() == FileEntry::NK_NotSet && !UseExternalNames))) S->setName(PathStr); return S; } else { // directory @@ -806,14 +792,7 @@ error_code VFSFromYAML::openFileForRead(const Twine &Path, if (!F) // FIXME: errc::not_a_file? return error_code(errc::invalid_argument, system_category()); - if (error_code EC = ExternalFS->openFileForRead(F->getExternalContentsPath(), - Result)) - return EC; - - if (!F->useExternalName(UseExternalNames)) - Result->setName(Path.str()); - - return error_code::success(); + return ExternalFS->openFileForRead(F->getExternalContentsPath(), Result); } IntrusiveRefCntPtr<FileSystem> diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index dd8363df9ca..cdc5d7e3381 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -688,7 +688,6 @@ public: if (!D.HasData) return CacheMissing; - Data.Name = Path; Data.Size = D.Size; Data.ModTime = D.ModTime; Data.UniqueID = D.UniqueID; diff --git a/clang/test/VFS/Inputs/external-names.h b/clang/test/VFS/Inputs/external-names.h deleted file mode 100644 index 8b0baa3f023..00000000000 --- a/clang/test/VFS/Inputs/external-names.h +++ /dev/null @@ -1,4 +0,0 @@ -void foo(char **c) { - *c = __FILE__; - int x = c; // produce a diagnostic -} diff --git a/clang/test/VFS/Inputs/use-external-names.yaml b/clang/test/VFS/Inputs/use-external-names.yaml deleted file mode 100644 index b9ea6342cf0..00000000000 --- a/clang/test/VFS/Inputs/use-external-names.yaml +++ /dev/null @@ -1,7 +0,0 @@ -{ - 'version': 0, - 'use-external-names': EXTERNAL_NAMES, - 'roots': [{ 'type': 'file', 'name': 'OUT_DIR/external-names.h', - 'external-contents': 'INPUT_DIR/external-names.h' - }] -} diff --git a/clang/test/VFS/external-names.c b/clang/test/VFS/external-names.c deleted file mode 100644 index aa0bd674530..00000000000 --- a/clang/test/VFS/external-names.c +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" -e "s:EXTERNAL_NAMES:true:" %S/Inputs/use-external-names.yaml > %t.external.yaml -// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" -e "s:EXTERNAL_NAMES:false:" %S/Inputs/use-external-names.yaml > %t.yaml -// REQUIRES: shell - -#include "external-names.h" - -//// -// Preprocessor (__FILE__ macro and # directives): - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -E %s | FileCheck -check-prefix=CHECK-PP-EXTERNAL %s -// CHECK-PP-EXTERNAL: # {{[0-9]*}} "[[NAME:.*Inputs.external-names.h]]" -// CHECK-PP-EXTERNAL-NEXT: void foo(char **c) { -// CHECK-PP-EXTERNAL-NEXT: *c = "[[NAME]]"; - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -E %s | FileCheck -check-prefix=CHECK-PP %s -// CHECK-PP-NOT: Inputs - -//// -// Diagnostics: - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG-EXTERNAL %s -// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{.}}external-names.h:{{[0-9]*:[0-9]*}}: warning: incompatible pointer - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG %s -// CHECK-DIAG-NOT: Inputs - -//// -// Debug info - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -triple %itanium_abi_triple -g -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG-EXTERNAL %s -// CHECK-DEBUG-EXTERNAL: ![[Num:[0-9]*]] = metadata !{metadata !"{{.*}}Inputs{{.}}external-names.h -// CHECK-DEBUG-EXTERNAL: metadata !{i32 {{[0-9]*}}, metadata ![[Num]]{{.*}}DW_TAG_file_type - -// RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -triple %itanium_abi_triple -g -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG %s -// CHECK-DEBUG-NOT: Inputs diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 113c7fee4c8..5b35e687350 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -30,7 +30,6 @@ private: FileData Data; memset(&Data, 0, sizeof(FileData)); llvm::sys::fs::UniqueID ID(1, INode); - Data.Name = Path; Data.UniqueID = ID; Data.IsDirectory = !IsFile; StatCalls[Path] = Data; |