Coverage Report

Created: 2018-07-21 08:31

/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 "clang/Basic/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
    UnknownDistro
66
  };
67
68
private:
69
  /// The distribution, possibly with specific version.
70
  DistroType DistroVal;
71
72
public:
73
  /// @name Constructors
74
  /// @{
75
76
  /// Default constructor leaves the distribution unknown.
77
  Distro() : DistroVal() {}
78
79
  /// Constructs a Distro type for specific distribution.
80
6.87k
  Distro(DistroType D) : DistroVal(D) {}
81
82
  /// Detects the distribution using specified VFS.
83
  explicit Distro(clang::vfs::FileSystem& VFS);
84
85
6.87k
  bool operator==(const Distro &Other) const {
86
6.87k
    return DistroVal == Other.DistroVal;
87
6.87k
  }
88
89
0
  bool operator!=(const Distro &Other) const {
90
0
    return DistroVal != Other.DistroVal;
91
0
  }
92
93
0
  bool operator>=(const Distro &Other) const {
94
0
    return DistroVal >= Other.DistroVal;
95
0
  }
96
97
0
  bool operator<=(const Distro &Other) const {
98
0
    return DistroVal <= Other.DistroVal;
99
0
  }
100
101
  /// @}
102
  /// @name Convenience Predicates
103
  /// @{
104
105
4.73k
  bool IsRedhat() const {
106
4.73k
    return DistroVal == Fedora || 
(4.73k
DistroVal >= RHEL54.73k
&&
DistroVal <= RHEL74.73k
);
107
4.73k
  }
108
109
9.27k
  bool IsOpenSUSE() const {
110
9.27k
    return DistroVal == OpenSUSE;
111
9.27k
  }
112
113
27.6k
  bool IsDebian() const {
114
27.6k
    return DistroVal >= DebianLenny && 
DistroVal <= DebianBuster27.6k
;
115
27.6k
  }
116
117
4.73k
  bool IsUbuntu() const {
118
4.73k
    return DistroVal >= UbuntuHardy && 
DistroVal <= UbuntuCosmic4.73k
;
119
4.73k
  }
120
121
7.49k
  bool IsAlpineLinux() const {
122
7.49k
    return DistroVal == AlpineLinux;
123
7.49k
  }
124
125
  /// @}
126
};
127
128
} // end namespace driver
129
} // end namespace clang
130
131
#endif