[PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.
Filipe Cabecinhas via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 21 06:58:20 PDT 2016
filcab added a comment.
The patch needs to get through clang-format.
Should we deal with typeid and dynamic_cast, since they're mentioned in the same paragraph in the standard?
================
Comment at: lib/Sema/SemaDeclCXX.cpp:3895
@@ +3894,3 @@
+ // Check if member call is actually to the given class.
+ if (E->getRecordDecl() == nullptr
+ || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass
----------------
What's the rationale for warning if `getRecordDecl` returns `nullptr`?
================
Comment at: lib/Sema/SemaDeclCXX.cpp:3897
@@ +3896,3 @@
+ || E->getRecordDecl()->getCanonicalDecl() == OnlyForClass
+ || OnlyForClass->isDerivedFrom(E->getRecordDecl())) {
+ FoundMemberCall = E;
----------------
Please run clang-format on the patch.
================
Comment at: lib/Sema/SemaDeclCXX.cpp:3941
@@ +3940,3 @@
+ if (Member->isBaseInitializer()) {
+ // Calling a member function from a ctor-initializer
+ // before the base class results in undefined behavior [C++11 12.6.2 p13].
----------------
clang-format
================
Comment at: lib/Sema/SemaDeclCXX.cpp:3942
@@ +3941,3 @@
+ // Calling a member function from a ctor-initializer
+ // before the base class results in undefined behavior [C++11 12.6.2 p13].
+ // FIXME: We only check for member functions directly called from this
----------------
"before the base class is initialized"?
http://reviews.llvm.org/D19312
More information about the cfe-commits
mailing list