diff options
author | Luchesar V. ILIEV | 2016-05-09 21:02:20 +0300 |
---|---|---|
committer | Luchesar V. ILIEV | 2016-05-09 23:06:57 +0300 |
commit | b85cf6b100ec9ab4afd32188829a857f223ea160 (patch) | |
tree | e4cacd8763417c71bf971c5218a550f0cebb1532 /D18035-add-gcc-abi_tag-support-mangler-part.patch | |
parent | 20b808d4a1d1e59f6cbd16d5fe26bdb600efbcb6 (diff) | |
download | aur-b85cf6b100ec9ab4afd32188829a857f223ea160.tar.gz |
Update D18035
Diffstat (limited to 'D18035-add-gcc-abi_tag-support-mangler-part.patch')
-rw-r--r-- | D18035-add-gcc-abi_tag-support-mangler-part.patch | 187 |
1 files changed, 76 insertions, 111 deletions
diff --git a/D18035-add-gcc-abi_tag-support-mangler-part.patch b/D18035-add-gcc-abi_tag-support-mangler-part.patch index 8bc9db4f013b..b935a10fdeb5 100644 --- a/D18035-add-gcc-abi_tag-support-mangler-part.patch +++ b/D18035-add-gcc-abi_tag-support-mangler-part.patch @@ -15,67 +15,25 @@ Index: lib/AST/ItaniumMangle.cpp /// The "structor" is the top-level declaration being mangled, if /// that's not a template specialization; otherwise it's the pattern -@@ -263,27 +269,190 @@ +@@ -263,27 +269,148 @@ } FunctionTypeDepth; + // abi_tag is a gcc attribute, taking one or more strings called "tags". -+ // + // The goal is to annotate against which version of a library an object was -+ // build and to be able to provide backwards compatibility ("dual abi"). -+ // -+ // For this the emitted mangled names have to be different, while you don't -+ // want the user to have to use different names in the source. -+ // -+ // The abi_tag can be present on Struct, Var and Function declarations as -+ // "explicit" tag, and on inline Namespace as "implicit" tag. Explicit tags -+ // are always emitted after the unqualified name, and (implicit) tags on -+ // namespace are not. -+ // -+ // For functions and variables there is a set of "implicitly available" -+ // tags. These tags are: all tags from the namespace/structs the name is -+ // embedded in, all tags from any template arguments of the name, and, for -+ // functions, alls tags used anywhere in the <bare-function-type> (i.e. -+ // parameters and sometimes the return type). -+ // -+ // For functions this is basically the list of all tags from the signature -+ // without the unqualified name and usually without the return type of the -+ // function. In `operator Type()` Type is NOT part of that list, as it is -+ // part of the unqualified name! -+ // -+ // Now all tags from the function return type/variable type which are not -+ // "implicitly available" must be added to the explicit list of tags, and -+ // are emitted after the unqualified name. -+ // -+ // Example: -+ // namespace std { -+ // inline namespace __cxx11 __attribute__((__abi_tag__("cxx11"))) { } -+ // inline namespace __cxx11 { -+ // struct string { }; -+ // } -+ // } -+ // -+ // std::string foo(); // needs abi tag "cxx11" on foo -+ // std::string foo(std::string); // does NOT need abi tag "cxx11" on foo -+ // __attribute__((__abi_tag__("cxx11"))) -+ // std::string foo2(std::string); // emit abi tag "cxx11" on foo anyway -+ // -+ // The tags are sorted by name before emitting, and are serialized as -+ // <abitag> ::= B <"tag" source-name> -+ ++ // built and to be able to provide backwards compatibility ("dual abi"). ++ // For more information see docs/ItaniumMangleAbiTags.rst. + typedef SmallVector<StringRef, 4> AbiTagList; ++ typedef llvm::SmallSetVector<StringRef, 4> AbiTagSet; + + // State to gather all implicit and explicit tags used in a mangled name. + // Must always have an instance of this while emitting any name to keep + // track. -+ // -+ // FIXME: how to handle substituted names? They should add the tags used in -+ // the substitution to the list of available tags. + class AbiTagState final { + //! All abi tags used implicitly or explicitly -+ std::set<StringRef> UsedAbiTags; ++ AbiTagSet UsedAbiTags; + //! All explicit abi tags (i.e. not from namespace) -+ std::set<StringRef> EmittedAbiTags; ++ AbiTagSet EmittedAbiTags; + + AbiTagState *&LinkHead; + AbiTagState *Parent = nullptr; @@ -153,12 +111,12 @@ Index: lib/AST/ItaniumMangle.cpp + writeSortedUniqueAbiTags(Out, TagList); + } + -+ const std::set<StringRef> &getUsedAbiTags() const { return UsedAbiTags; } -+ void setUsedAbiTags(const std::set<StringRef> &AbiTags) { ++ const AbiTagSet &getUsedAbiTags() const { return UsedAbiTags; } ++ void setUsedAbiTags(const AbiTagSet &AbiTags) { + UsedAbiTags = AbiTags; + } + -+ const std::set<StringRef> &getEmittedAbiTags() const { ++ const AbiTagSet &getEmittedAbiTags() const { + return EmittedAbiTags; + } + @@ -211,7 +169,7 @@ Index: lib/AST/ItaniumMangle.cpp #if MANGLE_CHECKER ~CXXNameMangler() { -@@ -298,14 +467,18 @@ +@@ -298,14 +425,18 @@ #endif raw_ostream &getStream() { return Out; } @@ -232,7 +190,7 @@ Index: lib/AST/ItaniumMangle.cpp void mangleType(QualType T); void mangleNameOrStandardSubstitution(const NamedDecl *ND); -@@ -336,31 +509,53 @@ +@@ -336,31 +467,53 @@ DeclarationName name, unsigned KnownArity = UnknownArity); @@ -298,7 +256,7 @@ Index: lib/AST/ItaniumMangle.cpp void mangleTemplatePrefix(TemplateName Template); bool mangleUnresolvedTypeOrSimpleId(QualType DestroyedType, StringRef Prefix = ""); -@@ -411,6 +606,15 @@ +@@ -411,6 +564,13 @@ void mangleTemplateParameter(unsigned Index); void mangleFunctionParam(const ParmVarDecl *parm); @@ -306,15 +264,13 @@ Index: lib/AST/ItaniumMangle.cpp + void writeAbiTags(const NamedDecl *ND, + const AbiTagList *AdditionalAbiTags = nullptr); + -+ std::set<StringRef> -+ getTagsFromPrefixAndTemplateArguments(const NamedDecl *ND); -+ ++ AbiTagSet getTagsFromPrefixAndTemplateArguments(const NamedDecl *ND); + AbiTagList makeAdditionalTagsForFunction(const FunctionDecl *FD); + AbiTagList makeAdditionalTagsForVariable(const VarDecl *VD); }; } -@@ -454,13 +658,20 @@ +@@ -454,13 +614,20 @@ while (!DC->isNamespace() && !DC->isTranslationUnit()) DC = getEffectiveParentContext(DC); if (DC->isTranslationUnit() && D->getFormalLinkage() != InternalLinkage && @@ -335,7 +291,7 @@ Index: lib/AST/ItaniumMangle.cpp void CXXNameMangler::mangle(const NamedDecl *D) { // <mangled-name> ::= _Z <encoding> // ::= <data name> -@@ -476,14 +687,31 @@ +@@ -476,14 +643,31 @@ mangleName(cast<FieldDecl>(D)); } @@ -372,7 +328,7 @@ Index: lib/AST/ItaniumMangle.cpp if (FD->hasAttr<EnableIfAttr>()) { FunctionTypeDepthState Saved = FunctionTypeDepth.push(); Out << "Ua9enable_ifI"; -@@ -587,7 +815,24 @@ +@@ -587,7 +771,24 @@ return nullptr; } @@ -398,7 +354,7 @@ Index: lib/AST/ItaniumMangle.cpp // <name> ::= <nested-name> // ::= <unscoped-name> // ::= <unscoped-template-name> <template-args> -@@ -603,7 +848,7 @@ +@@ -603,7 +804,7 @@ while (!DC->isNamespace() && !DC->isTranslationUnit()) DC = getEffectiveParentContext(DC); else if (GetLocalClassDecl(ND)) { @@ -407,7 +363,7 @@ Index: lib/AST/ItaniumMangle.cpp return; } -@@ -613,76 +858,93 @@ +@@ -613,76 +814,93 @@ // Check if we have a template. const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { @@ -519,7 +475,7 @@ Index: lib/AST/ItaniumMangle.cpp addSubstitution(Template); } -@@ -841,14 +1103,16 @@ +@@ -841,14 +1059,16 @@ else Out << "sr"; mangleSourceName(qualifier->getAsNamespace()->getIdentifier()); @@ -536,7 +492,7 @@ Index: lib/AST/ItaniumMangle.cpp break; case NestedNameSpecifier::TypeSpec: -@@ -883,6 +1147,7 @@ +@@ -883,6 +1103,7 @@ Out << "sr"; mangleSourceName(qualifier->getAsIdentifier()); @@ -544,7 +500,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -928,7 +1193,8 @@ +@@ -928,7 +1149,8 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name, @@ -554,7 +510,7 @@ Index: lib/AST/ItaniumMangle.cpp unsigned Arity = KnownArity; // <unqualified-name> ::= <operator-name> // ::= <ctor-dtor-name> -@@ -947,6 +1213,7 @@ +@@ -947,6 +1169,7 @@ Out << 'L'; mangleSourceName(II); @@ -562,7 +518,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -986,6 +1253,7 @@ +@@ -986,6 +1209,7 @@ assert(FD->getIdentifier() && "Data member name isn't an identifier!"); mangleSourceName(FD->getIdentifier()); @@ -570,7 +526,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -1006,6 +1274,10 @@ +@@ -1006,6 +1230,10 @@ assert(D->getDeclName().getAsIdentifierInfo() && "Typedef was not named!"); mangleSourceName(D->getDeclName().getAsIdentifierInfo()); @@ -581,7 +537,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -1015,6 +1287,8 @@ +@@ -1015,6 +1243,8 @@ // <lambda-sig> ::= <parameter-type>+ # Parameter types or 'v' for 'void'. if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) { if (Record->isLambda() && Record->getLambdaManglingNumber()) { @@ -590,7 +546,7 @@ Index: lib/AST/ItaniumMangle.cpp mangleLambda(Record); break; } -@@ -1026,11 +1300,13 @@ +@@ -1026,11 +1256,13 @@ if (UnnamedMangle > 1) Out << UnnamedMangle - 2; Out << '_'; @@ -606,7 +562,7 @@ Index: lib/AST/ItaniumMangle.cpp // Mangle it as a source name in the form // [n] $_<id> -@@ -1058,6 +1334,7 @@ +@@ -1058,6 +1290,7 @@ // Otherwise, use the complete constructor name. This is relevant if a // class with a constructor is declared within a constructor. mangleCXXCtorType(Ctor_Complete); @@ -614,7 +570,7 @@ Index: lib/AST/ItaniumMangle.cpp break; case DeclarationName::CXXDestructorName: -@@ -1069,6 +1346,7 @@ +@@ -1069,6 +1302,7 @@ // Otherwise, use the complete destructor name. This is relevant if a // class with a destructor is declared within a destructor. mangleCXXDtorType(Dtor_Complete); @@ -622,7 +578,7 @@ Index: lib/AST/ItaniumMangle.cpp break; case DeclarationName::CXXOperatorName: -@@ -1084,6 +1362,7 @@ +@@ -1084,6 +1318,7 @@ case DeclarationName::CXXConversionFunctionName: case DeclarationName::CXXLiteralOperatorName: mangleOperatorName(Name, Arity); @@ -630,7 +586,7 @@ Index: lib/AST/ItaniumMangle.cpp break; case DeclarationName::CXXUsingDirective: -@@ -1100,7 +1379,9 @@ +@@ -1100,7 +1335,9 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND, const DeclContext *DC, @@ -641,7 +597,7 @@ Index: lib/AST/ItaniumMangle.cpp // <nested-name> // ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix> -@@ -1120,30 +1401,36 @@ +@@ -1120,30 +1357,36 @@ // Check if we have a template. const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { @@ -682,7 +638,7 @@ Index: lib/AST/ItaniumMangle.cpp // <local-name> := Z <function encoding> E <entity name> [<discriminator>] // := Z <function encoding> E s [<discriminator>] // <local-name> := Z <function encoding> E d [ <parameter number> ] -@@ -1155,15 +1442,26 @@ +@@ -1155,15 +1398,26 @@ Out << 'Z'; @@ -715,7 +671,7 @@ Index: lib/AST/ItaniumMangle.cpp 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 -@@ -1188,13 +1486,17 @@ +@@ -1188,13 +1442,17 @@ // Mangle the name relative to the closest enclosing function. // equality ok because RD derived from ND above if (D == RD) { @@ -736,7 +692,7 @@ Index: lib/AST/ItaniumMangle.cpp } } else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) { // Mangle a block in a default parameter; see above explanation for -@@ -1211,30 +1513,37 @@ +@@ -1211,30 +1469,37 @@ } } @@ -787,7 +743,7 @@ Index: lib/AST/ItaniumMangle.cpp return; } manglePrefix(getEffectiveDeclContext(Block)); -@@ -1245,10 +1554,11 @@ +@@ -1245,10 +1510,11 @@ if (Decl *Context = Block->getBlockManglingContextDecl()) { if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) && Context->getDeclContext()->isRecord()) { @@ -802,7 +758,7 @@ Index: lib/AST/ItaniumMangle.cpp } } } -@@ -1281,7 +1591,7 @@ +@@ -1281,7 +1547,7 @@ if (const IdentifierInfo *Name = cast<NamedDecl>(Context)->getIdentifier()) { mangleSourceName(Name); @@ -811,7 +767,7 @@ Index: lib/AST/ItaniumMangle.cpp } } } -@@ -1364,11 +1674,11 @@ +@@ -1364,11 +1630,11 @@ // Check if we have a template. const TemplateArgumentList *TemplateArgs = nullptr; if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) { @@ -825,7 +781,7 @@ Index: lib/AST/ItaniumMangle.cpp } addSubstitution(ND); -@@ -1379,27 +1689,30 @@ +@@ -1379,27 +1645,30 @@ // ::= <template-param> // ::= <substitution> if (TemplateDecl *TD = Template.getAsTemplateDecl()) @@ -862,7 +818,7 @@ Index: lib/AST/ItaniumMangle.cpp // <template-prefix> ::= <prefix> <template unqualified-name> // ::= <template-param> // ::= <substitution> -@@ -1414,7 +1727,8 @@ +@@ -1414,7 +1683,8 @@ mangleTemplateParameter(TTP->getIndex()); } else { manglePrefix(getEffectiveDeclContext(ND), NoFunction); @@ -872,7 +828,7 @@ Index: lib/AST/ItaniumMangle.cpp } addSubstitution(ND); -@@ -1458,6 +1772,7 @@ +@@ -1458,6 +1728,7 @@ // <name> ::= <nested-name> mangleUnresolvedPrefix(Dependent->getQualifier()); mangleSourceName(Dependent->getIdentifier()); @@ -880,7 +836,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -1550,16 +1865,19 @@ +@@ -1550,16 +1821,19 @@ case Type::Typedef: mangleSourceName(cast<TypedefType>(Ty)->getDecl()->getIdentifier()); @@ -900,7 +856,7 @@ Index: lib/AST/ItaniumMangle.cpp break; case Type::TemplateSpecialization: { -@@ -1578,6 +1896,7 @@ +@@ -1578,6 +1852,7 @@ goto unresolvedType; mangleSourceName(TD->getIdentifier()); @@ -908,7 +864,7 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -1609,16 +1928,19 @@ +@@ -1609,16 +1884,19 @@ case Type::InjectedClassName: mangleSourceName( cast<InjectedClassNameType>(Ty)->getDecl()->getIdentifier()); @@ -928,7 +884,7 @@ Index: lib/AST/ItaniumMangle.cpp mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs()); break; } -@@ -2081,7 +2403,9 @@ +@@ -2088,7 +2366,9 @@ case BuiltinType::Id: #include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: @@ -939,7 +895,7 @@ Index: lib/AST/ItaniumMangle.cpp case BuiltinType::ObjCId: Out << "11objc_object"; break; -@@ -2641,7 +2965,11 @@ +@@ -2620,7 +2900,11 @@ void CXXNameMangler::mangleType(const TemplateSpecializationType *T) { if (TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl()) { @@ -952,7 +908,7 @@ Index: lib/AST/ItaniumMangle.cpp } else { if (mangleSubstitution(QualType(T, 0))) return; -@@ -2967,12 +3295,14 @@ +@@ -2946,12 +3230,14 @@ case Expr::PseudoObjectExprClass: case Expr::AtomicExprClass: { @@ -973,11 +929,11 @@ Index: lib/AST/ItaniumMangle.cpp break; } -@@ -4115,6 +4445,97 @@ +@@ -4094,6 +4380,97 @@ Substitutions[Ptr] = SeqID++; } -+std::set<StringRef> ++CXXNameMangler::AbiTagSet +CXXNameMangler::getTagsFromPrefixAndTemplateArguments(const NamedDecl *ND) { + llvm::raw_null_ostream NullOutStream; + CXXNameMangler TrackPrefixAndTemplateArguments(*this, NullOutStream); @@ -1000,9 +956,9 @@ Index: lib/AST/ItaniumMangle.cpp + if (DisableDerivedAbiTags) + return AbiTagList(); + -+ std::set<StringRef> ImplicitlyAvailableTags = ++ AbiTagSet ImplicitlyAvailableTags = + getTagsFromPrefixAndTemplateArguments(FD); -+ std::set<StringRef> ReturnTypeTags; ++ AbiTagSet ReturnTypeTags; + + { + llvm::raw_null_ostream NullOutStream; @@ -1035,9 +991,9 @@ Index: lib/AST/ItaniumMangle.cpp + if (DisableDerivedAbiTags) + return AbiTagList(); + -+ std::set<StringRef> ImplicitlyAvailableTags = ++ AbiTagSet ImplicitlyAvailableTags = + getTagsFromPrefixAndTemplateArguments(VD); -+ std::set<StringRef> VariableTypeTags; ++ AbiTagSet VariableTypeTags; + + { + llvm::raw_null_ostream NullOutStream; @@ -1071,7 +1027,7 @@ Index: lib/AST/ItaniumMangle.cpp // /// Mangles the name of the declaration D and emits that name to the given -@@ -4216,6 +4637,8 @@ +@@ -4195,6 +4572,8 @@ // <special-name> ::= GV <object name> # Guard variable for one-time // # initialization CXXNameMangler Mangler(*this, Out); @@ -1084,7 +1040,7 @@ Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp -@@ -4667,10 +4667,6 @@ +@@ -4700,10 +4700,6 @@ D->addAttr(::new (S.Context) AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(), Attr.getAttributeSpellingListIndex())); @@ -1099,8 +1055,10 @@ Index: test/CodeGenCXX/mangle-abi-tag.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/mangle-abi-tag.cpp -@@ -0,0 +1,137 @@ +@@ -0,0 +1,146 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s ++// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s ++// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s + +struct __attribute__((abi_tag("A", "B"))) A { }; + @@ -1163,11 +1121,11 @@ Index: test/CodeGenCXX/mangle-abi-tag.cpp +// typeinfo +// CHECK: @_ZTI3A10B1AB1B = + -+// Local variables from f9. -+// f11()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B] -+// CHECK-DAG: @_ZZZ3f11vEN1L3fooB1CB1DEvE1aB1AB1B = -+// guard variable for f11()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B] -+// CHECK-DAG: @_ZGVZZ3f11vEN1L3fooB1CB1DEvE1aB1AB1B = ++// Local variables from f13. ++// f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B] ++// CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B = ++// guard variable for f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B] ++// CHECK-DAG: @_ZGVZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B = + +__attribute__ ((abi_tag("C", "D"))) +void* f1() { @@ -1214,15 +1172,23 @@ Index: test/CodeGenCXX/mangle-abi-tag.cpp + class C1 {}; +} +C1 f9() { return C1(); } -+// CHECK: @_Z2f9B6Names1v() ++// CHECK: @_Z2f9B6Names1v( + +inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) { + class C2 {}; +} +C2 f10() { return C2(); } -+// CHECK: @_Z3f10B4Tag1B4Tag2v() ++// CHECK: @_Z3f10B4Tag1B4Tag2v( ++ ++void __attribute__((abi_tag("A"))) f11(A) {} ++// f11[abi:A](A[abi:A][abi:B]) ++// CHECK: define {{.*}} @_Z3f11B1A1AB1AB1B( + -+inline void f11() { ++A f12(A) { return A(); } ++// f12(A[abi:A][abi:B]) ++// CHECK: define {{.*}} @_Z3f121AB1AB1B( ++ ++inline void f13() { + struct L { + static E<int>* foo() { + static A10 a; @@ -1232,11 +1198,10 @@ Index: test/CodeGenCXX/mangle-abi-tag.cpp + L::foo(); +} +void f11_test() { -+ f11(); ++ f13(); +} -+// f11()::L::foo[abi:C][abi:D]() -+// CHECK: define linkonce_odr %struct.E* @_ZZ3f11vEN1L3fooB1CB1DEv( -+ ++// f13()::L::foo[abi:C][abi:D]() ++// CHECK: define linkonce_odr %struct.E* @_ZZ3f13vEN1L3fooB1CB1DEv( Index: test/SemaCXX/attr-abi-tag-syntax.cpp =================================================================== --- test/SemaCXX/attr-abi-tag-syntax.cpp |