2011-01-14 02:57:25 +08:00
|
|
|
//===--- Mangle.cpp - Mangle C++ Names --------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-01-14 02:57:25 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements generic name mangling support for blocks and Objective-C.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2013-10-16 09:40:34 +08:00
|
|
|
#include "clang/AST/Attr.h"
|
2011-01-14 02:57:25 +08:00
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/AST/DeclCXX.h"
|
|
|
|
#include "clang/AST/DeclObjC.h"
|
|
|
|
#include "clang/AST/DeclTemplate.h"
|
|
|
|
#include "clang/AST/ExprCXX.h"
|
2014-01-07 19:51:46 +08:00
|
|
|
#include "clang/AST/Mangle.h"
|
2019-06-20 04:51:35 +08:00
|
|
|
#include "clang/AST/VTableBuilder.h"
|
2011-01-14 02:57:25 +08:00
|
|
|
#include "clang/Basic/ABI.h"
|
|
|
|
#include "clang/Basic/SourceManager.h"
|
2013-10-16 09:40:34 +08:00
|
|
|
#include "clang/Basic/TargetInfo.h"
|
2011-01-14 02:57:25 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2019-06-20 14:01:06 +08:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2019-06-20 04:51:35 +08:00
|
|
|
#include "llvm/IR/Mangler.h"
|
2011-01-14 02:57:25 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2020-06-23 20:59:05 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2011-01-14 02:57:25 +08:00
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
// FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
|
|
|
|
// much to be desired. Come up with a better mangling scheme.
|
|
|
|
|
|
|
|
static void mangleFunctionBlock(MangleContext &Context,
|
2011-07-23 18:55:15 +08:00
|
|
|
StringRef Outer,
|
2011-01-14 02:57:25 +08:00
|
|
|
const BlockDecl *BD,
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &Out) {
|
2012-06-27 00:06:38 +08:00
|
|
|
unsigned discriminator = Context.getBlockId(BD, true);
|
|
|
|
if (discriminator == 0)
|
|
|
|
Out << "__" << Outer << "_block_invoke";
|
|
|
|
else
|
2018-07-31 03:24:48 +08:00
|
|
|
Out << "__" << Outer << "_block_invoke_" << discriminator+1;
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void MangleContext::anchor() { }
|
|
|
|
|
2014-11-01 06:00:51 +08:00
|
|
|
enum CCMangling {
|
|
|
|
CCM_Other,
|
|
|
|
CCM_Fast,
|
2016-11-03 02:29:35 +08:00
|
|
|
CCM_RegCall,
|
2014-11-01 06:00:51 +08:00
|
|
|
CCM_Vector,
|
2019-11-26 01:50:58 +08:00
|
|
|
CCM_Std,
|
|
|
|
CCM_WasmMainArgcArgv
|
2013-10-16 09:40:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static bool isExternC(const NamedDecl *ND) {
|
|
|
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
|
|
|
|
return FD->isExternC();
|
Rework how UuidAttr, CXXUuidofExpr, and GUID template arguments and constants are represented.
Summary:
Previously, we treated CXXUuidofExpr as quite a special case: it was the
only kind of expression that could be a canonical template argument, it
could be a constant lvalue base object, and so on. In addition, we
represented the UUID value as a string, whose source form we did not
preserve faithfully, and that we partially parsed in multiple different
places.
With this patch, we create an MSGuidDecl object to represent the
implicit object of type 'struct _GUID' created by a UuidAttr. Each
UuidAttr holds a pointer to its 'struct _GUID' and its original
(as-written) UUID string. A non-value-dependent CXXUuidofExpr behaves
like a DeclRefExpr denoting that MSGuidDecl object. We cache an APValue
representation of the GUID on the MSGuidDecl and use it from constant
evaluation where needed.
This allows removing a lot of the special-case logic to handle these
expressions. Unfortunately, many parts of Clang assume there are only
a couple of interesting kinds of ValueDecl, so the total amount of
special-case logic is not really reduced very much.
This fixes a few bugs and issues:
* PR38490: we now support reading from GUID objects returned from
__uuidof during constant evaluation.
* Our Itanium mangling for a non-instantiation-dependent template
argument involving __uuidof no longer depends on which CXXUuidofExpr
template argument we happened to see first.
* We now predeclare ::_GUID, and permit use of __uuidof without
any header inclusion, better matching MSVC's behavior. We do not
predefine ::__s_GUID, though; that seems like a step too far.
* Our IR representation for GUID constants now uses the correct IR type
wherever possible. We will still fall back to using the
{i32, i16, i16, [8 x i8]}
layout if a definition of struct _GUID is not available. This is not
ideal: in principle the two layouts could have different padding.
Reviewers: rnk, jdoerfert
Subscribers: arphaman, cfe-commits, aeubanks
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78171
2020-04-12 13:15:29 +08:00
|
|
|
if (const VarDecl *VD = dyn_cast<VarDecl>(ND))
|
|
|
|
return VD->isExternC();
|
|
|
|
return false;
|
2013-10-16 09:40:34 +08:00
|
|
|
}
|
|
|
|
|
2014-11-01 06:00:51 +08:00
|
|
|
static CCMangling getCallingConvMangling(const ASTContext &Context,
|
|
|
|
const NamedDecl *ND) {
|
2013-10-16 09:40:34 +08:00
|
|
|
const TargetInfo &TI = Context.getTargetInfo();
|
2014-03-05 03:31:42 +08:00
|
|
|
const llvm::Triple &Triple = TI.getTriple();
|
2019-11-26 01:50:58 +08:00
|
|
|
|
|
|
|
// On wasm, the argc/argv form of "main" is renamed so that the startup code
|
|
|
|
// can call it with the correct function signature.
|
|
|
|
// On Emscripten, users may be exporting "main" and expecting to call it
|
|
|
|
// themselves, so we can't mangle it.
|
|
|
|
if (Triple.isWasm() && !Triple.isOSEmscripten())
|
|
|
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
|
|
|
|
if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
|
|
|
|
return CCM_WasmMainArgcArgv;
|
|
|
|
|
2020-01-07 17:32:39 +08:00
|
|
|
if (!Triple.isOSWindows() || !Triple.isX86())
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Other;
|
2013-10-16 09:40:34 +08:00
|
|
|
|
|
|
|
if (Context.getLangOpts().CPlusPlus && !isExternC(ND) &&
|
|
|
|
TI.getCXXABI() == TargetCXXABI::Microsoft)
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Other;
|
2013-10-16 09:40:34 +08:00
|
|
|
|
|
|
|
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
|
|
|
|
if (!FD)
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Other;
|
2013-10-16 09:40:34 +08:00
|
|
|
QualType T = FD->getType();
|
|
|
|
|
|
|
|
const FunctionType *FT = T->castAs<FunctionType>();
|
|
|
|
|
|
|
|
CallingConv CC = FT->getCallConv();
|
|
|
|
switch (CC) {
|
|
|
|
default:
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Other;
|
2013-10-16 09:40:34 +08:00
|
|
|
case CC_X86FastCall:
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Fast;
|
2013-10-16 09:40:34 +08:00
|
|
|
case CC_X86StdCall:
|
2014-11-01 06:00:51 +08:00
|
|
|
return CCM_Std;
|
|
|
|
case CC_X86VectorCall:
|
|
|
|
return CCM_Vector;
|
2013-10-16 09:40:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
|
|
|
|
const ASTContext &ASTContext = getASTContext();
|
|
|
|
|
2014-11-01 06:00:51 +08:00
|
|
|
CCMangling CC = getCallingConvMangling(ASTContext, D);
|
|
|
|
if (CC != CCM_Other)
|
2013-10-16 09:40:34 +08:00
|
|
|
return true;
|
|
|
|
|
2017-09-07 08:55:55 +08:00
|
|
|
// If the declaration has an owning module for linkage purposes that needs to
|
|
|
|
// be mangled, we must mangle its name.
|
|
|
|
if (!D->hasExternalFormalLinkage() && D->getOwningModuleForLinkage())
|
|
|
|
return true;
|
|
|
|
|
2021-03-06 02:49:47 +08:00
|
|
|
// C functions with internal linkage have to be mangled with option
|
|
|
|
// -funique-internal-linkage-names.
|
|
|
|
if (!getASTContext().getLangOpts().CPlusPlus &&
|
|
|
|
isUniqueInternalLinkageDecl(D))
|
|
|
|
return true;
|
|
|
|
|
2013-10-16 09:40:34 +08:00
|
|
|
// In C, functions with no attributes never need to be mangled. Fastpath them.
|
|
|
|
if (!getASTContext().getLangOpts().CPlusPlus && !D->hasAttrs())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Any decl can be declared with __asm("foo") on it, and this takes precedence
|
|
|
|
// over all other naming in the .o file.
|
|
|
|
if (D->hasAttr<AsmLabelAttr>())
|
|
|
|
return true;
|
|
|
|
|
Rework how UuidAttr, CXXUuidofExpr, and GUID template arguments and constants are represented.
Summary:
Previously, we treated CXXUuidofExpr as quite a special case: it was the
only kind of expression that could be a canonical template argument, it
could be a constant lvalue base object, and so on. In addition, we
represented the UUID value as a string, whose source form we did not
preserve faithfully, and that we partially parsed in multiple different
places.
With this patch, we create an MSGuidDecl object to represent the
implicit object of type 'struct _GUID' created by a UuidAttr. Each
UuidAttr holds a pointer to its 'struct _GUID' and its original
(as-written) UUID string. A non-value-dependent CXXUuidofExpr behaves
like a DeclRefExpr denoting that MSGuidDecl object. We cache an APValue
representation of the GUID on the MSGuidDecl and use it from constant
evaluation where needed.
This allows removing a lot of the special-case logic to handle these
expressions. Unfortunately, many parts of Clang assume there are only
a couple of interesting kinds of ValueDecl, so the total amount of
special-case logic is not really reduced very much.
This fixes a few bugs and issues:
* PR38490: we now support reading from GUID objects returned from
__uuidof during constant evaluation.
* Our Itanium mangling for a non-instantiation-dependent template
argument involving __uuidof no longer depends on which CXXUuidofExpr
template argument we happened to see first.
* We now predeclare ::_GUID, and permit use of __uuidof without
any header inclusion, better matching MSVC's behavior. We do not
predefine ::__s_GUID, though; that seems like a step too far.
* Our IR representation for GUID constants now uses the correct IR type
wherever possible. We will still fall back to using the
{i32, i16, i16, [8 x i8]}
layout if a definition of struct _GUID is not available. This is not
ideal: in principle the two layouts could have different padding.
Reviewers: rnk, jdoerfert
Subscribers: arphaman, cfe-commits, aeubanks
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78171
2020-04-12 13:15:29 +08:00
|
|
|
// Declarations that don't have identifier names always need to be mangled.
|
|
|
|
if (isa<MSGuidDecl>(D))
|
|
|
|
return true;
|
|
|
|
|
2013-10-16 09:40:34 +08:00
|
|
|
return shouldMangleCXXName(D);
|
|
|
|
}
|
|
|
|
|
2020-03-06 01:02:13 +08:00
|
|
|
void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
|
2021-04-20 01:39:20 +08:00
|
|
|
const ASTContext &ASTContext = getASTContext();
|
2020-03-06 01:02:13 +08:00
|
|
|
const NamedDecl *D = cast<NamedDecl>(GD.getDecl());
|
2021-04-20 01:39:20 +08:00
|
|
|
|
2013-10-16 09:40:34 +08:00
|
|
|
// Any decl can be declared with __asm("foo") on it, and this takes precedence
|
|
|
|
// over all other naming in the .o file.
|
|
|
|
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
|
|
|
|
// If we have an asm name, then we use it as the mangling.
|
|
|
|
|
2019-09-26 02:00:31 +08:00
|
|
|
// If the label isn't literal, or if this is an alias for an LLVM intrinsic,
|
|
|
|
// do not add a "\01" prefix.
|
|
|
|
if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
|
|
|
|
Out << ALA->getLabel();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-16 09:40:34 +08:00
|
|
|
// Adding the prefix can cause problems when one file has a "foo" and
|
|
|
|
// another has a "\01foo". That is known to happen on ELF with the
|
|
|
|
// tricks normally used for producing aliases (PR9177). Fortunately the
|
|
|
|
// llvm mangler on ELF is a nop, so we can just avoid adding the \01
|
2019-09-26 02:00:31 +08:00
|
|
|
// marker.
|
2021-04-20 01:39:20 +08:00
|
|
|
StringRef UserLabelPrefix =
|
|
|
|
getASTContext().getTargetInfo().getUserLabelPrefix();
|
|
|
|
#ifndef NDEBUG
|
2016-03-05 03:00:41 +08:00
|
|
|
char GlobalPrefix =
|
2021-04-20 01:39:20 +08:00
|
|
|
llvm::DataLayout(getASTContext().getTargetInfo().getDataLayoutString())
|
|
|
|
.getGlobalPrefix();
|
|
|
|
assert((UserLabelPrefix.empty() && !GlobalPrefix) ||
|
|
|
|
(UserLabelPrefix.size() == 1 && UserLabelPrefix[0] == GlobalPrefix));
|
|
|
|
#endif
|
|
|
|
if (!UserLabelPrefix.empty())
|
2013-10-16 09:40:34 +08:00
|
|
|
Out << '\01'; // LLVM IR Marker for __asm("foo")
|
|
|
|
|
|
|
|
Out << ALA->getLabel();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Rework how UuidAttr, CXXUuidofExpr, and GUID template arguments and constants are represented.
Summary:
Previously, we treated CXXUuidofExpr as quite a special case: it was the
only kind of expression that could be a canonical template argument, it
could be a constant lvalue base object, and so on. In addition, we
represented the UUID value as a string, whose source form we did not
preserve faithfully, and that we partially parsed in multiple different
places.
With this patch, we create an MSGuidDecl object to represent the
implicit object of type 'struct _GUID' created by a UuidAttr. Each
UuidAttr holds a pointer to its 'struct _GUID' and its original
(as-written) UUID string. A non-value-dependent CXXUuidofExpr behaves
like a DeclRefExpr denoting that MSGuidDecl object. We cache an APValue
representation of the GUID on the MSGuidDecl and use it from constant
evaluation where needed.
This allows removing a lot of the special-case logic to handle these
expressions. Unfortunately, many parts of Clang assume there are only
a couple of interesting kinds of ValueDecl, so the total amount of
special-case logic is not really reduced very much.
This fixes a few bugs and issues:
* PR38490: we now support reading from GUID objects returned from
__uuidof during constant evaluation.
* Our Itanium mangling for a non-instantiation-dependent template
argument involving __uuidof no longer depends on which CXXUuidofExpr
template argument we happened to see first.
* We now predeclare ::_GUID, and permit use of __uuidof without
any header inclusion, better matching MSVC's behavior. We do not
predefine ::__s_GUID, though; that seems like a step too far.
* Our IR representation for GUID constants now uses the correct IR type
wherever possible. We will still fall back to using the
{i32, i16, i16, [8 x i8]}
layout if a definition of struct _GUID is not available. This is not
ideal: in principle the two layouts could have different padding.
Reviewers: rnk, jdoerfert
Subscribers: arphaman, cfe-commits, aeubanks
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78171
2020-04-12 13:15:29 +08:00
|
|
|
if (auto *GD = dyn_cast<MSGuidDecl>(D))
|
|
|
|
return mangleMSGuidDecl(GD, Out);
|
|
|
|
|
2014-11-01 06:00:51 +08:00
|
|
|
CCMangling CC = getCallingConvMangling(ASTContext, D);
|
2019-11-26 01:50:58 +08:00
|
|
|
|
|
|
|
if (CC == CCM_WasmMainArgcArgv) {
|
|
|
|
Out << "__main_argc_argv";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-16 09:40:34 +08:00
|
|
|
bool MCXX = shouldMangleCXXName(D);
|
|
|
|
const TargetInfo &TI = Context.getTargetInfo();
|
2014-11-01 06:00:51 +08:00
|
|
|
if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {
|
2014-10-15 01:20:18 +08:00
|
|
|
if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
|
2020-09-29 14:25:24 +08:00
|
|
|
mangleObjCMethodNameAsSourceName(OMD, Out);
|
2014-10-15 01:20:18 +08:00
|
|
|
else
|
2020-03-06 01:02:13 +08:00
|
|
|
mangleCXXName(GD, Out);
|
2013-10-16 09:40:34 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Out << '\01';
|
2014-11-01 06:00:51 +08:00
|
|
|
if (CC == CCM_Std)
|
2013-10-16 09:40:34 +08:00
|
|
|
Out << '_';
|
2014-11-01 06:00:51 +08:00
|
|
|
else if (CC == CCM_Fast)
|
2013-10-16 09:40:34 +08:00
|
|
|
Out << '@';
|
2016-11-03 02:29:35 +08:00
|
|
|
else if (CC == CCM_RegCall)
|
|
|
|
Out << "__regcall3__";
|
2013-10-16 09:40:34 +08:00
|
|
|
|
|
|
|
if (!MCXX)
|
|
|
|
Out << D->getIdentifier()->getName();
|
2014-10-15 01:20:18 +08:00
|
|
|
else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
|
2020-09-29 14:25:24 +08:00
|
|
|
mangleObjCMethodNameAsSourceName(OMD, Out);
|
2013-10-16 09:40:34 +08:00
|
|
|
else
|
2020-03-06 01:02:13 +08:00
|
|
|
mangleCXXName(GD, Out);
|
2013-10-16 09:40:34 +08:00
|
|
|
|
|
|
|
const FunctionDecl *FD = cast<FunctionDecl>(D);
|
|
|
|
const FunctionType *FT = FD->getType()->castAs<FunctionType>();
|
|
|
|
const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT);
|
2014-11-01 06:00:51 +08:00
|
|
|
if (CC == CCM_Vector)
|
|
|
|
Out << '@';
|
2013-10-16 09:40:34 +08:00
|
|
|
Out << '@';
|
|
|
|
if (!Proto) {
|
|
|
|
Out << '0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
assert(!Proto->isVariadic());
|
|
|
|
unsigned ArgWords = 0;
|
|
|
|
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
|
|
|
|
if (!MD->isStatic())
|
|
|
|
++ArgWords;
|
2014-03-17 23:23:01 +08:00
|
|
|
for (const auto &AT : Proto->param_types())
|
2014-11-01 06:00:51 +08:00
|
|
|
// Size should be aligned to pointer size.
|
2016-01-15 05:00:27 +08:00
|
|
|
ArgWords +=
|
|
|
|
llvm::alignTo(ASTContext.getTypeSize(AT), TI.getPointerWidth(0)) /
|
|
|
|
TI.getPointerWidth(0);
|
2014-11-01 06:00:51 +08:00
|
|
|
Out << ((TI.getPointerWidth(0) / 8) * ArgWords);
|
2013-10-16 09:40:34 +08:00
|
|
|
}
|
|
|
|
|
Rework how UuidAttr, CXXUuidofExpr, and GUID template arguments and constants are represented.
Summary:
Previously, we treated CXXUuidofExpr as quite a special case: it was the
only kind of expression that could be a canonical template argument, it
could be a constant lvalue base object, and so on. In addition, we
represented the UUID value as a string, whose source form we did not
preserve faithfully, and that we partially parsed in multiple different
places.
With this patch, we create an MSGuidDecl object to represent the
implicit object of type 'struct _GUID' created by a UuidAttr. Each
UuidAttr holds a pointer to its 'struct _GUID' and its original
(as-written) UUID string. A non-value-dependent CXXUuidofExpr behaves
like a DeclRefExpr denoting that MSGuidDecl object. We cache an APValue
representation of the GUID on the MSGuidDecl and use it from constant
evaluation where needed.
This allows removing a lot of the special-case logic to handle these
expressions. Unfortunately, many parts of Clang assume there are only
a couple of interesting kinds of ValueDecl, so the total amount of
special-case logic is not really reduced very much.
This fixes a few bugs and issues:
* PR38490: we now support reading from GUID objects returned from
__uuidof during constant evaluation.
* Our Itanium mangling for a non-instantiation-dependent template
argument involving __uuidof no longer depends on which CXXUuidofExpr
template argument we happened to see first.
* We now predeclare ::_GUID, and permit use of __uuidof without
any header inclusion, better matching MSVC's behavior. We do not
predefine ::__s_GUID, though; that seems like a step too far.
* Our IR representation for GUID constants now uses the correct IR type
wherever possible. We will still fall back to using the
{i32, i16, i16, [8 x i8]}
layout if a definition of struct _GUID is not available. This is not
ideal: in principle the two layouts could have different padding.
Reviewers: rnk, jdoerfert
Subscribers: arphaman, cfe-commits, aeubanks
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78171
2020-04-12 13:15:29 +08:00
|
|
|
void MangleContext::mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &Out) {
|
|
|
|
// For now, follow the MSVC naming convention for GUID objects on all
|
|
|
|
// targets.
|
|
|
|
MSGuidDecl::Parts P = GD->getParts();
|
|
|
|
Out << llvm::format("_GUID_%08" PRIx32 "_%04" PRIx32 "_%04" PRIx32 "_",
|
|
|
|
P.Part1, P.Part2, P.Part3);
|
|
|
|
unsigned I = 0;
|
|
|
|
for (uint8_t C : P.Part4And5) {
|
|
|
|
Out << llvm::format("%02" PRIx8, C);
|
|
|
|
if (++I == 2)
|
|
|
|
Out << "_";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 02:57:25 +08:00
|
|
|
void MangleContext::mangleGlobalBlock(const BlockDecl *BD,
|
2012-06-27 00:06:38 +08:00
|
|
|
const NamedDecl *ID,
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &Out) {
|
2012-06-27 00:06:38 +08:00
|
|
|
unsigned discriminator = getBlockId(BD, false);
|
|
|
|
if (ID) {
|
|
|
|
if (shouldMangleDeclName(ID))
|
|
|
|
mangleName(ID, Out);
|
|
|
|
else {
|
|
|
|
Out << ID->getIdentifier()->getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (discriminator == 0)
|
|
|
|
Out << "_block_invoke";
|
|
|
|
else
|
|
|
|
Out << "_block_invoke_" << discriminator+1;
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MangleContext::mangleCtorBlock(const CXXConstructorDecl *CD,
|
|
|
|
CXXCtorType CT, const BlockDecl *BD,
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &ResStream) {
|
2012-02-05 10:13:05 +08:00
|
|
|
SmallString<64> Buffer;
|
2011-02-11 07:59:36 +08:00
|
|
|
llvm::raw_svector_ostream Out(Buffer);
|
2020-03-06 01:02:13 +08:00
|
|
|
mangleName(GlobalDecl(CD, CT), Out);
|
2011-02-11 07:59:36 +08:00
|
|
|
mangleFunctionBlock(*this, Buffer, BD, ResStream);
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MangleContext::mangleDtorBlock(const CXXDestructorDecl *DD,
|
|
|
|
CXXDtorType DT, const BlockDecl *BD,
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &ResStream) {
|
2012-02-05 10:13:05 +08:00
|
|
|
SmallString<64> Buffer;
|
2011-02-11 07:59:36 +08:00
|
|
|
llvm::raw_svector_ostream Out(Buffer);
|
2020-03-06 01:02:13 +08:00
|
|
|
mangleName(GlobalDecl(DD, DT), Out);
|
2011-02-11 07:59:36 +08:00
|
|
|
mangleFunctionBlock(*this, Buffer, BD, ResStream);
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD,
|
2011-07-23 18:55:15 +08:00
|
|
|
raw_ostream &Out) {
|
2011-01-14 02:57:25 +08:00
|
|
|
assert(!isa<CXXConstructorDecl>(DC) && !isa<CXXDestructorDecl>(DC));
|
|
|
|
|
2012-02-05 10:13:05 +08:00
|
|
|
SmallString<64> Buffer;
|
2011-02-11 10:52:17 +08:00
|
|
|
llvm::raw_svector_ostream Stream(Buffer);
|
2011-01-14 02:57:25 +08:00
|
|
|
if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
|
2020-09-29 14:25:24 +08:00
|
|
|
mangleObjCMethodNameAsSourceName(Method, Stream);
|
2011-01-14 02:57:25 +08:00
|
|
|
} else {
|
2014-10-15 01:20:14 +08:00
|
|
|
assert((isa<NamedDecl>(DC) || isa<BlockDecl>(DC)) &&
|
|
|
|
"expected a NamedDecl or BlockDecl");
|
|
|
|
if (isa<BlockDecl>(DC))
|
|
|
|
for (; DC && isa<BlockDecl>(DC); DC = DC->getParent())
|
|
|
|
(void) getBlockId(cast<BlockDecl>(DC), true);
|
2014-11-15 07:55:27 +08:00
|
|
|
assert((isa<TranslationUnitDecl>(DC) || isa<NamedDecl>(DC)) &&
|
|
|
|
"expected a TranslationUnitDecl or a NamedDecl");
|
2014-12-03 02:42:51 +08:00
|
|
|
if (const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
|
|
|
|
mangleCtorBlock(CD, /*CT*/ Ctor_Complete, BD, Out);
|
|
|
|
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
|
|
|
|
mangleDtorBlock(DD, /*DT*/ Dtor_Complete, BD, Out);
|
|
|
|
else if (auto ND = dyn_cast<NamedDecl>(DC)) {
|
2014-11-15 07:55:27 +08:00
|
|
|
if (!shouldMangleDeclName(ND) && ND->getIdentifier())
|
|
|
|
Stream << ND->getIdentifier()->getName();
|
|
|
|
else {
|
|
|
|
// FIXME: We were doing a mangleUnqualifiedName() before, but that's
|
|
|
|
// a private member of a class that will soon itself be private to the
|
|
|
|
// Itanium C++ ABI object. What should we do now? Right now, I'm just
|
|
|
|
// calling the mangleName() method on the MangleContext; is there a
|
|
|
|
// better way?
|
|
|
|
mangleName(ND, Stream);
|
|
|
|
}
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
}
|
2011-02-11 07:59:36 +08:00
|
|
|
mangleFunctionBlock(*this, Buffer, BD, Out);
|
2011-01-14 02:57:25 +08:00
|
|
|
}
|
|
|
|
|
2020-09-29 14:25:24 +08:00
|
|
|
void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD,
|
|
|
|
raw_ostream &OS,
|
|
|
|
bool includePrefixByte,
|
|
|
|
bool includeCategoryNamespace) {
|
2020-09-30 06:47:37 +08:00
|
|
|
if (getASTContext().getLangOpts().ObjCRuntime.isGNUFamily()) {
|
|
|
|
// This is the mangling we've always used on the GNU runtimes, but it
|
|
|
|
// has obvious collisions in the face of underscores within class
|
|
|
|
// names, category names, and selectors; maybe we should improve it.
|
|
|
|
|
|
|
|
OS << (MD->isClassMethod() ? "_c_" : "_i_")
|
|
|
|
<< MD->getClassInterface()->getName() << '_';
|
|
|
|
|
|
|
|
if (includeCategoryNamespace) {
|
|
|
|
if (auto category = MD->getCategory())
|
|
|
|
OS << category->getName();
|
|
|
|
}
|
|
|
|
OS << '_';
|
|
|
|
|
|
|
|
auto selector = MD->getSelector();
|
|
|
|
for (unsigned slotIndex = 0,
|
|
|
|
numArgs = selector.getNumArgs(),
|
|
|
|
slotEnd = std::max(numArgs, 1U);
|
|
|
|
slotIndex != slotEnd; ++slotIndex) {
|
|
|
|
if (auto name = selector.getIdentifierInfoForSlot(slotIndex))
|
|
|
|
OS << name->getName();
|
|
|
|
|
|
|
|
// Replace all the positions that would've been ':' with '_'.
|
|
|
|
// That's after each slot except that a unary selector doesn't
|
|
|
|
// end in ':'.
|
|
|
|
if (numArgs)
|
|
|
|
OS << '_';
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-29 14:25:24 +08:00
|
|
|
// \01+[ContainerName(CategoryName) SelectorName]
|
|
|
|
if (includePrefixByte) {
|
|
|
|
OS << '\01';
|
|
|
|
}
|
2017-03-07 17:26:07 +08:00
|
|
|
OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
|
2020-09-30 06:47:37 +08:00
|
|
|
if (const auto *CID = MD->getCategory()) {
|
2017-03-07 17:26:07 +08:00
|
|
|
OS << CID->getClassInterface()->getName();
|
2020-09-29 14:25:24 +08:00
|
|
|
if (includeCategoryNamespace) {
|
|
|
|
OS << '(' << *CID << ')';
|
|
|
|
}
|
|
|
|
} else if (const auto *CD =
|
|
|
|
dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) {
|
2017-03-07 17:26:07 +08:00
|
|
|
OS << CD->getName();
|
2020-09-29 14:25:24 +08:00
|
|
|
} else {
|
|
|
|
llvm_unreachable("Unexpected ObjC method decl context");
|
2017-03-07 17:26:07 +08:00
|
|
|
}
|
2014-01-04 01:59:55 +08:00
|
|
|
OS << ' ';
|
|
|
|
MD->getSelector().print(OS);
|
|
|
|
OS << ']';
|
2016-02-15 06:30:14 +08:00
|
|
|
}
|
|
|
|
|
2020-09-29 14:25:24 +08:00
|
|
|
void MangleContext::mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD,
|
|
|
|
raw_ostream &Out) {
|
2016-02-15 06:30:14 +08:00
|
|
|
SmallString<64> Name;
|
|
|
|
llvm::raw_svector_ostream OS(Name);
|
|
|
|
|
2020-09-29 14:25:24 +08:00
|
|
|
mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
|
|
|
|
/*includeCategoryNamespace=*/true);
|
2011-01-14 02:57:25 +08:00
|
|
|
Out << OS.str().size() << OS.str();
|
|
|
|
}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
class ASTNameGenerator::Implementation {
|
|
|
|
std::unique_ptr<MangleContext> MC;
|
|
|
|
llvm::DataLayout DL;
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
public:
|
|
|
|
explicit Implementation(ASTContext &Ctx)
|
2021-04-20 01:39:20 +08:00
|
|
|
: MC(Ctx.createMangleContext()),
|
|
|
|
DL(Ctx.getTargetInfo().getDataLayoutString()) {}
|
2019-06-20 14:01:06 +08:00
|
|
|
|
|
|
|
bool writeName(const Decl *D, raw_ostream &OS) {
|
|
|
|
// First apply frontend mangling.
|
|
|
|
SmallString<128> FrontendBuf;
|
|
|
|
llvm::raw_svector_ostream FrontendBufOS(FrontendBuf);
|
|
|
|
if (auto *FD = dyn_cast<FunctionDecl>(D)) {
|
|
|
|
if (FD->isDependentContext())
|
|
|
|
return true;
|
|
|
|
if (writeFuncOrVarName(FD, FrontendBufOS))
|
|
|
|
return true;
|
|
|
|
} else if (auto *VD = dyn_cast<VarDecl>(D)) {
|
|
|
|
if (writeFuncOrVarName(VD, FrontendBufOS))
|
|
|
|
return true;
|
|
|
|
} else if (auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
|
2020-09-29 14:25:24 +08:00
|
|
|
MC->mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
|
|
|
|
/*includeCategoryNamespace=*/true);
|
2019-06-20 14:01:06 +08:00
|
|
|
return false;
|
|
|
|
} else if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
|
|
|
|
writeObjCClassName(ID, FrontendBufOS);
|
|
|
|
} else {
|
2019-06-20 04:51:35 +08:00
|
|
|
return true;
|
2019-06-20 14:01:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now apply backend mangling.
|
|
|
|
llvm::Mangler::getNameWithPrefix(OS, FrontendBufOS.str(), DL);
|
2019-06-20 04:51:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::string getName(const Decl *D) {
|
|
|
|
std::string Name;
|
|
|
|
{
|
|
|
|
llvm::raw_string_ostream OS(Name);
|
|
|
|
writeName(D, OS);
|
|
|
|
}
|
|
|
|
return Name;
|
2019-06-20 04:51:35 +08:00
|
|
|
}
|
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
enum ObjCKind {
|
|
|
|
ObjCClass,
|
|
|
|
ObjCMetaclass,
|
|
|
|
};
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
static StringRef getClassSymbolPrefix(ObjCKind Kind,
|
|
|
|
const ASTContext &Context) {
|
|
|
|
if (Context.getLangOpts().ObjCRuntime.isGNUFamily())
|
|
|
|
return Kind == ObjCMetaclass ? "_OBJC_METACLASS_" : "_OBJC_CLASS_";
|
|
|
|
return Kind == ObjCMetaclass ? "OBJC_METACLASS_$_" : "OBJC_CLASS_$_";
|
|
|
|
}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::vector<std::string> getAllManglings(const ObjCContainerDecl *OCD) {
|
|
|
|
StringRef ClassName;
|
|
|
|
if (const auto *OID = dyn_cast<ObjCInterfaceDecl>(OCD))
|
|
|
|
ClassName = OID->getObjCRuntimeNameAsString();
|
|
|
|
else if (const auto *OID = dyn_cast<ObjCImplementationDecl>(OCD))
|
|
|
|
ClassName = OID->getObjCRuntimeNameAsString();
|
|
|
|
|
|
|
|
if (ClassName.empty())
|
|
|
|
return {};
|
|
|
|
|
|
|
|
auto Mangle = [&](ObjCKind Kind, StringRef ClassName) -> std::string {
|
|
|
|
SmallString<40> Mangled;
|
|
|
|
auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
|
|
|
|
llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
|
2020-01-29 03:23:46 +08:00
|
|
|
return std::string(Mangled.str());
|
2019-06-20 14:01:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
Mangle(ObjCClass, ClassName),
|
|
|
|
Mangle(ObjCMetaclass, ClassName),
|
|
|
|
};
|
|
|
|
}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::vector<std::string> getAllManglings(const Decl *D) {
|
|
|
|
if (const auto *OCD = dyn_cast<ObjCContainerDecl>(D))
|
|
|
|
return getAllManglings(OCD);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
if (!(isa<CXXRecordDecl>(D) || isa<CXXMethodDecl>(D)))
|
|
|
|
return {};
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
const NamedDecl *ND = cast<NamedDecl>(D);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
ASTContext &Ctx = ND->getASTContext();
|
|
|
|
std::unique_ptr<MangleContext> M(Ctx.createMangleContext());
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::vector<std::string> Manglings;
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
auto hasDefaultCXXMethodCC = [](ASTContext &C, const CXXMethodDecl *MD) {
|
|
|
|
auto DefaultCC = C.getDefaultCallingConvention(/*IsVariadic=*/false,
|
2019-07-16 12:46:31 +08:00
|
|
|
/*IsCXXMethod=*/true);
|
2019-10-07 21:58:05 +08:00
|
|
|
auto CC = MD->getType()->castAs<FunctionProtoType>()->getCallConv();
|
2019-06-20 14:01:06 +08:00
|
|
|
return CC == DefaultCC;
|
|
|
|
};
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
if (const auto *CD = dyn_cast_or_null<CXXConstructorDecl>(ND)) {
|
|
|
|
Manglings.emplace_back(getMangledStructor(CD, Ctor_Base));
|
|
|
|
|
|
|
|
if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily())
|
|
|
|
if (!CD->getParent()->isAbstract())
|
|
|
|
Manglings.emplace_back(getMangledStructor(CD, Ctor_Complete));
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
|
|
|
|
if (CD->hasAttr<DLLExportAttr>() && CD->isDefaultConstructor())
|
|
|
|
if (!(hasDefaultCXXMethodCC(Ctx, CD) && CD->getNumParams() == 0))
|
|
|
|
Manglings.emplace_back(getMangledStructor(CD, Ctor_DefaultClosure));
|
|
|
|
} else if (const auto *DD = dyn_cast_or_null<CXXDestructorDecl>(ND)) {
|
|
|
|
Manglings.emplace_back(getMangledStructor(DD, Dtor_Base));
|
|
|
|
if (Ctx.getTargetInfo().getCXXABI().isItaniumFamily()) {
|
|
|
|
Manglings.emplace_back(getMangledStructor(DD, Dtor_Complete));
|
|
|
|
if (DD->isVirtual())
|
|
|
|
Manglings.emplace_back(getMangledStructor(DD, Dtor_Deleting));
|
|
|
|
}
|
|
|
|
} else if (const auto *MD = dyn_cast_or_null<CXXMethodDecl>(ND)) {
|
|
|
|
Manglings.emplace_back(getName(ND));
|
|
|
|
if (MD->isVirtual())
|
|
|
|
if (const auto *TIV = Ctx.getVTableContext()->getThunkInfo(MD))
|
|
|
|
for (const auto &T : *TIV)
|
|
|
|
Manglings.emplace_back(getMangledThunk(MD, T));
|
2019-06-20 04:51:35 +08:00
|
|
|
}
|
2019-06-20 14:01:06 +08:00
|
|
|
|
|
|
|
return Manglings;
|
2019-06-20 04:51:35 +08:00
|
|
|
}
|
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
private:
|
|
|
|
bool writeFuncOrVarName(const NamedDecl *D, raw_ostream &OS) {
|
|
|
|
if (MC->shouldMangleDeclName(D)) {
|
2020-03-06 01:02:13 +08:00
|
|
|
GlobalDecl GD;
|
2019-06-20 14:01:06 +08:00
|
|
|
if (const auto *CtorD = dyn_cast<CXXConstructorDecl>(D))
|
2020-03-06 01:02:13 +08:00
|
|
|
GD = GlobalDecl(CtorD, Ctor_Complete);
|
2019-06-20 14:01:06 +08:00
|
|
|
else if (const auto *DtorD = dyn_cast<CXXDestructorDecl>(D))
|
2020-03-06 01:02:13 +08:00
|
|
|
GD = GlobalDecl(DtorD, Dtor_Complete);
|
2020-03-06 01:59:33 +08:00
|
|
|
else if (D->hasAttr<CUDAGlobalAttr>())
|
2020-03-18 13:43:20 +08:00
|
|
|
GD = GlobalDecl(cast<FunctionDecl>(D));
|
2019-06-20 14:01:06 +08:00
|
|
|
else
|
2020-03-06 01:02:13 +08:00
|
|
|
GD = GlobalDecl(D);
|
|
|
|
MC->mangleName(GD, OS);
|
2019-06-20 14:01:06 +08:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
IdentifierInfo *II = D->getIdentifier();
|
|
|
|
if (!II)
|
|
|
|
return true;
|
|
|
|
OS << II->getName();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
void writeObjCClassName(const ObjCInterfaceDecl *D, raw_ostream &OS) {
|
|
|
|
OS << getClassSymbolPrefix(ObjCClass, D->getASTContext());
|
|
|
|
OS << D->getObjCRuntimeNameAsString();
|
2019-06-20 04:51:35 +08:00
|
|
|
}
|
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::string getMangledStructor(const NamedDecl *ND, unsigned StructorType) {
|
|
|
|
std::string FrontendBuf;
|
|
|
|
llvm::raw_string_ostream FOS(FrontendBuf);
|
|
|
|
|
2020-03-06 01:02:13 +08:00
|
|
|
GlobalDecl GD;
|
2019-06-20 14:01:06 +08:00
|
|
|
if (const auto *CD = dyn_cast_or_null<CXXConstructorDecl>(ND))
|
2020-03-06 01:02:13 +08:00
|
|
|
GD = GlobalDecl(CD, static_cast<CXXCtorType>(StructorType));
|
2019-06-20 14:01:06 +08:00
|
|
|
else if (const auto *DD = dyn_cast_or_null<CXXDestructorDecl>(ND))
|
2020-03-06 01:02:13 +08:00
|
|
|
GD = GlobalDecl(DD, static_cast<CXXDtorType>(StructorType));
|
|
|
|
MC->mangleName(GD, FOS);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::string BackendBuf;
|
|
|
|
llvm::raw_string_ostream BOS(BackendBuf);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
llvm::Mangler::getNameWithPrefix(BOS, FOS.str(), DL);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
return BOS.str();
|
|
|
|
}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::string getMangledThunk(const CXXMethodDecl *MD, const ThunkInfo &T) {
|
|
|
|
std::string FrontendBuf;
|
|
|
|
llvm::raw_string_ostream FOS(FrontendBuf);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
MC->mangleThunk(MD, T, FOS);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
std::string BackendBuf;
|
|
|
|
llvm::raw_string_ostream BOS(BackendBuf);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
llvm::Mangler::getNameWithPrefix(BOS, FOS.str(), DL);
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
return BOS.str();
|
|
|
|
}
|
|
|
|
};
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
ASTNameGenerator::ASTNameGenerator(ASTContext &Ctx)
|
2019-08-15 07:04:18 +08:00
|
|
|
: Impl(std::make_unique<Implementation>(Ctx)) {}
|
2019-06-20 14:01:06 +08:00
|
|
|
|
|
|
|
ASTNameGenerator::~ASTNameGenerator() {}
|
2019-06-20 04:51:35 +08:00
|
|
|
|
2019-06-20 14:01:06 +08:00
|
|
|
bool ASTNameGenerator::writeName(const Decl *D, raw_ostream &OS) {
|
|
|
|
return Impl->writeName(D, OS);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ASTNameGenerator::getName(const Decl *D) {
|
|
|
|
return Impl->getName(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> ASTNameGenerator::getAllManglings(const Decl *D) {
|
|
|
|
return Impl->getAllManglings(D);
|
2019-06-20 04:51:35 +08:00
|
|
|
}
|