[cfe-commits] r124083 - in /cfe/trunk: include/clang/Basic/Attr.td include/clang/Sema/AttributeList.h lib/CodeGen/CGExprCXX.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/AttributeList.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp test/CXX/dcl.dcl/dcl.attr/dcl.attr.final/ test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp test/Parser/cxx0x-attributes.cpp test/SemaCXX/attr-cxx0x.cpp
Anders Carlsson
andersca at mac.com
Sun Jan 23 13:07:31 PST 2011
Author: andersca
Date: Sun Jan 23 15:07:30 2011
New Revision: 124083
URL: http://llvm.org/viewvc/llvm-project?rev=124083&view=rev
Log:
Get rid of the [[final]] C++0x attribute.
Added:
cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
- copied, changed from r124071, cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp
Removed:
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.final/
cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/AttributeList.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Parser/cxx0x-attributes.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=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sun Jan 23 15:07:30 2011
@@ -223,12 +223,6 @@
let Spellings = ["fastcall", "__fastcall"];
}
-def Final : InheritableAttr {
- let Spellings = ["final"];
- let Subjects = [CXXRecord, CXXVirtualMethod];
- let Namespaces = ["", "std"];
-}
-
def Format : InheritableAttr {
let Spellings = ["format"];
let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Sun Jan 23 15:07:30 2011
@@ -104,7 +104,6 @@
AT_dllimport,
AT_ext_vector_type,
AT_fastcall,
- AT_final,
AT_format,
AT_format_arg,
AT_global,
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Sun Jan 23 15:07:30 2011
@@ -63,14 +63,14 @@
if (Context.getLangOptions().AppleKext)
return false;
- // If the member function has the "final" attribute, we know that it can't be
+ // If the member function is marked 'final', we know that it can't be
// overridden and can therefore devirtualize it.
- if (MD->hasAttr<FinalAttr>())
+ if (MD->isMarkedFinal())
return true;
- // Similarly, if the class itself has the "final" attribute it can't be
- // overridden and we can therefore devirtualize the member function call.
- if (MD->getParent()->hasAttr<FinalAttr>())
+ // Similarly, if the class itself is marked 'final' it can't be overridden
+ // and we can therefore devirtualize the member function call.
+ if (MD->getParent()->isMarkedFinal())
return true;
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sun Jan 23 15:07:30 2011
@@ -2223,7 +2223,6 @@
// No arguments
case AttributeList::AT_base_check:
case AttributeList::AT_carries_dependency:
- case AttributeList::AT_final:
case AttributeList::AT_hiding:
case AttributeList::AT_noreturn:
case AttributeList::AT_override: {
Modified: cfe/trunk/lib/Sema/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AttributeList.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AttributeList.cpp (original)
+++ cfe/trunk/lib/Sema/AttributeList.cpp Sun Jan 23 15:07:30 2011
@@ -51,7 +51,6 @@
.Case("used", AT_used)
.Case("alias", AT_alias)
.Case("align", AT_aligned)
- .Case("final", AT_final)
.Case("cdecl", AT_cdecl)
.Case("const", AT_const)
.Case("__const", AT_const) // some GCC headers do contain this spelling
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Jan 23 15:07:30 2011
@@ -2437,32 +2437,6 @@
}
}
-static void HandleFinalAttr(Decl *d, const AttributeList &Attr, Sema &S) {
- // check the attribute arguments.
- if (Attr.getNumArgs() != 0) {
- S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
- return;
- }
-
- if (!isa<CXXRecordDecl>(d)
- && (!isa<CXXMethodDecl>(d) || !cast<CXXMethodDecl>(d)->isVirtual())) {
- S.Diag(Attr.getLoc(),
- Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type
- : diag::warn_attribute_wrong_decl_type)
- << Attr.getName() << 7 /*virtual method or class*/;
- return;
- }
-
- // FIXME: Conform to C++0x redeclaration rules.
-
- if (d->getAttr<FinalAttr>()) {
- S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "final";
- return;
- }
-
- d->addAttr(::new (S.Context) FinalAttr(Attr.getLoc(), S.Context));
-}
-
//===----------------------------------------------------------------------===//
// C++0x member checking attributes
//===----------------------------------------------------------------------===//
@@ -2632,11 +2606,11 @@
// GUID format is "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" or
// "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
- llvm::StringRef::iterator I = StrRef.begin();
- if (IsCurly) // Skip the optional '{'
- ++I;
-
- for (int i = 0; i < 36; ++i) {
+ llvm::StringRef::iterator I = StrRef.begin();
+ if (IsCurly) // Skip the optional '{'
+ ++I;
+
+ for (int i = 0; i < 36; ++i) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
if (*I != '-') {
S.Diag(Attr.getLoc(), diag::err_attribute_uuid_malformed_guid);
@@ -2709,7 +2683,6 @@
case AttributeList::AT_ext_vector_type:
HandleExtVectorTypeAttr(scope, D, Attr, S);
break;
- case AttributeList::AT_final: HandleFinalAttr (D, Attr, S); break;
case AttributeList::AT_format: HandleFormatAttr (D, Attr, S); break;
case AttributeList::AT_format_arg: HandleFormatArgAttr (D, Attr, S); break;
case AttributeList::AT_global: HandleGlobalAttr (D, Attr, S); break;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Jan 23 15:07:30 2011
@@ -533,15 +533,6 @@
return 0;
}
- // FIXME: Get rid of this.
- // C++0x CWG Issue #817 indicates that [[final]] classes shouldn't be bases.
- if (CXXBaseDecl->hasAttr<FinalAttr>()) {
- Diag(BaseLoc, diag::err_final_base) << BaseType.getAsString();
- Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl)
- << BaseType;
- return 0;
- }
-
if (BaseDecl->isInvalidDecl())
Class->setInvalidDecl();
@@ -913,15 +904,13 @@
/// C++0x [class.virtual]p3.
bool Sema::CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
const CXXMethodDecl *Old) {
- // FIXME: Get rid of FinalAttr here.
- if (Old->hasAttr<FinalAttr>() || Old->isMarkedFinal()) {
- Diag(New->getLocation(), diag::err_final_function_overridden)
- << New->getDeclName();
- Diag(Old->getLocation(), diag::note_overridden_virtual_function);
- return true;
- }
-
- return false;
+ if (!Old->isMarkedFinal())
+ return false;
+
+ Diag(New->getLocation(), diag::err_final_function_overridden)
+ << New->getDeclName();
+ Diag(Old->getLocation(), diag::note_overridden_virtual_function);
+ return true;
}
/// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
Removed: cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp?rev=124082&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 %s -O3 -emit-llvm -o - | FileCheck %s
-
-namespace Test1 {
- struct A {
- virtual int f() __attribute__((final)) { return 1; }
- };
-
- // CHECK: define i32 @_ZN5Test11fEPNS_1AE
- int f(A *a) {
- // CHECK: ret i32 1
- return a->f();
- }
-}
-
-namespace Test2 {
- struct __attribute__((final)) A {
- virtual int f() { return 1; }
- };
-
- // CHECK: define i32 @_ZN5Test21fEPNS_1AE
- int f(A *a) {
- // CHECK: ret i32 1
- return a->f();
- }
-}
Copied: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp (from r124071, cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp?p2=cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp&p1=cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp&r1=124071&r2=124083&rev=124083&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/attr-final-devirtualize-virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp Sun Jan 23 15:07:30 2011
@@ -1,25 +1,25 @@
-// RUN: %clang_cc1 %s -O3 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
namespace Test1 {
struct A {
- virtual int f() __attribute__((final)) { return 1; }
+ virtual int f() final;
};
// CHECK: define i32 @_ZN5Test11fEPNS_1AE
int f(A *a) {
- // CHECK: ret i32 1
+ // CHECK: call i32 @_ZN5Test11A1fEv
return a->f();
}
}
namespace Test2 {
- struct __attribute__((final)) A {
- virtual int f() { return 1; }
+ struct A final {
+ virtual int f();
};
// CHECK: define i32 @_ZN5Test21fEPNS_1AE
int f(A *a) {
- // CHECK: ret i32 1
+ // CHECK: call i32 @_ZN5Test21A1fEv
return a->f();
}
}
Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Sun Jan 23 15:07:30 2011
@@ -29,7 +29,6 @@
[[]] using namespace ns;
// Argument tests
-[[final()]] int final_params; // expected-error {{C++0x attribute 'final' cannot have an argument list}}
[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
Modified: cfe/trunk/test/SemaCXX/attr-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cxx0x.cpp?rev=124083&r1=124082&r2=124083&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-cxx0x.cpp Sun Jan 23 15:07:30 2011
@@ -1,13 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
-int final_fail [[final]]; //expected-error {{'final' attribute only applies to virtual method or class types}}
-
-struct [[final]] final_base { }; // expected-note {{'final_base' declared here}}
-struct final_child : final_base { }; // expected-error {{derivation from 'final' struct final_base}}
-
-struct final_member { virtual void quux [[final]] (); }; // expected-note {{overridden virtual function is here}}
-struct final_override : final_member { virtual void quux (); }; // expected-error {{declaration of 'quux' overrides a 'final' function}}
-
int align_illegal [[align(3)]]; //expected-error {{requested alignment is not a power of 2}}
char align_big [[align(int)]];
int align_small [[align(1)]]; // FIXME: this should be rejected
More information about the cfe-commits
mailing list