|
25 | 25 | #include "llvm/ADT/DenseMap.h"
|
26 | 26 | #include "llvm/ADT/DenseSet.h"
|
27 | 27 | #include "llvm/ADT/FoldingSet.h"
|
| 28 | +#include "llvm/ADT/ImmutableSet.h" |
28 | 29 | #include "llvm/ADT/iterator_range.h"
|
29 | 30 | #include "llvm/Support/Allocator.h"
|
30 | 31 | #include <cassert>
|
@@ -710,4 +711,35 @@ class SymbolVisitor {
|
710 | 711 |
|
711 | 712 | } // namespace clang
|
712 | 713 |
|
| 714 | +// Override the default definition that would use pointer values of SymbolRefs |
| 715 | +// to order them, which is unstable due to ASLR. |
| 716 | +// Use the SymbolID instead which reflect the order in which the symbols were |
| 717 | +// allocated. This is usually stable across runs leading to the stability of |
| 718 | +// ConstraintMap and other containers using SymbolRef as keys. |
| 719 | +template <> |
| 720 | +struct ::llvm::ImutContainerInfo<clang::ento::SymbolRef> |
| 721 | + : public ImutProfileInfo<clang::ento::SymbolRef> { |
| 722 | + using value_type = |
| 723 | + typename ImutProfileInfo<clang::ento::SymbolRef>::value_type; |
| 724 | + using value_type_ref = |
| 725 | + typename ImutProfileInfo<clang::ento::SymbolRef>::value_type_ref; |
| 726 | + using key_type = value_type; |
| 727 | + using key_type_ref = value_type_ref; |
| 728 | + using data_type = bool; |
| 729 | + using data_type_ref = bool; |
| 730 | + |
| 731 | + static key_type_ref KeyOfValue(value_type_ref D) { return D; } |
| 732 | + static data_type_ref DataOfValue(value_type_ref) { return true; } |
| 733 | + |
| 734 | + static bool isEqual(key_type_ref LHS, key_type_ref RHS) { |
| 735 | + return LHS->getSymbolID() == RHS->getSymbolID(); |
| 736 | + } |
| 737 | + |
| 738 | + static bool isLess(key_type_ref LHS, key_type_ref RHS) { |
| 739 | + return LHS->getSymbolID() < RHS->getSymbolID(); |
| 740 | + } |
| 741 | + |
| 742 | + static bool isDataEqual(data_type_ref, data_type_ref) { return true; } |
| 743 | +}; |
| 744 | + |
713 | 745 | #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
|
0 commit comments