[clang] 3de2147 - [clang][codegen] Mention the invariant that LLVM demangler should be … (#117346)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 08:23:14 PST 2024


Author: Viktoriia Bakalova
Date: 2024-11-25T17:23:10+01:00
New Revision: 3de21477c49172081e502b47d608e729915f0914

URL: https://github.com/llvm/llvm-project/commit/3de21477c49172081e502b47d608e729915f0914
DIFF: https://github.com/llvm/llvm-project/commit/3de21477c49172081e502b47d608e729915f0914.diff

LOG: [clang][codegen] Mention the invariant that LLVM demangler should be … (#117346)

…able to handle mangled names generated by clang.


https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8

Since we're putting the work on the above RFC on hold, let's leave a
comment in the source code pointing to prior efforts and the suggestion
of further steps.

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b854eeb62a80ce..1ff95edbbd8195 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2047,6 +2047,15 @@ 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((MangledName.startswith("_Z") || MangledName.startswith("?")) &&
+  //        !GD->hasAttr<AsmLabelAttr>() &&
+  //        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();
 }


        


More information about the cfe-commits mailing list