Open vgvassilev opened 1 year ago
[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
In the interface
InterOp::Declare
we have an optionsilent
which means that even if the code does not compile we should not print an error on the screen.Currently: https://github.com/compiler-research/CppInterOp/blob/8963daa77d3038cf35cd5d4c8d9f22fbb9e4f324/lib/Interpreter/InterOp.cpp#L2586-L2587
We handle this by turning on suppressing all diagnostics here:
https://github.com/compiler-research/CppInterOp/blob/8963daa77d3038cf35cd5d4c8d9f22fbb9e4f324/lib/Interpreter/InterOp.cpp#L2567-L2579
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 returnkFailure
. Ifsilent
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 functionstatic
members but do not have a good way to store this. Perhaps the easiest would be to implement our customclang::DiagnosticConsumer
which has a flag to ignore the coming diagnostics.