[PATCH] D31370: [clang-tidy] Prototype to check for exception specification
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 28 05:03:54 PDT 2017
aaron.ballman added inline comments.
================
Comment at: clang-tidy/modernize/NoexceptCorrectnessCheck.cpp:60
+ N.getNodeAs<FunctionDecl>("direct_throwing_decl")) {
+ // FIXME how is that done? i did not find a noThrow predicate
+ //if (ThrowingDecl->isNoThrow()) {
----------------
JonasToth wrote:
> JonasToth wrote:
> > mgehre wrote:
> > > JonasToth wrote:
> > > > How can i find out the exception spepcification in a `FunctionDecl`? I would like to check if `noexcept` might be added when it is not justified.
> > > Try `ThrowingDecl ->getType()->getAs<FunctionProtoType>()->getNoexceptSpec()`
> > Does not build :/
> >
> > note: candidate: clang::FunctionProtoType::NoexceptResult clang::FunctionProtoType::getNoexceptSpec(const clang::ASTContext&) const
> > NoexceptResult getNoexceptSpec(const ASTContext &Ctx) const;
> >
> > Where do i get the ASTContext from?
> `FunctionPrototype` has the `isNothrow` method, but it needs the `ASTContext` as well.
> An alternative solution would be `hasNoexceptExceptionSpec()`. It would ignore `throw()` most likely.
`Result.Context` is the ASTContext you need.
Repository:
rL LLVM
https://reviews.llvm.org/D31370
More information about the cfe-commits
mailing list