diff options
author | Devon Loehr <DKLoehr@users.noreply.github.com> | 2025-05-28 06:15:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-28 12:15:22 +0200 |
commit | 63de20c0de05ce7b8b3968a9d210aa0f3d01acd4 (patch) | |
tree | 45c8ead9d68f31f52836b0a18b331bfac8cf79c6 /clang | |
parent | 8b6e98559de15dc75edddf616ed37c5b6e23dfba (diff) | |
download | llvm-63de20c0de05ce7b8b3968a9d210aa0f3d01acd4.zip llvm-63de20c0de05ce7b8b3968a9d210aa0f3d01acd4.tar.gz llvm-63de20c0de05ce7b8b3968a9d210aa0f3d01acd4.tar.bz2 |
Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (#141091)
This fixes #139614 on non-clang compilers by moving `__has_warning`
completely inside the `#if defined(__clang__)` block. This prevents a
parse failure from compilers which don't recognize `__has_warning`.
Original description:
Followup to #138741.
This adds the requested macro to silence
`-Wunnecessary-virtual-specifier` when declaring virtual anchor
functions in `final` classes, per [LLVM
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers).
It also cleans up any remaining instances of the warning, allowing us to
stop disabling it when we build LLVM.
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/AST/Decl.h | 6 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclFriend.h | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclOpenMP.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Driver/Action.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/ByteCode/InterpFrame.h | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Hexagon.h | 4 |
10 files changed, 15 insertions, 15 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 9290ff3..69ad18f4 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -173,7 +173,7 @@ class PragmaCommentDecl final PragmaMSCommentKind CommentKind) : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {} - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: static PragmaCommentDecl *Create(const ASTContext &C, TranslationUnitDecl *DC, @@ -207,7 +207,7 @@ class PragmaDetectMismatchDecl final size_t ValueStart) : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {} - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: static PragmaDetectMismatchDecl *Create(const ASTContext &C, @@ -5024,7 +5024,7 @@ public: /// export void foo(); /// \endcode class ExportDecl final : public Decl, public DeclContext { - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); private: friend class ASTDeclReader; diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index d40d11c..df76e6f 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -3297,7 +3297,7 @@ class LifetimeExtendedTemporaryDecl final mutable APValue *Value = nullptr; - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling) : Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(), diff --git a/clang/include/clang/AST/DeclFriend.h b/clang/include/clang/AST/DeclFriend.h index 1644e2d..1f8c210 100644 --- a/clang/include/clang/AST/DeclFriend.h +++ b/clang/include/clang/AST/DeclFriend.h @@ -52,7 +52,7 @@ class ASTContext; class FriendDecl final : public Decl, private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> { - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>; diff --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h index cf38388..2d07f9d 100644 --- a/clang/include/clang/AST/DeclOpenMP.h +++ b/clang/include/clang/AST/DeclOpenMP.h @@ -110,7 +110,7 @@ public: class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> { friend class OMPDeclarativeDirective<Decl>; - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); OMPThreadPrivateDecl(DeclContext *DC = nullptr, SourceLocation L = SourceLocation()) @@ -418,7 +418,7 @@ class OMPRequiresDecl final : public OMPDeclarativeDirective<Decl> { friend class OMPDeclarativeDirective<Decl>; friend class ASTDeclReader; - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); OMPRequiresDecl(DeclContext *DC, SourceLocation L) : OMPDeclarativeDirective<Decl>(OMPRequires, DC, L) {} @@ -475,7 +475,7 @@ class OMPAllocateDecl final : public OMPDeclarativeDirective<Decl> { friend class OMPDeclarativeDirective<Decl>; friend class ASTDeclReader; - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); OMPAllocateDecl(DeclContext *DC, SourceLocation L) : OMPDeclarativeDirective<Decl>(OMPAllocate, DC, L) {} diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h index 92bb193..7aecfd8 100644 --- a/clang/include/clang/Driver/Action.h +++ b/clang/include/clang/Driver/Action.h @@ -267,7 +267,7 @@ public: /// programming model implementation needs and propagates the offloading kind to /// its dependences. class OffloadAction final : public Action { - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); public: /// Type used to communicate device actions. It associates bound architecture, diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 6680a45..b423e2a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -895,7 +895,7 @@ public: /// with a vtable when the vtable is emitted. Sema is final and not /// polymorphic, but the debug info size savings are so significant that it is /// worth adding a vtable just to take advantage of this optimization. - virtual void anchor(); + LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION(); const LangOptions &getLangOpts() const { return LangOpts; } OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; } diff --git a/clang/lib/AST/ByteCode/InterpFrame.h b/clang/lib/AST/ByteCode/InterpFrame.h index 360e6bf..cfebe93 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.h +++ b/clang/lib/AST/ByteCode/InterpFrame.h @@ -119,7 +119,7 @@ public: CodePtr getRetPC() const { return RetPC; } /// Map a location to a source. - virtual SourceInfo getSource(CodePtr PC) const; + SourceInfo getSource(CodePtr PC) const; const Expr *getExpr(CodePtr PC) const; SourceLocation getLocation(CodePtr PC) const; SourceRange getRange(CodePtr PC) const; diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index f746b48..9e27e63 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -323,7 +323,7 @@ public: CheckVarsEscapingDeclContext(CodeGenFunction &CGF, ArrayRef<const ValueDecl *> TeamsReductions) : CGF(CGF), EscapedDecls(llvm::from_range, TeamsReductions) {} - virtual ~CheckVarsEscapingDeclContext() = default; + ~CheckVarsEscapingDeclContext() = default; void VisitDeclStmt(const DeclStmt *S) { if (!S) return; diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 803c7ed..89a79a7 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4783,7 +4783,7 @@ class CheckVarsEscapingUntiedTaskDeclContext final public: explicit CheckVarsEscapingUntiedTaskDeclContext() = default; - virtual ~CheckVarsEscapingUntiedTaskDeclContext() = default; + ~CheckVarsEscapingUntiedTaskDeclContext() = default; void VisitDeclStmt(const DeclStmt *S) { if (!S) return; diff --git a/clang/lib/Driver/ToolChains/Hexagon.h b/clang/lib/Driver/ToolChains/Hexagon.h index e35a224..033d9b4 100644 --- a/clang/lib/Driver/ToolChains/Hexagon.h +++ b/clang/lib/Driver/ToolChains/Hexagon.h @@ -42,8 +42,8 @@ public: bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } - virtual void RenderExtraToolArgs(const JobAction &JA, - llvm::opt::ArgStringList &CmdArgs) const; + void RenderExtraToolArgs(const JobAction &JA, + llvm::opt::ArgStringList &CmdArgs) const; void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, |