[PATCH] D12945: [PATCH] Add checker for objects that should not be value types

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 08:35:04 PDT 2015


aaron.ballman added inline comments.

================
Comment at: clang-tidy/misc/NonCopyableObjects.cpp:21
@@ +20,3 @@
+  static const char *TypeNames[] = {
+    "::pthread_cond_t",
+    "::pthread_mutex_t",
----------------
alexfh wrote:
> How about making these lists configurable or adding a list for custom type names that should be checked in a similar way?
Do we have a helper function for making lists like these configurable? If so, I'll gladly use it. If not, perhaps we could make some helper functionality and then implement configurability at that time in a more comprehensive way?

================
Comment at: clang-tidy/misc/NonCopyableObjects.cpp:81
@@ +80,3 @@
+  if (D && BD)
+    diag(D->getLocation(), "'%0' declared as type '%1'; did you mean '%1 *'?")
+        << D->getName() << BD->getName();
----------------
alexfh wrote:
> I think, error messages should contain some explanation of why is this wrong. Not sure if this can be fit into a reasonable number of words, but we have to try.
Excellent point! How about:

'%0' declared as unsafely-copyable type '%1'; did you mean '%1 *'

or

'%0' declared as type '%1', which is unsafe to copy' did you mean '%1 *'?


http://reviews.llvm.org/D12945





More information about the cfe-commits mailing list