From abd3c27d94b7f18990377d518aa8e14b32659b5f Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Fri, 22 Nov 2024 17:26:57 +0100 Subject: [PATCH 1/3] [clang][codegen] Mention the invariant that LLVM demangler should be able to handle mangled names generated by clang. https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8 --- clang/lib/CodeGen/CodeGenModule.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b854eeb62a80ce..6eef085ae336eb 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2047,6 +2047,13 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { GD.getWithKernelReferenceKind(KernelReferenceKind::Kernel), ND)); + // This invariant should hold true in the future. + // Prior work: https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8 + // https://github.com/llvm/llvm-project/issues/111345 + // assert(llvm::isMangledName(MangledName) && + // llvm::demangle(MangledName) != MangledName && + // "LLVM demangler must demangle clang-generated names"); + auto Result = Manglings.insert(std::make_pair(MangledName, GD)); return MangledDeclNames[CanonicalGD] = Result.first->first(); } From 47cac5440b10f2582b3a42b06a630d8f291a1f53 Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Fri, 22 Nov 2024 17:46:43 +0100 Subject: [PATCH 2/3] [clang][codegen] Fix formatting --- clang/lib/CodeGen/CodeGenModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 6eef085ae336eb..26acf67c9bba90 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2048,7 +2048,8 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { ND)); // This invariant should hold true in the future. - // Prior work: https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8 + // Prior work: + // https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8 // https://github.com/llvm/llvm-project/issues/111345 // assert(llvm::isMangledName(MangledName) && // llvm::demangle(MangledName) != MangledName && From 9d6a16dac2f5b682e89ba9fbff1e7cdb501a54a8 Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Fri, 22 Nov 2024 18:57:56 +0100 Subject: [PATCH 3/3] [clang][codegen] Change the comment text to be more detailed on what a mangled name is. --- clang/lib/CodeGen/CodeGenModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 26acf67c9bba90..1ff95edbbd8195 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2051,7 +2051,8 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { // Prior work: // https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8 // https://github.com/llvm/llvm-project/issues/111345 - // assert(llvm::isMangledName(MangledName) && + // assert((MangledName.startswith("_Z") || MangledName.startswith("?")) && + // !GD->hasAttr() && // llvm::demangle(MangledName) != MangledName && // "LLVM demangler must demangle clang-generated names");