This is a prep patch for changing SourceManager to return
`Optional<MemoryBufferRef>` instead of `MemoryBuffer`. With that change the
address of the MemoryBuffer will be gone, so instead use the start of the
buffer as the key for this map.
No functionality change intended, as it's expected that the pointer identity
matches between the buffers and the buffer data.
Radar-Id: rdar://
70139990
Differential Revision: https://reviews.llvm.org/D89136
/// The datastructure that holds the mapping between the active memory buffers
/// and the individual skip mappings.
using ExcludedPreprocessorDirectiveSkipMapping =
- llvm::DenseMap<const llvm::MemoryBuffer *,
- const PreprocessorSkippedRangeMapping *>;
+ llvm::DenseMap<const char *, const PreprocessorSkippedRangeMapping *>;
} // end namespace clang
std::pair<FileID, unsigned> HashFileOffset =
SourceMgr.getDecomposedLoc(HashLoc);
const llvm::MemoryBuffer *Buf = SourceMgr.getBuffer(HashFileOffset.first);
- auto It = ExcludedConditionalDirectiveSkipMappings->find(Buf);
+ if (!Buf)
+ return None;
+ auto It =
+ ExcludedConditionalDirectiveSkipMappings->find(Buf->getBufferStart());
if (It == ExcludedConditionalDirectiveSkipMappings->end())
return None;
/*RequiresNullTerminator=*/false),
*Entry->getStatus());
if (!Entry->getPPSkippedRangeMapping().empty() && PPSkipMappings)
- (*PPSkipMappings)[Result->Buffer.get()] =
+ (*PPSkipMappings)[Result->Buffer->getBufferStart()] =
&Entry->getPPSkippedRangeMapping();
return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(
std::unique_ptr<llvm::vfs::File>(std::move(Result)));