dexonsmith created this revision. dexonsmith added a reviewer: arphaman. Herald added a subscriber: ributzka. dexonsmith requested review of this revision.
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 https://reviews.llvm.org/D89136 Files: clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h clang/lib/Lex/PPDirectives.cpp clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -219,7 +219,9 @@ llvm::ErrorOr<llvm::vfs::Status> status() override { return Stat; } - const llvm::MemoryBuffer *getBufferPtr() const { return Buffer.get(); } + const char *getBufferPtr() const { + return Buffer ? nullptr : Buffer->getBufferStart(); + } llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -380,7 +380,10 @@ 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; Index: clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h =================================================================== --- clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h +++ clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h @@ -23,8 +23,7 @@ /// 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
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -219,7 +219,9 @@ llvm::ErrorOr<llvm::vfs::Status> status() override { return Stat; } - const llvm::MemoryBuffer *getBufferPtr() const { return Buffer.get(); } + const char *getBufferPtr() const { + return Buffer ? nullptr : Buffer->getBufferStart(); + } llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -380,7 +380,10 @@ 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; Index: clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h =================================================================== --- clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h +++ clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h @@ -23,8 +23,7 @@ /// 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits