;
39 unsigneddiscriminator = Context.getBlockId(BD,
true);
40 if(discriminator == 0)
41Out <<
"__"<< Outer <<
"_block_invoke";
43Out <<
"__"<< Outer <<
"_block_invoke_"<< discriminator+1;
46voidMangleContext::anchor() { }
58 if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(ND))
59 returnFD->isExternC();
60 if(
const VarDecl*VD = dyn_cast<VarDecl>(ND))
61 returnVD->isExternC();
68 constllvm::Triple &Triple = TI.
getTriple();
73 if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(ND))
74 if(FD->isMain() && FD->getNumParams() == 2)
77 if(!Triple.isOSWindows() || !Triple.isX86())
81TI.
getCXXABI() == TargetCXXABI::Microsoft)
132 if(isa<MSGuidDecl>(
D))
144 if(
constAsmLabelAttr *ALA =
D->
getAttr<AsmLabelAttr>()) {
149 if(!ALA->getIsLiteralLabel() || ALA->getLabel().starts_with(
"llvm.")) {
150Out << ALA->getLabel();
159StringRef UserLabelPrefix =
163llvm::DataLayout(
getASTContext().getTargetInfo().getDataLayoutString())
165assert((UserLabelPrefix.empty() && !GlobalPrefix) ||
166(UserLabelPrefix.size() == 1 && UserLabelPrefix[0] == GlobalPrefix));
168 if(!UserLabelPrefix.empty())
171Out << ALA->getLabel();
175 if(
auto*GD = dyn_cast<MSGuidDecl>(
D))
181Out <<
"__main_argc_argv";
202Out <<
"__regcall4__";
204Out <<
"__regcall3__";
208Out <<
D->getIdentifier()->getName();
224assert(!Proto->isVariadic());
225 unsignedArgWords = 0;
227 if(MD->isImplicitObjectMemberFunction())
230 for(
const auto&AT : Proto->param_types()) {
234 if(AT->isIncompleteType())
240Out << ((DefaultPtrWidth / 8) * ArgWords);
247Out << llvm::format(
"_GUID_%08"PRIx32
"_%04"PRIx32
"_%04"PRIx32
"_",
248 P.Part1,
P.Part2,
P.Part3);
250 for(uint8_t
C:
P.Part4And5) {
251Out << llvm::format(
"%02"PRIx8,
C);
260 unsigneddiscriminator =
getBlockId(BD,
false);
265Out << ID->getIdentifier()->getName();
268 if(discriminator == 0)
269Out <<
"_block_invoke";
271Out <<
"_block_invoke_"<< discriminator+1;
276raw_ostream &ResStream) {
278llvm::raw_svector_ostream Out(Buffer);
285raw_ostream &ResStream) {
287llvm::raw_svector_ostream Out(Buffer);
294assert(!isa<CXXConstructorDecl>(DC) && !isa<CXXDestructorDecl>(DC));
297llvm::raw_svector_ostream Stream(Buffer);
298 if(
const ObjCMethodDecl*Method = dyn_cast<ObjCMethodDecl>(DC)) {
301assert((isa<NamedDecl>(DC) || isa<BlockDecl>(DC)) &&
302 "expected a NamedDecl or BlockDecl");
303 for(; isa_and_nonnull<BlockDecl>(DC); DC = DC->
getParent())
304(
void)
getBlockId(cast<BlockDecl>(DC),
true);
305assert((isa<TranslationUnitDecl>(DC) || isa<NamedDecl>(DC)) &&
306 "expected a TranslationUnitDecl or a NamedDecl");
307 if(
const auto*CD = dyn_cast<CXXConstructorDecl>(DC))
309 else if(
const auto*DD = dyn_cast<CXXDestructorDecl>(DC))
311 else if(
autoND = dyn_cast<NamedDecl>(DC)) {
313Stream << ND->getIdentifier()->getName();
329 boolincludePrefixByte,
330 boolincludeCategoryNamespace) {
339 if(includeCategoryNamespace) {
341OS << category->getName();
346 for(
unsignedslotIndex = 0,
347numArgs = selector.getNumArgs(),
348slotEnd = std::max(numArgs, 1U);
349slotIndex != slotEnd; ++slotIndex) {
350 if(
autoname = selector.getIdentifierInfoForSlot(slotIndex))
351OS << name->getName();
364 if(includePrefixByte) {
369OS << CID->getClassInterface()->getName();
370 if(includeCategoryNamespace) {
371OS <<
'('<< *CID <<
')';
373}
else if(
const auto*CD =
377llvm_unreachable(
"Unexpected ObjC method decl context");
387llvm::raw_svector_ostream OS(Name);
391Out << OS.str().size() << OS.str();
395std::unique_ptr<MangleContext> MC;
400: MC(Ctx.createMangleContext()),
401DL(Ctx.getTargetInfo().getDataLayoutString()) {}
406llvm::raw_svector_ostream FrontendBufOS(FrontendBuf);
407 if(
auto*FD = dyn_cast<FunctionDecl>(
D)) {
408 if(FD->isDependentContext())
410 if(writeFuncOrVarName(FD, FrontendBufOS))
412}
else if(
auto*VD = dyn_cast<VarDecl>(
D)) {
413 if(writeFuncOrVarName(VD, FrontendBufOS))
415}
else if(
auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
416MC->mangleObjCMethodName(MD, OS,
false,
419}
else if(
auto*ID = dyn_cast<ObjCInterfaceDecl>(
D)) {
420writeObjCClassName(ID, FrontendBufOS);
426llvm::Mangler::getNameWithPrefix(OS, FrontendBufOS.str(), DL);
433llvm::raw_string_ostream OS(Name);
447 returnKind ==
ObjCMetaclass?
"_OBJC_METACLASS_":
"_OBJC_CLASS_";
448 returnKind ==
ObjCMetaclass?
"OBJC_METACLASS_$_":
"OBJC_CLASS_$_";
453 if(
const auto*OID = dyn_cast<ObjCInterfaceDecl>(OCD))
454ClassName = OID->getObjCRuntimeNameAsString();
455 else if(
const auto*OID = dyn_cast<ObjCImplementationDecl>(OCD))
456ClassName = OID->getObjCRuntimeNameAsString();
458 if(ClassName.empty())
461 autoMangle = [&](
ObjCKindKind, StringRef ClassName) -> std::string {
464llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
465 returnstd::string(Mangled);
475 if(
const auto*OCD = dyn_cast<ObjCContainerDecl>(
D))
478 if(!(isa<CXXRecordDecl>(
D) || isa<CXXMethodDecl>(
D)))
486std::vector<std::string> Manglings;
489 autoDefaultCC =
C.getDefaultCallingConvention(
false,
492 returnCC == DefaultCC;
495 if(
const auto*CD = dyn_cast_or_null<CXXConstructorDecl>(ND)) {
496Manglings.emplace_back(getMangledStructor(CD,
Ctor_Base));
499 if(!CD->getParent()->isAbstract())
500Manglings.emplace_back(getMangledStructor(CD,
Ctor_Complete));
503 if(CD->hasAttr<DLLExportAttr>() && CD->isDefaultConstructor())
506}
else if(
const auto*DD = dyn_cast_or_null<CXXDestructorDecl>(ND)) {
507Manglings.emplace_back(getMangledStructor(DD,
Dtor_Base));
509Manglings.emplace_back(getMangledStructor(DD,
Dtor_Complete));
511Manglings.emplace_back(getMangledStructor(DD,
Dtor_Deleting));
513}
else if(
const auto*MD = dyn_cast_or_null<CXXMethodDecl>(ND)) {
514Manglings.emplace_back(
getName(ND));
515 if(MD->isVirtual()) {
517 for(
const auto&
T: *TIV) {
518std::string ThunkName;
519std::string ContextualizedName =
520getMangledThunk(MD,
T,
false);
522ThunkName = getMangledThunk(MD,
T,
true);
524ThunkName = ContextualizedName;
525Manglings.emplace_back(ThunkName);
535 boolwriteFuncOrVarName(
const NamedDecl*
D, raw_ostream &OS) {
536 if(MC->shouldMangleDeclName(
D)) {
538 if(
const auto*CtorD = dyn_cast<CXXConstructorDecl>(
D))
540 else if(
const auto*DtorD = dyn_cast<CXXDestructorDecl>(
D))
542 else if(
D->
hasAttr<CUDAGlobalAttr>())
546MC->mangleName(GD, OS);
559OS <<
D->getObjCRuntimeNameAsString();
562std::string getMangledStructor(
const NamedDecl*ND,
unsignedStructorType) {
563std::string FrontendBuf;
564llvm::raw_string_ostream FOS(FrontendBuf);
567 if(
const auto*CD = dyn_cast_or_null<CXXConstructorDecl>(ND))
569 else if(
const auto*DD = dyn_cast_or_null<CXXDestructorDecl>(ND))
571MC->mangleName(GD, FOS);
573std::string BackendBuf;
574llvm::raw_string_ostream BOS(BackendBuf);
576llvm::Mangler::getNameWithPrefix(BOS, FrontendBuf, DL);
582 boolElideOverrideInfo) {
583std::string FrontendBuf;
584llvm::raw_string_ostream FOS(FrontendBuf);
586MC->mangleThunk(MD,
T, ElideOverrideInfo, FOS);
588std::string BackendBuf;
589llvm::raw_string_ostream BOS(BackendBuf);
591llvm::Mangler::getNameWithPrefix(BOS, FrontendBuf, DL);
603 returnImpl->writeName(
D, OS);
607 returnImpl->getName(
D);
611 returnImpl->getAllManglings(
D);
Enums/classes describing ABI related information about constructors, destructors and thunks.
Defines the clang::ASTContext interface.
static bool hasDefaultCXXMethodCC(ASTContext &Context, const CXXMethodDecl *MD)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static void mangleFunctionBlock(MangleContext &Context, StringRef Outer, const BlockDecl *BD, raw_ostream &Out)
static bool isExternC(const NamedDecl *ND)
static CCMangling getCallingConvMangling(const ASTContext &Context, const NamedDecl *ND)
std::string getName(const Decl *D)
std::vector< std::string > getAllManglings(const Decl *D)
static StringRef getClassSymbolPrefix(ObjCKind Kind, const ASTContext &Context)
bool writeName(const Decl *D, raw_ostream &OS)
Implementation(ASTContext &Ctx)
std::vector< std::string > getAllManglings(const ObjCContainerDecl *OCD)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
const LangOptions & getLangOpts() const
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl, StringRef MangledName)
VTableContextBase * getVTableContext()
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
const TargetInfo & getTargetInfo() const
std::string getName(const Decl *D)
ASTNameGenerator(ASTContext &Ctx)
bool writeName(const Decl *D, raw_ostream &OS)
Writes name for D to OS.
std::vector< std::string > getAllManglings(const Decl *D)
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
DeclContext * getDeclContext()
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
Represents a function declaration or definition.
Represents a prototype with parameter type info, e.g.
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
GlobalDecl - represents a global declaration.
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
clang::ObjCRuntime ObjCRuntime
Parts getParts() const
Get the decomposed parts of this declaration.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
void mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out)
unsigned getBlockId(const BlockDecl *BD, bool Local)
void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT, const BlockDecl *BD, raw_ostream &Out)
ASTContext & getASTContext() const
void mangleGlobalBlock(const BlockDecl *BD, const NamedDecl *ID, raw_ostream &Out)
virtual bool isUniqueInternalLinkageDecl(const NamedDecl *ND)
bool shouldMangleDeclName(const NamedDecl *D)
void mangleName(GlobalDecl GD, raw_ostream &)
void mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD, raw_ostream &)
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &)=0
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &OS, bool includePrefixByte=true, bool includeCategoryNamespace=true)
void mangleDtorBlock(const CXXDestructorDecl *CD, CXXDtorType DT, const BlockDecl *BD, raw_ostream &Out)
virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &)
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
ObjCContainerDecl - Represents a container for method declarations.
Represents an ObjC class declaration.
ObjCMethodDecl - Represents an instance or class method declaration.
Selector getSelector() const
bool isInstanceMethod() const
ObjCCategoryDecl * getCategory()
If this method is declared or implemented in a category, return that category.
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
The basic abstraction for the target Objective-C runtime.
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
A (possibly-)qualified type.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const char * getUserLabelPrefix() const
Returns the default value of the USER_LABEL_PREFIX macro, which is the prefix given to user symbols b...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
const T * castAs() const
Member-template castAs<specific type>.
virtual const ThunkInfoVectorTy * getThunkInfo(GlobalDecl GD)
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_DefaultClosure
Default closure variant of a ctor.
@ Ctor_Complete
Complete object ctor.
CXXDtorType
C++ destructor types.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Parts of a decomposed MSGuidDecl.
The this pointer adjustment as well as an optional return adjustment for a thunk.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4