diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2018-12-04 16:04:19 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2018-12-04 16:04:19 +0000 |
commit | 65034b8698851e22d03b2c4f51fe12df957a5279 (patch) | |
tree | 6fc754c1f1bcb8cda236c461957abe665c9e8b50 /clang/lib/AST/Stmt.cpp | |
parent | e82c3dab12dd81362459d86ad824850e92a3d8ac (diff) | |
download | llvm-65034b8698851e22d03b2c4f51fe12df957a5279.zip llvm-65034b8698851e22d03b2c4f51fe12df957a5279.tar.gz llvm-65034b8698851e22d03b2c4f51fe12df957a5279.tar.bz2 |
[AST] Assert that no statement/expression class is polymorphic
Add a static_assert checking that no statement/expression class
is polymorphic. People should use LLVM style RTTI instead.
Differential Revision: https://reviews.llvm.org/D55222
Reviewed By: aaron.ballman
llvm-svn: 348278
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 32330ea..116291b 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -76,6 +76,14 @@ const char *Stmt::getStmtClassName() const { return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name; } +// Check that no statement / expression 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 STMT(CLASS, PARENT) \ + static_assert(!std::is_polymorphic<CLASS>::value, \ + #CLASS " should not be polymorphic!"); +#include "clang/AST/StmtNodes.inc" + void Stmt::PrintStats() { // Ensure the table is primed. getStmtInfoTableEntry(Stmt::NullStmtClass); |