[clang] 8f15c4c - [clang][Interp][NFC] Add Record::getDestructor()

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 23 01:21:25 PST 2023


Author: Timm Bäder
Date: 2023-01-23T10:19:34+01:00
New Revision: 8f15c4c2a0fb61469060f9cf85b0b5adee8e0275

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

LOG: [clang][Interp][NFC] Add Record::getDestructor()

Unused for now but will be used in later commits.

Added: 
    

Modified: 
    clang/lib/AST/Interp/Record.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Record.h b/clang/lib/AST/Interp/Record.h
index f638ae90a1c4..1742cb1cc4ee 100644
--- a/clang/lib/AST/Interp/Record.h
+++ b/clang/lib/AST/Interp/Record.h
@@ -13,8 +13,9 @@
 #ifndef LLVM_CLANG_AST_INTERP_RECORD_H
 #define LLVM_CLANG_AST_INTERP_RECORD_H
 
-#include "clang/AST/Decl.h"
 #include "Descriptor.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 
 namespace clang {
 namespace interp {
@@ -62,6 +63,12 @@ class Record final {
   const Base *getBase(const RecordDecl *FD) const;
   /// Returns a virtual base descriptor.
   const Base *getVirtualBase(const RecordDecl *RD) const;
+  // Returns the destructor of the record, if any.
+  const CXXDestructorDecl *getDestructor() const {
+    if (const auto *CXXDecl = dyn_cast<CXXRecordDecl>(Decl))
+      return CXXDecl->getDestructor();
+    return nullptr;
+  }
 
   using const_field_iter = FieldList::const_iterator;
   llvm::iterator_range<const_field_iter> fields() const {


        


More information about the cfe-commits mailing list