[PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 5 09:46:16 PDT 2016

aaron.ballman added inline comments.

Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:16
@@ +15,3 @@
+// FIXME: Should this be moved to ASTMatchers.h?
+namespace ast_matchers {
alexfh wrote:
> Yes, it might make sense to move it to ASTMatchers.h.
Yes, please (along with tests and documentation, etc).

Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:94
@@ +93,3 @@
+  const FunctionDecl *FuncDecl =
+      Result.Nodes.getNodeAs<clang::FunctionDecl>("functionDecl");
Can use `auto` here to not repeat the type name from the initializer.

Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:148
@@ +147,3 @@
+    CurrentLoc = Tok.getLocation();
+  }
I think all of this custom logic can be replaced by looking at the FunctionType. If it has a dynamic exception specification (`hasDynamicExceptionSpec()`) then whether it is throwing or not throwing (`isNothrow()`) determines whether you replace with `noexcept(false)`  or `noexcept`. But then you don't have to go back to the source to see what is written.


More information about the cfe-commits mailing list