Skip to content
Merged
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
9 changes: 2 additions & 7 deletions lib/CppInterOp/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,11 @@ using Interpreter = CppInternal::Interpreter;

class SynthesizingCodeRAII {
private:
Interpreter* m_Interpreter;
[[maybe_unused]] Interpreter* m_Interpreter;

public:
SynthesizingCodeRAII(Interpreter* i) : m_Interpreter(i) {}
~SynthesizingCodeRAII() {
auto GeneratedPTU = m_Interpreter->Parse("");
if (!GeneratedPTU)
llvm::logAllUnhandledErrors(GeneratedPTU.takeError(), llvm::errs(),
"Failed to generate PTU:");
}
// ~SynthesizingCodeRAII() {} // TODO: implement
};
} // namespace compat

Expand Down
7 changes: 7 additions & 0 deletions lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ static void InstantiateFunctionDefinition(Decl* D) {
getSema().InstantiateFunctionDefinition(SourceLocation(), FD,
/*Recursive=*/true,
/*DefinitionRequired=*/true);
// FIXME: this can go into a RAII object
clang::DiagnosticsEngine& Diags = getSema().getDiagnostics();
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.

We need a fixme to move this in a raii.

Copy link
Copy Markdown
Collaborator Author

@Vipul-Cariappa Vipul-Cariappa Feb 23, 2026

Choose a reason for hiding this comment

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

This is the only code path that requires this. Why create a RAII object for a one-off case?

Also, from the last meeting, what I understood is: The SynthesizingCodeRAII class should tackle failures at the JIT level. And to create a new RAII object for this (errors at the parser level). If the "diagnostics reset" is required in other code paths at that point, we should add a new RAII object.

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.

I think such a raii already exists in Sema.

if (!FD->isDefined() && Diags.hasErrorOccurred()) {
// instantiation failed, need to reset DiagnosticsEngine
Diags.Reset(/*soft=*/true);
Diags.getClient()->clear();
}
}
}

Expand Down
Loading