Branch: refs/heads/master
Revision: 3f4f122
Author: vasslitvinov
Log Message:
Merge pull request #17150 from vasslitvinov/use-override-not-virtual
Add and enforce C++11-style 'override' and 'final' in compiler
These are changes to the Chapel compiler source code.
Developed by @mppf with contribs by @vasslitvinov
- Adds
final
on AST classes that do not have subclasses - Removes
virtual
and addsoverride
on methods where appropriate - Adds
-Wsuggest-override
option for gcc 6 and later,
which takes effect in builds with CHPL_DEVELOPER on.
The code follows these conventions:
- If a method needs an
override
annotation, dropvirtual
.
Dittofinal
annotation, although this does not add any final methods. - The
final
annotation on an AST class can be removed when needed. - The destructors in non-final AST classes are marked
virtual
.
TODO: mark themvirtual
/override
as appropriate, incl. infinal
classes
I tested this by building Chapel with g++ 4.8, 5.4, 6.3, 7.3, 8.3, 10.1,
and clang/Apple LLVM 10.0.1. The special case for gcc 4.x in Makefile.gnu
is needed because without it gcc 4.8 generates tons of override warnings.
While there, I also tested for C++14 availability using litmus-test
code snippets suggested by @leekillough. Except for 4.8, all compilers
accepted them, once I replaced -std=gnu++11
with -std=gnu++14
when we
did throw it. Gcc 4.8 does not support C++14.
The change CForLoop::copy
-> CForLoop::copyInner
and similar other changes
move these AST classes to overriding copyInner consistently with the other
ASTs, instead of overriding copy
itself.
Next steps:
- consider removing
CXX11_STD
, instead redirect RE2 toCXX_STD
- tidy up the destructors on AST nodes, marking them virtual or override
as appropriate, as suggested by @leekillough
r: @mppf
Modified Files:
M compiler/AST/CForLoop.cpp
M compiler/AST/DeferStmt.cpp
M compiler/AST/DoWhileStmt.cpp
M compiler/AST/ForLoop.cpp
M compiler/AST/LoopExpr.cpp
M compiler/AST/ParamForLoop.cpp
M compiler/AST/WhileDoStmt.cpp
M compiler/AST/WhileStmt.cpp
M compiler/codegen/symbol.cpp
M compiler/include/AggregateType.h
M compiler/include/AstCount.h
M compiler/include/AstDump.h
M compiler/include/AstDumpToHtml.h
M compiler/include/AstDumpToNode.h
M compiler/include/AstLogger.h
M compiler/include/AstPrintDocs.h
M compiler/include/AstVisitorTraverse.h
M compiler/include/CForLoop.h
M compiler/include/CallExpr.h
M compiler/include/CatchStmt.h
M compiler/include/CollapseBlocks.h
M compiler/include/DecoratedClassType.h
M compiler/include/DeferStmt.h
M compiler/include/DoWhileStmt.h
M compiler/include/FnSymbol.h
M compiler/include/ForLoop.h
M compiler/include/ForallStmt.h
M compiler/include/IfExpr.h
M compiler/include/ImportStmt.h
M compiler/include/LoopExpr.h
M compiler/include/LoopStmt.h
M compiler/include/ModuleSymbol.h
M compiler/include/ParamForLoop.h
M compiler/include/TransformLogicalShortCircuit.h
M compiler/include/TryStmt.h
M compiler/include/UseStmt.h
M compiler/include/WhileDoStmt.h
M compiler/include/WhileStmt.h
M compiler/include/baseAST.h
M compiler/include/expr.h
M compiler/include/stmt.h
M compiler/include/symbol.h
M compiler/include/type.h
M compiler/llvm/clangUtil.cpp
M compiler/llvm/llvmAggregateGlobalOps.cpp
M compiler/llvm/llvmGlobalToWide.cpp
M compiler/optimizations/optimizeForallUnorderedOps.cpp
M compiler/passes/InitNormalize.cpp
M compiler/passes/errorHandling.cpp
M compiler/passes/initializerRules.cpp
M compiler/passes/normalize.cpp
M compiler/passes/normalizeErrors.cpp
M compiler/resolution/addAutoDestroyCalls.cpp
M compiler/resolution/callDestructors.cpp
M compiler/resolution/lifetime.cpp
M compiler/resolution/lowerForalls.cpp
M compiler/resolution/lowerIterators.cpp
M compiler/resolution/nilChecking.cpp
M compiler/resolution/resolveFunction.cpp
M make/compiler/Makefile.gnu
Compare: Comparing 827b79e534e2...3f4f122d9265 · chapel-lang/chapel · GitHub