================
@@ -33,6 +34,65 @@ struct clang::CIRGen::CGCoroData {
CIRGenFunction::CGCoroInfo::CGCoroInfo() {}
CIRGenFunction::CGCoroInfo::~CGCoroInfo() {}
+namespace {
+// FIXME: both GetParamRef and ParamReferenceReplacerRAII are good template
+// candidates to be shared among LLVM / CIR codegen.
+
+// Hunts for the parameter reference in the parameter copy/move declaration.
+struct GetParamRef : public StmtVisitor<GetParamRef> {
+public:
+ DeclRefExpr *expr = nullptr;
+ GetParamRef() {}
+ void VisitDeclRefExpr(DeclRefExpr *e) {
+ assert(expr == nullptr && "multilple declref in param move");
+ expr = e;
+ }
+ void VisitStmt(Stmt *s) {
+ for (auto *c : s->children()) {
+ if (c)
+ Visit(c);
+ }
+ }
+};
+
+// This class replaces references to parameters to their copies by changing
+// the addresses in CGF.LocalDeclMap and restoring back the original values in
+// its destructor.
+struct ParamReferenceReplacerRAII {
+ CIRGenFunction::DeclMapTy savedLocals;
+ CIRGenFunction::DeclMapTy &localDeclMap;
+
+ ParamReferenceReplacerRAII(CIRGenFunction::DeclMapTy &localDeclMap)
+ : localDeclMap(localDeclMap) {}
+
+ void addCopy(DeclStmt const *pm) {
----------------
Andres-Salamanca wrote:
Done
https://github.com/llvm/llvm-project/pull/166683
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits