diff options
author | Mariya Podchishchaeva <mariya.podchishchaeva@intel.com> | 2025-03-04 09:17:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-04 09:17:50 +0100 |
commit | d6942d54f677000cf713d2b0eba57b641452beb4 (patch) | |
tree | 5a1e1e7a9748b14506f2fe03136fa604381b5916 /clang/lib/CodeGen/CodeGenModule.h | |
parent | a619a2e53a9ba09ba18a047b8389bf4dd1912b72 (diff) | |
download | llvm-d6942d54f677000cf713d2b0eba57b641452beb4.zip llvm-d6942d54f677000cf713d2b0eba57b641452beb4.tar.gz llvm-d6942d54f677000cf713d2b0eba57b641452beb4.tar.bz2 |
[MS][clang] Add support for vector deleting destructors (#126240)
Whereas it is UB in terms of the standard to delete an array of objects
via pointer whose static type doesn't match its dynamic type, MSVC
supports an extension allowing to do it.
Aside from array deletion not working correctly in the mentioned case,
currently not having this extension implemented causes clang to generate
code that is not compatible with the code generated by MSVC, because
clang always puts scalar deleting destructor to the vftable. This PR
aims to resolve these problems.
Fixes https://github.com/llvm/llvm-project/issues/19772
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 5726d79..a72b4f7 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -528,6 +528,9 @@ private: /// that we don't re-emit the initializer. llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; + /// To remember which types did require a vector deleting dtor. + llvm::SmallPtrSet<const CXXRecordDecl *, 16> RequireVectorDeletingDtor; + typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *> GlobalInitData; @@ -1544,6 +1547,7 @@ public: void EmitGlobal(GlobalDecl D); bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D); + void EmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target); llvm::GlobalValue *GetGlobalValue(StringRef Ref); @@ -1807,6 +1811,8 @@ public: // behavior. So projects like the Linux kernel can rely on it. return !getLangOpts().CPlusPlus; } + void requireVectorDestructorDefinition(const CXXRecordDecl *RD); + bool classNeedsVectorDestructor(const CXXRecordDecl *RD); private: bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) const; |