diff --git a/clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h b/clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h --- a/clang/include/clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h +++ b/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; + llvm::DenseMap; } // end namespace clang diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -380,7 +380,10 @@ std::pair 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; diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -252,7 +252,7 @@ /*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(std::move(Result)));