Commit e8f8a04f authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Removed get_severity_spelling and now stores diagnostic severity as enum class

parent 892652a6
......@@ -4,8 +4,7 @@
#include "utility.h"
clangmm::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic) {
severity=clang_getDiagnosticSeverity(cx_diagnostic);
severity_spelling=get_severity_spelling(severity);
severity=static_cast<Severity>(clang_getDiagnosticSeverity(cx_diagnostic));
spelling=to_string(clang_getDiagnosticSpelling(cx_diagnostic));
SourceLocation location(clang_getDiagnosticLocation(cx_diagnostic));
......@@ -23,20 +22,3 @@ clangmm::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagn
fix_its.emplace_back(source, SourceRange(fix_it_range).get_offsets());
}
}
const std::string clangmm::Diagnostic::get_severity_spelling(unsigned severity) {
switch(severity) {
case CXDiagnostic_Ignored:
return "Ignored";
case CXDiagnostic_Note:
return "Note";
case CXDiagnostic_Warning:
return "Warning";
case CXDiagnostic_Error:
return "Error";
case CXDiagnostic_Fatal:
return "Fatal";
default:
return "";
}
}
......@@ -10,6 +10,14 @@ namespace clangmm {
friend class TranslationUnit;
Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic);
public:
enum class Severity {
Ignored = 0,
Note,
Warning,
Error,
Fatal
};
class FixIt {
public:
FixIt(const std::string &source, const std::pair<clangmm::Offset, clangmm::Offset> &offsets):
......@@ -17,11 +25,8 @@ namespace clangmm {
std::string source;
std::pair<clangmm::Offset, clangmm::Offset> offsets;
};
static const std::string get_severity_spelling(unsigned severity);
unsigned severity;
std::string severity_spelling;
Severity severity;
std::string spelling;
std::string path;
std::pair<clangmm::Offset, clangmm::Offset> offsets;
......
......@@ -27,5 +27,5 @@ int main() {
auto diagnostics=tu.get_diagnostics();
assert(diagnostics.size()>0);
assert(!diagnostics[0].spelling.empty());
assert(diagnostics[0].severity==3);
assert(diagnostics[0].severity==clangmm::Diagnostic::Severity::Error);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment