Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InterOp::Declare silent=true issue #96

Open
vgvassilev opened this issue Jun 25, 2023 · 1 comment
Open

InterOp::Declare silent=true issue #96

vgvassilev opened this issue Jun 25, 2023 · 1 comment

Comments

@vgvassilev
Copy link
Contributor

In the interface InterOp::Declare we have an option silent which means that even if the code does not compile we should not print an error on the screen.

Currently:

clangSilent diagSuppr(I.getSema().getDiagnostics());
return I.declare(code);

We handle this by turning on suppressing all diagnostics here:

class clangSilent {
public:
clangSilent(clang::DiagnosticsEngine &diag) : fDiagEngine(diag) {
fOldDiagValue = fDiagEngine.getSuppressAllDiagnostics();
fDiagEngine.setSuppressAllDiagnostics(true);
}
~clangSilent() { fDiagEngine.setSuppressAllDiagnostics(fOldDiagValue); }
protected:
clang::DiagnosticsEngine &fDiagEngine;
bool fOldDiagValue;
};

However, this prevents us to realize there was an error because the interpreter checks if diagnostics occurred to set the error and InterOp::Declare to return kFailure. If silent is passed we should swap the default diagnostic consumer with IgnoringDiagConsumer. However, the problem is that we should have some place to store the default and the ignoring consumer. The storing of such state is problematic for CppInterOp as we do not want many function static members but do not have a good way to store this. Perhaps the easiest would be to implement our custom clang::DiagnosticConsumer which has a flag to ignore the coming diagnostics.

@sudo-panda
Copy link
Contributor

[cling]$ InterOp::Declare("int i;", true)
(unsigned long) 0
[cling]$ InterOp::Declare("int i;", true)
(unsigned long) 1
[cling]$ InterOp::Declare("integer i;", true)
(unsigned long) 1
[cling]$ InterOp::Declare("int i1;", true)
(unsigned long) 0

It works on the cling backend, so it's only a problem on clang-REPL backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants