[llvm] d5d8569 - Fix static analysis warnings about classes with virtual methods not having virtual destructors

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 21 04:31:16 PDT 2020


Author: Simon Pilgrim
Date: 2020-03-21T11:30:44Z
New Revision: d5d8569df14e95e2c53d167bd1b37995bcbec565

URL: https://github.com/llvm/llvm-project/commit/d5d8569df14e95e2c53d167bd1b37995bcbec565
DIFF: https://github.com/llvm/llvm-project/commit/d5d8569df14e95e2c53d167bd1b37995bcbec565.diff

LOG: Fix static analysis warnings about classes with virtual methods not having virtual destructors

Added: 
    

Modified: 
    llvm/include/llvm/ADT/FoldingSet.h
    llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
    llvm/include/llvm/MC/MCSection.h
    llvm/include/llvm/Support/CommandLine.h
    llvm/include/llvm/Support/YAMLParser.h
    llvm/include/llvm/Transforms/Utils/ValueMapper.h
    llvm/lib/MC/MCSection.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index 4968b1ea7780..3748ff4e5bca 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/include/llvm/ADT/FoldingSet.h
@@ -126,7 +126,7 @@ class FoldingSetBase {
   explicit FoldingSetBase(unsigned Log2InitSize = 6);
   FoldingSetBase(FoldingSetBase &&Arg);
   FoldingSetBase &operator=(FoldingSetBase &&RHS);
-  ~FoldingSetBase();
+  virtual ~FoldingSetBase();
 
 public:
   //===--------------------------------------------------------------------===//

diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
index 961a8d82fe9e..38802dbe0865 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -46,7 +46,7 @@ class DWARFAcceleratorTable {
     Entry(Entry &&) = default;
     Entry &operator=(const Entry &) = default;
     Entry &operator=(Entry &&) = default;
-    ~Entry() = default;
+    virtual ~Entry() = default;
 
 
   public:

diff  --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index 14283ead3433..bbb0b7898589 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -104,7 +104,7 @@ class MCSection {
   SectionKind Kind;
 
   MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin);
-  ~MCSection();
+  virtual ~MCSection() = default;
 
 public:
   MCSection(const MCSection &) = delete;

diff  --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 0242e35c05bd..39172336e5a1 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -518,7 +518,7 @@ struct GenericOptionValue {
   GenericOptionValue() = default;
   GenericOptionValue(const GenericOptionValue&) = default;
   GenericOptionValue &operator=(const GenericOptionValue &) = default;
-  ~GenericOptionValue() = default;
+  virtual ~GenericOptionValue() = default;
 
 private:
   virtual void anchor();

diff  --git a/llvm/include/llvm/Support/YAMLParser.h b/llvm/include/llvm/Support/YAMLParser.h
index 3570119a3bfd..38c151f02a25 100644
--- a/llvm/include/llvm/Support/YAMLParser.h
+++ b/llvm/include/llvm/Support/YAMLParser.h
@@ -175,7 +175,7 @@ class Node {
   std::unique_ptr<Document> &Doc;
   SMRange SourceRange;
 
-  ~Node() = default;
+  virtual ~Node() = default;
 
 private:
   unsigned int TypeID;

diff  --git a/llvm/include/llvm/Transforms/Utils/ValueMapper.h b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
index ff5bfc609586..37238bde5529 100644
--- a/llvm/include/llvm/Transforms/Utils/ValueMapper.h
+++ b/llvm/include/llvm/Transforms/Utils/ValueMapper.h
@@ -54,7 +54,7 @@ class ValueMaterializer {
   ValueMaterializer() = default;
   ValueMaterializer(const ValueMaterializer &) = default;
   ValueMaterializer &operator=(const ValueMaterializer &) = default;
-  ~ValueMaterializer() = default;
+  virtual ~ValueMaterializer() = default;
 
 public:
   /// This method can be implemented to generate a mapped Value on demand. For

diff  --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp
index 074534bd73db..eebfc7d5f319 100644
--- a/llvm/lib/MC/MCSection.cpp
+++ b/llvm/lib/MC/MCSection.cpp
@@ -32,8 +32,6 @@ MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) {
 
 bool MCSection::hasEnded() const { return End && End->isInSection(); }
 
-MCSection::~MCSection() = default;
-
 void MCSection::setBundleLockState(BundleLockStateType NewState) {
   if (NewState == NotBundleLocked) {
     if (BundleLockNestingDepth == 0) {


        


More information about the llvm-commits mailing list