Skip to content

Commit 916e1e6

Browse files
authored
Constify DiagnosticEngine's lists of diagnostic info (#19335)
1 parent b920c02 commit 916e1e6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ struct StoredDiagnosticInfo {
5555
bool pointsToFirstBadToken : 1;
5656
bool isFatal : 1;
5757

58-
StoredDiagnosticInfo(DiagnosticKind k, bool firstBadToken, bool fatal)
58+
constexpr StoredDiagnosticInfo(DiagnosticKind k, bool firstBadToken,
59+
bool fatal)
5960
: kind(k), pointsToFirstBadToken(firstBadToken), isFatal(fatal) {}
60-
StoredDiagnosticInfo(DiagnosticKind k, DiagnosticOptions opts)
61+
constexpr StoredDiagnosticInfo(DiagnosticKind k, DiagnosticOptions opts)
6162
: StoredDiagnosticInfo(k,
6263
opts == DiagnosticOptions::PointsToFirstBadToken,
6364
opts == DiagnosticOptions::Fatal) {}
@@ -73,7 +74,7 @@ enum LocalDiagID : uint32_t {
7374
} // end anonymous namespace
7475

7576
// TODO: categorization
76-
static StoredDiagnosticInfo storedDiagnosticInfos[] = {
77+
static const constexpr StoredDiagnosticInfo storedDiagnosticInfos[] = {
7778
#define ERROR(ID, Options, Text, Signature) \
7879
StoredDiagnosticInfo(DiagnosticKind::Error, DiagnosticOptions::Options),
7980
#define WARNING(ID, Options, Text, Signature) \
@@ -88,7 +89,7 @@ static_assert(sizeof(storedDiagnosticInfos) / sizeof(StoredDiagnosticInfo) ==
8889
LocalDiagID::NumDiags,
8990
"array size mismatch");
9091

91-
static const char *diagnosticStrings[] = {
92+
static constexpr const char * const diagnosticStrings[] = {
9293
#define ERROR(ID, Options, Text, Signature) Text,
9394
#define WARNING(ID, Options, Text, Signature) Text,
9495
#define NOTE(ID, Options, Text, Signature) Text,

0 commit comments

Comments
 (0)