[cfe-commits] r124087 - in /cfe/trunk: include/clang/Basic/Attr.td include/clang/Sema/AttributeList.h lib/Parse/ParseDeclCXX.cpp lib/Sema/AttributeList.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp test/CXX/dcl.dcl/dcl.attr/dcl.attr.overrid
Nico Weber
thakis at chromium.org
Sun Jan 23 17:50:06 PST 2011
Why? Is the plan to reimplement this in some other way?
On Sun, Jan 23, 2011 at 1:33 PM, Anders Carlsson <andersca at mac.com> wrote:
> Author: andersca
> Date: Sun Jan 23 15:33:18 2011
> New Revision: 124087
>
> URL: http://llvm.org/viewvc/llvm-project?rev=124087&view=rev
> Log:
> Get rid of [[hiding]], [[override]] and [[base_check]].
>
> Removed:
> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.override/
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/AttributeList.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaCXX/attr-cxx0x.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Sun Jan 23 15:33:18 2011
> @@ -129,12 +129,6 @@
> let Args = [StringArgument<"Label">];
> }
>
> -def BaseCheck : InheritableAttr {
> - let Spellings = ["base_check"];
> - let Subjects = [CXXRecord];
> - let Namespaces = ["", "std"];
> -}
> -
> def Blocks : InheritableAttr {
> let Spellings = ["blocks"];
> let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
> @@ -238,12 +232,6 @@
> let Spellings = ["gnu_inline"];
> }
>
> -def Hiding : InheritableAttr {
> - let Spellings = ["hiding"];
> - let Subjects = [Field, CXXMethod];
> - let Namespaces = ["", "std"];
> -}
> -
> def IBAction : InheritableAttr {
> let Spellings = ["ibaction"];
> }
> @@ -344,12 +332,6 @@
> let Spellings = ["NSOjbect"];
> }
>
> -def Override : InheritableAttr {
> - let Spellings = ["override"];
> - let Subjects = [CXXVirtualMethod];
> - let Namespaces = ["", "std"];
> -}
> -
> def Overloadable : Attr {
> let Spellings = ["overloadable"];
> }
>
> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
> +++ cfe/trunk/include/clang/Sema/AttributeList.h Sun Jan 23 15:33:18 2011
> @@ -108,7 +108,6 @@
> AT_format_arg,
> AT_global,
> AT_gnu_inline,
> - AT_hiding,
> AT_host,
> AT_launch_bounds,
> AT_malloc,
> @@ -126,7 +125,6 @@
> AT_nothrow,
> AT_nsobject,
> AT_objc_exception,
> - AT_override,
> AT_cf_returns_not_retained, // Clang-specific.
> AT_cf_returns_retained, // Clang-specific.
> AT_ns_returns_not_retained, // Clang-specific.
>
> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sun Jan 23 15:33:18 2011
> @@ -2221,11 +2221,8 @@
> switch(AttributeList::getKind(AttrName))
> {
> // No arguments
> - case AttributeList::AT_base_check:
> case AttributeList::AT_carries_dependency:
> - case AttributeList::AT_hiding:
> - case AttributeList::AT_noreturn:
> - case AttributeList::AT_override: {
> + case AttributeList::AT_noreturn: {
> if (Tok.is(tok::l_paren)) {
> Diag(Tok.getLocation(), diag::err_cxx0x_attribute_forbids_arguments)
> << AttrName->getName();
>
> Modified: cfe/trunk/lib/Sema/AttributeList.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/AttributeList.cpp (original)
> +++ cfe/trunk/lib/Sema/AttributeList.cpp Sun Jan 23 15:33:18 2011
> @@ -56,7 +56,6 @@
> .Case("__const", AT_const) // some GCC headers do contain this spelling
> .Case("blocks", AT_blocks)
> .Case("format", AT_format)
> - .Case("hiding", AT_hiding)
> .Case("malloc", AT_malloc)
> .Case("packed", AT_packed)
> .Case("unused", AT_unused)
> @@ -77,7 +76,6 @@
> .Case("iboutletcollection", AT_IBOutletCollection)
> .Case("noreturn", AT_noreturn)
> .Case("noinline", AT_noinline)
> - .Case("override", AT_override)
> .Case("sentinel", AT_sentinel)
> .Case("NSObject", AT_nsobject)
> .Case("dllimport", AT_dllimport)
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jan 23 15:33:18 2011
> @@ -3372,52 +3372,6 @@
> }
> }
>
> -/// CheckClassMemberNameAttributes - Check for class member name checking
> -/// attributes according to [dcl.attr.override]
> -static void
> -CheckClassMemberNameAttributes(Sema& SemaRef, const FunctionDecl *FD) {
> - const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
> - if (!MD || !MD->isVirtual())
> - return;
> -
> - bool HasOverrideAttr = MD->hasAttr<OverrideAttr>();
> - bool HasOverriddenMethods =
> - MD->begin_overridden_methods() != MD->end_overridden_methods();
> -
> - /// C++ [dcl.attr.override]p2:
> - /// If a virtual member function f is marked override and does not override
> - /// a member function of a base class the program is ill-formed.
> - if (HasOverrideAttr && !HasOverriddenMethods) {
> - SemaRef.Diag(MD->getLocation(),
> - diag::err_function_marked_override_not_overriding)
> - << MD->getDeclName();
> - return;
> - }
> -
> - if (!MD->getParent()->hasAttr<BaseCheckAttr>())
> - return;
> -
> - /// C++ [dcl.attr.override]p6:
> - /// In a class definition marked base_check, if a virtual member function
> - /// that is neither implicitly-declared nor a destructor overrides a
> - /// member function of a base class and it is not marked override, the
> - /// program is ill-formed.
> - if (HasOverriddenMethods && !HasOverrideAttr && !MD->isImplicit() &&
> - !isa<CXXDestructorDecl>(MD)) {
> - llvm::SmallVector<const CXXMethodDecl*, 4>
> - OverriddenMethods(MD->begin_overridden_methods(),
> - MD->end_overridden_methods());
> -
> - SemaRef.Diag(MD->getLocation(),
> - diag::err_function_overriding_without_override)
> - << MD->getDeclName() << (unsigned)OverriddenMethods.size();
> -
> - for (unsigned I = 0; I != OverriddenMethods.size(); ++I)
> - SemaRef.Diag(OverriddenMethods[I]->getLocation(),
> - diag::note_overridden_virtual_function);
> - }
> -}
> -
> NamedDecl*
> Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
> QualType R, TypeSourceInfo *TInfo,
> @@ -4095,7 +4049,6 @@
> FunctionTemplate->setInvalidDecl();
> return FunctionTemplate;
> }
> - CheckClassMemberNameAttributes(*this, NewFD);
> }
>
> MarkUnusedFileScopedDecl(NewFD);
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Jan 23 15:33:18 2011
> @@ -2438,82 +2438,6 @@
> }
>
> //===----------------------------------------------------------------------===//
> -// C++0x member checking attributes
> -//===----------------------------------------------------------------------===//
> -
> -static void HandleBaseCheckAttr(Decl *d, const AttributeList &Attr, Sema &S) {
> - if (Attr.getNumArgs() != 0) {
> - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
> - return;
> - }
> -
> - if (!isa<CXXRecordDecl>(d)) {
> - S.Diag(Attr.getLoc(),
> - Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
> - : diag::warn_attribute_wrong_decl_type)
> - << Attr.getName() << 9 /*class*/;
> - return;
> - }
> -
> - if (d->getAttr<BaseCheckAttr>()) {
> - S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "base_check";
> - return;
> - }
> -
> - d->addAttr(::new (S.Context) BaseCheckAttr(Attr.getLoc(), S.Context));
> -}
> -
> -static void HandleHidingAttr(Decl *d, const AttributeList &Attr, Sema &S) {
> - if (Attr.getNumArgs() != 0) {
> - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
> - return;
> - }
> -
> - if (!isa<RecordDecl>(d->getDeclContext())) {
> - // FIXME: It's not the type that's the problem
> - S.Diag(Attr.getLoc(),
> - Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
> - : diag::warn_attribute_wrong_decl_type)
> - << Attr.getName() << 11 /*member*/;
> - return;
> - }
> -
> - // FIXME: Conform to C++0x redeclaration rules.
> -
> - if (d->getAttr<HidingAttr>()) {
> - S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "hiding";
> - return;
> - }
> -
> - d->addAttr(::new (S.Context) HidingAttr(Attr.getLoc(), S.Context));
> -}
> -
> -static void HandleOverrideAttr(Decl *d, const AttributeList &Attr, Sema &S) {
> - if (Attr.getNumArgs() != 0) {
> - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
> - return;
> - }
> -
> - if (!isa<CXXMethodDecl>(d) || !cast<CXXMethodDecl>(d)->isVirtual()) {
> - // FIXME: It's not the type that's the problem
> - S.Diag(Attr.getLoc(),
> - Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
> - : diag::warn_attribute_wrong_decl_type)
> - << Attr.getName() << 10 /*virtual method*/;
> - return;
> - }
> -
> - // FIXME: Conform to C++0x redeclaration rules.
> -
> - if (d->getAttr<OverrideAttr>()) {
> - S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "override";
> - return;
> - }
> -
> - d->addAttr(::new (S.Context) OverrideAttr(Attr.getLoc(), S.Context));
> -}
> -
> -//===----------------------------------------------------------------------===//
> // Checker-specific attribute handlers.
> //===----------------------------------------------------------------------===//
>
> @@ -2672,7 +2596,6 @@
> case AttributeList::AT_analyzer_noreturn:
> HandleAnalyzerNoReturnAttr (D, Attr, S); break;
> case AttributeList::AT_annotate: HandleAnnotateAttr (D, Attr, S); break;
> - case AttributeList::AT_base_check: HandleBaseCheckAttr (D, Attr, S); break;
> case AttributeList::AT_carries_dependency:
> HandleDependencyAttr (D, Attr, S); break;
> case AttributeList::AT_common: HandleCommonAttr (D, Attr, S); break;
> @@ -2687,7 +2610,6 @@
> case AttributeList::AT_format_arg: HandleFormatArgAttr (D, Attr, S); break;
> case AttributeList::AT_global: HandleGlobalAttr (D, Attr, S); break;
> case AttributeList::AT_gnu_inline: HandleGNUInlineAttr (D, Attr, S); break;
> - case AttributeList::AT_hiding: HandleHidingAttr (D, Attr, S); break;
> case AttributeList::AT_launch_bounds:
> HandleLaunchBoundsAttr(D, Attr, S);
> break;
> @@ -2703,7 +2625,6 @@
> case AttributeList::AT_naked: HandleNakedAttr (D, Attr, S); break;
> case AttributeList::AT_noreturn: HandleNoReturnAttr (D, Attr, S); break;
> case AttributeList::AT_nothrow: HandleNothrowAttr (D, Attr, S); break;
> - case AttributeList::AT_override: HandleOverrideAttr (D, Attr, S); break;
> case AttributeList::AT_shared: HandleSharedAttr (D, Attr, S); break;
> case AttributeList::AT_vecreturn: HandleVecReturnAttr (D, Attr, S); break;
>
>
> Modified: cfe/trunk/test/SemaCXX/attr-cxx0x.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cxx0x.cpp?rev=124087&r1=124086&r2=124087&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/attr-cxx0x.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-cxx0x.cpp Sun Jan 23 15:33:18 2011
> @@ -14,15 +14,3 @@
> static_assert(alignof(align_multiple) == 8, "l's alignment is wrong");
> static_assert(alignof(align_member) == 8, "quuux's alignment is wrong");
> static_assert(sizeof(align_member) == 8, "quuux's size is wrong");
> -
> -int bc_fail [[base_check]]; // expected-error {{'base_check' attribute only applies to class types}}
> -int hiding_fail [[hiding]]; // expected-error {{'hiding' attribute only applies to member types}}
> -int override_fail [[override]]; // expected-error {{'override' attribute only applies to virtual method types}}
> -
> -struct base {
> - virtual void function();
> - virtual void other_function();
> -};
> -
> -struct [[base_check, base_check]] bc : base { // expected-error {{'base_check' attribute cannot be repeated}}
> -};
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list