]> granicus.if.org Git - clang/commitdiff
[Driver] Use VFS to perform all distribution checks
authorMichal Gorny <mgorny@gentoo.org>
Mon, 17 Oct 2016 18:07:15 +0000 (18:07 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Mon, 17 Oct 2016 18:07:15 +0000 (18:07 +0000)
Use the VFS provided by D.getVFS() for all distribution checks,
including those performing read of the release file. Requested
by @bruno on D24954.

Differential Revision: https://reviews.llvm.org/D25641

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284403 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp

index b51ae1c50745b9232cc4f72a5b290a3da183e04b..a9fd7ee7195355fea60ce5871091af3831460492 100644 (file)
@@ -3844,7 +3844,7 @@ static bool IsUbuntu(enum Distro Distro) {
 
 static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
   llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
-      llvm::MemoryBuffer::getFile("/etc/lsb-release");
+      D.getVFS().getBufferForFile("/etc/lsb-release");
   if (File) {
     StringRef Data = File.get()->getBuffer();
     SmallVector<StringRef, 16> Lines;
@@ -3876,7 +3876,7 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
       return Version;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
+  File = D.getVFS().getBufferForFile("/etc/redhat-release");
   if (File) {
     StringRef Data = File.get()->getBuffer();
     if (Data.startswith("Fedora release"))
@@ -3894,7 +3894,7 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
     return UnknownDistro;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/debian_version");
+  File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
     StringRef Data = File.get()->getBuffer();
     if (Data[0] == '5')