Skip to content

Commit 3de2147

Browse files
authored
[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.
1 parent 4d8eb00 commit 3de2147

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,15 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
20472047
GD.getWithKernelReferenceKind(KernelReferenceKind::Kernel),
20482048
ND));
20492049

2050+
// This invariant should hold true in the future.
2051+
// Prior work:
2052+
// https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8
2053+
// https://github.com/llvm/llvm-project/issues/111345
2054+
// assert((MangledName.startswith("_Z") || MangledName.startswith("?")) &&
2055+
// !GD->hasAttr<AsmLabelAttr>() &&
2056+
// llvm::demangle(MangledName) != MangledName &&
2057+
// "LLVM demangler must demangle clang-generated names");
2058+
20502059
auto Result = Manglings.insert(std::make_pair(MangledName, GD));
20512060
return MangledDeclNames[CanonicalGD] = Result.first->first();
20522061
}

0 commit comments

Comments
 (0)