Coverage Report

Created: 2020-09-22 08:39

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/DiagnosticOptions.h
Line
Count
Source
1
//===- DiagnosticOptions.h --------------------------------------*- 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_BASIC_DIAGNOSTICOPTIONS_H
10
#define LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H
11
12
#include "clang/Basic/LLVM.h"
13
#include "llvm/ADT/IntrusiveRefCntPtr.h"
14
#include <string>
15
#include <type_traits>
16
#include <vector>
17
18
namespace clang {
19
20
/// Specifies which overload candidates to display when overload
21
/// resolution fails.
22
enum OverloadsShown : unsigned {
23
  /// Show all overloads.
24
  Ovl_All,
25
26
  /// Show just the "best" overload candidates.
27
  Ovl_Best
28
};
29
30
/// A bitmask representing the diagnostic levels used by
31
/// VerifyDiagnosticConsumer.
32
enum class DiagnosticLevelMask : unsigned {
33
  None    = 0,
34
  Note    = 1 << 0,
35
  Remark  = 1 << 1,
36
  Warning = 1 << 2,
37
  Error   = 1 << 3,
38
  All     = Note | Remark | Warning | Error
39
};
40
41
16.4k
inline DiagnosticLevelMask operator~(DiagnosticLevelMask M) {
42
16.4k
  using UT = std::underlying_type<DiagnosticLevelMask>::type;
43
16.4k
  return static_cast<DiagnosticLevelMask>(~static_cast<UT>(M));
44
16.4k
}
45
46
inline DiagnosticLevelMask operator|(DiagnosticLevelMask LHS,
47
451
                                     DiagnosticLevelMask RHS) {
48
451
  using UT = std::underlying_type<DiagnosticLevelMask>::type;
49
451
  return static_cast<DiagnosticLevelMask>(
50
451
    static_cast<UT>(LHS) | static_cast<UT>(RHS));
51
451
}
52
53
inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
54
132k
                                     DiagnosticLevelMask RHS) {
55
132k
  using UT = std::underlying_type<DiagnosticLevelMask>::type;
56
132k
  return static_cast<DiagnosticLevelMask>(
57
132k
    static_cast<UT>(LHS) & static_cast<UT>(RHS));
58
132k
}
59
60
raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
61
62
/// Options for controlling the compiler diagnostics engine.
63
class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
64
public:
65
  enum TextDiagnosticFormat { Clang, MSVC, Vi };
66
67
  // Default values.
68
  enum {
69
    DefaultTabStop = 8,
70
    MaxTabStop = 100,
71
    DefaultMacroBacktraceLimit = 6,
72
    DefaultTemplateBacktraceLimit = 10,
73
    DefaultConstexprBacktraceLimit = 10,
74
    DefaultSpellCheckingLimit = 50,
75
    DefaultSnippetLineLimit = 1,
76
  };
77
78
  // Define simple diagnostic options (with no accessors).
79
#define DIAGOPT(Name, Bits, Default) unsigned Name : Bits;
80
#define ENUM_DIAGOPT(Name, Type, Bits, Default)
81
#include "clang/Basic/DiagnosticOptions.def"
82
83
protected:
84
  // Define diagnostic options of enumeration type. These are private, and will
85
  // have accessors (below).
86
#define DIAGOPT(Name, Bits, Default)
87
#define ENUM_DIAGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
88
#include "clang/Basic/DiagnosticOptions.def"
89
90
public:
91
  /// The file to log diagnostic output to.
92
  std::string DiagnosticLogFile;
93
94
  /// The file to serialize diagnostics to (non-appending).
95
  std::string DiagnosticSerializationFile;
96
97
  /// The list of -W... options used to alter the diagnostic mappings, with the
98
  /// prefixes removed.
99
  std::vector<std::string> Warnings;
100
101
  /// The list of prefixes from -Wundef-prefix=... used to generate warnings
102
  /// for undefined macros.
103
  std::vector<std::string> UndefPrefixes;
104
105
  /// The list of -R... options used to alter the diagnostic mappings, with the
106
  /// prefixes removed.
107
  std::vector<std::string> Remarks;
108
109
  /// The prefixes for comment directives sought by -verify ("expected" by
110
  /// default).
111
  std::vector<std::string> VerifyPrefixes;
112
113
public:
114
  // Define accessors/mutators for diagnostic options of enumeration type.
115
#define DIAGOPT(Name, Bits, Default)
116
#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
117
239k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::DiagnosticOptions::getFormat() const
Line
Count
Source
117
82.1k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::DiagnosticOptions::getShowOverloads() const
Line
Count
Source
117
119k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::DiagnosticOptions::getVerifyIgnoreUnexpected() const
Line
Count
Source
117
38.1k
  Type get##Name() const { return static_cast<Type>(Name); } \
118
1.20M
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::DiagnosticOptions::setFormat(clang::DiagnosticOptions::TextDiagnosticFormat)
Line
Count
Source
118
400k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::DiagnosticOptions::setShowOverloads(clang::OverloadsShown)
Line
Count
Source
118
400k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::DiagnosticOptions::setVerifyIgnoreUnexpected(clang::DiagnosticLevelMask)
Line
Count
Source
118
399k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
119
#include "clang/Basic/DiagnosticOptions.def"
120
121
284k
  DiagnosticOptions() {
122
8.52M
#define DIAGOPT(Name, Bits, Default) Name = Default;
123
852k
#define ENUM_DIAGOPT(Name, Type, Bits, Default) set##Name(Default);
124
284k
#include "clang/Basic/DiagnosticOptions.def"
125
284k
  }
126
};
127
128
using TextDiagnosticFormat = DiagnosticOptions::TextDiagnosticFormat;
129
130
} // namespace clang
131
132
#endif // LLVM_CLANG_BASIC_DIAGNOSTICOPTIONS_H