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.
///
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()) {}
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
/// \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;
/// 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() {
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">,
let Spellings = ["overloadable"];
}
+def Override : InheritableAttr {
+ let Spellings = [];
+}
+
def Ownership : InheritableAttr {
let Spellings = ["ownership_holds", "ownership_returns", "ownership_takes"];
let Args = [EnumArgument<"OwnKind", "OwnershipKind",
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,
// 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)) {
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
// 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)
// 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();
// 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());
/// 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)
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);
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);
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;
if (D->isPure())
SemaRef.CheckPureMethod(Method, SourceRange());
- Method->setIsMarkedOverride(D->isMarkedOverride());
- Method->setIsMarkedFinal(D->isMarkedFinal());
Method->setAccess(D->getAccess());
SemaRef.CheckOverrideControl(Method);
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.
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)
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)
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());