1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include <QFlags>
29 
30 namespace Utils {
31 
32 enum class Language : unsigned char { None, C, Cxx };
33 
34 enum class LanguageVersion : unsigned char {
35     None,
36     C89,
37     C99,
38     C11,
39     C18,
40     LatestC = C18,
41     CXX98 = 32,
42     CXX03,
43     CXX11,
44     CXX14,
45     CXX17,
46     CXX20,
47     CXX2b,
48     LatestCxx = CXX2b,
49 };
50 
51 enum class LanguageExtension : unsigned char {
52     None = 0,
53 
54     Gnu = 1 << 0,
55     Microsoft = 1 << 1,
56     Borland = 1 << 2,
57     OpenMP = 1 << 3,
58     ObjectiveC = 1 << 4,
59 
60     All = Gnu | Microsoft | Borland | OpenMP | ObjectiveC
61 };
62 
63 enum class WarningFlags {
64     // General settings
65     NoWarnings = 0,
66     AsErrors = 1 << 0,
67     Default = 1 << 1,
68     All = 1 << 2,
69     Extra = 1 << 3,
70     Pedantic = 1 << 4,
71 
72     // Any language
73     UnusedLocals = 1 << 7,
74     UnusedParams = 1 << 8,
75     UnusedFunctions = 1 << 9,
76     UnusedResult = 1 << 10,
77     UnusedValue = 1 << 11,
78     Documentation = 1 << 12,
79     UninitializedVars = 1 << 13,
80     HiddenLocals = 1 << 14,
81     UnknownPragma = 1 << 15,
82     Deprecated = 1 << 16,
83     SignedComparison = 1 << 17,
84     IgnoredQualifiers = 1 << 18,
85 
86     // C++
87     OverloadedVirtual = 1 << 24,
88     EffectiveCxx = 1 << 25,
89     NonVirtualDestructor = 1 << 26
90 };
91 
92 Q_DECLARE_FLAGS(LanguageExtensions, LanguageExtension)
93 
94 enum class QtVersion { Unknown = -1, None, Qt4, Qt5, Qt6 };
95 
96 } // namespace Utils
97 
98 constexpr Utils::LanguageExtension operator|(Utils::LanguageExtension first,
99                                              Utils::LanguageExtension second)
100 {
101     return Utils::LanguageExtension(static_cast<unsigned char>(first)
102                                     | static_cast<unsigned char>(second));
103 }
104 
105 constexpr bool operator&&(Utils::LanguageExtension first, Utils::LanguageExtension second)
106 {
107     return static_cast<unsigned char>(first) & static_cast<unsigned char>(second);
108 }
109 
110 inline Utils::WarningFlags operator|(Utils::WarningFlags first, Utils::WarningFlags second)
111 {
112     return Utils::WarningFlags(int(first) | int(second));
113 }
114 
115 inline Utils::WarningFlags operator&(Utils::WarningFlags first, Utils::WarningFlags second)
116 {
117     return Utils::WarningFlags(int(first) & int(second));
118 }
119 
120 inline void operator|=(Utils::WarningFlags &first, Utils::WarningFlags second)
121 {
122     first = first | second;
123 }
124 
125 inline void operator&=(Utils::WarningFlags &first, Utils::WarningFlags second)
126 {
127     first = first & second;
128 }
129 
130 inline Utils::WarningFlags operator~(Utils::WarningFlags flags)
131 {
132     return Utils::WarningFlags(~int(flags));
133 }
134