|
28 | 28 | #include "clang/AST/QualTypeNames.h" |
29 | 29 | #include "clang/AST/RawCommentList.h" |
30 | 30 | #include "clang/AST/RecordLayout.h" |
| 31 | +#include "clang/AST/RecursiveASTVisitor.h" |
31 | 32 | #include "clang/AST/Stmt.h" |
32 | 33 | #include "clang/AST/Type.h" |
33 | 34 | #include "clang/Basic/DiagnosticSema.h" |
|
44 | 45 | #include "clang/Sema/Ownership.h" |
45 | 46 | #include "clang/Sema/Redeclaration.h" |
46 | 47 | #include "clang/Sema/Sema.h" |
47 | | -#include "clang/AST/RecursiveASTVisitor.h" |
48 | 48 | #include "clang/Sema/TemplateDeduction.h" |
49 | 49 |
|
50 | 50 | #include "llvm/ADT/SmallString.h" |
@@ -1693,6 +1693,23 @@ BestOverloadMatch(const std::vector<TCppScope_t>& candidates, |
1693 | 1693 | for (TCppScope_t F : candidates) { |
1694 | 1694 | Decl* D = (Decl*)F; |
1695 | 1695 |
|
| 1696 | + // Unwrap ConstructorUsingShadowDecl (from `using Base::Base;`) |
| 1697 | + // to get the inherited constructor and add it in the derived class context. |
| 1698 | + if (auto* Shadow = dyn_cast<ConstructorUsingShadowDecl>(D)) { |
| 1699 | + CXXConstructorDecl* CD = |
| 1700 | + dyn_cast<CXXConstructorDecl>(Shadow->getTargetDecl()); |
| 1701 | + if (!CD) |
| 1702 | + continue; |
| 1703 | + // Use the shadow's access (which reflects the using-decl's access), |
| 1704 | + // not the base constructor's access. |
| 1705 | + DeclAccessPair found = DeclAccessPair::make(CD, Shadow->getAccess()); |
| 1706 | + // Pass the derived class as the object type so Sema checks the right |
| 1707 | + // conversion sequences. |
| 1708 | + QualType DerivedTy = S.Context.getCanonicalTagType(Shadow->getParent()); |
| 1709 | + S.AddOverloadCandidate(CD, found, non_member_args, candSet); |
| 1710 | + continue; |
| 1711 | + } |
| 1712 | + |
1696 | 1713 | if (auto* MD = dyn_cast<CXXMethodDecl>(D)) { |
1697 | 1714 | if (!register_member(MD, dyn_cast<FunctionTemplateDecl>(MD))) |
1698 | 1715 | continue; |
@@ -2842,7 +2859,7 @@ TCppType_t GetTypeFromScope(TCppScope_t klass) { |
2842 | 2859 | namespace { |
2843 | 2860 | static unsigned long long gWrapperSerial = 0LL; |
2844 | 2861 |
|
2845 | | -static std::string generate_wrapper_name(char const *prefix) { |
| 2862 | +static std::string generate_wrapper_name(char const* prefix) { |
2846 | 2863 | std::ostringstream nm; |
2847 | 2864 | nm << prefix << gWrapperSerial++; |
2848 | 2865 | return nm.str(); |
@@ -4994,7 +5011,8 @@ static std::string PrepareStructorWrapper(const Decl* D, |
4994 | 5011 | } |
4995 | 5012 |
|
4996 | 5013 | template <WrapperKind K = WrapperKind::Jit> |
4997 | | -static auto make_dtor_wrapper(compat::Interpreter& interp, const Decl* D, const std::string &wrapper_name) { |
| 5014 | +static auto make_dtor_wrapper(compat::Interpreter& interp, const Decl* D, |
| 5015 | + const std::string& wrapper_name) { |
4998 | 5016 | // Make a code string that follows this pattern: |
4999 | 5017 | // |
5000 | 5018 | // void |
@@ -5068,22 +5086,25 @@ CPPINTEROP_API JitCall MakeFunctionCallable(TInterp_t I, |
5068 | 5086 | // FIXME: Unify with make_wrapper. |
5069 | 5087 | if (const auto* Dtor = dyn_cast<CXXDestructorDecl>(D)) { |
5070 | 5088 | auto wrapper_name = generate_wrapper_name("dtor"); |
5071 | | - if (auto Wrapper = make_dtor_wrapper(*interp, Dtor->getParent(), wrapper_name)) |
| 5089 | + if (auto Wrapper = |
| 5090 | + make_dtor_wrapper(*interp, Dtor->getParent(), wrapper_name)) |
5072 | 5091 | return {JitCall::kDestructorCall, Wrapper, Dtor}; |
5073 | 5092 | // FIXME: else error we failed to compile the wrapper. |
5074 | 5093 | return {}; |
5075 | 5094 | } |
5076 | 5095 |
|
5077 | 5096 | if (const auto* Ctor = dyn_cast<CXXConstructorDecl>(D)) { |
5078 | 5097 | auto wrapper_name = generate_wrapper_name("ctor"); |
5079 | | - if (auto Wrapper = make_wrapper<WrapperKind::Jit>(*interp, cast<FunctionDecl>(D), {}, wrapper_name)) |
| 5098 | + if (auto Wrapper = make_wrapper<WrapperKind::Jit>( |
| 5099 | + *interp, cast<FunctionDecl>(D), {}, wrapper_name)) |
5080 | 5100 | return {JitCall::kConstructorCall, Wrapper, Ctor}; |
5081 | 5101 | // FIXME: else error we failed to compile the wrapper. |
5082 | 5102 | return {}; |
5083 | 5103 | } |
5084 | 5104 |
|
5085 | 5105 | auto wrapper_name = generate_wrapper_name("function"); |
5086 | | - if (auto Wrapper = make_wrapper<WrapperKind::Jit>(*interp, cast<FunctionDecl>(D), {}, wrapper_name)) { |
| 5106 | + if (auto Wrapper = make_wrapper<WrapperKind::Jit>( |
| 5107 | + *interp, cast<FunctionDecl>(D), {}, wrapper_name)) { |
5087 | 5108 | return {JitCall::kGenericCall, Wrapper, cast<FunctionDecl>(D)}; |
5088 | 5109 | } |
5089 | 5110 | // FIXME: else error we failed to compile the wrapper. |
@@ -5481,9 +5502,9 @@ CreateInterpreter(const std::vector<const char*>& Args /*={}*/, |
5481 | 5502 | #ifdef CPPINTEROP_USE_CLING |
5482 | 5503 | auto I = new compat::Interpreter(ClingArgv.size(), &ClingArgv[0]); |
5483 | 5504 | #else |
5484 | | - auto Interp = |
5485 | | - compat::Interpreter::create(static_cast<int>(ClingArgv.size()), |
5486 | | - ClingArgv.data(), nullptr, {}, nullptr, true, VFS, CM); |
| 5505 | + auto Interp = compat::Interpreter::create(static_cast<int>(ClingArgv.size()), |
| 5506 | + ClingArgv.data(), nullptr, {}, |
| 5507 | + nullptr, true, VFS, CM); |
5487 | 5508 | if (!Interp) |
5488 | 5509 | return nullptr; |
5489 | 5510 | auto* I = Interp.release(); |
@@ -6330,7 +6351,8 @@ TCppObject_t Construct(TCppScope_t scope, void* arena /*=nullptr*/, |
6330 | 6351 |
|
6331 | 6352 | bool Destruct(compat::Interpreter& interp, TCppObject_t This, const Decl* Class, |
6332 | 6353 | bool withFree, TCppIndex_t nary) { |
6333 | | - if (auto wrapper = make_dtor_wrapper(interp, Class, generate_wrapper_name("dtor"))) { |
| 6354 | + if (auto wrapper = |
| 6355 | + make_dtor_wrapper(interp, Class, generate_wrapper_name("dtor"))) { |
6334 | 6356 | (*wrapper)(This, nary, withFree); |
6335 | 6357 | return true; |
6336 | 6358 | } |
|
0 commit comments