summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-core-diagnostics.cpp
blob: 4fbae6873eefddc3ab7b9f5c171287f522c86654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// slang-core-diagnostics.cpp
#include "slang-core-diagnostics.h"

namespace Slang
{

namespace MiscDiagnostics
{
#define DIAGNOSTIC(id, severity, name, messageFormat) \
    const DiagnosticInfo name = {id, Severity::severity, #name, messageFormat};
#include "slang-misc-diagnostic-defs.h"
#undef DIAGNOSTIC
} // namespace MiscDiagnostics

static const DiagnosticInfo* const kMiscDiagnostics[] = {
#define DIAGNOSTIC(id, severity, name, messageFormat) &MiscDiagnostics::name,
#include "slang-misc-diagnostic-defs.h"
#undef DIAGNOSTIC
};


namespace LexerDiagnostics
{
#define DIAGNOSTIC(id, severity, name, messageFormat) \
    const DiagnosticInfo name = {id, Severity::severity, #name, messageFormat};
#include "slang-lexer-diagnostic-defs.h"
#undef DIAGNOSTIC
} // namespace LexerDiagnostics

static const DiagnosticInfo* const kLexerDiagnostics[] = {
#define DIAGNOSTIC(id, severity, name, messageFormat) &LexerDiagnostics::name,
#include "slang-lexer-diagnostic-defs.h"
#undef DIAGNOSTIC
};

static DiagnosticsLookup* _newCoreDiagnosticsLookup()
{
    auto lookup = new DiagnosticsLookup;
    lookup->add(kMiscDiagnostics, SLANG_COUNT_OF(kMiscDiagnostics));
    lookup->add(kLexerDiagnostics, SLANG_COUNT_OF(kLexerDiagnostics));

    return lookup;
}

DiagnosticsLookup* getCoreDiagnosticsLookup()
{
    static RefPtr<DiagnosticsLookup> s_lookup = _newCoreDiagnosticsLookup();
    return s_lookup;
}

} // namespace Slang