From: Bruno Ricci Date: Tue, 4 Dec 2018 16:36:28 +0000 (+0000) Subject: [AST] Assert that no type class is polymorphic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b83d889f094a1d4cf2effa42e3e8f640818d856;p=clang [AST] Assert that no type class is polymorphic Add a static_assert checking that no type class is polymorphic. People should use LLVM style RTTI instead. Differential Revision: https://reviews.llvm.org/D55225 Reviewed By: aaron.ballman git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348281 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index bfb08c0d38..89ab2ce1fc 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -291,6 +291,14 @@ QualType QualType::getSingleStepDesugaredTypeImpl(QualType type, return Context.getQualifiedType(desugar, split.Quals); } +// Check that no type class is polymorphic. LLVM style RTTI should be used +// instead. If absolutely needed an exception can still be added here by +// defining the appropriate macro (but please don't do this). +#define TYPE(CLASS, BASE) \ + static_assert(!std::is_polymorphic::value, \ + #CLASS "Type should not be polymorphic!"); +#include "clang/AST/TypeNodes.def" + QualType Type::getLocallyUnqualifiedSingleStepDesugaredType() const { switch (getTypeClass()) { #define ABSTRACT_TYPE(Class, Parent)