dblaikie created this revision. dblaikie added a reviewer: akhuang. Herald added a project: All. dblaikie requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
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]]. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144931 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/debug-info-limited-ctor.cpp Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp +++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp @@ -68,6 +68,21 @@ }; void f(K k) {} +// CHECK-DAG: !DICompositeType({{.*}}name: "DeletedCtors",{{.*}}DIFlagTypePassBy +struct NonTrivial { + NonTrivial(); +}; +struct DeletedCtors { + DeletedCtors() = delete; + DeletedCtors(const DeletedCtors &) = default; + void f1(); + NonTrivial t; +}; + +const NonTrivial &f(const DeletedCtors &D) { + return D.t; +} + // Test that we don't use constructor homing on lambdas. // CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L" // CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue @@ -89,3 +104,4 @@ } // ITANIUM-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: DIFlagFwdDecl + Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -2489,9 +2489,18 @@ 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,
Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp +++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp @@ -68,6 +68,21 @@ }; void f(K k) {} +// CHECK-DAG: !DICompositeType({{.*}}name: "DeletedCtors",{{.*}}DIFlagTypePassBy +struct NonTrivial { + NonTrivial(); +}; +struct DeletedCtors { + DeletedCtors() = delete; + DeletedCtors(const DeletedCtors &) = default; + void f1(); + NonTrivial t; +}; + +const NonTrivial &f(const DeletedCtors &D) { + return D.t; +} + // Test that we don't use constructor homing on lambdas. // CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L" // CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue @@ -89,3 +104,4 @@ } // ITANIUM-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: DIFlagFwdDecl + Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -2489,9 +2489,18 @@ 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,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits