[cfe-dev] [clang-tidy] calling Sema from tidy + miscellaneous questions

Tiago Macarios via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 25 11:04:38 PST 2021


Hi I am working on a clang-tidy check to add constexpr to functions and I
have a couple of questions:

1 - The checker I am working on
calls Sema::CheckConstexprFunctionDefinition as well as other functions
that require a Sema reference. I currently don't see a way to call Sema
from a clang-tidy check. I am wondering what would be the best way to
accomplish that. Would saving a pointer to CompilerInstance in the
SourceManager would be a good solution?

2 - In the checker I sometimes need to suppress diagnostics and then
re-enable them. Does llvm have a "run at end of scope class" (similar to
gsl::finally
https://github.com/microsoft/GSL/blob/master/include/gsl/util#L50-L80)?

3 - Somewhat unrelated to this checker specifically. We use code similar
to clang::arcmt::trans::findSemiAfterLocation in a fair bit of our
checkers. I see that we already had discussions about moving this to a
better/more discoverable location:
http://clang-developers.42468.n3.nabble.com/Help-with-clang-AST-matchers-find-semicolon-after-a-decl-statement-td4040866.html
I am willing to do the work, just a bit unsure of where it should be moved
so that both arcmigrate and clang-tidy can access it.

Thanks,
Tiago
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210125/021475ed/attachment.html>


More information about the cfe-dev mailing list