Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,7 @@ TCppScope_t GetNamed(const std::string& name,
D = GetUnderlyingScope(D);
Within = llvm::dyn_cast<clang::DeclContext>(D);
}
#ifdef CPPINTEROP_USE_CLING
if (Within)
Within->getPrimaryContext()->buildLookup();
#endif

compat::SynthesizingCodeRAII RAII(&getInterp());
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);
if (ND && ND != (clang::NamedDecl*)-1) {
Expand Down Expand Up @@ -1163,6 +1160,8 @@ int64_t GetBaseClassOffset(TCppScope_t derived, TCppScope_t base) {

assert(derived || base);

compat::SynthesizingCodeRAII RAII(&getInterp());

auto* DD = (Decl*)derived;
auto* BD = (Decl*)base;
if (!isa<CXXRecordDecl>(DD) || !isa<CXXRecordDecl>(BD))
Expand Down Expand Up @@ -1315,6 +1314,7 @@ std::vector<TCppFunction_t> GetFunctionsUsingName(TCppScope_t scope,
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
RedeclarationKind::ForVisibleRedeclaration);

compat::SynthesizingCodeRAII RAII(&getInterp());
CppInternal::utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));

if (R.empty())
Expand Down Expand Up @@ -1469,6 +1469,7 @@ bool ExistsFunctionTemplate(const std::string& name, TCppScope_t parent) {
Within = llvm::dyn_cast<DeclContext>(D);
}

compat::SynthesizingCodeRAII RAII(&getInterp());
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);

if ((intptr_t)ND == (intptr_t)0)
Expand Down Expand Up @@ -1517,6 +1518,8 @@ bool GetClassTemplatedMethods(const std::string& name, TCppScope_t parent,
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
RedeclarationKind::ForVisibleRedeclaration);
auto* DC = clang::Decl::castToDeclContext(D);

compat::SynthesizingCodeRAII RAII(&getInterp());
CppInternal::utils::Lookup::Named(&S, R, DC);

if (R.getResultKind() == clang_LookupResult_Not_Found && funcs.empty())
Expand Down Expand Up @@ -1850,6 +1853,7 @@ TCppScope_t LookupDatamember(const std::string& name, TCppScope_t parent) {
Within = llvm::dyn_cast<clang::DeclContext>(D);
}

compat::SynthesizingCodeRAII RAII(&getInterp());
auto* ND = CppInternal::utils::Lookup::Named(&getSema(), name, Within);
if (ND && ND != (clang::NamedDecl*)-1) {
if (llvm::isa_and_nonnull<clang::FieldDecl>(ND)) {
Expand Down Expand Up @@ -1898,6 +1902,7 @@ intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,
return 0;

auto& C = I.getSema().getASTContext();
compat::SynthesizingCodeRAII RAII(&getInterp());

if (auto* FD = llvm::dyn_cast<FieldDecl>(D)) {
clang::RecordDecl* FieldParentRecordDecl = FD->getParent();
Expand Down
2 changes: 2 additions & 0 deletions lib/CppInterOp/CppInterOpInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ inline clang::NamespaceDecl* Namespace(clang::Sema* S, const char* Name,

inline void Named(clang::Sema* S, clang::LookupResult& R,
const clang::DeclContext* Within = nullptr) {
if (Within)
Within->getPrimaryContext()->buildLookup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'this' argument to member function 'buildLookup' has type 'const DeclContext', but function is not marked const [clang-diagnostic-error]

    Within->getPrimaryContext()->buildLookup();
    ^
Additional context

llvm/include/clang/AST/DeclBase.h:2679: 'buildLookup' declared here

  StoredDeclsMap *buildLookup();
                  ^

R.suppressDiagnostics();
if (!Within)
S->LookupName(R, S->TUScope);
Expand Down
Loading