[PATCH] D55225: [AST] Assert that no type class is polymorphic

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 3 10:44:33 PST 2018


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

LGTM!



================
Comment at: lib/AST/Type.cpp:299
+  static_assert(!std::is_polymorphic<CLASS##Type>::value, \
+                #CLASS "Type should not be polymorphic!");
+#include "clang/AST/TypeNodes.def"
----------------
riccibruno wrote:
> aaron.ballman wrote:
> > This will squish your class name and error text together. I think you need a whitespace before "Type" and make that lowercase.
> This is on purpose, since what is substituted into
> `CLASS` is the name of the type class, without the "Type",
> eg: for `FunctionProtoType`, `CLASS` will be `FunctionProto`
> and we want to stick the `Type` to it so that the error message will
> be "FunctionProtoType should not ....".
Ah! Thank you for pointing that out.


================
Comment at: lib/AST/Type.cpp:301
+#include "clang/AST/TypeNodes.def"
+
 QualType Type::getLocallyUnqualifiedSingleStepDesugaredType() const {
----------------
riccibruno wrote:
> aaron.ballman wrote:
> > I'd feel more comfortable if there was a `#undef TYPE` here.
> I can certainly add one but it is already done in `TypeNodes.def`.
Ah, nm then -- I didn't see we had that at the bottom of that file.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55225/new/

https://reviews.llvm.org/D55225





More information about the cfe-commits mailing list