@@ -389,30 +389,31 @@ class Interpreter {
389389 return nullptr ;
390390 }
391391
392- CompilationResult declare (const std::string& input,
392+ CompilationResult declare (const std::string& input, bool silent = false ,
393393 clang::PartialTranslationUnit** PTU = nullptr ) {
394- return process (input, /* Value=*/ nullptr , PTU);
394+ return process (input, /* Value=*/ nullptr , silent, PTU);
395395 }
396396
397- // /\brief Maybe transform the input line to implement cint command line
397+ // / Maybe transform the input line to implement cint command line
398398 // / semantics (declarations are global) and compile to produce a module.
399399 // /
400400 CompilationResult process (const std::string& input, clang::Value* V = 0 ,
401+ bool silent = false ,
401402 clang::PartialTranslationUnit** PTU = nullptr ,
402403 bool disableValuePrinting = false ) {
404+ DiagnosticGuard Guard (getSema ().getDiagnostics (), silent);
403405 auto PTUOrErr = Parse (input);
404406 if (!PTUOrErr) {
405- llvm::logAllUnhandledErrors (PTUOrErr.takeError (), llvm::errs (),
406- " Failed to parse via ::process:" );
407+ Guard. handleOrConsume (PTUOrErr.takeError (),
408+ " Failed to parse via ::process:" );
407409 return Interpreter::kFailure ;
408410 }
409411
410412 if (PTU)
411413 *PTU = &*PTUOrErr;
412414
413415 if (auto Err = Execute (*PTUOrErr)) {
414- llvm::logAllUnhandledErrors (std::move (Err), llvm::errs (),
415- " Failed to execute via ::process:" );
416+ Guard.handleOrConsume (std::move (Err), " Failed to execute via ::process:" );
416417 return Interpreter::kFailure ;
417418 }
418419 return Interpreter::kSuccess ;
0 commit comments