From 7da68cffd77940c9794fad896a7fc4944dc4be09 Mon Sep 17 00:00:00 2001 From: jeaye Date: Wed, 23 Apr 2025 11:50:36 -0700 Subject: [PATCH] Remove `name` check from `LookupConstructors` This parameter required the unscoped type name, but CppInterOp provides no way of getting that. Every usage of this appears to have a hard-coded type name instead. After speaking with Vassil on Discord, he suggested this additional check may not actually be needed. For now, the param has been kept, to not break existing code. If everything works correctly, we can follow up to remove the param entirely. If this param cannot be removed, please provide a way for the unscoped name to be accessed via CppInterOp. --- lib/Interpreter/CppInterOp.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/Interpreter/CppInterOp.cpp b/lib/Interpreter/CppInterOp.cpp index 99f80ae11..35f131a92 100755 --- a/lib/Interpreter/CppInterOp.cpp +++ b/lib/Interpreter/CppInterOp.cpp @@ -1043,19 +1043,15 @@ namespace Cpp { } // Looks up all constructors in the current DeclContext - void LookupConstructors(const std::string& name, TCppScope_t parent, + void LookupConstructors(const std::string&, TCppScope_t parent, std::vector& funcs) { auto* D = (Decl*)parent; if (auto* CXXRD = llvm::dyn_cast_or_null(D)) { getSema().ForceDeclarationOfImplicitMembers(CXXRD); DeclContextLookupResult Result = getSema().LookupConstructors(CXXRD); - // Obtaining all constructors when we intend to lookup a method under a - // scope can lead to crashes. We avoid that by accumulating constructors - // only if the Decl matches the lookup name. for (auto* i : Result) - if (GetName(i) == name) - funcs.push_back(i); + funcs.push_back(i); } }