[cfe-commits] r67476 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/abstract.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sun Mar 22 14:08:56 PDT 2009
Anders Carlsson wrote:
> Author: andersca
> Date: Sun Mar 22 15:18:17 2009
> New Revision: 67476
>
> URL: http://llvm.org/viewvc/llvm-project?rev=67476&view=rev
> Log:
> Disallow abstract types where appropriate.
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=67476&r1=67475&r2=67476&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Mar 22 15:18:17 2009
> @@ -731,7 +731,10 @@
> }
> }
>
> - bool empty() const { return Methods.empty(); }
> + bool empty() const { return Methods.empty(); }
> +
> + MethodList::const_iterator methods_begin() { return Methods.begin(); }
> + MethodList::const_iterator methods_end() { return Methods.end(); }
> };
>
> void PureVirtualMethodCollector::Collect(const CXXRecordDecl* RD,
> @@ -777,6 +780,47 @@
> }
> }
>
> +bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
> + unsigned SelID) {
> +
> + if (!getLangOptions().CPlusPlus)
> + return false;
> +
> + const RecordType *RT = T->getAsRecordType();
> + if (!RT)
> + return false;
> +
> + const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl());
> + if (!RD)
> + return false;
> +
> + if (!RD->isAbstract())
> + return false;
> +
> + Diag(Loc, diag::err_abstract_type_in_decl) << SelID << RD->getDeclName();
> +
> + // Check if we've already emitted the list of pure virtual functions for this
> + // class.
> + if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
> + return true;
> +
> + PureVirtualMethodCollector Collector(Context, RD);
> +
> + for (PureVirtualMethodCollector::MethodList::const_iterator I =
> + Collector.methods_begin(), E = Collector.methods_end(); I != E; ++I) {
> + const CXXMethodDecl *MD = *I;
>
This doesn't build. MethodList is private, so
Sema::RequireNonAbstractType cannot access it.
Sebastian
More information about the cfe-commits
mailing list