Browse Source

Improve diagnostic - error/warning info back to C#.

pull/1/head
Tarmo Pikaro 13 years ago committed by triton
parent
commit
64c46def5d
  1. 25
      src/Parser/Parser.cpp
  2. 12
      src/Parser/Parser.h

25
src/Parser/Parser.cpp

@ -1278,6 +1278,7 @@ void Parser::WalkMacros(clang::PreprocessingRecord* PR) @@ -1278,6 +1278,7 @@ void Parser::WalkMacros(clang::PreprocessingRecord* PR)
macro->Expression = marshalString<E_UTF8>(Expression)->Trim();
auto M = GetModule(BeginExpr);
if( M != nullptr )
M->Macros->Add(macro);
break;
@ -1560,6 +1561,7 @@ struct Diagnostic @@ -1560,6 +1561,7 @@ struct Diagnostic
{
clang::SourceLocation Location;
llvm::SmallString<100> Message;
clang::DiagnosticsEngine::Level Level;
};
struct DiagnosticConsumer : public clang::DiagnosticConsumer
@ -1570,6 +1572,7 @@ struct DiagnosticConsumer : public clang::DiagnosticConsumer @@ -1570,6 +1572,7 @@ struct DiagnosticConsumer : public clang::DiagnosticConsumer
const clang::Diagnostic& Info) override {
auto Diag = Diagnostic();
Diag.Location = Info.getLocation();
Diag.Level = Level;
Info.FormatDiagnostic(Diag.Message);
Diagnostics.push_back(Diag);
}
@ -1635,6 +1638,28 @@ ParserResult^ Parser::Parse(const std::string& File) @@ -1635,6 +1638,28 @@ ParserResult^ Parser::Parse(const std::string& File)
auto PDiag = ParserDiagnostic();
PDiag.FileName = marshalString<E_UTF8>(FileName.str());
PDiag.Message = marshalString<E_UTF8>(Diag.Message.str());
switch( Diag.Level )
{
case clang::DiagnosticsEngine::Ignored:
PDiag.Level = ParserDiagnosticLevel::Ignored;
break;
case clang::DiagnosticsEngine::Note:
PDiag.Level = ParserDiagnosticLevel::Note;
break;
case clang::DiagnosticsEngine::Warning:
default:
PDiag.Level = ParserDiagnosticLevel::Warning;
break;
case clang::DiagnosticsEngine::Error:
PDiag.Level = ParserDiagnosticLevel::Error;
break;
case clang::DiagnosticsEngine::Fatal:
PDiag.Level = ParserDiagnosticLevel::Fatal;
break;
break;
} // switch
res->Diagnostics->Add(PDiag);
}

12
src/Parser/Parser.h

@ -55,10 +55,22 @@ public ref struct ParserOptions @@ -55,10 +55,22 @@ public ref struct ParserOptions
bool Verbose;
};
public enum struct ParserDiagnosticLevel
{
Ignored,
Note,
Warning,
Error,
Fatal
};
public value struct ParserDiagnostic
{
System::String^ FileName;
System::String^ Message;
ParserDiagnosticLevel Level;
};
public enum struct ParserResultKind

Loading…
Cancel
Save