[cfe-commits] r124122 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclCXX.h include/clang/Basic/Attr.td lib/AST/DeclCXX.cpp lib/CodeGen/CGExprCXX.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriter.cpp lib/Serialization/ASTWriterDecl.cpp
Anders Carlsson
andersca at mac.com
Mon Jan 24 08:26:15 PST 2011
Author: andersca
Date: Mon Jan 24 10:26:15 2011
New Revision: 124122
URL: http://llvm.org/viewvc/llvm-project?rev=124122&view=rev
Log:
Use attributes for all the override control specifiers.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Jan 24 10:26:15 2011
@@ -1195,8 +1195,6 @@
bool IsDeleted : 1;
bool IsTrivial : 1; // sunk from CXXMethodDecl
bool HasImplicitReturnZero : 1;
- bool IsMarkedOverride : 1; // sunk from CXXMethodDecl
- bool IsMarkedFinal : 1; // sunk from CXXMethodDecl
/// \brief End part of this FunctionDecl's source range.
///
@@ -1276,8 +1274,7 @@
IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified),
IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
- HasImplicitReturnZero(false), IsMarkedOverride(false),
- IsMarkedFinal(false), EndRangeLoc(NameInfo.getEndLoc()),
+ HasImplicitReturnZero(false), EndRangeLoc(NameInfo.getEndLoc()),
TemplateOrSpecialization(),
DNLoc(NameInfo.getInfo()) {}
@@ -1390,16 +1387,6 @@
bool hasImplicitReturnZero() const { return HasImplicitReturnZero; }
void setHasImplicitReturnZero(bool IRZ) { HasImplicitReturnZero = IRZ; }
- /// \brief Whether this member function is marked with the 'override' keyword,
- /// C++0x [class.mem]p8.
- bool isMarkedOverride() const { return IsMarkedOverride; }
- void setIsMarkedOverride(bool IMO) { IsMarkedOverride = IMO; }
-
- /// \brief Whether this member function is marked with the 'final' keyword,
- /// C++0x [class.mem]p8.
- bool isMarkedFinal() const { return IsMarkedFinal; }
- void setIsMarkedFinal(bool IMF) { IsMarkedFinal = IMF; }
-
/// \brief Whether this function has a prototype, either because one
/// was explicitly written or because it was "inherited" by merging
/// a declaration without a prototype with a declaration that has a
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Jan 24 10:26:15 2011
@@ -356,12 +356,6 @@
/// \brief Whether we have already declared a destructor within the class.
bool DeclaredDestructor : 1;
- /// \brief Whether this class is marked 'final'.
- bool IsMarkedFinal : 1;
-
- /// \brief Whether this class is marked 'explicit'.
- bool IsMarkedExplicit : 1;
-
/// NumBases - The number of base class specifiers in Bases.
unsigned NumBases;
@@ -665,18 +659,6 @@
/// This value is used for lazy creation of destructors.
bool hasDeclaredDestructor() const { return data().DeclaredDestructor; }
- /// \brief Whether this class is marked 'final'.
- bool isMarkedFinal() const { return data().IsMarkedFinal; }
-
- /// \brief Mark this class as 'final'.
- void setIsMarkedFinal(bool IMF) { data().IsMarkedFinal = IMF; }
-
- /// \brief Whether this class is marked 'explicit'.
- bool isMarkedExplicit() const { return data().IsMarkedExplicit; }
-
- /// \brief Mark this class as 'explicit'.
- void setIsMarkedExplicit(bool IME) { data().IsMarkedExplicit = IME; }
-
/// getConversions - Retrieve the overload set containing all of the
/// conversion functions in this class.
UnresolvedSetImpl *getConversionFunctions() {
Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Jan 24 10:26:15 2011
@@ -213,10 +213,18 @@
let Spellings = ["dllimport"];
}
+def Explicit : InheritableAttr {
+ let Spellings = [];
+}
+
def FastCall : InheritableAttr {
let Spellings = ["fastcall", "__fastcall"];
}
+def Final : InheritableAttr {
+ let Spellings = [];
+}
+
def Format : InheritableAttr {
let Spellings = ["format"];
let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
@@ -336,6 +344,10 @@
let Spellings = ["overloadable"];
}
+def Override : InheritableAttr {
+ let Spellings = [];
+}
+
def Ownership : InheritableAttr {
let Spellings = ["ownership_holds", "ownership_returns", "ownership_takes"];
let Args = [EnumArgument<"OwnKind", "OwnershipKind",
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Jan 24 10:26:15 2011
@@ -36,9 +36,8 @@
HasTrivialDestructor(true), ComputedVisibleConversions(false),
DeclaredDefaultConstructor(false), DeclaredCopyConstructor(false),
DeclaredCopyAssignment(false), DeclaredDestructor(false),
- IsMarkedFinal(false), IsMarkedExplicit(false),
- NumBases(0), NumVBases(0), Bases(), VBases(),
- Definition(D), FirstFriend(0) {
+ NumBases(0), NumVBases(0), Bases(), VBases(),
+ Definition(D), FirstFriend(0) {
}
CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Mon Jan 24 10:26:15 2011
@@ -65,12 +65,12 @@
// If the member function is marked 'final', we know that it can't be
// overridden and can therefore devirtualize it.
- if (MD->isMarkedFinal())
+ if (MD->hasAttr<FinalAttr>())
return true;
// 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())
+ if (MD->getParent()->hasAttr<FinalAttr>())
return true;
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 24 10:26:15 2011
@@ -6386,8 +6386,10 @@
if (!Record->getIdentifier())
return;
- Record->setIsMarkedFinal(CVS.isFinalSpecified());
- Record->setIsMarkedExplicit(CVS.isExplicitSpecified());
+ if (CVS.isFinalSpecified())
+ Record->addAttr(new (Context) FinalAttr(CVS.getFinalLoc(), Context));
+ if (CVS.isExplicitSpecified())
+ Record->addAttr(new (Context) ExplicitAttr(CVS.getExplicitLoc(), Context));
// C++ [class]p2:
// [...] The class-name is also inserted into the scope of the
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jan 24 10:26:15 2011
@@ -525,7 +525,7 @@
// If a class is marked with the class-virt-specifier final and it appears
// as a base-type-specifier in a base-clause (10 class.derived), the program
// is ill-formed.
- if (CXXBaseDecl->isMarkedFinal()) {
+ if (CXXBaseDecl->hasAttr<FinalAttr>()) {
Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
<< CXXBaseDecl->getDeclName();
Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl)
@@ -871,7 +871,7 @@
// the program is ill-formed.
bool HasOverriddenMethods =
MD->begin_overridden_methods() != MD->end_overridden_methods();
- if (MD->isMarkedOverride() && !HasOverriddenMethods) {
+ if (MD->hasAttr<OverrideAttr>() && !HasOverriddenMethods) {
Diag(MD->getLocation(),
diag::err_function_marked_override_not_overriding)
<< MD->getDeclName();
@@ -883,8 +883,8 @@
// 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 with the virt-specifier override, the program is ill-formed.
- if (MD->getParent()->isMarkedExplicit() && !isa<CXXDestructorDecl>(MD) &&
- HasOverriddenMethods && !MD->isMarkedOverride()) {
+ if (MD->getParent()->hasAttr<ExplicitAttr>() && !isa<CXXDestructorDecl>(MD) &&
+ HasOverriddenMethods && !MD->hasAttr<OverrideAttr>()) {
llvm::SmallVector<const CXXMethodDecl*, 4>
OverriddenMethods(MD->begin_overridden_methods(),
MD->end_overridden_methods());
@@ -904,7 +904,7 @@
/// C++0x [class.virtual]p3.
bool Sema::CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
const CXXMethodDecl *Old) {
- if (!Old->isMarkedFinal())
+ if (!Old->hasAttr<FinalAttr>())
return false;
Diag(New->getLocation(), diag::err_final_function_overridden)
@@ -1057,7 +1057,7 @@
diag::override_keyword_only_allowed_on_virtual_member_functions)
<< "override" << FixItHint::CreateRemoval(VS.getOverrideLoc());
} else
- MD->setIsMarkedOverride(true);
+ MD->addAttr(new (Context) OverrideAttr(VS.getOverrideLoc(), Context));
}
if (VS.isFinalSpecified()) {
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Member);
@@ -1066,7 +1066,7 @@
diag::override_keyword_only_allowed_on_virtual_member_functions)
<< "final" << FixItHint::CreateRemoval(VS.getFinalLoc());
} else
- MD->setIsMarkedFinal(true);
+ MD->addAttr(new (Context) FinalAttr(VS.getFinalLoc(), Context));
}
CheckOverrideControl(Member);
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Jan 24 10:26:15 2011
@@ -1640,9 +1640,6 @@
Instantiation->setTagKind(Pattern->getTagKind());
- Instantiation->setIsMarkedFinal(Pattern->isMarkedFinal());
- Instantiation->setIsMarkedExplicit(Pattern->isMarkedExplicit());
-
// Do substitution on the base class specifiers.
if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
Invalid = true;
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Jan 24 10:26:15 2011
@@ -1389,8 +1389,6 @@
if (D->isPure())
SemaRef.CheckPureMethod(Method, SourceRange());
- Method->setIsMarkedOverride(D->isMarkedOverride());
- Method->setIsMarkedFinal(D->isMarkedFinal());
Method->setAccess(D->getAccess());
SemaRef.CheckOverrideControl(Method);
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Jan 24 10:26:15 2011
@@ -395,9 +395,6 @@
FD->IsDeleted = Record[Idx++];
FD->IsTrivial = Record[Idx++];
FD->HasImplicitReturnZero = Record[Idx++];
- FD->IsMarkedOverride = Record[Idx++];
- FD->IsMarkedFinal = Record[Idx++];
-
FD->EndRangeLoc = ReadSourceLocation(Record, Idx);
// Read in the parameters.
@@ -800,8 +797,6 @@
Data.DeclaredCopyConstructor = Record[Idx++];
Data.DeclaredCopyAssignment = Record[Idx++];
Data.DeclaredDestructor = Record[Idx++];
- Data.IsMarkedFinal = Record[Idx++];
- Data.IsMarkedExplicit = Record[Idx++];
Data.NumBases = Record[Idx++];
if (Data.NumBases)
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Jan 24 10:26:15 2011
@@ -3394,8 +3394,6 @@
Record.push_back(Data.DeclaredCopyConstructor);
Record.push_back(Data.DeclaredCopyAssignment);
Record.push_back(Data.DeclaredDestructor);
- Record.push_back(Data.IsMarkedFinal);
- Record.push_back(Data.IsMarkedExplicit);
Record.push_back(Data.NumBases);
if (Data.NumBases > 0)
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=124122&r1=124121&r2=124122&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Jan 24 10:26:15 2011
@@ -312,8 +312,6 @@
Record.push_back(D->isDeleted());
Record.push_back(D->isTrivial());
Record.push_back(D->hasImplicitReturnZero());
- Record.push_back(D->isMarkedOverride());
- Record.push_back(D->isMarkedFinal());
Writer.AddSourceLocation(D->getLocEnd(), Record);
Record.push_back(D->param_size());
More information about the cfe-commits
mailing list