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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 18:03:30 PDT 2015


alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

One of the error messages still needs to be made more clear. Otherwise looks good.

Thank you!


================
Comment at: clang-tidy/misc/NonCopyableObjects.cpp:88
@@ +87,3 @@
+  else if (E)
+    diag(E->getExprLoc(), "expression has suspicious type '%0'")
+        << BD->getName();
----------------
aaron.ballman wrote:
> alexfh wrote:
> > What's a "suspicious type" and why should the user know about this? Should the message explain better what's wrong and what can be done about that?
> I was trying to find better wording for this, but it's really hard. This comes from dereferencing a type that should only be used as an opaque pointer type. eg) memcpy(some_buffer, *some_pthread_mutex_t, sizeof(pthread_mutex_t));
> 
> Perhaps:
> 
> expression has opaque data structure type '%0'; do not rely on internal implementation details
> 
> or something to that effect?
That's much better, but the "do not rely on internal implementation details" is still not very clear. Maybe add that the type should only be used as a pointer and should never be dereferenced in the user code?


http://reviews.llvm.org/D12945





More information about the cfe-commits mailing list