///
/// This routine should only be used for fatal errors that have to
/// do with non-routine failures (e.g., corrupted AST file).
- void Error(const char *Msg);
+ void Error(llvm::StringRef Msg);
+ void Error(unsigned DiagID, llvm::StringRef Arg1 = llvm::StringRef(),
+ llvm::StringRef Arg2 = llvm::StringRef());
ASTReader(const ASTReader&); // do not implement
ASTReader &operator=(const ASTReader &); // do not implement
return false;
}
-void ASTReader::Error(const char *Msg) {
- Diag(diag::err_fe_pch_malformed) << Msg;
+void ASTReader::Error(llvm::StringRef Msg) {
+ Error(diag::err_fe_pch_malformed, Msg);
+}
+
+void ASTReader::Error(unsigned DiagID,
+ llvm::StringRef Arg1, llvm::StringRef Arg2) {
+ if (Diags.isDiagnosticInFlight())
+ Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2);
+ else
+ Diag(DiagID) << Arg1 << Arg2;
}
/// \brief Tell the AST listener about the predefines buffers in the chain.
|| (time_t)Record[5] != File->getModificationTime()
#endif
)) {
- Diag(diag::err_fe_pch_file_modified)
- << Filename;
+ Error(diag::err_fe_pch_file_modified, Filename);
return Failure;
}
--- /dev/null
+// Don't crash.
+
+// RUN: %clang_cc1 -DCAKE -x c-header %S/modified-header-crash.h -emit-pch -o %t
+// RUN: touch %S/modified-header-crash.h
+// RUN: not %clang_cc1 %s -include-pch %t -fsyntax-only
+
+void f(void) {
+ foo = 3;
+}