diff options
| author | Michael Liao <michael.hliao@gmail.com> | 2019-10-09 19:08:52 +0000 |
|---|---|---|
| committer | Michael Liao <michael.hliao@gmail.com> | 2019-10-09 19:08:52 +0000 |
| commit | fd18e94697c987d5f24e25aa4e27adaffff3cce4 (patch) | |
| tree | f03c7359e09612eb9b193ca1d4a206a7d8176c58 /clang/lib/AST | |
| parent | bc2350a3412676977ec2ffc801e661aa0cec9de6 (diff) | |
| download | bcm5719-llvm-fd18e94697c987d5f24e25aa4e27adaffff3cce4.tar.gz bcm5719-llvm-fd18e94697c987d5f24e25aa4e27adaffff3cce4.zip | |
[mangle] Fix mangling where an extra mangle context is required.
Summary:
- [Itanium C++ ABI][1], for certain contexts like default parameter and
etc., mangling numbering will be local to the particular argument in
which it appears.
- However, for these cases, the mangle numbering context is allocated per
expression evaluation stack entry. That causes, for example, two
lambdas defined/used understand the same default parameter are
numbered as the same value and, in turn, one of them is not generated
at all.
- In this patch, an extra mangle numbering context map is maintained in
the AST context to map taht extra declaration context to its numbering
context. So that, 2 different lambdas defined/used in the same default
parameter are numbered differently.
[1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html
Reviewers: rsmith, eli.friedman
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68715
llvm-svn: 374200
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a41b64ffcc8..8dd57f2bd28 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10261,6 +10261,16 @@ ASTContext::getManglingNumberContext(const DeclContext *DC) { return *MCtx; } +MangleNumberingContext & +ASTContext::getManglingNumberContext(NeedExtraManglingDecl_t, const Decl *D) { + assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C. + std::unique_ptr<MangleNumberingContext> &MCtx = + ExtraMangleNumberingContexts[D]; + if (!MCtx) + MCtx = createMangleNumberingContext(); + return *MCtx; +} + std::unique_ptr<MangleNumberingContext> ASTContext::createMangleNumberingContext() const { return ABI->createMangleNumberingContext(); |

