Quuxplusone requested changes to this revision. Quuxplusone added inline comments. This revision now requires changes to proceed.
================ Comment at: clang/lib/Sema/SemaLookup.cpp:4345 + return; } } ---------------- It seems like this code is overdue for a "compare these two corrections" //predicate//. The simple version would be ``` auto IsBetter = [&](const TypoCorrection& TC1, const TypoCorrection& TC2) { std::pair<bool, std::string> Key1 = { IsDeprecated(TC1.getFoundDecl()), TC1.getAsString(SemaRef.getLangOpts()) }; std::pair<bool, std::string> Key2 = { IsDeprecated(TC2.getFoundDecl()), TC2.getAsString(SemaRef.getLangOpts()) }; return Key1 < Key2; // prefer non-deprecated, alphabetically earlier declarations }; for (TypoCorrection& TC : CList) { if (IsBetter(Correction, TC)) TC = Correction; } ``` Actually, you could even replicate the hoisting of the loop-invariant stuff, the way the old code did: ``` std::pair<bool, std::string> CorrectionKey = { IsDeprecated(Correction.getFoundDecl()), Correction.getAsString(SemaRef.getLangOpts()) }; auto CorrectionIsBetterThan = [&](const TypoCorrection& TC) { std::pair<bool, std::string> Key = { IsDeprecated(TC.getFoundDecl()), TC.getAsString(SemaRef.getLangOpts()) }; return CorrectionKey < Key; // prefer non-deprecated, alphabetically earlier declarations }; for (TypoCorrection& TC : CList) { if (CorrectionIsBetterThan(TC)) TC = Correction; } ``` ================ Comment at: clang/test/SemaCXX/typo-correction.cpp:764-769 +namespace Views { +int Take(); // expected-note{{'Views::Take' declared here}} +} +namespace [[deprecated("use Views instead")]] View { +using Views::Take; +} ---------------- I suggest //three// namespaces, named `[[deprecated]] A`, `B`, and `[[deprecated]] C`, and declared in that lexical order too, so that no matter how the preference predicate is expressed, we're still testing that the non-deprecated (middle) declaration gets chosen. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116775/new/ https://reviews.llvm.org/D116775 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits