[cfe-commits] r75168 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclCXX.cpp test/SemaCXX/constructor-initializer.cpp test/SemaCXX/warn-reorder-ctor-initialization.cpp
Douglas Gregor
dgregor at apple.com
Tue Jul 21 10:08:09 PDT 2009
On Jul 9, 2009, at 1:00 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Thu Jul 9 14:59:47 2009
> New Revision: 75168
>
> URL: http://llvm.org/viewvc/llvm-project?rev=75168&view=rev
> Log:
> Sema check on out of order object initialization of
> class object's base and members under -Wreorder flag.
Very nice!
> + int Last = AllBaseOrMembers.size();
> + int curIndex = 0;
> + CXXBaseOrMemberInitializer *PrevMember = 0;
> + for (unsigned i = 0; i < NumMemInits; i++) {
> + CXXBaseOrMemberInitializer *Member =
> + static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
> + void *MemberInCtorList;
> + if (Member->isBaseInitializer())
> + MemberInCtorList = Member->getBaseClass();
> + else
> + MemberInCtorList = Member->getMember();
> +
> + int j;
> + for (j = curIndex; j < Last; j++)
> + if (MemberInCtorList == AllBaseOrMembers[j])
> + break;
It's too bad that this is O(N^2), but I can't think of a way to make
it faster without having the ability to sort the initializer list by
its initialization-position. Besides, the initializer list will
generally be short.
- Doug
More information about the cfe-commits
mailing list