Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -659,8 +659,7 @@ } bool ItaniumMangleContextImpl::shouldMangleCXXName(const NamedDecl *D) { - const FunctionDecl *FD = dyn_cast(D); - if (FD) { + if (const FunctionDecl *FD = dyn_cast(D)) { LanguageLinkage L = FD->getLanguageLinkage(); // Overloadable functions need mangling. if (FD->hasAttr()) @@ -696,21 +695,24 @@ if (!getASTContext().getLangOpts().CPlusPlus) return false; - const VarDecl *VD = dyn_cast(D); - if (VD && !isa(D)) { + if (const VarDecl *VD = dyn_cast(D)) { + // Decompositions are mangled. + if (isa(VD)) + return true; + // C variables are not mangled. if (VD->isExternC()) return false; - // Variables at global scope with non-internal linkage are not mangled + // Variables at global scope with non-internal linkage are not mangled. const DeclContext *DC = getEffectiveDeclContext(D); // Check for extern variable declared locally. if (DC->isFunctionOrMethod() && D->hasLinkage()) - while (!DC->isNamespace() && !DC->isTranslationUnit()) + while (!DC->isFileContext()) DC = getEffectiveParentContext(DC); if (DC->isTranslationUnit() && D->getFormalLinkage() != InternalLinkage && !CXXNameMangler::shouldHaveAbiTags(*this, VD) && - !isa(D)) + !isa(VD)) return false; } @@ -5889,9 +5891,11 @@ } void CXXNameMangler::mangleSeqID(unsigned SeqID) { - if (SeqID == 1) + if (SeqID == 0) { + // Nothing. + } else if (SeqID == 1) { Out << '0'; - else if (SeqID > 1) { + } else { SeqID--; // is encoded in base-36, using digits and upper case letters.