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.

36 lines
1.1 KiB

#include "Diagnostic.h"
11 years ago
#include "SourceLocation.h"
#include "Tokens.h"
clang::Diagnostic::Diagnostic(CXTranslationUnit& tu, CXDiagnostic& clang_diagnostic) {
11 years ago
severity=clang_getDiagnosticSeverity(clang_diagnostic);
severity_spelling=get_severity_spelling(severity);
spelling=clang_getCString(clang_getDiagnosticSpelling(clang_diagnostic));
clang::SourceLocation location(clang_getDiagnosticLocation(clang_diagnostic));
clang::SourceRange range(&location, &location);
clang::Tokens tokens(tu, &range);
if(tokens.size()==1) {
auto& token=tokens[0];
clang::SourceRange range=token.get_source_range();
auto end_location=clang::SourceLocation(&range, false);
this->range=SourceRange::get_range_data(location, end_location);
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 "";
}
}