Index: include/clang/Driver/Distro.h =================================================================== --- include/clang/Driver/Distro.h +++ include/clang/Driver/Distro.h @@ -39,6 +39,7 @@ RHEL6, RHEL7, Fedora, + Gentoo, OpenSUSE, UbuntuHardy, UbuntuIntrepid, Index: lib/Driver/Distro.cpp =================================================================== --- lib/Driver/Distro.cpp +++ lib/Driver/Distro.cpp @@ -138,6 +138,9 @@ if (VFS.exists("/etc/arch-release")) return Distro::ArchLinux; + if (VFS.exists("/etc/gentoo-release")) + return Distro::Gentoo; + return Distro::UnknownDistro; } Index: unittests/Driver/DistroTest.cpp =================================================================== --- unittests/Driver/DistroTest.cpp +++ unittests/Driver/DistroTest.cpp @@ -302,4 +302,28 @@ ASSERT_FALSE(ArchLinux.IsDebian()); } +TEST(DistroTest, DetectGentoo) { + llvm::vfs::InMemoryFileSystem GentooFileSystem; + GentooFileSystem.addFile( + "/etc/gentoo-release", 0, + llvm::MemoryBuffer::getMemBuffer("Gentoo Base System release 2.6")); + GentooFileSystem.addFile( + "/etc/os-release", 0, + llvm::MemoryBuffer::getMemBuffer( + "NAME=Gentoo\n" + "ID=gentoo\n" + "PRETTY_NAME=\"Gentoo/Linux\"\n" + "ANSI_COLOR=\"1;32\"\n" + "HOME_URL=\"https://www.gentoo.org/\"\n" + "SUPPORT_URL=\"https://www.gentoo.org/support/\"\n" + "BUG_REPORT_URL=\"https://bugs.gentoo.org/\"\n")); + + Distro Gentoo{GentooFileSystem}; + ASSERT_EQ(Distro(Distro::Gentoo), Gentoo); + ASSERT_FALSE(Gentoo.IsUbuntu()); + ASSERT_FALSE(Gentoo.IsRedhat()); + ASSERT_FALSE(Gentoo.IsOpenSUSE()); + ASSERT_FALSE(Gentoo.IsDebian()); +} + } // end anonymous namespace