[cfe-dev] getting at the compiler error messages array?
Paul Griffiths
gafferuk at gmail.com
Tue Oct 19 03:56:52 PDT 2010
ok, i have changed from:
TextDiagnosticPrinter *DiagClient =
new TextDiagnosticPrinter(llvm::errs(), DiagnosticOptions());
Diagnostic Diags(DiagClient);
Driver TheDriver(Path.str(), llvm::sys::getHostTriple(),
"a.out", /*IsProduction=*/false, /*CXXIsProduction=*/false,
Diags);
to:
TextDiagnosticBuffer *DiagClient =
new TextDiagnosticBuffer();
Diagnostic Diags(DiagClient);
Driver TheDriver(Path.str(), llvm::sys::getHostTriple(),
"a.out", /*IsProduction=*/false, /*CXXIsProduction=*/false,
Diags);
but when i add the following code, I get get no errors reported even
though I have added some errors to my c code.
if (!Clang.ExecuteAction(*Act))
{
TextDiagnosticBuffer::const_iterator itTextDiagnosticBuffer;
{
vector<std::String> vWarnings;
int iTotalWarnings = 0;
for (itTextDiagnosticBuffer = DiagClient->warn_begin();
itTextDiagnosticBuffer != DiagClient->warn_end();
++itTextDiagnosticBuffer)
{
vWarnings.push_back(itTextDiagnosticBuffer->second.data());
iTotalWarnings++;
}
char cErrorText[255];
sprintf (cErrorText, "Total %d warnings!", iTotalWarnings);
}
{
vector<std::String> vErrors;
int iTotalErrors = 0;
for (itTextDiagnosticBuffer = DiagClient->err_begin();
itTextDiagnosticBuffer != DiagClient->err_end();
++itTextDiagnosticBuffer)
{
vErrors.push_back(itTextDiagnosticBuffer->second.data());
iTotalErrors++;
}
char cErrorText[255];
sprintf (cErrorText, "Total %d errors!", iTotalErrors);
}
}
what am i doing wrong?
On 19 October 2010 09:34, Pedro Ferreira <Pedro.Ferreira at imgtec.com> wrote:
>
>> -----Original Message-----
>> From: cfe-dev-bounces at cs.uiuc.edu
>> [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Paul Griffiths
>> Sent: 19 October 2010 09:24
>> To: cfe-dev at cs.uiuc.edu
>> Subject: [cfe-dev] getting at the compiler error messages array?
>>
>> Ive added clang to my music application to compile audio plugins.
>> Using the interpreter example as a base code, how do I get to
>> the error messages array buffer so can add the messages to my
>> code compiler window?
>>
>> Thanks.
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
> Check the Diagnostics section of Doxygen, in particular, the
> DiagnosticClient
>
> http://clang.llvm.org/doxygen/classclang_1_1DiagnosticClient.html
>
> Remember you can create your own to suit your own format. Pass the
> DiagnosticClient to your compiler instance.
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list