This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG4761321d49db: [Analyzer][solver][NFC] print constraints deterministically (ordered by their… (authored by martong).
Changed prior to commit: https://reviews.llvm.org/D106642?vs=361142&id=361648#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106642/new/ https://reviews.llvm.org/D106642 Files: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -2630,6 +2630,13 @@ printDisequalities(Out, State, NL, Space, IsDot); } +static std::string toString(const SymbolRef &Sym) { + std::string S; + llvm::raw_string_ostream O(S); + Sym->dumpToStream(O); + return O.str(); +} + void RangeConstraintManager::printConstraints(raw_ostream &Out, ProgramStateRef State, const char *NL, @@ -2643,25 +2650,32 @@ return; } - ++Space; - Out << '[' << NL; - bool First = true; + std::map<std::string, RangeSet> OrderedConstraints; for (std::pair<EquivalenceClass, RangeSet> P : Constraints) { SymbolSet ClassMembers = P.first.getClassMembers(State); + for (const SymbolRef &ClassMember : ClassMembers) { + bool insertion_took_place; + std::tie(std::ignore, insertion_took_place) = + OrderedConstraints.insert({toString(ClassMember), P.second}); + assert(insertion_took_place && + "two symbols should not have the same dump"); + } + } - // We can print the same constraint for every class member. - for (SymbolRef ClassMember : ClassMembers) { - if (First) { - First = false; - } else { - Out << ','; - Out << NL; - } - Indent(Out, Space, IsDot) - << "{ \"symbol\": \"" << ClassMember << "\", \"range\": \""; - P.second.dump(Out); - Out << "\" }"; + ++Space; + Out << '[' << NL; + bool First = true; + for (std::pair<std::string, RangeSet> P : OrderedConstraints) { + if (First) { + First = false; + } else { + Out << ','; + Out << NL; } + Indent(Out, Space, IsDot) + << "{ \"symbol\": \"" << P.first << "\", \"range\": \""; + P.second.dump(Out); + Out << "\" }"; } Out << NL; @@ -2669,13 +2683,6 @@ Indent(Out, Space, IsDot) << "]," << NL; } -static std::string toString(const SymbolRef &Sym) { - std::string S; - llvm::raw_string_ostream O(S); - Sym->dumpToStream(O); - return O.str(); -} - static std::string toString(ProgramStateRef State, EquivalenceClass Class) { SymbolSet ClassMembers = Class.getClassMembers(State); llvm::SmallVector<SymbolRef, 8> ClassMembersSorted(ClassMembers.begin(),
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -2630,6 +2630,13 @@ printDisequalities(Out, State, NL, Space, IsDot); } +static std::string toString(const SymbolRef &Sym) { + std::string S; + llvm::raw_string_ostream O(S); + Sym->dumpToStream(O); + return O.str(); +} + void RangeConstraintManager::printConstraints(raw_ostream &Out, ProgramStateRef State, const char *NL, @@ -2643,25 +2650,32 @@ return; } - ++Space; - Out << '[' << NL; - bool First = true; + std::map<std::string, RangeSet> OrderedConstraints; for (std::pair<EquivalenceClass, RangeSet> P : Constraints) { SymbolSet ClassMembers = P.first.getClassMembers(State); + for (const SymbolRef &ClassMember : ClassMembers) { + bool insertion_took_place; + std::tie(std::ignore, insertion_took_place) = + OrderedConstraints.insert({toString(ClassMember), P.second}); + assert(insertion_took_place && + "two symbols should not have the same dump"); + } + } - // We can print the same constraint for every class member. - for (SymbolRef ClassMember : ClassMembers) { - if (First) { - First = false; - } else { - Out << ','; - Out << NL; - } - Indent(Out, Space, IsDot) - << "{ \"symbol\": \"" << ClassMember << "\", \"range\": \""; - P.second.dump(Out); - Out << "\" }"; + ++Space; + Out << '[' << NL; + bool First = true; + for (std::pair<std::string, RangeSet> P : OrderedConstraints) { + if (First) { + First = false; + } else { + Out << ','; + Out << NL; } + Indent(Out, Space, IsDot) + << "{ \"symbol\": \"" << P.first << "\", \"range\": \""; + P.second.dump(Out); + Out << "\" }"; } Out << NL; @@ -2669,13 +2683,6 @@ Indent(Out, Space, IsDot) << "]," << NL; } -static std::string toString(const SymbolRef &Sym) { - std::string S; - llvm::raw_string_ostream O(S); - Sym->dumpToStream(O); - return O.str(); -} - static std::string toString(ProgramStateRef State, EquivalenceClass Class) { SymbolSet ClassMembers = Class.getClassMembers(State); llvm::SmallVector<SymbolRef, 8> ClassMembersSorted(ClassMembers.begin(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits