[PATCH] D31370: [clang-tidy] Prototype to check for exception specification
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 28 01:57:26 PDT 2017
JonasToth marked an inline comment as done.
JonasToth 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:
> 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.
Repository:
rL LLVM
https://reviews.llvm.org/D31370
More information about the cfe-commits
mailing list