Skip to content

Commit f0ccd97

Browse files
committed
Fix crash in hash_value for SILLocation
We should not dereference the file position if this SILLocation is not a position. If it's a pointer, we compare the pointers. (cherry picked from commit bc3bf84)
1 parent 961c49e commit f0ccd97

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/swift/SIL/SILLocation.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,13 @@ class SILLocation {
520520
};
521521

522522
inline llvm::hash_code hash_value(const SILLocation &R) {
523-
return llvm::hash_combine(R.kindAndFlags.packedKindAndFlags,
524-
*R.storage.filePositionLoc);
523+
if (R.isFilenameAndLocation()) {
524+
return llvm::hash_combine(R.kindAndFlags.packedKindAndFlags,
525+
*R.storage.filePositionLoc);
526+
} else {
527+
return llvm::hash_combine(R.kindAndFlags.packedKindAndFlags,
528+
R.storage.filePositionLoc);
529+
}
525530
}
526531

527532
inline llvm::hash_code hash_value(const SILLocation::FilenameAndLocation &R) {

0 commit comments

Comments
 (0)