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)
|
||||
: Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
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) {}
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
static PragmaDetectMismatchDecl *Create(const ASTContext &C,
|
||||
@ -5024,7 +5024,7 @@ public:
|
||||
/// export void foo();
|
||||
/// \endcode
|
||||
class ExportDecl final : public Decl, public DeclContext {
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
private:
|
||||
friend class ASTDeclReader;
|
||||
|
@ -3297,7 +3297,7 @@ class LifetimeExtendedTemporaryDecl final
|
||||
|
||||
mutable APValue *Value = nullptr;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
LifetimeExtendedTemporaryDecl(Expr *Temp, ValueDecl *EDecl, unsigned Mangling)
|
||||
: Decl(Decl::LifetimeExtendedTemporary, EDecl->getDeclContext(),
|
||||
|
@ -52,7 +52,7 @@ class ASTContext;
|
||||
class FriendDecl final
|
||||
: public Decl,
|
||||
private llvm::TrailingObjects<FriendDecl, TemplateParameterList *> {
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
using FriendUnion = llvm::PointerUnion<NamedDecl *, TypeSourceInfo *>;
|
||||
|
@ -110,7 +110,7 @@ public:
|
||||
class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
|
||||
friend class OMPDeclarativeDirective<Decl>;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
OMPThreadPrivateDecl(DeclContext *DC = nullptr,
|
||||
SourceLocation L = SourceLocation())
|
||||
@ -418,7 +418,7 @@ class OMPRequiresDecl final : public OMPDeclarativeDirective<Decl> {
|
||||
friend class OMPDeclarativeDirective<Decl>;
|
||||
friend class ASTDeclReader;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
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;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
OMPAllocateDecl(DeclContext *DC, SourceLocation L)
|
||||
: OMPDeclarativeDirective<Decl>(OMPAllocate, DC, L) {}
|
||||
|
@ -267,7 +267,7 @@ public:
|
||||
/// programming model implementation needs and propagates the offloading kind to
|
||||
/// its dependences.
|
||||
class OffloadAction final : public Action {
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
/// 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
|
||||
/// polymorphic, but the debug info size savings are so significant that it is
|
||||
/// 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; }
|
||||
OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
CodePtr getRetPC() const { return RetPC; }
|
||||
|
||||
/// Map a location to a source.
|
||||
SourceInfo getSource(CodePtr PC) const;
|
||||
virtual SourceInfo getSource(CodePtr PC) const;
|
||||
const Expr *getExpr(CodePtr PC) const;
|
||||
SourceLocation getLocation(CodePtr PC) const;
|
||||
SourceRange getRange(CodePtr PC) const;
|
||||
|
@ -323,7 +323,7 @@ public:
|
||||
CheckVarsEscapingDeclContext(CodeGenFunction &CGF,
|
||||
ArrayRef<const ValueDecl *> TeamsReductions)
|
||||
: CGF(CGF), EscapedDecls(llvm::from_range, TeamsReductions) {}
|
||||
~CheckVarsEscapingDeclContext() = default;
|
||||
virtual ~CheckVarsEscapingDeclContext() = default;
|
||||
void VisitDeclStmt(const DeclStmt *S) {
|
||||
if (!S)
|
||||
return;
|
||||
|
@ -4783,7 +4783,7 @@ class CheckVarsEscapingUntiedTaskDeclContext final
|
||||
|
||||
public:
|
||||
explicit CheckVarsEscapingUntiedTaskDeclContext() = default;
|
||||
~CheckVarsEscapingUntiedTaskDeclContext() = default;
|
||||
virtual ~CheckVarsEscapingUntiedTaskDeclContext() = default;
|
||||
void VisitDeclStmt(const DeclStmt *S) {
|
||||
if (!S)
|
||||
return;
|
||||
|
@ -42,8 +42,8 @@ public:
|
||||
bool hasIntegratedCPP() const override { return false; }
|
||||
bool isLinkJob() const override { return true; }
|
||||
|
||||
void RenderExtraToolArgs(const JobAction &JA,
|
||||
llvm::opt::ArgStringList &CmdArgs) const;
|
||||
virtual 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,
|
||||
|
@ -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.
|
||||
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")
|
||||
append("-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
|
||||
endif()
|
||||
|
@ -36,7 +36,7 @@ class InstSimplifyFolder final : public IRBuilderFolder {
|
||||
TargetFolder ConstFolder;
|
||||
SimplifyQuery SQ;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
explicit InstSimplifyFolder(const DataLayout &DL) : ConstFolder(DL), SQ(DL) {}
|
||||
|
@ -39,7 +39,7 @@ class TargetFolder final : public IRBuilderFolder {
|
||||
return ConstantFoldConstant(C, DL);
|
||||
}
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
|
||||
|
@ -28,7 +28,7 @@ namespace llvm {
|
||||
|
||||
/// ConstantFolder - Create constants with minimum, target independent, folding.
|
||||
class ConstantFolder final : public IRBuilderFolder {
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
explicit ConstantFolder() = default;
|
||||
|
@ -33,7 +33,7 @@ namespace llvm {
|
||||
|
||||
/// NoFolder - Create "constants" (actually, instructions) with no folding.
|
||||
class NoFolder final : public IRBuilderFolder {
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
explicit NoFolder() = default;
|
||||
|
@ -710,22 +710,4 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
|
||||
#define LLVM_PREFERRED_TYPE(T)
|
||||
#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
|
||||
|
@ -452,7 +452,7 @@ public:
|
||||
IntOperands[NumIntOperands++] = IntOperand;
|
||||
}
|
||||
|
||||
void allocateIntOperands(BumpPtrAllocator &Allocator) {
|
||||
virtual void allocateIntOperands(BumpPtrAllocator &Allocator) {
|
||||
assert(!IntOperands && "Operands already allocated");
|
||||
IntOperands = Allocator.Allocate<unsigned>(MaxIntOperands);
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ public:
|
||||
ValueToValueMapTy &UnderlyingMap)
|
||||
: TypeMap(TypeMap),
|
||||
InternalMapper(UnderlyingMap, RF_None, TypeMap, this) {}
|
||||
~FatPtrConstMaterializer() = default;
|
||||
virtual ~FatPtrConstMaterializer() = default;
|
||||
|
||||
Value *materialize(Value *V) override;
|
||||
};
|
||||
|
@ -225,7 +225,7 @@ class X86InstrInfo final : public X86GenInstrInfo {
|
||||
X86Subtarget &Subtarget;
|
||||
const X86RegisterInfo RI;
|
||||
|
||||
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
|
||||
virtual void anchor();
|
||||
|
||||
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
||||
MachineBasicBlock *&FBB,
|
||||
|
Loading…
x
Reference in New Issue
Block a user