[clang] Revert "[Clang][Sema] Fix crash when using name of UnresolvedUsingValueDecl with template arguments (#83842)" (PR #84457)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 02:53:43 PST 2024
https://github.com/sdkrystian created https://github.com/llvm/llvm-project/pull/84457
This reverts commit a642eb89bdaf10c6b4994fc1187de27b441236ed.
>From 02f98e180b94bec0c6abafeaaf8a7513f5116eab Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Fri, 8 Mar 2024 05:44:48 -0500
Subject: [PATCH] Revert "[Clang][Sema] Fix crash when using name of
UnresolvedUsingValueDecl with template arguments (#83842)"
This reverts commit a642eb89bdaf10c6b4994fc1187de27b441236ed.
---
clang/docs/ReleaseNotes.rst | 2 --
clang/lib/Sema/SemaDecl.cpp | 5 +---
clang/lib/Sema/SemaTemplate.cpp | 10 +++----
.../unqual-unresolved-using-value.cpp | 30 -------------------
4 files changed, 5 insertions(+), 42 deletions(-)
delete mode 100644 clang/test/SemaTemplate/unqual-unresolved-using-value.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 225ca85e18115d..0ee2801766a9cc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -332,8 +332,6 @@ Bug Fixes to C++ Support
our attention by an attempt to fix in (#GH77703). Fixes (#GH83385).
- Fix evaluation of some immediate calls in default arguments.
Fixes (#GH80630)
-- Fix a crash when an explicit template argument list is used with a name for which lookup
- finds a non-template function and a dependent using declarator.
- Fixed an issue where the ``RequiresExprBody`` was involved in the lambda dependency
calculation. (#GH56556), (#GH82849).
- Fix a bug where overload resolution falsely reported an ambiguity when it was comparing
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 910d0dfbf9f65f..1f4a041e88dfff 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1110,9 +1110,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS,
// unqualified-id followed by a < and name lookup finds either one
// or more functions or finds nothing.
if (!IsFilteredTemplateName)
- FilterAcceptableTemplateNames(Result,
- /*AllowFunctionTemplates=*/true,
- /*AllowDependent=*/true);
+ FilterAcceptableTemplateNames(Result);
bool IsFunctionTemplate;
bool IsVarTemplate;
@@ -1122,7 +1120,6 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS,
Template = Context.getOverloadedTemplateName(Result.begin(),
Result.end());
} else if (!Result.empty()) {
- assert(!Result.isUnresolvableResult());
auto *TD = cast<TemplateDecl>(getAsTemplateNameDecl(
*Result.begin(), /*AllowFunctionTemplates=*/true,
/*AllowDependent=*/false));
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7e91815c2d52a8..83eee83aa6cad8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -491,20 +491,18 @@ bool Sema::LookupTemplateName(LookupResult &Found,
// To keep our behavior consistent, we apply the "finds nothing" part in
// all language modes, and diagnose the empty lookup in ActOnCallExpr if we
// successfully form a call to an undeclared template-id.
- bool AnyFunctions =
- getLangOpts().CPlusPlus20 && llvm::any_of(Found, [](NamedDecl *ND) {
+ bool AllFunctions =
+ getLangOpts().CPlusPlus20 && llvm::all_of(Found, [](NamedDecl *ND) {
return isa<FunctionDecl>(ND->getUnderlyingDecl());
});
- if (AnyFunctions || (Found.empty() && !IsDependent)) {
+ if (AllFunctions || (Found.empty() && !IsDependent)) {
// If lookup found any functions, or if this is a name that can only be
// used for a function, then strongly assume this is a function
// template-id.
*ATK = (Found.empty() && Found.getLookupName().isIdentifier())
? AssumedTemplateKind::FoundNothing
: AssumedTemplateKind::FoundFunctions;
- FilterAcceptableTemplateNames(Found,
- /*AllowFunctionTemplates*/ true,
- /*AllowDependent*/ true);
+ Found.clear();
return false;
}
}
diff --git a/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp b/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp
deleted file mode 100644
index 688e7a0a10b779..00000000000000
--- a/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
-
-template<typename T>
-struct A : T {
- using T::f;
- using T::g;
- using T::h;
-
- void f();
- void g();
-
- void i() {
- f<int>();
- g<int>(); // expected-error{{no member named 'g' in 'A<B>'}}
- h<int>(); // expected-error{{expected '(' for function-style cast or type construction}}
- // expected-error at -1{{expected expression}}
- }
-};
-
-struct B {
- template<typename T>
- void f();
-
- void g();
-
- template<typename T>
- void h();
-};
-
-template struct A<B>; // expected-note{{in instantiation of member function 'A<B>::i' requested here}}
More information about the cfe-commits
mailing list