aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Driver/Distro.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Driver/Distro.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Driver/Distro.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/contrib/llvm-project/clang/lib/Driver/Distro.cpp b/contrib/llvm-project/clang/lib/Driver/Distro.cpp
index ee4fe841e7ee..a7e7f169dc14 100644
--- a/contrib/llvm-project/clang/lib/Driver/Distro.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/Distro.cpp
@@ -11,11 +11,11 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Threading.h"
+#include "llvm/TargetParser/Host.h"
+#include "llvm/TargetParser/Triple.h"
using namespace clang::driver;
using namespace clang;
@@ -34,8 +34,9 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
// Obviously this can be improved a lot.
for (StringRef Line : Lines)
- if (Version == Distro::UnknownDistro && Line.startswith("ID="))
+ if (Version == Distro::UnknownDistro && Line.starts_with("ID="))
Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(3))
+ .Case("alpine", Distro::AlpineLinux)
.Case("fedora", Distro::Fedora)
.Case("gentoo", Distro::Gentoo)
.Case("arch", Distro::ArchLinux)
@@ -59,7 +60,7 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
for (StringRef Line : Lines)
if (Version == Distro::UnknownDistro &&
- Line.startswith("DISTRIB_CODENAME="))
+ Line.starts_with("DISTRIB_CODENAME="))
Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(17))
.Case("hardy", Distro::UbuntuHardy)
.Case("intrepid", Distro::UbuntuIntrepid)
@@ -88,6 +89,12 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
.Case("focal", Distro::UbuntuFocal)
.Case("groovy", Distro::UbuntuGroovy)
.Case("hirsute", Distro::UbuntuHirsute)
+ .Case("impish", Distro::UbuntuImpish)
+ .Case("jammy", Distro::UbuntuJammy)
+ .Case("kinetic", Distro::UbuntuKinetic)
+ .Case("lunar", Distro::UbuntuLunar)
+ .Case("mantic", Distro::UbuntuMantic)
+ .Case("noble", Distro::UbuntuNoble)
.Default(Distro::UnknownDistro);
return Version;
}
@@ -106,21 +113,21 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
if (Version != Distro::UnknownDistro)
return Version;
- // Otherwise try some distro-specific quirks for RedHat...
+ // Otherwise try some distro-specific quirks for Red Hat...
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
VFS.getBufferForFile("/etc/redhat-release");
if (File) {
StringRef Data = File.get()->getBuffer();
- if (Data.startswith("Fedora release"))
+ if (Data.starts_with("Fedora release"))
return Distro::Fedora;
- if (Data.startswith("Red Hat Enterprise Linux") ||
- Data.startswith("CentOS") || Data.startswith("Scientific Linux")) {
- if (Data.find("release 7") != StringRef::npos)
+ if (Data.starts_with("Red Hat Enterprise Linux") ||
+ Data.starts_with("CentOS") || Data.starts_with("Scientific Linux")) {
+ if (Data.contains("release 7"))
return Distro::RHEL7;
- else if (Data.find("release 6") != StringRef::npos)
+ else if (Data.contains("release 6"))
return Distro::RHEL6;
- else if (Data.find("release 5") != StringRef::npos)
+ else if (Data.contains("release 5"))
return Distro::RHEL5;
}
return Distro::UnknownDistro;
@@ -148,6 +155,10 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
return Distro::DebianBuster;
case 11:
return Distro::DebianBullseye;
+ case 12:
+ return Distro::DebianBookworm;
+ case 13:
+ return Distro::DebianTrixie;
default:
return Distro::UnknownDistro;
}
@@ -159,6 +170,8 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
.Case("stretch/sid", Distro::DebianStretch)
.Case("buster/sid", Distro::DebianBuster)
.Case("bullseye/sid", Distro::DebianBullseye)
+ .Case("bookworm/sid", Distro::DebianBookworm)
+ .Case("trixie/sid", Distro::DebianTrixie)
.Default(Distro::UnknownDistro);
}
@@ -169,7 +182,7 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
SmallVector<StringRef, 8> Lines;
Data.split(Lines, "\n");
for (const StringRef &Line : Lines) {
- if (!Line.trim().startswith("VERSION"))
+ if (!Line.trim().starts_with("VERSION"))
continue;
std::pair<StringRef, StringRef> SplitLine = Line.split('=');
// Old versions have split VERSION and PATCHLEVEL
@@ -188,15 +201,6 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
}
// ...and others.
- if (VFS.exists("/etc/exherbo-release"))
- return Distro::Exherbo;
-
- if (VFS.exists("/etc/alpine-release"))
- return Distro::AlpineLinux;
-
- if (VFS.exists("/etc/arch-release"))
- return Distro::ArchLinux;
-
if (VFS.exists("/etc/gentoo-release"))
return Distro::Gentoo;