Enhance PTHManager::Create() to take an optional Diagnostic* argument that can be used to report issues such as a missing PTH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63231 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index f9f2b21..36f509c 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -390,13 +390,20 @@
free(PerIDCache);
}
-PTHManager* PTHManager::Create(const std::string& file) {
+PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
// Memory map the PTH file.
llvm::OwningPtr<llvm::MemoryBuffer>
File(llvm::MemoryBuffer::getFile(file.c_str()));
- if (!File)
+ if (!File) {
+ if (Diags) {
+ unsigned DiagID = Diags->getCustomDiagID(Diagnostic::Note,
+ "PTH file %0 could not be read");
+ Diags->Report(FullSourceLoc(), DiagID) << file;
+ }
+
return 0;
+ }
// Get the buffer ranges and check if there are at least three 32-bit
// words at the end of the file.