diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-15 22:54:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-15 22:54:52 +0000 |
commit | 802b77601e50161f0b0d2451a722e11f3b49cdfb (patch) | |
tree | fa9b72b5282af43966aff1b27012e481accbf26b /clang/lib/Frontend/RewriteObjC.cpp | |
parent | 45c1505bf60a17a02846a823fac6d8544a27501c (diff) | |
download | bcm5719-llvm-802b77601e50161f0b0d2451a722e11f3b49cdfb.tar.gz bcm5719-llvm-802b77601e50161f0b0d2451a722e11f3b49cdfb.zip |
Introduce a new BufferResult class to act as the return type of
SourceManager's getBuffer() (and similar) operations. This abstract
can be used to force callers to cope with errors in getBuffer(), such
as missing files and changed files. Fix a bunch of callers to use the
new interface.
Add some very basic checks for file consistency (file size,
modification time) into ContentCache::getBuffer(), although these
checks don't help much until we've updated the main callers (e.g.,
SourceManager::getSpelling()).
llvm-svn: 98585
Diffstat (limited to 'clang/lib/Frontend/RewriteObjC.cpp')
-rw-r--r-- | clang/lib/Frontend/RewriteObjC.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp index 3181a55088b..cd3d4ee0b96 100644 --- a/clang/lib/Frontend/RewriteObjC.cpp +++ b/clang/lib/Frontend/RewriteObjC.cpp @@ -706,7 +706,11 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) { void RewriteObjC::RewriteInclude() { SourceLocation LocStart = SM->getLocForStartOfFile(MainFileID); - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); + std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID, + Diags); + if (!MainBuf.first) + return; + const char *MainBufStart = MainBuf.first; const char *MainBufEnd = MainBuf.second; size_t ImportLen = strlen("import"); @@ -731,7 +735,11 @@ void RewriteObjC::RewriteInclude() { } void RewriteObjC::RewriteTabs() { - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); + std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID, + Diags); + if (!MainBuf.first) + return; + const char *MainBufStart = MainBuf.first; const char *MainBufEnd = MainBuf.second; @@ -973,7 +981,10 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { } void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); + std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID, + Diags); + if (!MainBuf.first) + return; SourceLocation LocStart = PDecl->getLocStart(); |