[PATCH] D14619: [PATCH] clang-tidy checker for nothrow copy constructible exception objects

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 13 07:28:41 PST 2015


aaron.ballman marked 4 inline comments as done.

================
Comment at: clang-tidy/cert/ThrownExceptionTypeCheck.cpp:18
@@ +17,3 @@
+namespace {
+AST_MATCHER(CXXConstructorDecl, isNoThrowCopyConstructible) {
+  if (!Node.isCopyConstructor())
----------------
alexfh wrote:
> nit: I suggest changing `isNoThrowCopyConstructible` to `isNoThrowCopyConstructor`, because "constructible" is a trait of a class, not its constructor.
Good catch; that was a holdover from the previous version where it was operating on the CXXRecordDecl instead.

================
Comment at: clang-tidy/cert/ThrownExceptionTypeCheck.cpp:22
@@ +21,3 @@
+
+  if (Node.isTrivial())
+    return true;
----------------
alexfh wrote:
> Out of curiosity: are we short-circuiting here for performance reasons or would the code below return `false` in this case?
I pulled the logic from the unary type trait evaluation logic, but stripped out the bits that were already handled by the AST matcher logic itself. I don't believe this is actually necessary for this checker, however.

================
Comment at: clang-tidy/cert/ThrownExceptionTypeCheck.cpp:34
@@ +33,3 @@
+  }
+  return true;
+}
----------------
alexfh wrote:
> Is this `return` reachable? If yes, when exactly does this happen and is there a test for this case?
No, it is not reachable. There's no way, that I am aware of, to get a copy constructor with no function prototype.


http://reviews.llvm.org/D14619





More information about the cfe-commits mailing list