dexonsmith created this revision. dexonsmith added a reviewer: arphaman. Herald added a subscriber: ributzka. dexonsmith requested review of this revision.
Update clang/lib/Lex to stop relying on a `MemoryBuffer*`, using the `MemoryBufferRef` from `getBufferOrNone` since both locations had logic for checking validity of the buffer. There's potentially a functionality change, since the logic was wrong (it checked for `nullptr`, which was never returned by the old API), but if that was reachable the new behaviour should be better. https://reviews.llvm.org/D89402 Files: clang/lib/Lex/ModuleMap.cpp clang/lib/Lex/PPDirectives.cpp Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -379,7 +379,8 @@ std::pair<FileID, unsigned> HashFileOffset = SourceMgr.getDecomposedLoc(HashLoc); - const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first); + Optional<llvm::MemoryBufferRef> Buf = + SourceMgr.getBufferOrNone(HashFileOffset.first); if (!Buf) return None; auto It = Index: clang/lib/Lex/ModuleMap.cpp =================================================================== --- clang/lib/Lex/ModuleMap.cpp +++ clang/lib/Lex/ModuleMap.cpp @@ -3004,7 +3004,7 @@ } assert(Target && "Missing target information"); - const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(ID); + llvm::Optional<llvm::MemoryBufferRef> Buffer = SourceMgr.getBufferOrNone(ID); if (!Buffer) return ParsedModuleMap[File] = true; assert((!Offset || *Offset <= Buffer->getBufferSize()) &&
Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -379,7 +379,8 @@ std::pair<FileID, unsigned> HashFileOffset = SourceMgr.getDecomposedLoc(HashLoc); - const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first); + Optional<llvm::MemoryBufferRef> Buf = + SourceMgr.getBufferOrNone(HashFileOffset.first); if (!Buf) return None; auto It = Index: clang/lib/Lex/ModuleMap.cpp =================================================================== --- clang/lib/Lex/ModuleMap.cpp +++ clang/lib/Lex/ModuleMap.cpp @@ -3004,7 +3004,7 @@ } assert(Target && "Missing target information"); - const llvm::MemoryBuffer *Buffer = SourceMgr.getBuffer(ID); + llvm::Optional<llvm::MemoryBufferRef> Buffer = SourceMgr.getBufferOrNone(ID); if (!Buffer) return ParsedModuleMap[File] = true; assert((!Offset || *Offset <= Buffer->getBufferSize()) &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits