ldc/gen/mangling.h
Martin Kinkelin b7c6a2f101 Fix colliding WinEH TypeDescriptors for exceptions with the same TypeInfo_Class name
As reported in https://github.com/ldc-developers/ldc/issues/3501#issuecomment-661551187.

Previously, LDC would simply override an existing TypeDescriptor global
with an equivalent definition if assertions were disabled.

Use different equivalent TypeDescriptors in this exotic case now, by
using proper mangling. [The linker can presumably still fold duplicates
via ICF.]

Ideally, these descriptors would be truly unique, but WinEH depends on
string comparisons to check for matching catch clauses, and currently
depends on TypeInfo_Class.name to generate these strings at runtime when
throwing an exception, see
19731a92a9/src/ldc/eh_msvc.d (L192-L211).
So if those names were fully qualified (`cd->toPrettyChars(*true*)`
during ClassInfo generation), we'd be fine, but that'd obviously be a
breaking change and diverge from upstream.
2020-11-13 06:05:28 +01:00

46 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//===-- mangling.h --------------------------------------------------------===//
//
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
//
// Tries to centralize functionality for mangling of symbols.
//
//===----------------------------------------------------------------------===//
#pragma once
#include <string>
#include "dmd/globals.h"
class AggregateDeclaration;
class ClassDeclaration;
class FuncDeclaration;
class Module;
class VarDeclaration;
/*
* These functions return a symbol's LLVM mangle.
* LLVM's codegen performs target-specific postprocessing of these LLVM mangles
* (for the final object file mangles) unless the LLVM mangle starts with a 0x1
* byte. The TargetABI gets a chance to tweak the LLVM mangle.
*/
std::string getIRMangledName(FuncDeclaration *fdecl, LINK link);
std::string getIRMangledName(VarDeclaration *vd);
std::string getIRMangledFuncName(std::string baseMangle, LINK link);
std::string getIRMangledVarName(std::string baseMangle, LINK link);
std::string getIRMangledAggregateName(AggregateDeclaration *aggrdecl,
const char *suffix = nullptr);
std::string getIRMangledInitSymbolName(AggregateDeclaration *aggrdecl);
std::string getIRMangledVTableSymbolName(AggregateDeclaration *aggrdecl);
std::string getIRMangledClassInfoSymbolName(AggregateDeclaration *aggrdecl);
std::string getIRMangledInterfaceInfosSymbolName(ClassDeclaration *cd);
std::string getIRMangledModuleInfoSymbolName(Module *module);
std::string getIRMangledModuleRefSymbolName(const char *moduleMangle);