Skip to content

Commit de132b2

Browse files
[Clang][CodeGen] Fix demangler invariant comment assertion (#130522)
This patch makes the assertion (that is currently in a comment) that validates that names mangled by clang can be demangled by LLVM actually compile/work. There were some minor issues that needed to be fixed (like starts_with not being available on std::string and needing to call getDecl() on GD), and a logic issue that should be fixed in this patch. This enables just uncommenting the assertion to enable it within the compiler (minus needing to add the header file).
1 parent 8b9c91e commit de132b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,9 +2068,10 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
20682068
// Prior work:
20692069
// https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8
20702070
// https://github.com/llvm/llvm-project/issues/111345
2071-
// assert((MangledName.startswith("_Z") || MangledName.startswith("?")) &&
2072-
// !GD->hasAttr<AsmLabelAttr>() &&
2073-
// llvm::demangle(MangledName) != MangledName &&
2071+
// assert(!((StringRef(MangledName).starts_with("_Z") ||
2072+
// StringRef(MangledName).starts_with("?")) &&
2073+
// !GD.getDecl()->hasAttr<AsmLabelAttr>() &&
2074+
// llvm::demangle(MangledName) == MangledName) &&
20742075
// "LLVM demangler must demangle clang-generated names");
20752076

20762077
auto Result = Manglings.insert(std::make_pair(MangledName, GD));

0 commit comments

Comments
 (0)