[cfe-commits] r63231 - in /cfe/trunk: Driver/clang.cpp include/clang/Lex/PTHManager.h lib/Lex/PTHLexer.cpp
Ted Kremenek
kremenek at apple.com
Wed Jan 28 12:49:33 PST 2009
Author: kremenek
Date: Wed Jan 28 14:49:33 2009
New Revision: 63231
URL: http://llvm.org/viewvc/llvm-project?rev=63231&view=rev
Log:
Enhance PTHManager::Create() to take an optional Diagnostic* argument that can be used to report issues such as a missing PTH file.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Lex/PTHManager.h
cfe/trunk/lib/Lex/PTHLexer.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=63231&r1=63230&r2=63231&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Jan 28 14:49:33 2009
@@ -1154,7 +1154,7 @@
// Use PTH?
if (!TokenCache.empty())
- PTHMgr.reset(PTHManager::Create(TokenCache));
+ PTHMgr.reset(PTHManager::Create(TokenCache, &Diags));
// Create the Preprocessor.
llvm::OwningPtr<Preprocessor> PP(new Preprocessor(Diags, LangInfo, Target,
Modified: cfe/trunk/include/clang/Lex/PTHManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHManager.h?rev=63231&r1=63230&r2=63231&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PTHManager.h (original)
+++ cfe/trunk/include/clang/Lex/PTHManager.h Wed Jan 28 14:49:33 2009
@@ -29,6 +29,7 @@
class FileEntry;
class PTHLexer;
+class Diagnostic;
class PTHManager : public IdentifierInfoLookup {
friend class PTHLexer;
@@ -107,7 +108,7 @@
/// Create - This method creates PTHManager objects. The 'file' argument
/// is the name of the PTH file. This method returns NULL upon failure.
- static PTHManager *Create(const std::string& file);
+ static PTHManager *Create(const std::string& file, Diagnostic* Diags = 0);
void setPreprocessor(Preprocessor *pp) { PP = pp; }
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=63231&r1=63230&r2=63231&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Wed Jan 28 14:49:33 2009
@@ -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.
More information about the cfe-commits
mailing list