aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorAiden Grossman <aidengrossman@google.com>2025-03-09 19:56:40 -0700
committerGitHub <noreply@github.com>2025-03-09 19:56:40 -0700
commitde132b2a0c344729703358a1c3ac90fb28fdb130 (patch)
tree9bd8e1a9e7176652d6998d7dbcd451a62cd9867b /clang/lib/CodeGen/CodeGenModule.cpp
parent8b9c91ec7da0ca3daab8ff6711126443e500bb66 (diff)
downloadllvm-de132b2a0c344729703358a1c3ac90fb28fdb130.zip
llvm-de132b2a0c344729703358a1c3ac90fb28fdb130.tar.gz
llvm-de132b2a0c344729703358a1c3ac90fb28fdb130.tar.bz2
[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).
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d2c97ce..1f6321a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2068,9 +2068,10 @@ 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((MangledName.startswith("_Z") || MangledName.startswith("?")) &&
- // !GD->hasAttr<AsmLabelAttr>() &&
- // llvm::demangle(MangledName) != MangledName &&
+ // assert(!((StringRef(MangledName).starts_with("_Z") ||
+ // StringRef(MangledName).starts_with("?")) &&
+ // !GD.getDecl()->hasAttr<AsmLabelAttr>() &&
+ // llvm::demangle(MangledName) == MangledName) &&
// "LLVM demangler must demangle clang-generated names");
auto Result = Manglings.insert(std::make_pair(MangledName, GD));