diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-21 04:17:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-21 04:17:39 +0000 |
commit | 5878cbcfaa90b8515550db86033fd5a0efab971d (patch) | |
tree | 7cb574e300ff00ea50204363fbc09578a8f8f9f9 /lib/AST/ItaniumMangle.cpp | |
parent | 702afbc68b933af520420688cdf6783b411a8f70 (diff) |
Implement non-internal linkage for lambda closure types that need a
stable mangling, since these lambdas can end up in multiple
translation units. Sema is responsible for deciding when this is the
case, because it's already responsible for choosing the mangling
number.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 47f50cf078..5e167f58dc 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -52,7 +52,7 @@ static const DeclContext *getEffectiveDeclContext(const Decl *D) { if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) { if (RD->isLambda()) if (ParmVarDecl *ContextParam - = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl())) + = dyn_cast_or_null<ParmVarDecl>(RD->getLambdaContextDecl())) return ContextParam->getDeclContext(); } @@ -1114,7 +1114,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, // <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)) { - if (Record->isLambda()) { + if (Record->isLambda() && Record->getLambdaManglingNumber()) { mangleLambda(Record); break; } @@ -1347,10 +1347,10 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) { // (in lexical order) with that same <lambda-sig> and context. // // The AST keeps track of the number for us. - if (unsigned Number = Lambda->getLambdaManglingNumber()) { - if (Number > 1) - mangleNumber(Number - 2); - } + unsigned Number = Lambda->getLambdaManglingNumber(); + assert(Number > 0 && "Lambda should be mangled as an unnamed class"); + if (Number > 1) + mangleNumber(Number - 2); Out << '_'; } |