From: Craig Topper Date: Tue, 11 Mar 2014 06:22:39 +0000 (+0000) Subject: [C++11] Add 'override' keyword to virtual methods that override their base class. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae7e589c07248fda4fca0a39e9eb7c547689314b;p=clang [C++11] Add 'override' keyword to virtual methods that override their base class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203543 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 822686a071..655bcabcf3 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -131,7 +131,7 @@ public: }; class InheritableParamAttr : public InheritableAttr { - virtual void anchor(); + void anchor() override; protected: InheritableParamAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex = 0) diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 11b667fd5c..be64d901e3 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -304,7 +304,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const NamedDecl &ND) { /// location of the statement. For GNU local labels (__label__), the decl /// location is where the __label__ is. class LabelDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; LabelStmt *TheStmt; /// LocStart - For normal labels, this is the same as the main declaration /// label, i.e., the location of the identifier; for GNU local labels, @@ -329,7 +329,7 @@ public: bool isGnuLocal() const { return LocStart != getLocation(); } void setLocStart(SourceLocation L) { LocStart = L; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(LocStart, getLocation()); } @@ -359,9 +359,9 @@ class NamespaceDecl : public NamedDecl, public DeclContext, NamespaceDecl *PrevDecl); typedef Redeclarable redeclarable_base; - virtual NamespaceDecl *getNextRedeclaration(); - virtual NamespaceDecl *getPreviousDeclImpl(); - virtual NamespaceDecl *getMostRecentDeclImpl(); + NamespaceDecl *getNextRedeclaration() override; + NamespaceDecl *getPreviousDeclImpl() override; + NamespaceDecl *getMostRecentDeclImpl() override; public: static NamespaceDecl *Create(ASTContext &C, DeclContext *DC, @@ -435,14 +435,14 @@ public: } /// Retrieves the canonical declaration of this namespace. - NamespaceDecl *getCanonicalDecl() { + NamespaceDecl *getCanonicalDecl() override { return getOriginalNamespace(); } const NamespaceDecl *getCanonicalDecl() const { return getOriginalNamespace(); } - - virtual SourceRange getSourceRange() const LLVM_READONLY { + + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(LocStart, RBraceLoc); } @@ -469,7 +469,7 @@ public: /// an lvalue) a function (in which case it is a function designator) or /// an enum constant. class ValueDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; QualType DeclType; protected: @@ -570,7 +570,7 @@ public: /// range taking into account any outer template declarations. SourceLocation getOuterLocStart() const; - virtual SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY { return getOuterLocStart(); } @@ -772,11 +772,11 @@ protected: TypeSourceInfo *TInfo, StorageClass SC); typedef Redeclarable redeclarable_base; - virtual VarDecl *getNextRedeclaration() { return RedeclLink.getNext(); } - virtual VarDecl *getPreviousDeclImpl() { + VarDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } + VarDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual VarDecl *getMostRecentDeclImpl() { + VarDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -796,8 +796,8 @@ public: StorageClass S); static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - virtual SourceRange getSourceRange() const LLVM_READONLY; + + SourceRange getSourceRange() const override LLVM_READONLY; /// \brief Returns the storage class as written in the source. For the /// computed linkage of symbol, see getLinkage. @@ -918,7 +918,7 @@ public: return getKind() != Decl::ParmVar && getDeclContext()->isRecord(); } - virtual VarDecl *getCanonicalDecl(); + VarDecl *getCanonicalDecl() override; const VarDecl *getCanonicalDecl() const { return const_cast(this)->getCanonicalDecl(); } @@ -965,7 +965,7 @@ public: /// \brief Determine whether this is or was instantiated from an out-of-line /// definition of a static data member. - virtual bool isOutOfLine() const; + bool isOutOfLine() const override; /// \brief If this is a static data member, find its out-of-line definition. VarDecl *getOutOfLineDefinition(); @@ -1213,7 +1213,7 @@ public: }; class ImplicitParamDecl : public VarDecl { - virtual void anchor(); + void anchor() override; public: static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, @@ -1259,8 +1259,8 @@ public: StorageClass S, Expr *DefArg); static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - virtual SourceRange getSourceRange() const LLVM_READONLY; + + SourceRange getSourceRange() const override LLVM_READONLY; void setObjCMethodScopeInfo(unsigned parameterIndex) { ParmVarDeclBits.IsObjCMethodParam = true; @@ -1564,11 +1564,11 @@ protected: DNLoc(NameInfo.getInfo()) {} typedef Redeclarable redeclarable_base; - virtual FunctionDecl *getNextRedeclaration() { return RedeclLink.getNext(); } - virtual FunctionDecl *getPreviousDeclImpl() { + FunctionDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } + FunctionDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual FunctionDecl *getMostRecentDeclImpl() { + FunctionDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -1612,13 +1612,12 @@ public: return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } - virtual void getNameForDiagnostic(raw_ostream &OS, - const PrintingPolicy &Policy, - bool Qualified) const; + void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, + bool Qualified) const override; void setRangeEnd(SourceLocation E) { EndRangeLoc = E; } - virtual SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; /// \brief Returns true if the function has a body (definition). The /// function body might be in any of the (re-)declarations of this @@ -1627,7 +1626,7 @@ public: /// containing the body (if there is one). bool hasBody(const FunctionDecl *&Definition) const; - virtual bool hasBody() const { + bool hasBody() const override { const FunctionDecl* Definition; return hasBody(Definition); } @@ -1655,7 +1654,7 @@ public: /// unnecessary AST de-serialization of the body. Stmt *getBody(const FunctionDecl *&Definition) const; - virtual Stmt *getBody() const { + Stmt *getBody() const override { const FunctionDecl* Definition; return getBody(Definition); } @@ -1835,7 +1834,7 @@ public: void setPreviousDeclaration(FunctionDecl * PrevDecl); virtual const FunctionDecl *getCanonicalDecl() const; - virtual FunctionDecl *getCanonicalDecl(); + FunctionDecl *getCanonicalDecl() override; unsigned getBuiltinID() const; @@ -2120,7 +2119,7 @@ public: /// \brief Determine whether this is or was instantiated from an out-of-line /// definition of a member function. - virtual bool isOutOfLine() const; + bool isOutOfLine() const override; /// \brief Identify a memory copying or setting function. /// If the given function is a memory copy or setting function, returns @@ -2259,10 +2258,10 @@ public: return cast(getDeclContext()); } - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; /// Retrieves the canonical declaration of this field. - FieldDecl *getCanonicalDecl() { return getFirstDecl(); } + FieldDecl *getCanonicalDecl() override { return getFirstDecl(); } const FieldDecl *getCanonicalDecl() const { return getFirstDecl(); } // Implement isa/cast/dyncast/etc. @@ -2301,10 +2300,10 @@ public: void setInitExpr(Expr *E) { Init = (Stmt*) E; } void setInitVal(const llvm::APSInt &V) { Val = V; } - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; /// Retrieves the canonical declaration of this enumerator. - EnumConstantDecl *getCanonicalDecl() { return getFirstDecl(); } + EnumConstantDecl *getCanonicalDecl() override { return getFirstDecl(); } const EnumConstantDecl *getCanonicalDecl() const { return getFirstDecl(); } // Implement isa/cast/dyncast/etc. @@ -2318,7 +2317,7 @@ public: /// field injected from an anonymous union/struct into the parent scope. /// IndirectFieldDecl are always implicit. class IndirectFieldDecl : public ValueDecl { - virtual void anchor(); + void anchor() override; NamedDecl **Chaining; unsigned ChainingSize; @@ -2364,7 +2363,7 @@ public: /// TypeDecl - Represents a declaration of a type. /// class TypeDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; /// TypeForDecl - This indicates the Type object that represents /// this TypeDecl. It is a cache maintained by /// ASTContext::getTypedefType, ASTContext::getTagDeclType, and @@ -2394,7 +2393,7 @@ public: SourceLocation getLocStart() const LLVM_READONLY { return LocStart; } void setLocStart(SourceLocation L) { LocStart = L; } - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { if (LocStart.isValid()) return SourceRange(LocStart, getLocation()); else @@ -2409,7 +2408,7 @@ public: /// Base class for declarations which introduce a typedef-name. class TypedefNameDecl : public TypeDecl, public Redeclarable { - virtual void anchor(); + void anchor() override; typedef std::pair ModedTInfo; llvm::PointerUnion MaybeModedTInfo; @@ -2420,13 +2419,13 @@ protected: : TypeDecl(DK, DC, IdLoc, Id, StartLoc), MaybeModedTInfo(TInfo) {} typedef Redeclarable redeclarable_base; - virtual TypedefNameDecl *getNextRedeclaration() { + TypedefNameDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } - virtual TypedefNameDecl *getPreviousDeclImpl() { + TypedefNameDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual TypedefNameDecl *getMostRecentDeclImpl() { + TypedefNameDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -2460,7 +2459,7 @@ public: } /// Retrieves the canonical declaration of this typedef-name. - TypedefNameDecl *getCanonicalDecl() { return getFirstDecl(); } + TypedefNameDecl *getCanonicalDecl() override { return getFirstDecl(); } const TypedefNameDecl *getCanonicalDecl() const { return getFirstDecl(); } // Implement isa/cast/dyncast/etc. @@ -2482,8 +2481,8 @@ public: SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - SourceRange getSourceRange() const LLVM_READONLY; + + SourceRange getSourceRange() const override LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2503,7 +2502,7 @@ public: IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2604,11 +2603,11 @@ protected: } typedef Redeclarable redeclarable_base; - virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); } - virtual TagDecl *getPreviousDeclImpl() { + TagDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } + TagDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual TagDecl *getMostRecentDeclImpl() { + TagDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -2637,9 +2636,9 @@ public: /// getOuterLocStart - Return SourceLocation representing start of source /// range taking into account any outer template declarations. SourceLocation getOuterLocStart() const; - virtual SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; - virtual TagDecl* getCanonicalDecl(); + TagDecl* getCanonicalDecl() override; const TagDecl* getCanonicalDecl() const { return const_cast(this)->getCanonicalDecl(); } @@ -2807,7 +2806,7 @@ public: /// with a fixed underlying type, and in C we allow them to be forward-declared /// with no underlying type as an extension. class EnumDecl : public TagDecl { - virtual void anchor(); + void anchor() override; /// IntegerType - This represent the integer type that the enum corresponds /// to for code generation purposes. Note that the enumerator constants may /// have a different type than this does. @@ -2853,7 +2852,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); public: - EnumDecl *getCanonicalDecl() { + EnumDecl *getCanonicalDecl() override { return cast(TagDecl::getCanonicalDecl()); } const EnumDecl *getCanonicalDecl() const { @@ -3202,7 +3201,7 @@ public: SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(getAsmLoc(), getRParenLoc()); } @@ -3298,7 +3297,7 @@ public: void setIsVariadic(bool value) { IsVariadic = value; } CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; } - Stmt *getBody() const { return (Stmt*) Body; } + Stmt *getBody() const override { return (Stmt*) Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; } @@ -3386,7 +3385,7 @@ public: ManglingContextDecl = Ctx; } - virtual SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -3422,7 +3421,7 @@ public: static CapturedDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams); - Stmt *getBody() const { return Body; } + Stmt *getBody() const override { return Body; } void setBody(Stmt *B) { Body = B; } unsigned getNumParams() const { return NumParams; } @@ -3525,9 +3524,9 @@ public: /// This will return an empty array if the locations of the individual /// identifiers aren't available. ArrayRef getIdentifierLocs() const; - - virtual SourceRange getSourceRange() const LLVM_READONLY; - + + SourceRange getSourceRange() const override LLVM_READONLY; + static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Import; } }; diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index cf027387cb..475ea01ae8 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -1009,7 +1009,7 @@ public: SourceManager &sm, const char *Msg) : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {} - virtual void print(raw_ostream &OS) const; + void print(raw_ostream &OS) const override; }; typedef llvm::MutableArrayRef DeclContextLookupResult; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 1f7c2bbfe1..6971d17042 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -123,7 +123,7 @@ public: /// \brief Sets the location of the colon. void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(getAccessSpecifierLoc(), getColonLoc()); } @@ -627,7 +627,7 @@ public: typedef std::reverse_iterator reverse_base_class_const_iterator; - virtual CXXRecordDecl *getCanonicalDecl() { + CXXRecordDecl *getCanonicalDecl() override { return cast(RecordDecl::getCanonicalDecl()); } virtual const CXXRecordDecl *getCanonicalDecl() const { @@ -1546,7 +1546,7 @@ public: void finishedDefaultedOrDeletedMember(CXXMethodDecl *MD); /// \brief Indicates that the definition of this class is now complete. - virtual void completeDefinition(); + void completeDefinition() override; /// \brief Indicates that the definition of this class is now complete, /// and provides a final overrider map to help determine @@ -1654,7 +1654,7 @@ public: /// In the terminology of the C++ Standard, these are the (static and /// non-static) member functions, whether virtual or not. class CXXMethodDecl : public FunctionDecl { - virtual void anchor(); + void anchor() override; protected: CXXMethodDecl(Kind DK, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, @@ -1721,10 +1721,10 @@ public: /// \brief Determine whether this is a move assignment operator. bool isMoveAssignmentOperator() const; - CXXMethodDecl *getCanonicalDecl() { + CXXMethodDecl *getCanonicalDecl() override { return cast(FunctionDecl::getCanonicalDecl()); } - const CXXMethodDecl *getCanonicalDecl() const { + const CXXMethodDecl *getCanonicalDecl() const override { return const_cast(this)->getCanonicalDecl(); } @@ -2084,7 +2084,7 @@ public: /// }; /// \endcode class CXXConstructorDecl : public CXXMethodDecl { - virtual void anchor(); + void anchor() override; /// \brief Whether this constructor declaration has the \c explicit keyword /// specified. bool IsExplicitSpecified : 1; @@ -2258,10 +2258,10 @@ public: /// \brief Set the constructor that this inheriting constructor is based on. void setInheritedConstructor(const CXXConstructorDecl *BaseCtor); - const CXXConstructorDecl *getCanonicalDecl() const { + const CXXConstructorDecl *getCanonicalDecl() const override { return cast(FunctionDecl::getCanonicalDecl()); } - CXXConstructorDecl *getCanonicalDecl() { + CXXConstructorDecl *getCanonicalDecl() override { return cast(FunctionDecl::getCanonicalDecl()); } @@ -2284,7 +2284,7 @@ public: /// }; /// \endcode class CXXDestructorDecl : public CXXMethodDecl { - virtual void anchor(); + void anchor() override; FunctionDecl *OperatorDelete; @@ -2333,7 +2333,7 @@ public: /// }; /// \endcode class CXXConversionDecl : public CXXMethodDecl { - virtual void anchor(); + void anchor() override; /// Whether this conversion function declaration is marked /// "explicit", meaning that it can only be applied when the user /// explicitly wrote a cast. This is a C++0x feature. @@ -2462,7 +2462,7 @@ public: return decls_empty() ? getLocation() : decls_begin()->getLocEnd(); } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(ExternLoc, getLocEnd()); } @@ -2487,7 +2487,7 @@ public: /// artificial names for all using-directives in order to store /// them in DeclContext effectively. class UsingDirectiveDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; /// \brief The location of the \c using keyword. SourceLocation UsingLoc; @@ -2568,8 +2568,8 @@ public: NamedDecl *Nominated, DeclContext *CommonAncestor); static UsingDirectiveDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - SourceRange getSourceRange() const LLVM_READONLY { + + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(UsingLoc, getLocation()); } @@ -2590,7 +2590,7 @@ public: /// namespace Foo = Bar; /// \endcode class NamespaceAliasDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; /// \brief The location of the \c namespace keyword. SourceLocation NamespaceLoc; @@ -2663,8 +2663,8 @@ public: NamedDecl *Namespace); static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - virtual SourceRange getSourceRange() const LLVM_READONLY { + + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(NamespaceLoc, IdentLoc); } @@ -2686,7 +2686,7 @@ public: /// } /// \endcode class UsingShadowDecl : public NamedDecl, public Redeclarable { - virtual void anchor(); + void anchor() override; /// The referenced declaration. NamedDecl *Underlying; @@ -2709,13 +2709,13 @@ class UsingShadowDecl : public NamedDecl, public Redeclarable { } typedef Redeclarable redeclarable_base; - virtual UsingShadowDecl *getNextRedeclaration() { + UsingShadowDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } - virtual UsingShadowDecl *getPreviousDeclImpl() { + UsingShadowDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual UsingShadowDecl *getMostRecentDeclImpl() { + UsingShadowDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -2736,10 +2736,10 @@ public: using redeclarable_base::getPreviousDecl; using redeclarable_base::getMostRecentDecl; - virtual UsingShadowDecl *getCanonicalDecl() { + UsingShadowDecl *getCanonicalDecl() override { return getFirstDecl(); } - virtual const UsingShadowDecl *getCanonicalDecl() const { + const UsingShadowDecl *getCanonicalDecl() const { return getFirstDecl(); } @@ -2778,7 +2778,7 @@ public: /// using someNameSpace::someIdentifier; /// \endcode class UsingDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; /// \brief The source location of the 'using' keyword itself. SourceLocation UsingLocation; @@ -2894,7 +2894,7 @@ public: static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Using; } @@ -2915,7 +2915,7 @@ public: /// }; /// \endcode class UnresolvedUsingValueDecl : public ValueDecl { - virtual void anchor(); + void anchor() override; /// \brief The source location of the 'using' keyword SourceLocation UsingLocation; @@ -2968,7 +2968,7 @@ public: static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == UnresolvedUsingValue; } @@ -2989,7 +2989,7 @@ public: /// The type associated with an unresolved using typename decl is /// currently always a typename type. class UnresolvedUsingTypenameDecl : public TypeDecl { - virtual void anchor(); + void anchor() override; /// \brief The source location of the 'typename' keyword SourceLocation TypenameLocation; @@ -3067,7 +3067,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(getLocation(), getRParenLoc()); } diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index be6f2eb3e3..5d4633e066 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -132,7 +132,7 @@ public: } /// Retrieves the source range for the friend declaration. - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { if (NamedDecl *ND = getFriendDecl()) { if (FunctionTemplateDecl *FTD = dyn_cast(ND)) return FTD->getSourceRange(); diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c46c1a9ed8..7e7e421d9a 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -246,7 +246,7 @@ private: /// \brief A definition will return its interface declaration. /// An interface declaration will return its definition. /// Otherwise it will return itself. - virtual ObjCMethodDecl *getNextRedeclaration(); + ObjCMethodDecl *getNextRedeclaration() override; public: static ObjCMethodDecl * @@ -259,8 +259,8 @@ public: bool HasRelatedResultType = false); static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - virtual ObjCMethodDecl *getCanonicalDecl(); + + ObjCMethodDecl *getCanonicalDecl() override; const ObjCMethodDecl *getCanonicalDecl() const { return const_cast(this)->getCanonicalDecl(); } @@ -289,7 +289,7 @@ public: // Location information, modeled after the Stmt API. SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); } SourceLocation getLocEnd() const LLVM_READONLY; - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(getLocation(), getLocEnd()); } @@ -473,10 +473,10 @@ public: const ObjCMethodDecl **InitMethod = 0) const; /// \brief Determine whether this method has a body. - virtual bool hasBody() const { return Body.isValid(); } + bool hasBody() const override { return Body.isValid(); } /// \brief Retrieve the body of this method, if it has one. - virtual Stmt *getBody() const; + Stmt *getBody() const override; void setLazyBody(uint64_t Offset) { Body = Offset; } @@ -505,7 +505,7 @@ public: /// ObjCProtocolDecl, and ObjCImplDecl. /// class ObjCContainerDecl : public NamedDecl, public DeclContext { - virtual void anchor(); + void anchor() override; SourceLocation AtStart; @@ -596,7 +596,7 @@ public: AtEnd = atEnd; } - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(AtStart, getAtEndRange().getEnd()); } @@ -642,7 +642,7 @@ public: /// class ObjCInterfaceDecl : public ObjCContainerDecl , public Redeclarable { - virtual void anchor(); + void anchor() override; /// TypeForDecl - This indicates the Type object that represents this /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType @@ -735,13 +735,13 @@ class ObjCInterfaceDecl : public ObjCContainerDecl void allocateDefinitionData(); typedef Redeclarable redeclarable_base; - virtual ObjCInterfaceDecl *getNextRedeclaration() { + ObjCInterfaceDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } - virtual ObjCInterfaceDecl *getPreviousDeclImpl() { + ObjCInterfaceDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual ObjCInterfaceDecl *getMostRecentDeclImpl() { + ObjCInterfaceDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -755,7 +755,7 @@ public: static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); @@ -1177,8 +1177,8 @@ public: ObjCPropertyDecl *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const; - virtual void collectPropertiesToImplement(PropertyMap &PM, - PropertyDeclOrder &PO) const; + void collectPropertiesToImplement(PropertyMap &PM, + PropertyDeclOrder &PO) const override; /// isSuperClassOf - Return true if this class is the specified class or is a /// super class of the specified interface class. @@ -1284,7 +1284,7 @@ public: using redeclarable_base::isFirstDecl; /// Retrieves the canonical declaration of this Objective-C class. - ObjCInterfaceDecl *getCanonicalDecl() { return getFirstDecl(); } + ObjCInterfaceDecl *getCanonicalDecl() override { return getFirstDecl(); } const ObjCInterfaceDecl *getCanonicalDecl() const { return getFirstDecl(); } // Low-level accessor @@ -1319,7 +1319,7 @@ private: /// } /// class ObjCIvarDecl : public FieldDecl { - virtual void anchor(); + void anchor() override; public: enum AccessControl { @@ -1382,7 +1382,7 @@ private: /// \brief Represents a field declaration created by an \@defs(...). class ObjCAtDefsFieldDecl : public FieldDecl { - virtual void anchor(); + void anchor() override; ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW) @@ -1435,7 +1435,7 @@ public: /// class ObjCProtocolDecl : public ObjCContainerDecl, public Redeclarable { - virtual void anchor(); + void anchor() override; struct DefinitionData { // \brief The declaration that defines this protocol. @@ -1464,13 +1464,13 @@ class ObjCProtocolDecl : public ObjCContainerDecl, void allocateDefinitionData(); typedef Redeclarable redeclarable_base; - virtual ObjCProtocolDecl *getNextRedeclaration() { + ObjCProtocolDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } - virtual ObjCProtocolDecl *getPreviousDeclImpl() { + ObjCProtocolDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual ObjCProtocolDecl *getMostRecentDeclImpl() { + ObjCProtocolDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -1576,7 +1576,7 @@ public: /// \brief Starts the definition of this Objective-C protocol. void startDefinition(); - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); @@ -1593,14 +1593,14 @@ public: using redeclarable_base::isFirstDecl; /// Retrieves the canonical declaration of this Objective-C protocol. - ObjCProtocolDecl *getCanonicalDecl() { return getFirstDecl(); } + ObjCProtocolDecl *getCanonicalDecl() override { return getFirstDecl(); } const ObjCProtocolDecl *getCanonicalDecl() const { return getFirstDecl(); } - virtual void collectPropertiesToImplement(PropertyMap &PM, - PropertyDeclOrder &PO) const; - -void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, - ProtocolPropertyMap &PM) const; + void collectPropertiesToImplement(PropertyMap &PM, + PropertyDeclOrder &PO) const override; + + void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, + ProtocolPropertyMap &PM) const; static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ObjCProtocol; } @@ -1628,7 +1628,7 @@ void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, /// don't support this level of dynamism, which is both powerful and dangerous. /// class ObjCCategoryDecl : public ObjCContainerDecl { - virtual void anchor(); + void anchor() override; /// Interface belonging to this category ObjCInterfaceDecl *ClassInterface; @@ -1739,7 +1739,7 @@ public: }; class ObjCImplDecl : public ObjCContainerDecl { - virtual void anchor(); + void anchor() override; /// Class interface for this class/category implementation ObjCInterfaceDecl *ClassInterface; @@ -1803,7 +1803,7 @@ public: /// /// ObjCCategoryImplDecl class ObjCCategoryImplDecl : public ObjCImplDecl { - virtual void anchor(); + void anchor() override; // Category name IdentifierInfo *Id; @@ -1883,7 +1883,7 @@ raw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID); /// specified, they need to be *identical* to the interface. /// class ObjCImplementationDecl : public ObjCImplDecl { - virtual void anchor(); + void anchor() override; /// Implementation Class's super class. ObjCInterfaceDecl *SuperClass; SourceLocation SuperLoc; @@ -2030,7 +2030,7 @@ raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID); /// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is /// declared as \@compatibility_alias alias class. class ObjCCompatibleAliasDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; /// Class that this is an alias of. ObjCInterfaceDecl *AliasedClass; @@ -2061,7 +2061,7 @@ public: /// \@property (assign, readwrite) int MyProperty; /// \endcode class ObjCPropertyDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; public: enum PropertyAttributeKind { OBJC_PR_noattr = 0x00, @@ -2220,7 +2220,7 @@ public: return PropertyIvarDecl; } - virtual SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(AtLoc, getLocation()); } @@ -2290,8 +2290,8 @@ public: SourceLocation ivarLoc); static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); - - virtual SourceRange getSourceRange() const LLVM_READONLY; + + SourceRange getSourceRange() const override LLVM_READONLY; SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 5f22262980..cc843e56c4 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -227,7 +227,7 @@ public: /// The TemplateDecl class stores the list of template parameters and a /// reference to the templated scoped declaration: the underlying AST node. class TemplateDecl : public NamedDecl { - virtual void anchor(); + void anchor() override; protected: // This is probably never used. TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, @@ -261,7 +261,7 @@ public: return K >= firstTemplate && K <= lastTemplate; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(TemplateParams->getTemplateLoc(), TemplatedDecl->getSourceRange().getEnd()); } @@ -530,13 +530,13 @@ class RedeclarableTemplateDecl : public TemplateDecl, public Redeclarable { typedef Redeclarable redeclarable_base; - virtual RedeclarableTemplateDecl *getNextRedeclaration() { + RedeclarableTemplateDecl *getNextRedeclaration() override { return RedeclLink.getNext(); } - virtual RedeclarableTemplateDecl *getPreviousDeclImpl() { + RedeclarableTemplateDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } - virtual RedeclarableTemplateDecl *getMostRecentDeclImpl() { + RedeclarableTemplateDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } @@ -631,7 +631,9 @@ public: template friend class RedeclarableTemplate; /// \brief Retrieves the canonical declaration of this template. - RedeclarableTemplateDecl *getCanonicalDecl() { return getFirstDecl(); } + RedeclarableTemplateDecl *getCanonicalDecl() override { + return getFirstDecl(); + } const RedeclarableTemplateDecl *getCanonicalDecl() const { return getFirstDecl(); } @@ -775,7 +777,7 @@ protected: TemplateParameterList *Params, NamedDecl *Decl) : RedeclarableTemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { } - CommonBase *newCommon(ASTContext &C) const; + CommonBase *newCommon(ASTContext &C) const override; Common *getCommonPtr() const { return static_cast(RedeclarableTemplateDecl::getCommonPtr()); @@ -815,7 +817,7 @@ public: FunctionDecl *findSpecialization(const TemplateArgument *Args, unsigned NumArgs, void *&InsertPos); - FunctionTemplateDecl *getCanonicalDecl() { + FunctionTemplateDecl *getCanonicalDecl() override { return cast( RedeclarableTemplateDecl::getCanonicalDecl()); } @@ -1008,7 +1010,7 @@ public: /// \brief Returns whether this is a parameter pack. bool isParameterPack() const; - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -1085,7 +1087,7 @@ public: using TemplateParmPosition::setPosition; using TemplateParmPosition::getIndex; - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; /// \brief Determine whether this template parameter has a default /// argument. @@ -1205,7 +1207,7 @@ public: class TemplateTemplateParmDecl : public TemplateDecl, protected TemplateParmPosition { - virtual void anchor(); + void anchor() override; /// DefaultArgument - The default template argument, if any. TemplateArgumentLoc DefaultArgument; @@ -1346,7 +1348,7 @@ public: DefaultArgumentWasInherited = false; } - SourceRange getSourceRange() const LLVM_READONLY { + SourceRange getSourceRange() const override LLVM_READONLY { SourceLocation End = getLocation(); if (hasDefaultArgument() && !defaultArgumentWasInherited()) End = getDefaultArgument().getSourceRange().getEnd(); @@ -1443,9 +1445,8 @@ public: static ClassTemplateSpecializationDecl * CreateDeserialized(ASTContext &C, unsigned ID); - virtual void getNameForDiagnostic(raw_ostream &OS, - const PrintingPolicy &Policy, - bool Qualified) const; + void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, + bool Qualified) const override; ClassTemplateSpecializationDecl *getMostRecentDecl() { CXXRecordDecl *Recent = static_cast( @@ -1616,7 +1617,7 @@ public: return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); } - SourceRange getSourceRange() const LLVM_READONLY; + SourceRange getSourceRange() const override LLVM_READONLY; void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext()); @@ -1642,7 +1643,7 @@ public: class ClassTemplatePartialSpecializationDecl : public ClassTemplateSpecializationDecl { - virtual void anchor(); + void anchor() override; /// \brief The list of template parameters TemplateParameterList* TemplateParams; @@ -1839,7 +1840,7 @@ protected: : RedeclarableTemplateDecl(ClassTemplate, 0, SourceLocation(), DeclarationName(), 0, 0) { } - CommonBase *newCommon(ASTContext &C) const; + CommonBase *newCommon(ASTContext &C) const override; Common *getCommonPtr() const { return static_cast(RedeclarableTemplateDecl::getCommonPtr()); @@ -1878,7 +1879,7 @@ public: /// in. InsertPos must be obtained from findSpecialization. void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos); - ClassTemplateDecl *getCanonicalDecl() { + ClassTemplateDecl *getCanonicalDecl() override { return cast( RedeclarableTemplateDecl::getCanonicalDecl()); } @@ -2108,7 +2109,7 @@ protected: TemplateParameterList *Params, NamedDecl *Decl) : RedeclarableTemplateDecl(TypeAliasTemplate, DC, L, Name, Params, Decl) { } - CommonBase *newCommon(ASTContext &C) const; + CommonBase *newCommon(ASTContext &C) const override; Common *getCommonPtr() { return static_cast(RedeclarableTemplateDecl::getCommonPtr()); @@ -2121,7 +2122,7 @@ public: } - TypeAliasTemplateDecl *getCanonicalDecl() { + TypeAliasTemplateDecl *getCanonicalDecl() override { return cast( RedeclarableTemplateDecl::getCanonicalDecl()); } @@ -2314,9 +2315,8 @@ public: static VarTemplateSpecializationDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual void getNameForDiagnostic(raw_ostream &OS, - const PrintingPolicy &Policy, - bool Qualified) const; + void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, + bool Qualified) const override; VarTemplateSpecializationDecl *getMostRecentDecl() { VarDecl *Recent = static_cast(this)->getMostRecentDecl(); @@ -2508,7 +2508,7 @@ public: class VarTemplatePartialSpecializationDecl : public VarTemplateSpecializationDecl { - virtual void anchor(); + void anchor() override; /// \brief The list of template parameters TemplateParameterList *TemplateParams; @@ -2683,7 +2683,7 @@ protected: : RedeclarableTemplateDecl(VarTemplate, 0, SourceLocation(), DeclarationName(), 0, 0) {} - CommonBase *newCommon(ASTContext &C) const; + CommonBase *newCommon(ASTContext &C) const override; Common *getCommonPtr() const { return static_cast(RedeclarableTemplateDecl::getCommonPtr()); @@ -2722,7 +2722,7 @@ public: /// in. InsertPos must be obtained from findSpecialization. void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos); - VarTemplateDecl *getCanonicalDecl() { + VarTemplateDecl *getCanonicalDecl() override { return cast(RedeclarableTemplateDecl::getCanonicalDecl()); } const VarTemplateDecl *getCanonicalDecl() const { diff --git a/include/clang/AST/VTableBuilder.h b/include/clang/AST/VTableBuilder.h index 4560dd5226..02132d8f8f 100644 --- a/include/clang/AST/VTableBuilder.h +++ b/include/clang/AST/VTableBuilder.h @@ -329,7 +329,7 @@ private: VirtualBaseClassOffsetOffsetsMapTy; VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets; - void computeVTableRelatedInformation(const CXXRecordDecl *RD); + void computeVTableRelatedInformation(const CXXRecordDecl *RD) override; public: ItaniumVTableContext(ASTContext &Context); @@ -495,7 +495,7 @@ private: void enumerateVFPtrs(const CXXRecordDecl *ForClass, VPtrInfoVector &Result); - void computeVTableRelatedInformation(const CXXRecordDecl *RD); + void computeVTableRelatedInformation(const CXXRecordDecl *RD) override; void dumpMethodLocations(const CXXRecordDecl *RD, const MethodVFTableLocationsTy &NewMethods, @@ -520,7 +520,7 @@ public: const MethodVFTableLocation &getMethodVFTableLocation(GlobalDecl GD); - const ThunkInfoVectorTy *getThunkInfo(GlobalDecl GD) { + const ThunkInfoVectorTy *getThunkInfo(GlobalDecl GD) override { // Complete destructors don't have a slot in a vftable, so no thunks needed. if (isa(GD.getDecl()) && GD.getDtorType() == Dtor_Complete) diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp index e1bc0da83b..90e5bb94db 100644 --- a/lib/AST/ItaniumCXXABI.cpp +++ b/lib/AST/ItaniumCXXABI.cpp @@ -37,11 +37,11 @@ class ItaniumNumberingContext : public MangleNumberingContext { public: /// Variable decls are numbered by identifier. - virtual unsigned getManglingNumber(const VarDecl *VD, unsigned) { + unsigned getManglingNumber(const VarDecl *VD, unsigned) override { return ++VarManglingNumbers[VD->getIdentifier()]; } - virtual unsigned getManglingNumber(const TagDecl *TD, unsigned) { + unsigned getManglingNumber(const TagDecl *TD, unsigned) override { return ++TagManglingNumbers[TD->getIdentifier()]; } }; @@ -53,7 +53,7 @@ public: ItaniumCXXABI(ASTContext &Ctx) : Context(Ctx) { } std::pair - getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const { + getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const override { const TargetInfo &Target = Context.getTargetInfo(); TargetInfo::IntType PtrDiff = Target.getPtrDiffType(0); uint64_t Width = Target.getTypeWidth(PtrDiff); @@ -63,7 +63,7 @@ public: return std::make_pair(Width, Align); } - CallingConv getDefaultMethodCallConv(bool isVariadic) const { + CallingConv getDefaultMethodCallConv(bool isVariadic) const override { const llvm::Triple &T = Context.getTargetInfo().getTriple(); if (!isVariadic && T.getOS() == llvm::Triple::MinGW32 && T.getArch() == llvm::Triple::x86) @@ -73,7 +73,7 @@ public: // We cheat and just check that the class has a vtable pointer, and that it's // only big enough to have a vtable pointer and nothing more (or less). - bool isNearlyEmpty(const CXXRecordDecl *RD) const { + bool isNearlyEmpty(const CXXRecordDecl *RD) const override { // Check that the class has a vtable pointer. if (!RD->isDynamicClass()) @@ -85,7 +85,7 @@ public: return Layout.getNonVirtualSize() == PointerSize; } - virtual MangleNumberingContext *createMangleNumberingContext() const { + MangleNumberingContext *createMangleNumberingContext() const override { return new ItaniumNumberingContext(); } }; diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index db90d6247e..16e1e1c775 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -125,36 +125,33 @@ public: /// @name Mangler Entry Points /// @{ - bool shouldMangleCXXName(const NamedDecl *D); - void mangleCXXName(const NamedDecl *D, raw_ostream &); - void mangleThunk(const CXXMethodDecl *MD, - const ThunkInfo &Thunk, - raw_ostream &); + bool shouldMangleCXXName(const NamedDecl *D) override; + void mangleCXXName(const NamedDecl *D, raw_ostream &) override; + void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, + raw_ostream &) override; void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &ThisAdjustment, - raw_ostream &); - void mangleReferenceTemporary(const VarDecl *D, - raw_ostream &); - void mangleCXXVTable(const CXXRecordDecl *RD, - raw_ostream &); - void mangleCXXVTT(const CXXRecordDecl *RD, - raw_ostream &); + raw_ostream &) override; + void mangleReferenceTemporary(const VarDecl *D, raw_ostream &) override; + void mangleCXXVTable(const CXXRecordDecl *RD, raw_ostream &) override; + void mangleCXXVTT(const CXXRecordDecl *RD, raw_ostream &) override; void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset, - const CXXRecordDecl *Type, - raw_ostream &); - void mangleCXXRTTI(QualType T, raw_ostream &); - void mangleCXXRTTIName(QualType T, raw_ostream &); - void mangleTypeName(QualType T, raw_ostream &); + const CXXRecordDecl *Type, raw_ostream &) override; + void mangleCXXRTTI(QualType T, raw_ostream &) override; + void mangleCXXRTTIName(QualType T, raw_ostream &) override; + void mangleTypeName(QualType T, raw_ostream &) override; void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, - raw_ostream &); + raw_ostream &) override; void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, - raw_ostream &); - - void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &); - void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out); - void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &Out); - void mangleItaniumThreadLocalInit(const VarDecl *D, raw_ostream &); - void mangleItaniumThreadLocalWrapper(const VarDecl *D, raw_ostream &); + raw_ostream &) override; + + void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &) override; + void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out) override; + void mangleDynamicAtExitDestructor(const VarDecl *D, + raw_ostream &Out) override; + void mangleItaniumThreadLocalInit(const VarDecl *D, raw_ostream &) override; + void mangleItaniumThreadLocalWrapper(const VarDecl *D, + raw_ostream &) override; bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) { // Lambda closure types are already numbered. diff --git a/lib/AST/MicrosoftCXXABI.cpp b/lib/AST/MicrosoftCXXABI.cpp index 9ee0321b0b..359e864827 100644 --- a/lib/AST/MicrosoftCXXABI.cpp +++ b/lib/AST/MicrosoftCXXABI.cpp @@ -29,13 +29,13 @@ namespace { /// Typically these are things like static locals, lambdas, or blocks. class MicrosoftNumberingContext : public MangleNumberingContext { public: - virtual unsigned getManglingNumber(const VarDecl *VD, - unsigned MSLocalManglingNumber) { + unsigned getManglingNumber(const VarDecl *VD, + unsigned MSLocalManglingNumber) override { return MSLocalManglingNumber; } - virtual unsigned getManglingNumber(const TagDecl *TD, - unsigned MSLocalManglingNumber) { + unsigned getManglingNumber(const TagDecl *TD, + unsigned MSLocalManglingNumber) override { return MSLocalManglingNumber; } }; @@ -46,16 +46,16 @@ public: MicrosoftCXXABI(ASTContext &Ctx) : Context(Ctx) { } std::pair - getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const; + getMemberPointerWidthAndAlign(const MemberPointerType *MPT) const override; - CallingConv getDefaultMethodCallConv(bool isVariadic) const { + CallingConv getDefaultMethodCallConv(bool isVariadic) const override { if (!isVariadic && Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) return CC_X86ThisCall; return CC_C; } - bool isNearlyEmpty(const CXXRecordDecl *RD) const { + bool isNearlyEmpty(const CXXRecordDecl *RD) const override { // FIXME: Audit the corners if (!RD->isDynamicClass()) return false; @@ -69,7 +69,7 @@ public: Layout.getNonVirtualSize() == PointerSize * 2; } - MangleNumberingContext *createMangleNumberingContext() const { + MangleNumberingContext *createMangleNumberingContext() const override { return new MicrosoftNumberingContext(); } }; diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 4321777a8b..3eac72fe86 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -92,34 +92,32 @@ class MicrosoftMangleContextImpl : public MicrosoftMangleContext { public: MicrosoftMangleContextImpl(ASTContext &Context, DiagnosticsEngine &Diags) : MicrosoftMangleContext(Context, Diags) {} - virtual bool shouldMangleCXXName(const NamedDecl *D); - virtual void mangleCXXName(const NamedDecl *D, raw_ostream &Out); - virtual void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD, - raw_ostream &); - virtual void mangleThunk(const CXXMethodDecl *MD, - const ThunkInfo &Thunk, - raw_ostream &); - virtual void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, - const ThisAdjustment &ThisAdjustment, - raw_ostream &); - virtual void mangleCXXVFTable(const CXXRecordDecl *Derived, - ArrayRef BasePath, - raw_ostream &Out); - virtual void mangleCXXVBTable(const CXXRecordDecl *Derived, - ArrayRef BasePath, - raw_ostream &Out); - virtual void mangleCXXRTTI(QualType T, raw_ostream &); - virtual void mangleCXXRTTIName(QualType T, raw_ostream &); - virtual void mangleTypeName(QualType T, raw_ostream &); - virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, - raw_ostream &); - virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, - raw_ostream &); - virtual void mangleReferenceTemporary(const VarDecl *, raw_ostream &); - virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &Out); - virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out); - virtual void mangleDynamicAtExitDestructor(const VarDecl *D, - raw_ostream &Out); + bool shouldMangleCXXName(const NamedDecl *D) override; + void mangleCXXName(const NamedDecl *D, raw_ostream &Out) override; + void mangleVirtualMemPtrThunk(const CXXMethodDecl *MD, raw_ostream &) override; + void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk, + raw_ostream &) override; + void mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, + const ThisAdjustment &ThisAdjustment, + raw_ostream &) override; + void mangleCXXVFTable(const CXXRecordDecl *Derived, + ArrayRef BasePath, + raw_ostream &Out) override; + void mangleCXXVBTable(const CXXRecordDecl *Derived, + ArrayRef BasePath, + raw_ostream &Out) override; + void mangleCXXRTTI(QualType T, raw_ostream &) override; + void mangleCXXRTTIName(QualType T, raw_ostream &) override; + void mangleTypeName(QualType T, raw_ostream &) override; + void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, + raw_ostream &) override; + void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, + raw_ostream &) override; + void mangleReferenceTemporary(const VarDecl *, raw_ostream &) override; + void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &Out) override; + void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out) override; + void mangleDynamicAtExitDestructor(const VarDecl *D, + raw_ostream &Out) override; bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) { // Lambda closure types are already numbered. if (isLambda(ND)) diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index b2c6b6cddf..d4f8d57c61 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -1491,10 +1491,10 @@ void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) { OS << " }\n\n"; } - OS << " virtual " << R.getName() << "Attr *clone (ASTContext &C) const;\n"; - OS << " virtual void printPretty(raw_ostream &OS,\n" - << " const PrintingPolicy &Policy) const;\n"; - OS << " virtual const char *getSpelling() const;\n"; + OS << " " << R.getName() << "Attr *clone(ASTContext &C) const override;\n"; + OS << " void printPretty(raw_ostream &OS,\n" + << " const PrintingPolicy &Policy) const override;\n"; + OS << " const char *getSpelling() const override;\n"; if (!ElideSpelling) { assert(!SemanticToSyntacticMap.empty() && "Empty semantic mapping list"); @@ -1524,11 +1524,11 @@ void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) { << "attr::" << R.getName() << "; }\n"; bool LateParsed = R.getValueAsBit("LateParsed"); - OS << " virtual bool isLateParsed() const { return " + OS << " bool isLateParsed() const override { return " << LateParsed << "; }\n"; if (R.getValueAsBit("DuplicatesAllowedWhileMerging")) - OS << " virtual bool duplicatesAllowed() const { return true; }\n\n"; + OS << " bool duplicatesAllowed() const override { return true; }\n\n"; OS << "};\n\n"; }