@@ -927,6 +927,8 @@ int64_t GetBaseClassOffset(TCppScope_t derived, TCppScope_t base) {
927927
928928 assert (derived || base);
929929
930+ compat::SynthesizingCodeRAII RAII (&getInterp ());
931+
930932 auto * DD = (Decl*)derived;
931933 auto * BD = (Decl*)base;
932934 if (!isa<CXXRecordDecl>(DD ) || !isa<CXXRecordDecl>(BD ))
@@ -1053,8 +1055,13 @@ std::vector<TCppFunction_t> GetFunctionsUsingName(TCppScope_t scope,
10531055 DeclarationName DName = &getASTContext ().Idents .get (name);
10541056 clang::LookupResult R (S, DName, SourceLocation (), Sema::LookupOrdinaryName,
10551057 For_Visible_Redeclaration);
1056-
1057- CppInternal::utils::Lookup::Named (&S, R, Decl::castToDeclContext (D));
1058+ auto * Within = Decl::castToDeclContext (D);
1059+ #ifdef CPPINTEROP_USE_CLING
1060+ if (Within)
1061+ Within->getPrimaryContext ()->buildLookup ();
1062+ #endif
1063+ compat::SynthesizingCodeRAII RAII (&getInterp ());
1064+ CppInternal::utils::Lookup::Named (&S, R, Within);
10581065
10591066 if (R.empty ())
10601067 return funcs;
@@ -1198,6 +1205,11 @@ bool ExistsFunctionTemplate(const std::string& name, TCppScope_t parent) {
11981205 Within = llvm::dyn_cast<DeclContext>(D);
11991206 }
12001207
1208+ #ifdef CPPINTEROP_USE_CLING
1209+ if (Within)
1210+ Within->getPrimaryContext ()->buildLookup ();
1211+ #endif
1212+ compat::SynthesizingCodeRAII RAII (&getInterp ());
12011213 auto * ND = CppInternal::utils::Lookup::Named (&getSema (), name, Within);
12021214
12031215 if ((intptr_t )ND == (intptr_t )0 )
@@ -1243,6 +1255,11 @@ bool GetClassTemplatedMethods(const std::string& name, TCppScope_t parent,
12431255 clang::LookupResult R (S, DName, SourceLocation (), Sema::LookupOrdinaryName,
12441256 For_Visible_Redeclaration);
12451257 auto * DC = clang::Decl::castToDeclContext (D);
1258+ #ifdef CPPINTEROP_USE_CLING
1259+ if (DC )
1260+ DC ->getPrimaryContext ()->buildLookup ();
1261+ #endif
1262+ compat::SynthesizingCodeRAII RAII (&getInterp ());
12461263 CppInternal::utils::Lookup::Named (&S, R, DC );
12471264
12481265 if (R.getResultKind () == clang_LookupResult_Not_Found && funcs.empty ())
@@ -1556,6 +1573,11 @@ TCppScope_t LookupDatamember(const std::string& name, TCppScope_t parent) {
15561573 Within = llvm::dyn_cast<clang::DeclContext>(D);
15571574 }
15581575
1576+ #ifdef CPPINTEROP_USE_CLING
1577+ if (Within)
1578+ Within->getPrimaryContext ()->buildLookup ();
1579+ #endif
1580+ compat::SynthesizingCodeRAII RAII (&getInterp ());
15591581 auto * ND = CppInternal::utils::Lookup::Named (&getSema (), name, Within);
15601582 if (ND && ND != (clang::NamedDecl*)-1 ) {
15611583 if (llvm::isa_and_nonnull<clang::FieldDecl>(ND )) {
@@ -1602,6 +1624,7 @@ intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,
16021624 return 0 ;
16031625
16041626 auto & C = I.getSema ().getASTContext ();
1627+ compat::SynthesizingCodeRAII RAII (&getInterp ());
16051628
16061629 if (auto * FD = llvm::dyn_cast<FieldDecl>(D)) {
16071630 clang::RecordDecl* FieldParentRecordDecl = FD ->getParent ();
0 commit comments