Skip to content

Commit

Permalink
[AST] Assert that no type class is polymorphic
Browse files Browse the repository at this point in the history
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

llvm-svn: 348281
  • Loading branch information
riccibruno committed Dec 4, 2018
1 parent 660d233 commit 32a7282
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/lib/AST/Type.cpp
Expand Up @@ -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<CLASS##Type>::value, \
#CLASS "Type should not be polymorphic!");
#include "clang/AST/TypeNodes.def"

QualType Type::getLocallyUnqualifiedSingleStepDesugaredType() const {
switch (getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
Expand Down

0 comments on commit 32a7282

Please sign in to comment.