[PATCH] D89402: clang/Lex: Stop using SourceManager::getBuffer
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 09:43:14 PDT 2020
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()) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89402.298168.patch
Type: text/x-patch
Size: 1019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201014/ebad23af/attachment.bin>
More information about the cfe-commits
mailing list