summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ItaniumMangle.cpp')
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 3b99a3d9afd..2dc04f2f3d8 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -46,10 +46,10 @@ namespace {
/// Retrieve the declaration context that should be used when mangling the given
/// declaration.
static const DeclContext *getEffectiveDeclContext(const Decl *D) {
- // The ABI assumes that lambda closure types that occur within
+ // The ABI assumes that lambda closure types that occur within
// default arguments live in the context of the function. However, due to
// the way in which Clang parses and creates function declarations, this is
- // not the case: the lambda closure type ends up living in the context
+ // not the case: the lambda closure type ends up living in the context
// where the function itself resides, because the function declaration itself
// had not yet been created. Fix the context here.
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -65,7 +65,7 @@ static const DeclContext *getEffectiveDeclContext(const Decl *D) {
= dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
return ContextParam->getDeclContext();
}
-
+
const DeclContext *DC = D->getDeclContext();
if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC)) {
return getEffectiveDeclContext(cast<Decl>(DC));
@@ -441,7 +441,7 @@ public:
void mangleName(const NamedDecl *ND);
void mangleType(QualType T);
void mangleNameOrStandardSubstitution(const NamedDecl *ND);
-
+
private:
bool mangleSubstitution(const NamedDecl *ND);
@@ -786,7 +786,7 @@ static bool isStd(const NamespaceDecl *NS) {
if (!IgnoreLinkageSpecDecls(getEffectiveParentContext(NS))
->isTranslationUnit())
return false;
-
+
const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
return II && II->isStr("std");
}
@@ -998,7 +998,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(
// ::= <substitution>
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
-
+
if (mangleSubstitution(Template))
return;
@@ -1100,7 +1100,7 @@ void CXXNameMangler::manglePrefix(QualType type) {
if (const auto *TST = type->getAs<TemplateSpecializationType>()) {
if (!mangleSubstitution(QualType(TST, 0))) {
mangleTemplatePrefix(TST->getTemplateName());
-
+
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
@@ -1372,7 +1372,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
// safety, just handle all ObjC containers here.
if (isa<ObjCContainerDecl>(ND))
break;
-
+
// We must have an anonymous struct.
const TagDecl *TD = cast<TagDecl>(ND);
if (const TypedefNameDecl *D = TD->getTypedefNameForAnonDecl()) {
@@ -1389,7 +1389,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
}
// <unnamed-type-name> ::= <closure-type-name>
- //
+ //
// <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _
// <lambda-sig> ::= <parameter-type>+ # Parameter types or 'v' for 'void'.
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
@@ -1515,9 +1515,9 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
const DeclContext *DC,
const AbiTagList *AdditionalAbiTags,
bool NoFunction) {
- // <nested-name>
+ // <nested-name>
// ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E
- // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix>
+ // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix>
// <template-args> E
Out << 'N';
@@ -1530,7 +1530,7 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
mangleQualifiers(MethodQuals);
mangleRefQualifier(Method->getRefQualifier());
}
-
+
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
@@ -1561,7 +1561,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
const AbiTagList *AdditionalAbiTags) {
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
// := Z <function encoding> E s [<discriminator>]
- // <local-name> := Z <function encoding> E d [ <parameter number> ]
+ // <local-name> := Z <function encoding> E d [ <parameter number> ]
// _ <entity name>
// <discriminator> := _ <non-negative number>
assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
@@ -1591,9 +1591,9 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
// be a bug that is fixed in trunk.
if (RD) {
- // The parameter number is omitted for the last parameter, 0 for the
- // second-to-last parameter, 1 for the third-to-last parameter, etc. The
- // <entity name> will of course contain a <closure-type-name>: Its
+ // The parameter number is omitted for the last parameter, 0 for the
+ // second-to-last parameter, 1 for the third-to-last parameter, etc. The
+ // <entity name> will of course contain a <closure-type-name>: Its
// numbering will be local to the particular argument in which it appears
// -- other default arguments do not affect its encoding.
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD);
@@ -1610,7 +1610,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
}
}
}
-
+
// Mangle the name relative to the closest enclosing function.
// equality ok because RD derived from ND above
if (D == RD) {
@@ -1699,8 +1699,8 @@ void CXXNameMangler::mangleUnqualifiedBlock(const BlockDecl *Block) {
}
void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
- // If the context of a closure type is an initializer for a class member
- // (static or nonstatic), it is encoded in a qualified name with a final
+ // If the context of a closure type is an initializer for a class member
+ // (static or nonstatic), it is encoded in a qualified name with a final
// <prefix> of the form:
//
// <data-member-prefix> := <member source-name> M
@@ -1730,9 +1730,9 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
mangleBareFunctionType(Proto, /*MangleReturnType=*/false,
Lambda->getLambdaStaticInvoker());
Out << "E";
-
- // The number is omitted for the first closure type with a given
- // <lambda-sig> in a given context; it is n-2 for the nth closure type
+
+ // The number is omitted for the first closure type with a given
+ // <lambda-sig> in a given context; it is n-2 for the nth closure type
// (in lexical order) with that same <lambda-sig> and context.
//
// The AST keeps track of the number for us.
@@ -1740,7 +1740,7 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
assert(Number > 0 && "Lambda should be mangled as an unnamed class");
if (Number > 1)
mangleNumber(Number - 2);
- Out << '_';
+ Out << '_';
}
void CXXNameMangler::manglePrefix(NestedNameSpecifier *qualifier) {
@@ -1795,10 +1795,10 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
assert(!isLocalContainerContext(DC));
- const NamedDecl *ND = cast<NamedDecl>(DC);
+ const NamedDecl *ND = cast<NamedDecl>(DC);
if (mangleSubstitution(ND))
return;
-
+
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
@@ -2286,19 +2286,19 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp
switch (Quals.getObjCLifetime()) {
case Qualifiers::OCL_None:
break;
-
+
case Qualifiers::OCL_Weak:
// Do nothing as we already handled this case above.
break;
-
+
case Qualifiers::OCL_Strong:
mangleVendorQualifier("__strong");
break;
-
+
case Qualifiers::OCL_Autoreleasing:
mangleVendorQualifier("__autoreleasing");
break;
-
+
case Qualifiers::OCL_ExplicitNone:
// The __unsafe_unretained qualifier is *not* mangled, so that
// __unsafe_unretained types in ARC produce the same manglings as the
@@ -2329,11 +2329,11 @@ void CXXNameMangler::mangleRefQualifier(RefQualifierKind RefQualifier) {
switch (RefQualifier) {
case RQ_None:
break;
-
+
case RQ_LValue:
Out << 'R';
break;
-
+
case RQ_RValue:
Out << 'O';
break;
@@ -2364,15 +2364,15 @@ static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty,
void CXXNameMangler::mangleType(QualType T) {
// If our type is instantiation-dependent but not dependent, we mangle
- // it as it was written in the source, removing any top-level sugar.
+ // it as it was written in the source, removing any top-level sugar.
// Otherwise, use the canonical type.
//
- // FIXME: This is an approximation of the instantiation-dependent name
+ // FIXME: This is an approximation of the instantiation-dependent name
// mangling rules, since we should really be using the type as written and
// augmented via semantic analysis (i.e., with implicit conversions and
- // default template arguments) for any instantiation-dependent type.
+ // default template arguments) for any instantiation-dependent type.
// Unfortunately, that requires several changes to our AST:
- // - Instantiation-dependent TemplateSpecializationTypes will need to be
+ // - Instantiation-dependent TemplateSpecializationTypes will need to be
// uniqued, so that we can handle substitutions properly
// - Default template arguments will need to be represented in the
// TemplateSpecializationType, since they need to be mangled even though
@@ -2402,16 +2402,16 @@ void CXXNameMangler::mangleType(QualType T) {
do {
// Don't desugar through template specialization types that aren't
// type aliases. We need to mangle the template arguments as written.
- if (const TemplateSpecializationType *TST
+ if (const TemplateSpecializationType *TST
= dyn_cast<TemplateSpecializationType>(T))
if (!TST->isTypeAlias())
break;
- QualType Desugared
+ QualType Desugared
= T.getSingleStepDesugaredType(Context.getASTContext());
if (Desugared == T)
break;
-
+
T = Desugared;
} while (true);
}
@@ -2435,7 +2435,7 @@ void CXXNameMangler::mangleType(QualType T) {
}
if (quals || ty->isDependentAddressSpaceType()) {
- if (const DependentAddressSpaceType *DAST =
+ if (const DependentAddressSpaceType *DAST =
dyn_cast<DependentAddressSpaceType>(ty)) {
SplitQualType splitDAST = DAST->getPointeeType().split();
mangleQualifiers(splitDAST.Quals, DAST);
@@ -2899,7 +2899,7 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {
QualType PointeeType = T->getPointeeType();
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
mangleType(FPT);
-
+
// Itanium C++ ABI 5.1.8:
//
// The type of a non-static member function is considered to be different,
@@ -2907,8 +2907,8 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {
// static member function whose type appears similar. The types of two
// non-static member functions are considered to be different, for the
// purposes of substitution, if the functions are members of different
- // classes. In other words, for the purposes of substitution, the class of
- // which the function is a member is considered part of the type of
+ // classes. In other words, for the purposes of substitution, the class of
+ // which the function is a member is considered part of the type of
// function.
// Given that we already substitute member function pointers as a
@@ -3225,9 +3225,9 @@ void CXXNameMangler::mangleType(const TemplateSpecializationType *T) {
} else {
if (mangleSubstitution(QualType(T, 0)))
return;
-
+
mangleTemplatePrefix(T->getTemplateName());
-
+
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
@@ -3283,7 +3283,7 @@ void CXXNameMangler::mangleType(const DependentTemplateSpecializationType *T) {
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
- mangleTemplateArgs(T->getArgs(), T->getNumArgs());
+ mangleTemplateArgs(T->getArgs(), T->getNumArgs());
Out << 'E';
}
@@ -3328,7 +3328,7 @@ void CXXNameMangler::mangleType(const UnaryTransformType *T) {
// mangle it as the underlying type since they are equivalent.
if (T->isDependentType()) {
Out << 'U';
-
+
switch (T->getUTTKind()) {
case UnaryTransformType::EnumUnderlyingType:
Out << "3eut";
@@ -3498,7 +3498,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
// ::= L <mangled-name> E # external name
// ::= fpT # 'this' expression
QualType ImplicitlyConvertedToType;
-
+
recurse:
switch (E->getStmtClass()) {
case Expr::NoStmtClass:
@@ -3861,24 +3861,24 @@ recurse:
case Expr::UnaryExprOrTypeTraitExprClass: {
const UnaryExprOrTypeTraitExpr *SAE = cast<UnaryExprOrTypeTraitExpr>(E);
-
+
if (!SAE->isInstantiationDependent()) {
// Itanium C++ ABI:
- // If the operand of a sizeof or alignof operator is not
- // instantiation-dependent it is encoded as an integer literal
+ // If the operand of a sizeof or alignof operator is not
+ // instantiation-dependent it is encoded as an integer literal
// reflecting the result of the operator.
//
- // If the result of the operator is implicitly converted to a known
- // integer type, that type is used for the literal; otherwise, the type
+ // If the result of the operator is implicitly converted to a known
+ // integer type, that type is used for the literal; otherwise, the type
// of std::size_t or std::ptrdiff_t is used.
- QualType T = (ImplicitlyConvertedToType.isNull() ||
+ QualType T = (ImplicitlyConvertedToType.isNull() ||
!ImplicitlyConvertedToType->isIntegerType())? SAE->getType()
: ImplicitlyConvertedToType;
llvm::APSInt V = SAE->EvaluateKnownConstInt(Context.getASTContext());
mangleIntegerLiteral(T, V);
break;
}
-
+
switch(SAE->getKind()) {
case UETT_SizeOf:
Out << 's';
@@ -3994,16 +3994,16 @@ recurse:
E = cast<ImplicitCastExpr>(E)->getSubExpr();
goto recurse;
}
-
+
case Expr::ObjCBridgedCastExprClass: {
- // Mangle ownership casts as a vendor extended operator __bridge,
+ // Mangle ownership casts as a vendor extended operator __bridge,
// __bridge_transfer, or __bridge_retain.
StringRef Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
Out << "v1U" << Kind.size() << Kind;
}
// Fall through to mangle the cast itself.
LLVM_FALLTHROUGH;
-
+
case Expr::CStyleCastExprClass:
mangleCastExpression(E, "cv");
break;
@@ -4143,7 +4143,7 @@ recurse:
Out << (cast<ObjCBoolLiteralExpr>(E)->getValue() ? '1' : '0');
Out << 'E';
break;
-
+
case Expr::CXXBoolLiteralExprClass:
Out << "Lb";
Out << (cast<CXXBoolLiteralExpr>(E)->getValue() ? '1' : '0');
@@ -4198,12 +4198,12 @@ recurse:
Out << "LDnE";
break;
}
-
+
case Expr::PackExpansionExprClass:
Out << "sp";
mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
break;
-
+
case Expr::SizeOfPackExprClass: {
auto *SPE = cast<SizeOfPackExpr>(E);
if (SPE->isPartiallySubstituted()) {
@@ -4430,11 +4430,11 @@ void CXXNameMangler::mangleTemplateArg(TemplateArgument A) {
// ::= J <template-arg>* E # argument pack
if (!A.isInstantiationDependent() || A.isDependent())
A = Context.getASTContext().getCanonicalTemplateArgument(A);
-
+
switch (A.getKind()) {
case TemplateArgument::Null:
llvm_unreachable("Cannot mangle NULL template argument");
-
+
case TemplateArgument::Type:
mangleType(A.getAsType());
break;
@@ -4461,7 +4461,7 @@ void CXXNameMangler::mangleTemplateArg(TemplateArgument A) {
break;
}
}
-
+
Out << 'X';
mangleExpression(E);
Out << 'E';
@@ -4578,7 +4578,7 @@ bool CXXNameMangler::mangleSubstitution(QualType T) {
bool CXXNameMangler::mangleSubstitution(TemplateName Template) {
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return mangleSubstitution(TD);
-
+
Template = Context.getASTContext().getCanonicalTemplateName(Template);
return mangleSubstitution(
reinterpret_cast<uintptr_t>(Template.getAsVoidPointer()));
@@ -4743,7 +4743,7 @@ void CXXNameMangler::addSubstitution(QualType T) {
void CXXNameMangler::addSubstitution(TemplateName Template) {
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return addSubstitution(TD);
-
+
Template = Context.getASTContext().getCanonicalTemplateName(Template);
addSubstitution(reinterpret_cast<uintptr_t>(Template.getAsVoidPointer()));
}
@@ -4865,14 +4865,14 @@ void ItaniumMangleContextImpl::mangleThunk(const CXXMethodDecl *MD,
// # base is the nominal target function of thunk
// # first call-offset is 'this' adjustment
// # second call-offset is result adjustment
-
+
assert(!isa<CXXDestructorDecl>(MD) &&
"Use mangleCXXDtor for destructor decls!");
CXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "_ZT";
if (!Thunk.Return.isEmpty())
Mangler.getStream() << 'c';
-
+
// Mangle the 'this' pointer adjustment.
Mangler.mangleCallOffset(Thunk.This.NonVirtual,
Thunk.This.Virtual.Itanium.VCallOffsetOffset);
@@ -4894,7 +4894,7 @@ void ItaniumMangleContextImpl::mangleCXXDtorThunk(
Mangler.getStream() << "_ZT";
// Mangle the 'this' pointer adjustment.
- Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
+ Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
ThisAdjustment.Virtual.Itanium.VCallOffsetOffset);
Mangler.mangleFunctionEncoding(DD);
OpenPOWER on IntegriCloud