[cfe-dev] Diagnostic won't emit
Billy O'Mahony via cfe-dev
cfe-dev at lists.llvm.org
Fri Oct 9 12:43:16 PDT 2020
thanks for the reply. My code is basically identical to the mccabe example:
454 const clang::BinaryOperator *binOp =
455 if (!binOp || binOp->getOpcodeStr() != std::string("="))
// TODO check for isAssignmentOp
457 auto& Diagnostics = mContext->getDiagnostics();
458 const auto ID =
value from '%0' is not assigned");
460 auto Builder =
463 cout << "ERROR: Return val from API call not assigned
'" << Diagnostics.getClient() << " " << fnDecl->getNameAsString()
464 return true;
I know that my DiagnosticsEngine does have a DiagnosticConsumer as
Diagnostics.getClient() returns non-null.
My understanding is that when the Build object is destroyed after the
return that the diagnostic should be emitted.
I will have a look at those samples.
On Fri, 9 Oct 2020 at 20:18, Andrzej Warzynski <andrzej.warzynski at arm.com>
> Hi Billy,
> It's a bit tricky to help without seeing the code :) Are you using any
> specific/custom diagnostic consumer? Is your properly DiagnosticBuilder
> destroyed? AFAIK, that's when the message is printed.
> Here's a bit more up-to-date example:
> And a test that verifies that the diagnostic is indeed printed:
> Happy to help if that example doesn't work for you! Hopefully it will
> help debugging your own code :)
> On 09/10/2020 16:26, Billy O'Mahony via cfe-dev wrote:
> > Hi,
> > hopefully a straightforward issue.
> > I have written a standalone cfe tool to catch some project-specific bugs
> > in a code base.
> > I am now replacing my cout << "ERROR..." messages with
> > clang::Diagnostics by following this example:
> > However I don't see anything being printed when I run it (except my own
> > cout << "error.." messages)..
> > I've seen the mcabbe example generate diagnostics on a
> > youtube presentation and both it and my app use
> > clang::Tool. mccabbe uses ast_matcher::MatchFinder whereas I use
> > several classes derived from RecursiveASTVisitor. Presumably MatchFinder
> > sets up a DiagnosticsConsumer that finally emits the diagnostics??
> > But I couldn't really find out how to set up a DiagnosticsConsumer - if
> > that is indeed what I need to do.
> > Thanks,
> > Billy.
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev