This is an archive of the discontinued LLVM Phabricator instance.

Lex: Avoid MemoryBuffer* key in ExcludedPreprocessorDirectiveSkipMapping, NFC
ClosedPublic

Authored by dexonsmith on Oct 9 2020, 8:46 AM.

Details

Summary

This is a prep patch for https://reviews.llvm.org/D66782, 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.

Radar-Id: rdar://70139990

Diff Detail

Event Timeline

dexonsmith created this revision.Oct 9 2020, 8:46 AM
arphaman added inline comments.Oct 12 2020, 9:53 AM
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
224

Looking over the code this method doesn't seem necessary anymore. Can you get the buffer pointer in createFile down below, after llvm::MemoryBuffer::getMemBuffer(*Contents, Entry->getName(), /*RequiresNullTerminator=*/false) is constructed?

dexonsmith marked an inline comment as done.

Agreed, looks cleaner without the indirection.

arphaman accepted this revision.Oct 12 2020, 12:42 PM
arphaman added inline comments.
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
255

Buffer is private, does this work here, or do you need a friend? Either way, LGTM

This revision is now accepted and ready to land.Oct 12 2020, 12:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2020, 2:39 PM

I cleaned up the access and removed getBufferPtr separately in d07b290e4b7c55823895e88b683de4178ffc66db, then landed my change in 69feac12d0539a7cc19cbda906d46f67029486e1.