Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -8481,6 +8481,10 @@ } } NextCursor: + // De-serialized SourceLocations get negative FileIDs for other modules, + // potentially invalidating the original order. Sort it again. + std::sort(Comments.begin(), Comments.end(), + BeforeThanCompare(SourceMgr)); Context.Comments.addDeserializedComments(Comments); } }