Only reset error count if there was no error before!

This commit is contained in:
Axel Naumann 2017-03-31 16:00:25 +02:00 committed by sftnight
parent fa6d32fe73
commit 91f23f3d4a
2 changed files with 10 additions and 3 deletions

View File

@ -31,6 +31,8 @@ namespace cling {
clang::Preprocessor& PP;
decltype(clang::Parser::TemplateIds) OldTemplateIds;
bool ResetIncrementalProcessing;
bool PPDiagHadErrors;
bool SemaDiagHadErrors;
bool OldSuppressAllDiagnostics;
bool OldPPSuppressAllDiagnostics;
bool OldSpellChecking;

View File

@ -17,6 +17,8 @@ cling::ParserStateRAII::ParserStateRAII(Parser& p, bool skipToEOF)
: P(&p), PP(p.getPreprocessor()),
ResetIncrementalProcessing(p.getPreprocessor()
.isIncrementalProcessingEnabled()),
PPDiagHadErrors(PP.getDiagnostics().hasErrorOccurred()),
SemaDiagHadErrors(P->getActions().getDiagnostics().hasErrorOccurred()),
OldSuppressAllDiagnostics(P->getActions().getDiagnostics()
.getSuppressAllDiagnostics()),
OldPPSuppressAllDiagnostics(p.getPreprocessor().getDiagnostics()
@ -53,10 +55,13 @@ cling::ParserStateRAII::~ParserStateRAII() {
if (SkipToEOF)
P->SkipUntil(tok::eof);
PP.enableIncrementalProcessing(ResetIncrementalProcessing);
// Doesn't reset the diagnostic mappings
P->getActions().getDiagnostics().Reset(/*soft=*/true);
if (!SemaDiagHadErrors) {
// Doesn't reset the diagnostic mappings
P->getActions().getDiagnostics().Reset(/*soft=*/true);
}
P->getActions().getDiagnostics().setSuppressAllDiagnostics(OldSuppressAllDiagnostics);
PP.getDiagnostics().Reset(/*soft=*/true);
if (!PPDiagHadErrors)
PP.getDiagnostics().Reset(/*soft=*/true);
PP.getDiagnostics().setSuppressAllDiagnostics(OldPPSuppressAllDiagnostics);
const_cast<LangOptions&>(PP.getLangOpts()).SpellChecking =
OldSpellChecking;