llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-modules

<details>
<summary>Changes</summary>

The issue #<!-- -->53952 is reported indicating clang is giving a crashing pch 
file, when hasErrors is been passed incorrectly to WriteAST method.

To fix the issue, I have a added an assertion to make sure the given value of 
ASTHasCompilerErrors is matching with Preprocessor diagnostics. And this 
assertion will get triggered inside Debug builds.

For release builds, based on the conditional check, forcefully set the 
ASTHasCompilerErrors member variable to a valid value from Preprocessor.

---
Full diff: https://github.com/llvm/llvm-project/pull/68127.diff


1 Files Affected:

- (modified) clang/lib/Serialization/ASTWriter.cpp (+6) 


``````````diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..35f37de9b1850ad 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -4628,6 +4628,12 @@ ASTFileSignature ASTWriter::WriteAST(Sema &SemaRef, 
StringRef OutputFile,
   WritingAST = true;
 
   ASTHasCompilerErrors = hasErrors;
+  bool trueHasErrors = 
SemaRef.PP.getDiagnostics().hasUncompilableErrorOccurred();
+  assert(ASTHasCompilerErrors == trueHasErrors);
+  if (trueHasErrors != ASTHasCompilerErrors) {
+      // forcing the compiler errors flag to be set correctly
+      ASTHasCompilerErrors = trueHasErrors;
+  }
 
   // Emit the file header.
   Stream.Emit((unsigned)'C', 8);

``````````

</details>


https://github.com/llvm/llvm-project/pull/68127
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to