Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -8634,7 +8634,7 @@ // Map the FromID to the "to" source manager. FileID ToID; if (FromSLoc.isExpansion()) { - const SrcMgr::ExpansionInfo &FromEx = FromSLoc.getExpansion(); + SrcMgr::ExpansionInfo FromEx = FromSLoc.getExpansion(); ExpectedSLoc ToSpLoc = Import(FromEx.getSpellingLoc()); if (!ToSpLoc) return ToSpLoc.takeError(); @@ -8654,11 +8654,12 @@ } ToID = ToSM.getFileID(MLoc); } else { - const SrcMgr::ContentCache *Cache = &FromSLoc.getFile().getContentCache(); + SrcMgr::FileInfo FromFI = FromSLoc.getFile(); + const SrcMgr::ContentCache *Cache = &FromFI.getContentCache(); if (!IsBuiltin && !Cache->BufferOverridden) { // Include location of this file. - ExpectedSLoc ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc()); + ExpectedSLoc ToIncludeLoc = Import(FromFI.getIncludeLoc()); if (!ToIncludeLoc) return ToIncludeLoc.takeError(); @@ -8683,7 +8684,7 @@ // the memory buffer below. if (Entry) ToID = ToSM.createFileID(*Entry, ToIncludeLocOrFakeLoc, - FromSLoc.getFile().getFileCharacteristic()); + FromFI.getFileCharacteristic()); } } @@ -8698,8 +8699,8 @@ std::unique_ptr ToBuf = llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(), FromBuf->getBufferIdentifier()); - ToID = ToSM.createFileID(std::move(ToBuf), - FromSLoc.getFile().getFileCharacteristic()); + ToID = + ToSM.createFileID(std::move(ToBuf), FromFI.getFileCharacteristic()); } }