本文整理汇总了C++中Mangler::appendSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ Mangler::appendSymbol方法的具体用法?C++ Mangler::appendSymbol怎么用?C++ Mangler::appendSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mangler
的用法示例。
在下文中一共展示了Mangler::appendSymbol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mangle
//.........这里部分代码省略.........
// global ::= 'Wt' protocol-conformance identifier
case Kind::AssociatedTypeMetadataAccessFunction:
mangler.append("_TWt");
mangler.mangleProtocolConformance(getProtocolConformance());
mangler.mangleIdentifier(getAssociatedType()->getNameStr());
return mangler.finalize(buffer);
// global ::= 'WT' protocol-conformance identifier nominal-type
case Kind::AssociatedTypeWitnessTableAccessFunction:
mangler.append("_TWT");
mangler.mangleProtocolConformance(getProtocolConformance());
mangler.mangleIdentifier(getAssociatedType()->getNameStr());
mangler.mangleProtocolDecl(getAssociatedProtocol());
return mangler.finalize(buffer);
// For all the following, this rule was imposed above:
// global ::= local-marker? entity // some identifiable thing
// entity ::= declaration // other declaration
case Kind::Function:
// As a special case, functions can have manually mangled names.
if (auto AsmA = getDecl()->getAttrs().getAttribute<SILGenNameAttr>()) {
mangler.append(AsmA->Name);
return mangler.finalize(buffer);
}
// Otherwise, fall through into the 'other decl' case.
SWIFT_FALLTHROUGH;
case Kind::Other:
// As a special case, Clang functions and globals don't get mangled at all.
if (auto clangDecl = getDecl()->getClangDecl()) {
if (auto namedClangDecl = dyn_cast<clang::DeclaratorDecl>(clangDecl)) {
if (auto asmLabel = namedClangDecl->getAttr<clang::AsmLabelAttr>()) {
mangler.append('\01');
mangler.append(asmLabel->getLabel());
} else if (namedClangDecl->hasAttr<clang::OverloadableAttr>()) {
// FIXME: When we can import C++, use Clang's mangler all the time.
std::string storage;
llvm::raw_string_ostream SS(storage);
mangleClangDecl(SS, namedClangDecl, getDecl()->getASTContext());
mangler.append(SS.str());
} else {
mangler.append(namedClangDecl->getName());
}
return mangler.finalize(buffer);
}
}
mangler.append("_T");
if (auto type = dyn_cast<NominalTypeDecl>(getDecl())) {
mangler.mangleNominalType(type, Mangler::BindGenerics::None);
} else if (auto ctor = dyn_cast<ConstructorDecl>(getDecl())) {
// FIXME: Hack. LinkInfo should be able to refer to the allocating
// constructor rather than inferring it here.
mangler.mangleConstructorEntity(ctor, /*isAllocating=*/true,
getUncurryLevel());
} else {
mangler.mangleEntity(getDecl(), getUncurryLevel());
}
return mangler.finalize(buffer);
// An Objective-C class reference reference. The symbol is private, so
// the mangling is unimportant; it should just be readable in LLVM IR.
case Kind::ObjCClassRef: {
mangler.append("OBJC_CLASS_REF_$_");
llvm::SmallString<64> tempBuffer;
StringRef name = cast<ClassDecl>(getDecl())->getObjCRuntimeName(tempBuffer);
mangler.append(name);
return mangler.finalize(buffer);
}
// An Objective-C class reference; not a swift mangling.
case Kind::ObjCClass: {
llvm::SmallString<64> TempBuffer;
mangler.append("OBJC_CLASS_$_");
StringRef Name = cast<ClassDecl>(getDecl())->getObjCRuntimeName(TempBuffer);
mangler.append(Name);
return mangler.finalize(buffer);
}
// An Objective-C metaclass reference; not a swift mangling.
case Kind::ObjCMetaclass: {
llvm::SmallString<64> TempBuffer;
mangler.append("OBJC_METACLASS_$_");
StringRef Name = cast<ClassDecl>(getDecl())->getObjCRuntimeName(TempBuffer);
mangler.append(Name);
return mangler.finalize(buffer);
}
case Kind::SILFunction:
mangler.appendSymbol(getSILFunction()->getName());
return mangler.finalize(buffer);
case Kind::SILGlobalVariable:
mangler.appendSymbol(getSILGlobalVariable()->getName());
return mangler.finalize(buffer);
}
llvm_unreachable("bad entity kind!");
}