[clang] 46518a1 - Revert "Revert "Fixes and closes #53952. Setting the ASTHasCompilerErrors member variable correctly based on the PP diagnostics. (#68127)""
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 6 04:44:05 PDT 2023
Author: Aaron Ballman
Date: 2023-10-06T07:43:19-04:00
New Revision: 46518a14f1ab594c0fc7091bc55c10872b64075d
URL: https://github.com/llvm/llvm-project/commit/46518a14f1ab594c0fc7091bc55c10872b64075d
DIFF: https://github.com/llvm/llvm-project/commit/46518a14f1ab594c0fc7091bc55c10872b64075d.diff
LOG: Revert "Revert "Fixes and closes #53952. Setting the ASTHasCompilerErrors member variable correctly based on the PP diagnostics. (#68127)""
This reverts commit a6acf3fd49a20c570a390af2a3c84e10b9545b68 and
relands a50e63b38b931d945f97eac882278068221eca17. The original revert
was done by mistake.
Added:
Modified:
clang/include/clang/Serialization/ASTWriter.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/GeneratePCH.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h
index f2c7c03ff093607..98445d40ebd82c3 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -613,7 +613,6 @@ class ASTWriter : public ASTDeserializationListener,
/// the module but currently is merely a random 32-bit number.
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile,
Module *WritingModule, StringRef isysroot,
- bool hasErrors = false,
bool ShouldCacheASTInMemory = false);
/// Emit a token.
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 016f88a43a56ddd..85157c3b21b6648 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -2341,12 +2341,9 @@ bool ASTUnit::Save(StringRef File) {
return false;
}
-static bool serializeUnit(ASTWriter &Writer,
- SmallVectorImpl<char> &Buffer,
- Sema &S,
- bool hasErrors,
- raw_ostream &OS) {
- Writer.WriteAST(S, std::string(), nullptr, "", hasErrors);
+static bool serializeUnit(ASTWriter &Writer, SmallVectorImpl<char> &Buffer,
+ Sema &S, raw_ostream &OS) {
+ Writer.WriteAST(S, std::string(), nullptr, "");
// Write the generated bitstream to "Out".
if (!Buffer.empty())
@@ -2356,18 +2353,14 @@ static bool serializeUnit(ASTWriter &Writer,
}
bool ASTUnit::serialize(raw_ostream &OS) {
- // For serialization we are lenient if the errors were only warn-as-error kind.
- bool hasErrors = getDiagnostics().hasUncompilableErrorOccurred();
-
if (WriterData)
- return serializeUnit(WriterData->Writer, WriterData->Buffer,
- getSema(), hasErrors, OS);
+ return serializeUnit(WriterData->Writer, WriterData->Buffer, getSema(), OS);
SmallString<128> Buffer;
llvm::BitstreamWriter Stream(Buffer);
InMemoryModuleCache ModuleCache;
ASTWriter Writer(Stream, Buffer, ModuleCache, {});
- return serializeUnit(Writer, Buffer, getSema(), hasErrors, OS);
+ return serializeUnit(Writer, Buffer, getSema(), OS);
}
using SLocRemap = ContinuousRangeMap<unsigned, int, 2>;
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 8d8a10336576d97..12473bf5aace632 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -4622,12 +4622,12 @@ time_t ASTWriter::getTimestampForOutput(const FileEntry *E) const {
ASTFileSignature ASTWriter::WriteAST(Sema &SemaRef, StringRef OutputFile,
Module *WritingModule, StringRef isysroot,
- bool hasErrors,
bool ShouldCacheASTInMemory) {
llvm::TimeTraceScope scope("WriteAST", OutputFile);
WritingAST = true;
- ASTHasCompilerErrors = hasErrors;
+ ASTHasCompilerErrors =
+ SemaRef.PP.getDiagnostics().hasUncompilableErrorOccurred();
// Emit the file header.
Stream.Emit((unsigned)'C', 8);
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 601a24b4aec46ad..cf8084333811f13 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -65,12 +65,8 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
// Emit the PCH file to the Buffer.
assert(SemaPtr && "No Sema?");
- Buffer->Signature =
- Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
- // For serialization we are lenient if the errors were
- // only warn-as-error kind.
- PP.getDiagnostics().hasUncompilableErrorOccurred(),
- ShouldCacheASTInMemory);
+ Buffer->Signature = Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
+ ShouldCacheASTInMemory);
Buffer->IsComplete = true;
}
More information about the cfe-commits
mailing list