dexonsmith created this revision. dexonsmith added a reviewer: jansvoboda11. Herald added a subscriber: ributzka. dexonsmith requested review of this revision.
This logic seems easier to follow without the `Error()` helper, and checking `DiagnosticsEngine::isDiagnosticInFlight` just once up front. https://reviews.llvm.org/D91366 Files: clang/include/clang/Serialization/ASTReader.h clang/lib/Serialization/ASTReader.cpp Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -1246,12 +1246,6 @@ Diag(DiagID) << Arg1 << Arg2 << Arg3; } -void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2, - unsigned Select) const { - if (!Diags.isDiagnosticInFlight()) - Diag(DiagID) << Arg1 << Arg2 << Select; -} - void ASTReader::Error(llvm::Error &&Err) const { Error(toString(std::move(Err))); } @@ -2395,7 +2389,7 @@ auto FileChange = HasInputFileChanged(); // For an overridden file, there is nothing to validate. if (!Overridden && FileChange != ModificationType::None) { - if (Complain) { + if (Complain && !Diags.isDiagnosticInFlight()) { // Build a list of the PCH imports that got us here (in reverse). SmallVector<ModuleFile *, 4> ImportStack(1, &F); while (!ImportStack.back()->ImportedBy.empty()) @@ -2406,17 +2400,17 @@ unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind); if (DiagnosticKind == 0) - Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_pch_file_modified) + << Filename << TopLevelPCHName << FileChange; else if (DiagnosticKind == 1) - Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_module_file_modified) + << Filename << TopLevelPCHName << FileChange; else - Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_ast_file_modified) + << Filename << TopLevelPCHName << FileChange; // Print the import stack. - if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) { + if (ImportStack.size() > 1) { Diag(diag::note_pch_required_by) << Filename << ImportStack[0]->FileName; for (unsigned I = 1; I < ImportStack.size(); ++I) @@ -2424,8 +2418,7 @@ << ImportStack[I-1]->FileName << ImportStack[I]->FileName; } - if (!Diags.isDiagnosticInFlight()) - Diag(diag::note_pch_rebuild_required) << TopLevelPCHName; + Diag(diag::note_pch_rebuild_required) << TopLevelPCHName; } IsOutOfDate = true; Index: clang/include/clang/Serialization/ASTReader.h =================================================================== --- clang/include/clang/Serialization/ASTReader.h +++ clang/include/clang/Serialization/ASTReader.h @@ -1450,8 +1450,6 @@ void Error(StringRef Msg) const; void Error(unsigned DiagID, StringRef Arg1 = StringRef(), StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const; - void Error(unsigned DiagID, StringRef Arg1, StringRef Arg2, - unsigned Select) const; void Error(llvm::Error &&Err) const; public:
Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -1246,12 +1246,6 @@ Diag(DiagID) << Arg1 << Arg2 << Arg3; } -void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2, - unsigned Select) const { - if (!Diags.isDiagnosticInFlight()) - Diag(DiagID) << Arg1 << Arg2 << Select; -} - void ASTReader::Error(llvm::Error &&Err) const { Error(toString(std::move(Err))); } @@ -2395,7 +2389,7 @@ auto FileChange = HasInputFileChanged(); // For an overridden file, there is nothing to validate. if (!Overridden && FileChange != ModificationType::None) { - if (Complain) { + if (Complain && !Diags.isDiagnosticInFlight()) { // Build a list of the PCH imports that got us here (in reverse). SmallVector<ModuleFile *, 4> ImportStack(1, &F); while (!ImportStack.back()->ImportedBy.empty()) @@ -2406,17 +2400,17 @@ unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind); if (DiagnosticKind == 0) - Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_pch_file_modified) + << Filename << TopLevelPCHName << FileChange; else if (DiagnosticKind == 1) - Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_module_file_modified) + << Filename << TopLevelPCHName << FileChange; else - Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName, - (unsigned)FileChange); + Diag(diag::err_fe_ast_file_modified) + << Filename << TopLevelPCHName << FileChange; // Print the import stack. - if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) { + if (ImportStack.size() > 1) { Diag(diag::note_pch_required_by) << Filename << ImportStack[0]->FileName; for (unsigned I = 1; I < ImportStack.size(); ++I) @@ -2424,8 +2418,7 @@ << ImportStack[I-1]->FileName << ImportStack[I]->FileName; } - if (!Diags.isDiagnosticInFlight()) - Diag(diag::note_pch_rebuild_required) << TopLevelPCHName; + Diag(diag::note_pch_rebuild_required) << TopLevelPCHName; } IsOutOfDate = true; Index: clang/include/clang/Serialization/ASTReader.h =================================================================== --- clang/include/clang/Serialization/ASTReader.h +++ clang/include/clang/Serialization/ASTReader.h @@ -1450,8 +1450,6 @@ void Error(StringRef Msg) const; void Error(unsigned DiagID, StringRef Arg1 = StringRef(), StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const; - void Error(unsigned DiagID, StringRef Arg1, StringRef Arg2, - unsigned Select) const; void Error(llvm::Error &&Err) const; public:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits