You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

#include "Diagnostic.h"
11 years ago
#include "SourceLocation.h"
#include "Tokens.h"
#include "Utility.h"
11 years ago
clang::Diagnostic::Diagnostic(CXTranslationUnit& cx_tu, CXDiagnostic& cx_diagnostic) {
severity=clang_getDiagnosticSeverity(cx_diagnostic);
11 years ago
severity_spelling=get_severity_spelling(severity);
spelling=clang::to_string(clang_getDiagnosticSpelling(cx_diagnostic));
11 years ago
clang::SourceLocation start_location(clang_getDiagnosticLocation(cx_diagnostic));
11 years ago
11 years ago
path=start_location.get_path();
unsigned start_offset=start_location.get_offset();
11 years ago
clang::Tokens tokens(cx_tu, SourceRange(start_location, start_location));
if(tokens.size()==1) {
11 years ago
offsets=std::pair<unsigned, unsigned>(start_offset, tokens[0].offsets.second);
11 years ago
}
}
const std::string clang::Diagnostic::get_severity_spelling(unsigned severity) {
switch(severity) {
11 years ago
case CXDiagnostic_Ignored:
return "Ignored";
11 years ago
case CXDiagnostic_Note:
return "Note";
11 years ago
case CXDiagnostic_Warning:
return "Warning";
11 years ago
case CXDiagnostic_Error:
return "Error";
11 years ago
case CXDiagnostic_Fatal:
return "Fatal";
default:
return "";
}
}