24 #include "llvm/ADT/StringExtras.h" 25 #include "llvm/Support/ErrorHandling.h" 26 #include "llvm/Support/raw_ostream.h" 28 using namespace clang;
37 unsigned discriminator = Context.
getBlockId(BD,
true);
38 if (discriminator == 0)
39 Out <<
"__" << Outer <<
"_block_invoke";
41 Out <<
"__" << Outer <<
"_block_invoke_" << discriminator+1;
44 void MangleContext::anchor() { }
56 return FD->isExternC();
63 const llvm::Triple &Triple = TI.
getTriple();
64 if (!Triple.isOSWindows() ||
65 !(Triple.getArch() == llvm::Triple::x86 ||
66 Triple.getArch() == llvm::Triple::x86_64))
111 if (D->
hasAttr<AsmLabelAttr>())
120 if (
const AsmLabelAttr *ALA = D->
getAttr<AsmLabelAttr>()) {
131 if (GlobalPrefix && !ALA->getLabel().startswith(
"llvm."))
134 Out << ALA->getLabel();
156 Out <<
"__regcall3__";
175 assert(!Proto->isVariadic());
176 unsigned ArgWords = 0;
180 for (
const auto &AT : Proto->param_types())
191 unsigned discriminator =
getBlockId(BD,
false);
199 if (discriminator == 0)
200 Out <<
"_block_invoke";
202 Out <<
"_block_invoke_" << discriminator+1;
207 raw_ostream &ResStream) {
209 llvm::raw_svector_ostream Out(Buffer);
216 raw_ostream &ResStream) {
218 llvm::raw_svector_ostream Out(Buffer);
225 assert(!isa<CXXConstructorDecl>(DC) && !isa<CXXDestructorDecl>(DC));
228 llvm::raw_svector_ostream Stream(Buffer);
229 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
232 assert((isa<NamedDecl>(DC) || isa<BlockDecl>(DC)) &&
233 "expected a NamedDecl or BlockDecl");
234 if (isa<BlockDecl>(DC))
235 for (; DC && isa<BlockDecl>(DC); DC = DC->
getParent())
237 assert((isa<TranslationUnitDecl>(DC) || isa<NamedDecl>(DC)) &&
238 "expected a TranslationUnitDecl or a NamedDecl");
239 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
241 else if (
const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
243 else if (
auto ND = dyn_cast<NamedDecl>(DC)) {
245 Stream << ND->getIdentifier()->getName();
263 assert (CD &&
"Missing container decl in GetNameForMethod");
266 OS << CID->getClassInterface()->getName();
267 OS <<
'(' << *CID <<
')';
279 llvm::raw_svector_ostream OS(Name);
282 Out << OS.str().size() << OS.str();
Defines the clang::ASTContext interface.
Represents a function declaration or definition.
A (possibly-)qualified type.
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
FunctionType - C99 6.7.5.3 - Function Declarators.
virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, raw_ostream &)=0
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Defines the SourceManager interface.
virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type, raw_ostream &)=0
Defines the C++ template declaration subclasses.
const TargetInfo & getTargetInfo() const
Represents a C++ constructor within a class.
ObjCMethodDecl - Represents an instance or class method declaration.
Defines the clang::Expr interface and subclasses for C++ expressions.
void mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD, raw_ostream &)
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
static CCMangling getCallingConvMangling(const ASTContext &Context, const NamedDecl *ND)
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool shouldMangleDeclName(const NamedDecl *D)
ObjCContainerDecl - Represents a container for method declarations.
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
Enums/classes describing ABI related information about constructors, destructors and thunks...
void mangleName(const NamedDecl *D, raw_ostream &)
Represents a prototype with parameter type info, e.g.
Exposes information about the current target.
CXXDtorType
C++ destructor types.
ASTContext & getASTContext() const
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ destructor within a class.
DeclContext * getDeclContext()
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isInstanceMethod() const
Selector getSelector() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
unsigned getBlockId(const BlockDecl *BD, bool Local)
void mangleDtorBlock(const CXXDestructorDecl *CD, CXXDtorType DT, const BlockDecl *BD, raw_ostream &Out)
virtual bool shouldMangleCXXName(const NamedDecl *D)=0
Represents a static or instance method of a struct/union/class.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
virtual void mangleCXXName(const NamedDecl *D, raw_ostream &)=0
const llvm::DataLayout & getDataLayout() const
CXXCtorType
C++ constructor types.
StringRef getName() const
Return the actual identifier string.
void mangleGlobalBlock(const BlockDecl *BD, const NamedDecl *ID, raw_ostream &Out)
void mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out)
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &)
static void mangleFunctionBlock(MangleContext &Context, StringRef Outer, const BlockDecl *BD, raw_ostream &Out)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
CallingConv getCallConv() const
Defines the clang::TargetInfo interface.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
This represents a decl that may have a name.
void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT, const BlockDecl *BD, raw_ostream &Out)
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
static bool isExternC(const NamedDecl *ND)