Skip to content

Commit

Permalink
Bypass the class/struct reserved name check for C++ aggregates and st…
Browse files Browse the repository at this point in the history
…op prefixing C++ aggregate names such as TypeInfo_xxx, Exception, etc. with ℂ.

This prevents encountering MSVC linker directives with unsupported UTF-8 characters.
  • Loading branch information
Syniurge committed Nov 3, 2019
1 parent b2964d9 commit e9630ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
13 changes: 0 additions & 13 deletions dmd/cpp/calypso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,6 @@ Identifier *getIdentifierOrNull(const clang::NamedDecl *D, SpecValue *spec, bool
}
}

if (isa<clang::RecordDecl>(D))
{
// Prefix reserved class names with 'ℂ'
if (ident == Id::Object || ident == Id::Throwable || ident == Id::Exception || ident == Id::Error ||
ident == Id::TypeInfo || ident == Id::TypeInfo_Class || ident == Id::TypeInfo_Interface ||
ident == Id::TypeInfo_Struct || ident == Id::TypeInfo_Pointer ||
ident == Id::TypeInfo_Array || ident == Id::TypeInfo_StaticArray || ident == Id::TypeInfo_AssociativeArray ||
ident == Id::TypeInfo_Enum || ident == Id::TypeInfo_Function || ident == Id::TypeInfo_Delegate ||
ident == Id::TypeInfo_Tuple || ident == Id::TypeInfo_Const || ident == Id::TypeInfo_Invariant ||
ident == Id::TypeInfo_Shared || ident == Id::TypeInfo_Wild || ident == Id::TypeInfo_Vector) // thanks C++...
needsPrefixing = true;
}

if (needsPrefixing)
ident = prefixConflictingIdentifier(ident);

Expand Down
9 changes: 6 additions & 3 deletions dmd/cpp/cppaggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void LangPlugin::mangleAnonymousAggregate(::AggregateDeclaration* ad, OutBuffer
StructDeclaration::StructDeclaration(Loc loc, Identifier* id,
const clang::RecordDecl* RD)
{
construct_StructDeclaration(this, loc, id);
construct_StructDeclaration(this, loc, calypso.id_Scpp);
this->ident = id; // bypassed the reserved struct names check
this->RD = RD;
}

Expand All @@ -68,7 +69,8 @@ StructDeclaration::StructDeclaration(const StructDeclaration& o)
ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses,
Dsymbols* members, const clang::CXXRecordDecl *RD)
{
construct_ClassDeclaration(this, loc, id, baseclasses, members);
construct_ClassDeclaration(this, loc, calypso.id_Scpp, baseclasses, members);
this->ident = id; // bypassed the reserved class names check
this->RD = RD;
}

Expand All @@ -80,7 +82,8 @@ ClassDeclaration::ClassDeclaration(const ClassDeclaration& o)
UnionDeclaration::UnionDeclaration(Loc loc, Identifier* id,
const clang::RecordDecl* RD)
{
construct_UnionDeclaration(this, loc, id);
construct_UnionDeclaration(this, loc, calypso.id_Scpp);
this->ident = id; // bypassed the reserved struct names check
this->RD = RD;
}

Expand Down

0 comments on commit e9630ac

Please sign in to comment.