summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2016-10-20 20:45:40 +0000
committerMichal Gorny <mgorny@gentoo.org>2016-10-20 20:45:40 +0000
commit16f37c30a3d8578bf95120c9d56aac2051a57e9a (patch)
treebc7d35a916520ac264fd6dcde21a2bd44bf807ca /clang
parent8210959afdc2cba1bee288cee7d6fca05f71592d (diff)
downloadbcm5719-llvm-16f37c30a3d8578bf95120c9d56aac2051a57e9a.tar.gz
bcm5719-llvm-16f37c30a3d8578bf95120c9d56aac2051a57e9a.zip
[Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC
Refactor the DetectDistro() function to take a single vfs::FileSystem reference only, instead of Driver and llvm::Triple::ArchType. The ArchType parameter was not used anyway, and Driver was only used to obtain the VFS. Aside to making the API simpler and more transparent, it makes it easier to add unit tests for the function in the future -- since the tests would need only to provide an appropriate VFS. Differential Revision: https://reviews.llvm.org/D25819 llvm-svn: 284774
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Driver/ToolChains.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index cb1bddf5ca3..131cdae56d2 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -3850,9 +3850,9 @@ static bool IsUbuntu(enum Distro Distro) {
return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
}
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
- D.getVFS().getBufferForFile("/etc/lsb-release");
+ VFS.getBufferForFile("/etc/lsb-release");
if (File) {
StringRef Data = File.get()->getBuffer();
SmallVector<StringRef, 16> Lines;
@@ -3884,7 +3884,7 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
return Version;
}
- File = D.getVFS().getBufferForFile("/etc/redhat-release");
+ File = VFS.getBufferForFile("/etc/redhat-release");
if (File) {
StringRef Data = File.get()->getBuffer();
if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
return UnknownDistro;
}
- File = D.getVFS().getBufferForFile("/etc/debian_version");
+ File = VFS.getBufferForFile("/etc/debian_version");
if (File) {
StringRef Data = File.get()->getBuffer();
// Contents: < major.minor > or < codename/sid >
@@ -3931,13 +3931,13 @@ static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
.Default(UnknownDistro);
}
- if (D.getVFS().exists("/etc/SuSE-release"))
+ if (VFS.exists("/etc/SuSE-release"))
return OpenSUSE;
- if (D.getVFS().exists("/etc/exherbo-release"))
+ if (VFS.exists("/etc/exherbo-release"))
return Exherbo;
- if (D.getVFS().exists("/etc/arch-release"))
+ if (VFS.exists("/etc/arch-release"))
return ArchLinux;
return UnknownDistro;
@@ -4122,7 +4122,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
GCCInstallation.getTriple().str() + "/bin")
.str());
- Distro Distro = DetectDistro(D, Arch);
+ Distro Distro = DetectDistro(D.getVFS());
if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
ExtraOpts.push_back("-z");
@@ -4326,7 +4326,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
const llvm::Triple::ArchType Arch = getArch();
const llvm::Triple &Triple = getTriple();
- const enum Distro Distro = DetectDistro(getDriver(), Arch);
+ const enum Distro Distro = DetectDistro(getDriver().getVFS());
if (Triple.isAndroid())
return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
OpenPOWER on IntegriCloud