Skip to content

Constify DiagnosticEngine's lists of diagnostic info #19335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ struct StoredDiagnosticInfo {
bool pointsToFirstBadToken : 1;
bool isFatal : 1;

StoredDiagnosticInfo(DiagnosticKind k, bool firstBadToken, bool fatal)
constexpr StoredDiagnosticInfo(DiagnosticKind k, bool firstBadToken,
bool fatal)
: kind(k), pointsToFirstBadToken(firstBadToken), isFatal(fatal) {}
StoredDiagnosticInfo(DiagnosticKind k, DiagnosticOptions opts)
constexpr StoredDiagnosticInfo(DiagnosticKind k, DiagnosticOptions opts)
: StoredDiagnosticInfo(k,
opts == DiagnosticOptions::PointsToFirstBadToken,
opts == DiagnosticOptions::Fatal) {}
Expand All @@ -73,7 +74,7 @@ enum LocalDiagID : uint32_t {
} // end anonymous namespace

// TODO: categorization
static StoredDiagnosticInfo storedDiagnosticInfos[] = {
static const constexpr StoredDiagnosticInfo storedDiagnosticInfos[] = {
#define ERROR(ID, Options, Text, Signature) \
StoredDiagnosticInfo(DiagnosticKind::Error, DiagnosticOptions::Options),
#define WARNING(ID, Options, Text, Signature) \
Expand All @@ -88,7 +89,7 @@ static_assert(sizeof(storedDiagnosticInfos) / sizeof(StoredDiagnosticInfo) ==
LocalDiagID::NumDiags,
"array size mismatch");

static const char *diagnosticStrings[] = {
static constexpr const char * const diagnosticStrings[] = {
#define ERROR(ID, Options, Text, Signature) Text,
#define WARNING(ID, Options, Text, Signature) Text,
#define NOTE(ID, Options, Text, Signature) Text,
Expand Down