Coverage Report

Created: 2018-11-13 17:19

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Driver/Distro.h
Line
Count
Source (jump to first uncovered line)
1
//===--- Distro.h - Linux distribution detection support --------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_DRIVER_DISTRO_H
11
#define LLVM_CLANG_DRIVER_DISTRO_H
12
13
#include "llvm/Support/VirtualFileSystem.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
    // NB: Releases of a particular Linux distro should be kept together
27
    // in this enum, because some tests are done by integer comparison against
28
    // the first and last known member in the family, e.g. IsRedHat().
29
    AlpineLinux,
30
    ArchLinux,
31
    DebianLenny,
32
    DebianSqueeze,
33
    DebianWheezy,
34
    DebianJessie,
35
    DebianStretch,
36
    DebianBuster,
37
    Exherbo,
38
    RHEL5,
39
    RHEL6,
40
    RHEL7,
41
    Fedora,
42
    OpenSUSE,
43
    UbuntuHardy,
44
    UbuntuIntrepid,
45
    UbuntuJaunty,
46
    UbuntuKarmic,
47
    UbuntuLucid,
48
    UbuntuMaverick,
49
    UbuntuNatty,
50
    UbuntuOneiric,
51
    UbuntuPrecise,
52
    UbuntuQuantal,
53
    UbuntuRaring,
54
    UbuntuSaucy,
55
    UbuntuTrusty,
56
    UbuntuUtopic,
57
    UbuntuVivid,
58
    UbuntuWily,
59
    UbuntuXenial,
60
    UbuntuYakkety,
61
    UbuntuZesty,
62
    UbuntuArtful,
63
    UbuntuBionic,
64
    UbuntuCosmic,
65
    UbuntuDisco,
66
    UnknownDistro
67
  };
68
69
private:
70
  /// The distribution, possibly with specific version.
71
  DistroType DistroVal;
72
73
public:
74
  /// @name Constructors
75
  /// @{
76
77
  /// Default constructor leaves the distribution unknown.
78
  Distro() : DistroVal() {}
79
80
  /// Constructs a Distro type for specific distribution.
81
8.00k
  Distro(DistroType D) : DistroVal(D) {}
82
83
  /// Detects the distribution using specified VFS.
84
  explicit Distro(llvm::vfs::FileSystem &VFS);
85
86
8.00k
  bool operator==(const Distro &Other) const {
87
8.00k
    return DistroVal == Other.DistroVal;
88
8.00k
  }
89
90
0
  bool operator!=(const Distro &Other) const {
91
0
    return DistroVal != Other.DistroVal;
92
0
  }
93
94
0
  bool operator>=(const Distro &Other) const {
95
0
    return DistroVal >= Other.DistroVal;
96
0
  }
97
98
0
  bool operator<=(const Distro &Other) const {
99
0
    return DistroVal <= Other.DistroVal;
100
0
  }
101
102
  /// @}
103
  /// @name Convenience Predicates
104
  /// @{
105
106
5.30k
  bool IsRedhat() const {
107
5.30k
    return DistroVal == Fedora || 
(5.30k
DistroVal >= RHEL55.30k
&&
DistroVal <= RHEL75.29k
);
108
5.30k
  }
109
110
10.3k
  bool IsOpenSUSE() const {
111
10.3k
    return DistroVal == OpenSUSE;
112
10.3k
  }
113
114
29.2k
  bool IsDebian() const {
115
29.2k
    return DistroVal >= DebianLenny && 
DistroVal <= DebianBuster29.2k
;
116
29.2k
  }
117
118
5.30k
  bool IsUbuntu() const {
119
5.30k
    return DistroVal >= UbuntuHardy && 
DistroVal <= UbuntuDisco5.29k
;
120
5.30k
  }
121
122
8.27k
  bool IsAlpineLinux() const {
123
8.27k
    return DistroVal == AlpineLinux;
124
8.27k
  }
125
126
  /// @}
127
};
128
129
} // end namespace driver
130
} // end namespace clang
131
132
#endif