Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/ItaniumMangle.cpp
Show First 20 Lines • Show All 707 Lines • ▼ Show 20 Lines | if (const auto *VD = dyn_cast<VarDecl>(D)) { | ||||
// linkage or are specializations or are attached to a named module. | // linkage or are specializations or are attached to a named module. | ||||
const DeclContext *DC = getEffectiveDeclContext(D); | const DeclContext *DC = getEffectiveDeclContext(D); | ||||
// Check for extern variable declared locally. | // Check for extern variable declared locally. | ||||
if (DC->isFunctionOrMethod() && D->hasLinkage()) | if (DC->isFunctionOrMethod() && D->hasLinkage()) | ||||
while (!DC->isFileContext()) | while (!DC->isFileContext()) | ||||
DC = getEffectiveParentContext(DC); | DC = getEffectiveParentContext(DC); | ||||
if (DC->isTranslationUnit() && D->getFormalLinkage() != InternalLinkage && | if (DC->isTranslationUnit() && D->getFormalLinkage() != InternalLinkage && | ||||
!CXXNameMangler::shouldHaveAbiTags(*this, VD) && | !CXXNameMangler::shouldHaveAbiTags(*this, VD) && | ||||
!isa<VarTemplateSpecializationDecl>(VD) && | !isa<VarTemplateSpecializationDecl>(VD) && | ||||
Lint: Pre-merge checks: clang-format: please reformat the code
```
- !isa<VarTemplateSpecializationDecl>(VD) &&… | |||||
!VD->getOwningModuleForLinkage()) | !VD->getModuleAttachment()) | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void CXXNameMangler::writeAbiTags(const NamedDecl *ND, | void CXXNameMangler::writeAbiTags(const NamedDecl *ND, | ||||
const AbiTagList *AdditionalAbiTags) { | const AbiTagList *AdditionalAbiTags) { | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | if (DC->isTranslationUnit() || isStdNamespace(DC)) { | ||||
return; | return; | ||||
} | } | ||||
mangleNestedName(GD, DC, AdditionalAbiTags); | mangleNestedName(GD, DC, AdditionalAbiTags); | ||||
} | } | ||||
void CXXNameMangler::mangleModuleName(const NamedDecl *ND) { | void CXXNameMangler::mangleModuleName(const NamedDecl *ND) { | ||||
if (ND->isExternallyVisible()) | if (ND->isExternallyVisible()) | ||||
if (Module *M = ND->getOwningModuleForLinkage()) | if (Module *M = ND->getModuleAttachment()) | ||||
mangleModuleNamePrefix(M->Name); | mangleModuleNamePrefix(M->Name); | ||||
} | } | ||||
// <module-name> ::= <module-subname> | // <module-name> ::= <module-subname> | ||||
// ::= <module-name> <module-subname> | // ::= <module-name> <module-subname> | ||||
// ::= <substitution> | // ::= <substitution> | ||||
// <module-subname> ::= W <source-name> | // <module-subname> ::= W <source-name> | ||||
// ::= W P <source-name> | // ::= W P <source-name> | ||||
▲ Show 20 Lines • Show All 4,971 Lines • ▼ Show 20 Lines | static bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A) { | ||||
const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); | const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs(); | ||||
if (TemplateArgs.size() != 1) | if (TemplateArgs.size() != 1) | ||||
return false; | return false; | ||||
if (TemplateArgs[0].getAsType() != A) | if (TemplateArgs[0].getAsType() != A) | ||||
return false; | return false; | ||||
if (SD->getSpecializedTemplate()->getOwningModuleForLinkage()) | if (SD->getSpecializedTemplate()->getModuleAttachment()) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
/// Returns whether SD is a template specialization std::Name<char, | /// Returns whether SD is a template specialization std::Name<char, | ||||
/// std::char_traits<char> [, std::allocator<char>]> | /// std::char_traits<char> [, std::allocator<char>]> | ||||
/// HasAllocator controls whether the 3rd template argument is needed. | /// HasAllocator controls whether the 3rd template argument is needed. | ||||
Show All 16 Lines | static bool isStdCharSpecialization(const ClassTemplateSpecializationDecl *SD, | ||||
if (!isSpecializedAs(TemplateArgs[1].getAsType(), "char_traits", A)) | if (!isSpecializedAs(TemplateArgs[1].getAsType(), "char_traits", A)) | ||||
return false; | return false; | ||||
if (HasAllocator && | if (HasAllocator && | ||||
!isSpecializedAs(TemplateArgs[2].getAsType(), "allocator", A)) | !isSpecializedAs(TemplateArgs[2].getAsType(), "allocator", A)) | ||||
return false; | return false; | ||||
if (SD->getSpecializedTemplate()->getOwningModuleForLinkage()) | if (SD->getSpecializedTemplate()->getModuleAttachment()) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
} | } | ||||
bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { | bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { | ||||
// <substitution> ::= St # ::std:: | // <substitution> ::= St # ::std:: | ||||
if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) { | if (const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ND)) { | ||||
if (isStd(NS)) { | if (isStd(NS)) { | ||||
Out << "St"; | Out << "St"; | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
if (const ClassTemplateDecl *TD = dyn_cast<ClassTemplateDecl>(ND)) { | if (const ClassTemplateDecl *TD = dyn_cast<ClassTemplateDecl>(ND)) { | ||||
if (!isStdNamespace(getEffectiveDeclContext(TD))) | if (!isStdNamespace(getEffectiveDeclContext(TD))) | ||||
return false; | return false; | ||||
if (TD->getOwningModuleForLinkage()) | if (TD->getModuleAttachment()) | ||||
return false; | return false; | ||||
// <substitution> ::= Sa # ::std::allocator | // <substitution> ::= Sa # ::std::allocator | ||||
if (TD->getIdentifier()->isStr("allocator")) { | if (TD->getIdentifier()->isStr("allocator")) { | ||||
Out << "Sa"; | Out << "Sa"; | ||||
return true; | return true; | ||||
} | } | ||||
// <<substitution> ::= Sb # ::std::basic_string | // <<substitution> ::= Sb # ::std::basic_string | ||||
if (TD->getIdentifier()->isStr("basic_string")) { | if (TD->getIdentifier()->isStr("basic_string")) { | ||||
Out << "Sb"; | Out << "Sb"; | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
if (const ClassTemplateSpecializationDecl *SD = | if (const ClassTemplateSpecializationDecl *SD = | ||||
dyn_cast<ClassTemplateSpecializationDecl>(ND)) { | dyn_cast<ClassTemplateSpecializationDecl>(ND)) { | ||||
if (!isStdNamespace(getEffectiveDeclContext(SD))) | if (!isStdNamespace(getEffectiveDeclContext(SD))) | ||||
return false; | return false; | ||||
if (SD->getSpecializedTemplate()->getOwningModuleForLinkage()) | if (SD->getSpecializedTemplate()->getModuleAttachment()) | ||||
return false; | return false; | ||||
// <substitution> ::= Ss # ::std::basic_string<char, | // <substitution> ::= Ss # ::std::basic_string<char, | ||||
// ::std::char_traits<char>, | // ::std::char_traits<char>, | ||||
// ::std::allocator<char> > | // ::std::allocator<char> > | ||||
if (isStdCharSpecialization(SD, "basic_string", /*HasAllocator=*/true)) { | if (isStdCharSpecialization(SD, "basic_string", /*HasAllocator=*/true)) { | ||||
Out << "Ss"; | Out << "Ss"; | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 362 Lines • Show Last 20 Lines |
clang-format: please reformat the code