Revert "Add macro to suppress -Wunnecessary-virtual-specifier (#139614)"
This reverts commit 0954c9d487e7cb30673df9f0ac125f71320d2936. It breaks the build when built with gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04).
This commit is contained in:
parent
cbe9af1a9c
commit
e4e7a7e64e
@ -173,7 +173,7 @@ class PragmaCommentDecl final
|
|||||||
PragmaMSCommentKind CommentKind)
|
PragmaMSCommentKind CommentKind)
|
||||||
: Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
|
: Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PragmaCommentDecl *Create(const ASTContext &C, TranslationUnitDecl *DC,
|
static PragmaCommentDecl *Create(const ASTContext &C, TranslationUnitDecl *DC,
|
||||||
@ -207,7 +207,7 @@ class PragmaDetectMismatchDecl final
|
|||||||
size_t ValueStart)
|
size_t ValueStart)
|
||||||
: Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
|
: Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PragmaDetectMismatchDecl *Create(const ASTContext &C,
|
static PragmaDetectMismatchDecl *Create(const ASTContext &C,
|
||||||
@ -5024,7 +5024,7 @@ public:
|
|||||||
/// export void foo();
|
/// export void foo();
|
||||||
/// \endcode
|
/// \endcode
|
||||||
class ExportDecl final : public Decl, public DeclContext {
|
class ExportDecl final : public Decl, public DeclContext {
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ASTDeclReader;
|
friend class ASTDeclReader;
|
||||||
|
@ -3297,7 +3297,7 @@ class LifetimeExtendedTemporaryDecl final
|
|||||||
|
|
||||||
mutable APValue *Value = nullptr;
|
mutable APValue *Value = nullptr;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling)
|
LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling)
|
||||||
: Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),
|
: Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),
|
||||||
|
@ -52,7 +52,7 @@ class ASTContext;
|
|||||||
class FriendDecl final
|
class FriendDecl final
|
||||||
: public Decl,
|
: public Decl,
|
||||||
private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
|
private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>;
|
using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>;
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
|
class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
|
||||||
friend class OMPDeclarativeDirective<Decl>;
|
friend class OMPDeclarativeDirective<Decl>;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
OMPThreadPrivateDecl(DeclContext *DC = nullptr,
|
OMPThreadPrivateDecl(DeclContext *DC = nullptr,
|
||||||
SourceLocation L = SourceLocation())
|
SourceLocation L = SourceLocation())
|
||||||
@ -418,7 +418,7 @@ class OMPRequiresDecl final : public OMPDeclarativeDirective<Decl> {
|
|||||||
friend class OMPDeclarativeDirective<Decl>;
|
friend class OMPDeclarativeDirective<Decl>;
|
||||||
friend class ASTDeclReader;
|
friend class ASTDeclReader;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
OMPRequiresDecl(DeclContext *DC, SourceLocation L)
|
OMPRequiresDecl(DeclContext *DC, SourceLocation L)
|
||||||
: OMPDeclarativeDirective<Decl>(OMPRequires, DC, L) {}
|
: OMPDeclarativeDirective<Decl>(OMPRequires, DC, L) {}
|
||||||
@ -475,7 +475,7 @@ class OMPAllocateDecl final : public OMPDeclarativeDirective<Decl> {
|
|||||||
friend class OMPDeclarativeDirective<Decl>;
|
friend class OMPDeclarativeDirective<Decl>;
|
||||||
friend class ASTDeclReader;
|
friend class ASTDeclReader;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
OMPAllocateDecl(DeclContext *DC, SourceLocation L)
|
OMPAllocateDecl(DeclContext *DC, SourceLocation L)
|
||||||
: OMPDeclarativeDirective<Decl>(OMPAllocate, DC, L) {}
|
: OMPDeclarativeDirective<Decl>(OMPAllocate, DC, L) {}
|
||||||
|
@ -267,7 +267,7 @@ public:
|
|||||||
/// programming model implementation needs and propagates the offloading kind to
|
/// programming model implementation needs and propagates the offloading kind to
|
||||||
/// its dependences.
|
/// its dependences.
|
||||||
class OffloadAction final : public Action {
|
class OffloadAction final : public Action {
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Type used to communicate device actions. It associates bound architecture,
|
/// Type used to communicate device actions. It associates bound architecture,
|
||||||
|
@ -895,7 +895,7 @@ public:
|
|||||||
/// with a vtable when the vtable is emitted. Sema is final and not
|
/// 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
|
/// polymorphic, but the debug info size savings are so significant that it is
|
||||||
/// worth adding a vtable just to take advantage of this optimization.
|
/// worth adding a vtable just to take advantage of this optimization.
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
const LangOptions &getLangOpts() const { return LangOpts; }
|
const LangOptions &getLangOpts() const { return LangOpts; }
|
||||||
OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
|
OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
CodePtr getRetPC() const { return RetPC; }
|
CodePtr getRetPC() const { return RetPC; }
|
||||||
|
|
||||||
/// Map a location to a source.
|
/// Map a location to a source.
|
||||||
SourceInfo getSource(CodePtr PC) const;
|
virtual SourceInfo getSource(CodePtr PC) const;
|
||||||
const Expr *getExpr(CodePtr PC) const;
|
const Expr *getExpr(CodePtr PC) const;
|
||||||
SourceLocation getLocation(CodePtr PC) const;
|
SourceLocation getLocation(CodePtr PC) const;
|
||||||
SourceRange getRange(CodePtr PC) const;
|
SourceRange getRange(CodePtr PC) const;
|
||||||
|
@ -323,7 +323,7 @@ public:
|
|||||||
CheckVarsEscapingDeclContext(CodeGenFunction &CGF,
|
CheckVarsEscapingDeclContext(CodeGenFunction &CGF,
|
||||||
ArrayRef<const ValueDecl *> TeamsReductions)
|
ArrayRef<const ValueDecl *> TeamsReductions)
|
||||||
: CGF(CGF), EscapedDecls(llvm::from_range, TeamsReductions) {}
|
: CGF(CGF), EscapedDecls(llvm::from_range, TeamsReductions) {}
|
||||||
~CheckVarsEscapingDeclContext() = default;
|
virtual ~CheckVarsEscapingDeclContext() = default;
|
||||||
void VisitDeclStmt(const DeclStmt *S) {
|
void VisitDeclStmt(const DeclStmt *S) {
|
||||||
if (!S)
|
if (!S)
|
||||||
return;
|
return;
|
||||||
|
@ -4783,7 +4783,7 @@ class CheckVarsEscapingUntiedTaskDeclContext final
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CheckVarsEscapingUntiedTaskDeclContext() = default;
|
explicit CheckVarsEscapingUntiedTaskDeclContext() = default;
|
||||||
~CheckVarsEscapingUntiedTaskDeclContext() = default;
|
virtual ~CheckVarsEscapingUntiedTaskDeclContext() = default;
|
||||||
void VisitDeclStmt(const DeclStmt *S) {
|
void VisitDeclStmt(const DeclStmt *S) {
|
||||||
if (!S)
|
if (!S)
|
||||||
return;
|
return;
|
||||||
|
@ -42,8 +42,8 @@ public:
|
|||||||
bool hasIntegratedCPP() const override { return false; }
|
bool hasIntegratedCPP() const override { return false; }
|
||||||
bool isLinkJob() const override { return true; }
|
bool isLinkJob() const override { return true; }
|
||||||
|
|
||||||
void RenderExtraToolArgs(const JobAction &JA,
|
virtual void RenderExtraToolArgs(const JobAction &JA,
|
||||||
llvm::opt::ArgStringList &CmdArgs) const;
|
llvm::opt::ArgStringList &CmdArgs) const;
|
||||||
void ConstructJob(Compilation &C, const JobAction &JA,
|
void ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
const InputInfo &Output, const InputInfoList &Inputs,
|
const InputInfo &Output, const InputInfoList &Inputs,
|
||||||
const llvm::opt::ArgList &TCArgs,
|
const llvm::opt::ArgList &TCArgs,
|
||||||
|
@ -882,6 +882,11 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
|
|||||||
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
|
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
|
||||||
append("-Wno-noexcept-type" CMAKE_CXX_FLAGS)
|
append("-Wno-noexcept-type" CMAKE_CXX_FLAGS)
|
||||||
|
|
||||||
|
# LLVM has a policy of including virtual "anchor" functions to control
|
||||||
|
# where the vtable is emitted. In `final` classes, these are exactly what
|
||||||
|
# this warning detects: unnecessary virtual methods.
|
||||||
|
add_flag_if_supported("-Wno-unnecessary-virtual-specifier" CXX_SUPPORTS_UNNECESSARY_VIRTUAL_FLAG)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
append("-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
|
append("-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
|
||||||
endif()
|
endif()
|
||||||
|
@ -36,7 +36,7 @@ class InstSimplifyFolder final : public IRBuilderFolder {
|
|||||||
TargetFolder ConstFolder;
|
TargetFolder ConstFolder;
|
||||||
SimplifyQuery SQ;
|
SimplifyQuery SQ;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InstSimplifyFolder(const DataLayout &DL) : ConstFolder(DL), SQ(DL) {}
|
explicit InstSimplifyFolder(const DataLayout &DL) : ConstFolder(DL), SQ(DL) {}
|
||||||
|
@ -39,7 +39,7 @@ class TargetFolder final : public IRBuilderFolder {
|
|||||||
return ConstantFoldConstant(C, DL);
|
return ConstantFoldConstant(C, DL);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
|
explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
|
||||||
|
@ -28,7 +28,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// ConstantFolder - Create constants with minimum, target independent, folding.
|
/// ConstantFolder - Create constants with minimum, target independent, folding.
|
||||||
class ConstantFolder final : public IRBuilderFolder {
|
class ConstantFolder final : public IRBuilderFolder {
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConstantFolder() = default;
|
explicit ConstantFolder() = default;
|
||||||
|
@ -33,7 +33,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// NoFolder - Create "constants" (actually, instructions) with no folding.
|
/// NoFolder - Create "constants" (actually, instructions) with no folding.
|
||||||
class NoFolder final : public IRBuilderFolder {
|
class NoFolder final : public IRBuilderFolder {
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NoFolder() = default;
|
explicit NoFolder() = default;
|
||||||
|
@ -710,22 +710,4 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
|
|||||||
#define LLVM_PREFERRED_TYPE(T)
|
#define LLVM_PREFERRED_TYPE(T)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// \macro LLVM_VIRTUAL_ANCHOR_FUNCTION
|
|
||||||
/// This macro is used to adhere to LLVM's policy that each class with a vtable
|
|
||||||
/// must have at least one out-of-line virtual function. This macro allows us
|
|
||||||
/// to declare such a function in `final` classes without triggering a warning.
|
|
||||||
// clang-format off
|
|
||||||
// Autoformatting makes this look awful.
|
|
||||||
#if defined(__clang__) && __has_warning("-Wunnecessary-virtual-specifier")
|
|
||||||
#define LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION() \
|
|
||||||
_Pragma("clang diagnostic push") \
|
|
||||||
_Pragma("clang diagnostic ignored \"-Wunnecessary-virtual-specifier\"") \
|
|
||||||
virtual void anchor() \
|
|
||||||
_Pragma("clang diagnostic pop")
|
|
||||||
#else
|
|
||||||
#define LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION() \
|
|
||||||
virtual void anchor()
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -452,7 +452,7 @@ public:
|
|||||||
IntOperands[NumIntOperands++] = IntOperand;
|
IntOperands[NumIntOperands++] = IntOperand;
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocateIntOperands(BumpPtrAllocator &Allocator) {
|
virtual void allocateIntOperands(BumpPtrAllocator &Allocator) {
|
||||||
assert(!IntOperands && "Operands already allocated");
|
assert(!IntOperands && "Operands already allocated");
|
||||||
IntOperands = Allocator.Allocate<unsigned>(MaxIntOperands);
|
IntOperands = Allocator.Allocate<unsigned>(MaxIntOperands);
|
||||||
}
|
}
|
||||||
|
@ -1212,7 +1212,7 @@ public:
|
|||||||
ValueToValueMapTy &UnderlyingMap)
|
ValueToValueMapTy &UnderlyingMap)
|
||||||
: TypeMap(TypeMap),
|
: TypeMap(TypeMap),
|
||||||
InternalMapper(UnderlyingMap, RF_None, TypeMap, this) {}
|
InternalMapper(UnderlyingMap, RF_None, TypeMap, this) {}
|
||||||
~FatPtrConstMaterializer() = default;
|
virtual ~FatPtrConstMaterializer() = default;
|
||||||
|
|
||||||
Value *materialize(Value *V) override;
|
Value *materialize(Value *V) override;
|
||||||
};
|
};
|
||||||
|
@ -225,7 +225,7 @@ class X86InstrInfo final : public X86GenInstrInfo {
|
|||||||
X86Subtarget &Subtarget;
|
X86Subtarget &Subtarget;
|
||||||
const X86RegisterInfo RI;
|
const X86RegisterInfo RI;
|
||||||
|
|
||||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
virtual void anchor();
|
||||||
|
|
||||||
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
||||||
MachineBasicBlock *&FBB,
|
MachineBasicBlock *&FBB,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user