Skip to content

InterOp::Declare silent=true issue #96

Open
@vgvassilev

Description

@vgvassilev

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions