Skip to content

Commit

Permalink
Improve the test coverage of the C API -- Take 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnimuc committed Jan 13, 2025
1 parent 40f21ca commit 0333803
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 6 additions & 8 deletions lib/Interpreter/CXCppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,16 @@ void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir) {
getInterpreter(I)->AddIncludePath(dir);
}

namespace Cpp {
int Declare(compat::Interpreter& interp, const char* code, bool silent);
} // namespace Cpp

enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code,
bool silent) {
auto* interp = getInterpreter(I);
auto& diag = interp->getSema().getDiagnostics();

const bool is_silent_old = diag.getSuppressAllDiagnostics();

diag.setSuppressAllDiagnostics(silent);
const auto result = interp->declare(code);
diag.setSuppressAllDiagnostics(is_silent_old);

if (result != Cpp::Interpreter::kSuccess)
const auto result = Cpp::Declare(*interp, code, silent);
if (result)
return CXError_Failure;

return CXError_Success;
Expand Down
8 changes: 5 additions & 3 deletions lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2887,9 +2887,7 @@ namespace Cpp {
};
} // namespace

int Declare(const char* code, bool silent) {
auto& I = getInterp();

int Declare(compat::Interpreter& I, const char* code, bool silent) {
if (silent) {
clangSilent diagSuppr(I.getSema().getDiagnostics());
return I.declare(code);
Expand All @@ -2898,6 +2896,10 @@ namespace Cpp {
return I.declare(code);
}

int Declare(const char* code, bool silent) {
return Declare(getInterp(), code, silent);
}

int Process(const char *code) {
return getInterp().process(code);
}
Expand Down

0 comments on commit 0333803

Please sign in to comment.