OLD | NEW |
(Empty) | |
| 1 #include "DiagnosticEmitter.h" |
| 2 |
| 3 #include "clang/Basic/Diagnostic.h" |
| 4 #include "clang/Frontend/CompilerInstance.h" |
| 5 |
| 6 namespace clang { |
| 7 |
| 8 DiagnosticEmitter::DiagnosticEmitter(CompilerInstance* instance, |
| 9 const std::string& name) |
| 10 : instance_(instance), |
| 11 diagnostic_(&instance_->getDiagnostics()) { |
| 12 } |
| 13 |
| 14 void DiagnosticEmitter::EmitWarning(SourceLocation loc, |
| 15 const char* raw_error) { |
| 16 FullSourceLoc full(loc, instance_->getSourceManager()); |
| 17 std::string err(name_); |
| 18 err += raw_error; |
| 19 Diagnostic::Level level = |
| 20 diagnostic_->getWarningsAsErrors() ? |
| 21 Diagnostic::Error : |
| 22 Diagnostic::Warning; |
| 23 unsigned id = diagnostic_->getCustomDiagID(level, err); |
| 24 diagnostic_->Report(full, id).Emit(); |
| 25 } |
| 26 |
| 27 void DiagnosticEmitter::EmitError(SourceLocation loc, const char* raw_error) { |
| 28 FullSourceLoc full(loc, instance_->getSourceManager()); |
| 29 std::string err(name_); |
| 30 err += raw_error; |
| 31 unsigned id = diagnostic_->getCustomDiagID(Diagnostic::Error, err); |
| 32 diagnostic_->Report(full, id).Emit(); |
| 33 } |
| 34 |
| 35 } // namespace clang |
OLD | NEW |