Get the name of a \c FieldDecl in case this \c FieldDecl is part of a lambda. The name has to be retrieved from the capture fields or can be \c __this.
| 595 | /// Get the name of a \c FieldDecl in case this \c FieldDecl is part of a lambda. The name has to be retrieved from the |
| 596 | /// capture fields or can be \c __this. |
| 597 | static std::optional<std::string> GetFieldDeclNameForLambda(const FieldDecl& fieldDecl, |
| 598 | const CXXRecordDecl& cxxRecordDecl) |
| 599 | { |
| 600 | if(cxxRecordDecl.isLambda()) { |
| 601 | llvm::DenseMap<const ValueDecl*, FieldDecl*> captures{}; |
| 602 | |
| 603 | FieldDecl* thisCapture{}; |
| 604 | |
| 605 | cxxRecordDecl.getCaptureFields(captures, thisCapture); |
| 606 | |
| 607 | if(&fieldDecl == thisCapture) { |
| 608 | return std::string{kwInternalThis}; |
| 609 | } else { |
| 610 | for(const auto& [key, value] : captures) { |
| 611 | if(&fieldDecl == value) { |
| 612 | return GetName(*key); |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | return {}; |
| 619 | } |
| 620 | //----------------------------------------------------------------------------- |
| 621 | |
| 622 | void CodeGenerator::InsertArg(const SourceLocExpr* stmt) |