clang_saveTranslationUnit() to save a PCH file if the only errors it
contains are recoverable errors. Fixes <rdar://problem/
9727804>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134503
91177308-0d34-0410-b5e6-
96231b3b80d8
bool ErrorOccurred;
bool FatalErrorOccurred;
+ /// \brief Indicates that an unrecoverable error has occurred.
+ bool UnrecoverableErrorOccurred;
+
/// \brief Toggles for DiagnosticErrorTrap to check whether an error occurred
/// during a parsing section, e.g. during parsing a function.
bool TrapErrorOccurred;
bool hasErrorOccurred() const { return ErrorOccurred; }
bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
-
+
+ /// \brief Determine whether any kind of unrecoverable error has occurred.
+ bool hasUnrecoverableErrorOccurred() const {
+ return FatalErrorOccurred || UnrecoverableErrorOccurred;
+ }
+
unsigned getNumWarnings() const { return NumWarnings; }
void setNumWarnings(unsigned NumWarnings) {
void Diagnostic::Reset() {
ErrorOccurred = false;
FatalErrorOccurred = false;
+ UnrecoverableErrorOccurred = false;
NumWarnings = 0;
NumErrors = 0;
NumErrorsSuppressed = 0;
+
CurDiagID = ~0U;
// Set LastDiagLevel to an "unset" state. If we set it to 'Ignored', notes
// using a Diagnostic associated to a translation unit that follow
if (DiagLevel >= DiagnosticIDs::Error) {
Diag.TrapErrorOccurred = true;
- if (isUnrecoverable(DiagID))
+ if (isUnrecoverable(DiagID)) {
Diag.TrapUnrecoverableErrorOccurred = true;
-
+ Diag.UnrecoverableErrorOccurred = true;
+ }
+
if (Diag.Client->IncludeInDiagnosticCounts()) {
Diag.ErrorOccurred = true;
++Diag.NumErrors;
}
// Only errors may be unrecoverable.
- if (getBuiltinDiagClass(DiagID) < DiagnosticIDs::Error)
+ if (getBuiltinDiagClass(DiagID) < CLASS_ERROR)
return false;
if (DiagID == diag::err_unavailable ||
}
CXSaveError ASTUnit::Save(llvm::StringRef File) {
- if (getDiagnostics().hasErrorOccurred())
+ if (getDiagnostics().hasUnrecoverableErrorOccurred())
return CXSaveError_TranslationErrors;
// FIXME: Can we somehow regenerate the stat cache here, or do we need to
--- /dev/null
+inline int *get_int_ptr(float *fp) {
+ return fp;
+}
+
+#ifdef FATAL
+void fatal(int);
+void fatal(float);
+#endif
+
+// CHECK-FATAL: translation errors
+
+// RUN: c-index-test -write-pch %t.pch -Werror %s
+// RUN: not c-index-test -write-pch %t.pch -DFATAL -Werror %s 2>%t.err
+// RUN: FileCheck -check-prefix=CHECK-FATAL %s < %t.err
+