diff options
author | David Blaikie <dblaikie@gmail.com> | 2023-02-28 00:54:24 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2023-02-28 01:25:22 +0000 |
commit | d8a1a559f3009a31c517f864156db91d2ae3012c (patch) | |
tree | 5cadedbcfa3a8402a96fe37e5e9d6602a1912507 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 6957a8cc6c92db5c1b6e9307b29bb78eb1beb718 (diff) | |
download | llvm-d8a1a559f3009a31c517f864156db91d2ae3012c.zip llvm-d8a1a559f3009a31c517f864156db91d2ae3012c.tar.gz llvm-d8a1a559f3009a31c517f864156db91d2ae3012c.tar.bz2 |
DebugInfo: Disable ctor homing for types with only deleted (non copy/move) ctors
Such a type is never going to have a ctor home, and may be used for type
punning or other ways of creating objects.
May be a more generally acceptable solution in some cases compared to
attributing with [[clang::standalone_debug]].
Differential Revision: https://reviews.llvm.org/D144931
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 4dab595..126b239 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2489,9 +2489,18 @@ static bool canUseCtorHoming(const CXXRecordDecl *RD) { if (isClassOrMethodDLLImport(RD)) return false; - return !RD->isLambda() && !RD->isAggregate() && - !RD->hasTrivialDefaultConstructor() && - !RD->hasConstexprNonCopyMoveConstructor(); + if (RD->isLambda() || RD->isAggregate() || + RD->hasTrivialDefaultConstructor() || + RD->hasConstexprNonCopyMoveConstructor()) + return false; + + for (const CXXConstructorDecl *Ctor : RD->ctors()) { + if (Ctor->isCopyOrMoveConstructor()) + continue; + if (!Ctor->isDeleted()) + return true; + } + return false; } static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind, |