[clang] d87fd09 - Serialization: Hoist the check for in-flight diagnostics in ASTReader::getInputFile, NFC
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 13 10:26:46 PST 2020
Author: Duncan P. N. Exon Smith
Date: 2020-11-13T13:26:37-05:00
New Revision: d87fd096ac3eb27f376c0182ed5e3034ce240861
URL: https://github.com/llvm/llvm-project/commit/d87fd096ac3eb27f376c0182ed5e3034ce240861
DIFF: https://github.com/llvm/llvm-project/commit/d87fd096ac3eb27f376c0182ed5e3034ce240861.diff
LOG: Serialization: Hoist the check for in-flight diagnostics in ASTReader::getInputFile, NFC
This logic seems easier to follow without the `Error()` helper, and
checking `DiagnosticsEngine::isDiagnosticInFlight` just once up front.
Differential Revision: https://reviews.llvm.org/D91366
Added:
Modified:
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 29c4f15e57b0..94491e45b55b 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1450,8 +1450,6 @@ class ASTReader
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:
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index f3ecb1e51368..6e09fa464940 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1246,12 +1246,6 @@ void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
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 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
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 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
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 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
<< 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;
More information about the cfe-commits
mailing list