Skip to content

[Clang] Don't ditch typo-corrected lookup result #139374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,10 @@ Improvements to Clang's diagnostics

- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about overlapping and non-overlapping ranges involving character literals and floating-point literals.
The warning message for non-overlapping cases has also been improved (#GH13473).


- Fixed a duplicate diagnostic when performing typo correction on function template
calls with explicit template arguments. (#GH139226)

Improvements to Clang's time-trace
----------------------------------

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS,
if (Found.isAmbiguous()) {
Found.clear();
} else if (!Found.empty()) {
// Do not erase the typo-corrected result to avoid duplicated
// diagnostics.
AllowFunctionTemplatesInLookup = true;
Found.setLookupName(Corrected.getCorrection());
if (LookupCtx) {
std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
Expand Down
13 changes: 13 additions & 0 deletions clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,16 @@ namespace PR11856 {
}
}
}

namespace GH139226 {

struct Foo {
template <class T> void LookupWithID(); // expected-note {{declared here}}
};

void test(Foo &f) {
f.LookupWithId<int>();
// expected-error@-1 {{did you mean 'LookupWithID'}}
}

}