Prazek added inline comments. ================ Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:25 @@ +24,3 @@ + Finder->addMatcher( + cxxThrowExpr(stmt(hasAncestor(functionDecl(isNoThrow()).bind("func")))) + .bind("throw"), ---------------- aaron.ballman wrote: > Prazek wrote: > > you can use forFunction instead of hasAncestor(functionDecl( > > cxxThrowExpr(stmt(forFunction(isNoThrow() or > > cxxThrowExpr(stmt(forFunction(functionDecl(isNoThrow()))) > > you can even try to remove stmt. > > > > > > Also add test case > > > > void getFunction() noexcept { > > struct X { > > static void inner() > > { > > throw 42; > > } > > }; > > } > > > Hmm, I wonder if it's trivial enough to filter out throw statements that are > inside a try block scope (even without checking the expression and catch > block types)? unless(hasAncestor(cxxTryStmt())) should do the work for almost all cases. Maybe even something like this to catch only valid try blocks
cxxThrowExpr(stmt(forFunction(functionDecl(isNoThrow()).bind("func"))), unless(hasAncestor(cxxTryStmt().bind("try"), forFunction(hasBody(hasDescendant(equalsBoundNode("try"))))) + it should check that the throw is not in CXXCatchStmt (unless it is in another try block). Repository: rL LLVM http://reviews.llvm.org/D19201 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits