Author: Orlando Cazalet-Hyams Date: 2025-05-23T10:02:26+01:00 New Revision: 5c3a99760274a06f8cb7e7247ce69c2fde5fbf2a
URL: https://github.com/llvm/llvm-project/commit/5c3a99760274a06f8cb7e7247ce69c2fde5fbf2a DIFF: https://github.com/llvm/llvm-project/commit/5c3a99760274a06f8cb7e7247ce69c2fde5fbf2a.diff LOG: [KeyInstr][Clang] Member initalization atom (#134640) This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed. Added: clang/test/DebugInfo/KeyInstructions/init-member.cpp Modified: clang/lib/CodeGen/CGClass.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 6beb2bccfeae0..251b059c256f6 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -1338,6 +1338,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD, assert(!Member->isBaseInitializer()); assert(Member->isAnyMemberInitializer() && "Delegating initializer on non-delegating constructor"); + ApplyAtomGroup Grp(getDebugInfo()); CM.addMemberInitializer(Member); } CM.finish(); diff --git a/clang/test/DebugInfo/KeyInstructions/init-member.cpp b/clang/test/DebugInfo/KeyInstructions/init-member.cpp new file mode 100644 index 0000000000000..5ccefd4064421 --- /dev/null +++ b/clang/test/DebugInfo/KeyInstructions/init-member.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - \ +// RUN: | FileCheck %s + +struct B { + float y; +}; + +class Cls { + public: + int x = 1; + B b = {5.f}; +}; + +void fun() { + Cls c; +} + +// CHECK: store i32 1, ptr %x{{.*}}, !dbg [[G1R1:!.*]] +// CHECK: store float 5.000000e+00, ptr %y{{.*}}, !dbg [[G2R1:!.*]] + +// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) +// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits