clang
20.0.0git
include
clang
Driver
Distro.h
Go to the documentation of this file.
1
//===--- Distro.h - Linux distribution detection support --------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_DRIVER_DISTRO_H
10
#define LLVM_CLANG_DRIVER_DISTRO_H
11
12
#include "llvm/Support/VirtualFileSystem.h"
13
#include "llvm/TargetParser/Triple.h"
14
15
namespace
clang
{
16
namespace
driver {
17
18
/// Distro - Helper class for detecting and classifying Linux distributions.
19
///
20
/// This class encapsulates the clang Linux distribution detection mechanism
21
/// as well as helper functions that match the specific (versioned) results
22
/// into wider distribution classes.
23
class
Distro
{
24
public
:
25
enum
DistroType
{
26
// Special value means that no detection was performed yet.
27
UninitializedDistro
,
28
// NB: Releases of a particular Linux distro should be kept together
29
// in this enum, because some tests are done by integer comparison against
30
// the first and last known member in the family, e.g. IsRedHat().
31
AlpineLinux
,
32
ArchLinux
,
33
DebianLenny
,
34
DebianSqueeze
,
35
DebianWheezy
,
36
DebianJessie
,
37
DebianStretch
,
38
DebianBuster
,
39
DebianBullseye
,
40
DebianBookworm
,
41
DebianTrixie
,
42
Exherbo
,
43
RHEL5
,
44
RHEL6
,
45
RHEL7
,
46
Fedora
,
47
Gentoo
,
48
OpenSUSE
,
49
UbuntuHardy
,
50
UbuntuIntrepid
,
51
UbuntuJaunty
,
52
UbuntuKarmic
,
53
UbuntuLucid
,
54
UbuntuMaverick
,
55
UbuntuNatty
,
56
UbuntuOneiric
,
57
UbuntuPrecise
,
58
UbuntuQuantal
,
59
UbuntuRaring
,
60
UbuntuSaucy
,
61
UbuntuTrusty
,
62
UbuntuUtopic
,
63
UbuntuVivid
,
64
UbuntuWily
,
65
UbuntuXenial
,
66
UbuntuYakkety
,
67
UbuntuZesty
,
68
UbuntuArtful
,
69
UbuntuBionic
,
70
UbuntuCosmic
,
71
UbuntuDisco
,
72
UbuntuEoan
,
73
UbuntuFocal
,
74
UbuntuGroovy
,
75
UbuntuHirsute
,
76
UbuntuImpish
,
77
UbuntuJammy
,
78
UbuntuKinetic
,
79
UbuntuLunar
,
80
UbuntuMantic
,
81
UbuntuNoble
,
82
UbuntuOracular
,
83
UbuntuPlucky
,
84
UnknownDistro
85
};
86
87
private
:
88
/// The distribution, possibly with specific version.
89
DistroType
DistroVal;
90
91
public
:
92
/// @name Constructors
93
/// @{
94
95
/// Default constructor leaves the distribution unknown.
96
Distro
() : DistroVal() {}
97
98
/// Constructs a Distro type for specific distribution.
99
Distro
(
DistroType
D
) : DistroVal(
D
) {}
100
101
/// Detects the distribution using specified VFS.
102
explicit
Distro
(llvm::vfs::FileSystem &VFS,
const
llvm::Triple &TargetOrHost);
103
104
bool
operator==
(
const
Distro
&
Other
)
const
{
105
return
DistroVal ==
Other
.DistroVal;
106
}
107
108
bool
operator!=
(
const
Distro
&
Other
)
const
{
109
return
DistroVal !=
Other
.DistroVal;
110
}
111
112
bool
operator>=
(
const
Distro
&
Other
)
const
{
113
return
DistroVal >=
Other
.DistroVal;
114
}
115
116
bool
operator<=
(
const
Distro
&
Other
)
const
{
117
return
DistroVal <=
Other
.DistroVal;
118
}
119
120
/// @}
121
/// @name Convenience Predicates
122
/// @{
123
124
bool
IsRedhat
()
const
{
125
return
DistroVal ==
Fedora
|| (DistroVal >=
RHEL5
&& DistroVal <=
RHEL7
);
126
}
127
128
bool
IsOpenSUSE
()
const
{
return
DistroVal ==
OpenSUSE
; }
129
130
bool
IsDebian
()
const
{
131
return
DistroVal >=
DebianLenny
&& DistroVal <=
DebianTrixie
;
132
}
133
134
bool
IsUbuntu
()
const
{
135
return
DistroVal >=
UbuntuHardy
&& DistroVal <=
UbuntuPlucky
;
136
}
137
138
bool
IsAlpineLinux
()
const
{
return
DistroVal ==
AlpineLinux
; }
139
140
bool
IsGentoo
()
const
{
return
DistroVal ==
Gentoo
; }
141
142
/// @}
143
};
144
145
}
// end namespace driver
146
}
// end namespace clang
147
148
#endif
D
const Decl * D
Definition:
CheckExprLifetime.cpp:211
clang::driver::Distro
Distro - Helper class for detecting and classifying Linux distributions.
Definition:
Distro.h:23
clang::driver::Distro::IsDebian
bool IsDebian() const
Definition:
Distro.h:130
clang::driver::Distro::Distro
Distro()
Default constructor leaves the distribution unknown.
Definition:
Distro.h:96
clang::driver::Distro::IsOpenSUSE
bool IsOpenSUSE() const
Definition:
Distro.h:128
clang::driver::Distro::IsGentoo
bool IsGentoo() const
Definition:
Distro.h:140
clang::driver::Distro::Distro
Distro(DistroType D)
Constructs a Distro type for specific distribution.
Definition:
Distro.h:99
clang::driver::Distro::operator!=
bool operator!=(const Distro &Other) const
Definition:
Distro.h:108
clang::driver::Distro::operator==
bool operator==(const Distro &Other) const
Definition:
Distro.h:104
clang::driver::Distro::DistroType
DistroType
Definition:
Distro.h:25
clang::driver::Distro::RHEL5
@ RHEL5
Definition:
Distro.h:43
clang::driver::Distro::UbuntuBionic
@ UbuntuBionic
Definition:
Distro.h:69
clang::driver::Distro::UbuntuNoble
@ UbuntuNoble
Definition:
Distro.h:81
clang::driver::Distro::UbuntuUtopic
@ UbuntuUtopic
Definition:
Distro.h:62
clang::driver::Distro::UbuntuArtful
@ UbuntuArtful
Definition:
Distro.h:68
clang::driver::Distro::Gentoo
@ Gentoo
Definition:
Distro.h:47
clang::driver::Distro::UbuntuZesty
@ UbuntuZesty
Definition:
Distro.h:67
clang::driver::Distro::UbuntuJammy
@ UbuntuJammy
Definition:
Distro.h:77
clang::driver::Distro::DebianJessie
@ DebianJessie
Definition:
Distro.h:36
clang::driver::Distro::DebianTrixie
@ DebianTrixie
Definition:
Distro.h:41
clang::driver::Distro::UbuntuQuantal
@ UbuntuQuantal
Definition:
Distro.h:58
clang::driver::Distro::UbuntuImpish
@ UbuntuImpish
Definition:
Distro.h:76
clang::driver::Distro::UbuntuPlucky
@ UbuntuPlucky
Definition:
Distro.h:83
clang::driver::Distro::DebianBullseye
@ DebianBullseye
Definition:
Distro.h:39
clang::driver::Distro::UninitializedDistro
@ UninitializedDistro
Definition:
Distro.h:27
clang::driver::Distro::DebianStretch
@ DebianStretch
Definition:
Distro.h:37
clang::driver::Distro::ArchLinux
@ ArchLinux
Definition:
Distro.h:32
clang::driver::Distro::OpenSUSE
@ OpenSUSE
Definition:
Distro.h:48
clang::driver::Distro::UbuntuKarmic
@ UbuntuKarmic
Definition:
Distro.h:52
clang::driver::Distro::UbuntuRaring
@ UbuntuRaring
Definition:
Distro.h:59
clang::driver::Distro::DebianWheezy
@ DebianWheezy
Definition:
Distro.h:35
clang::driver::Distro::UbuntuNatty
@ UbuntuNatty
Definition:
Distro.h:55
clang::driver::Distro::UbuntuHardy
@ UbuntuHardy
Definition:
Distro.h:49
clang::driver::Distro::DebianLenny
@ DebianLenny
Definition:
Distro.h:33
clang::driver::Distro::RHEL7
@ RHEL7
Definition:
Distro.h:45
clang::driver::Distro::UbuntuIntrepid
@ UbuntuIntrepid
Definition:
Distro.h:50
clang::driver::Distro::UbuntuDisco
@ UbuntuDisco
Definition:
Distro.h:71
clang::driver::Distro::UbuntuHirsute
@ UbuntuHirsute
Definition:
Distro.h:75
clang::driver::Distro::UbuntuJaunty
@ UbuntuJaunty
Definition:
Distro.h:51
clang::driver::Distro::UbuntuOracular
@ UbuntuOracular
Definition:
Distro.h:82
clang::driver::Distro::UbuntuCosmic
@ UbuntuCosmic
Definition:
Distro.h:70
clang::driver::Distro::AlpineLinux
@ AlpineLinux
Definition:
Distro.h:31
clang::driver::Distro::UbuntuVivid
@ UbuntuVivid
Definition:
Distro.h:63
clang::driver::Distro::UbuntuTrusty
@ UbuntuTrusty
Definition:
Distro.h:61
clang::driver::Distro::DebianBookworm
@ DebianBookworm
Definition:
Distro.h:40
clang::driver::Distro::UbuntuEoan
@ UbuntuEoan
Definition:
Distro.h:72
clang::driver::Distro::UbuntuKinetic
@ UbuntuKinetic
Definition:
Distro.h:78
clang::driver::Distro::Exherbo
@ Exherbo
Definition:
Distro.h:42
clang::driver::Distro::UbuntuYakkety
@ UbuntuYakkety
Definition:
Distro.h:66
clang::driver::Distro::UbuntuMaverick
@ UbuntuMaverick
Definition:
Distro.h:54
clang::driver::Distro::UbuntuMantic
@ UbuntuMantic
Definition:
Distro.h:80
clang::driver::Distro::UbuntuLunar
@ UbuntuLunar
Definition:
Distro.h:79
clang::driver::Distro::RHEL6
@ RHEL6
Definition:
Distro.h:44
clang::driver::Distro::UbuntuGroovy
@ UbuntuGroovy
Definition:
Distro.h:74
clang::driver::Distro::DebianBuster
@ DebianBuster
Definition:
Distro.h:38
clang::driver::Distro::UnknownDistro
@ UnknownDistro
Definition:
Distro.h:84
clang::driver::Distro::UbuntuXenial
@ UbuntuXenial
Definition:
Distro.h:65
clang::driver::Distro::UbuntuFocal
@ UbuntuFocal
Definition:
Distro.h:73
clang::driver::Distro::UbuntuPrecise
@ UbuntuPrecise
Definition:
Distro.h:57
clang::driver::Distro::UbuntuSaucy
@ UbuntuSaucy
Definition:
Distro.h:60
clang::driver::Distro::UbuntuWily
@ UbuntuWily
Definition:
Distro.h:64
clang::driver::Distro::Fedora
@ Fedora
Definition:
Distro.h:46
clang::driver::Distro::UbuntuOneiric
@ UbuntuOneiric
Definition:
Distro.h:56
clang::driver::Distro::DebianSqueeze
@ DebianSqueeze
Definition:
Distro.h:34
clang::driver::Distro::UbuntuLucid
@ UbuntuLucid
Definition:
Distro.h:53
clang::driver::Distro::IsAlpineLinux
bool IsAlpineLinux() const
Definition:
Distro.h:138
clang::driver::Distro::IsRedhat
bool IsRedhat() const
Definition:
Distro.h:124
clang::driver::Distro::operator<=
bool operator<=(const Distro &Other) const
Definition:
Distro.h:116
clang::driver::Distro::operator>=
bool operator>=(const Distro &Other) const
Definition:
Distro.h:112
clang::driver::Distro::IsUbuntu
bool IsUbuntu() const
Definition:
Distro.h:134
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition:
CalledOnceCheck.h:17
clang::ImplicitParamKind::Other
@ Other
Other implicit parameter.
Generated on Wed Dec 25 2024 05:25:21 for clang by
1.9.6