Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (#140680)
For a dependent variable template specialization, we don't build a dependent Decl node or a DeclRefExpr to represent it. Instead, we preserve the UnresolvedLookupExpr until instantiation. However, this approach isn't ideal for constraint normalization. We consider the qualifier during profiling, but since that's based on the written code, it can introduce confusing differences, even when the expressions resolve to the same declaration. This change profiles the underlying VarTemplateDecl if UnresolvedLookupExpr is used to model a dependent use of it. Fixes https://github.com/llvm/llvm-project/issues/139476
This commit is contained in:
@@ -852,6 +852,7 @@ Bug Fixes to C++ Support
|
||||
- Fixed the handling of pack indexing types in the constraints of a member function redeclaration. (#GH138255)
|
||||
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
|
||||
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
|
||||
- Fixed a function declaration mismatch that caused inconsistencies between concepts and variable template declarations. (#GH139476)
|
||||
- Clang no longer segfaults when there is a configuration mismatch between modules and their users (http://crbug.com/400353616).
|
||||
- Fix an incorrect deduction when calling an explicit object member function template through an overload set address.
|
||||
- Fixed bug in constant evaluation that would allow using the value of a
|
||||
|
||||
@@ -2189,8 +2189,14 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
|
||||
|
||||
void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
|
||||
VisitExpr(S);
|
||||
VisitNestedNameSpecifier(S->getQualifier());
|
||||
VisitName(S->getName(), /*TreatAsDecl*/ true);
|
||||
bool DescribingDependentVarTemplate =
|
||||
S->getNumDecls() == 1 && isa<VarTemplateDecl>(*S->decls_begin());
|
||||
if (DescribingDependentVarTemplate) {
|
||||
VisitDecl(*S->decls_begin());
|
||||
} else {
|
||||
VisitNestedNameSpecifier(S->getQualifier());
|
||||
VisitName(S->getName(), /*TreatAsDecl*/ true);
|
||||
}
|
||||
ID.AddBoolean(S->hasExplicitTemplateArgs());
|
||||
if (S->hasExplicitTemplateArgs())
|
||||
VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
|
||||
|
||||
@@ -52,3 +52,24 @@ namespace AssignmentOp {
|
||||
D2 &operator=(const D2&); // expected-error {{more lax}}
|
||||
};
|
||||
}
|
||||
|
||||
namespace OverloadedFunctions {
|
||||
|
||||
template <typename T>
|
||||
void f(T&) noexcept;
|
||||
|
||||
template <typename T, int N>
|
||||
void f(T (&arr)[N]) noexcept(noexcept(f(*arr)));
|
||||
|
||||
template <typename T>
|
||||
inline void f(T&) noexcept {}
|
||||
|
||||
template <typename T, int N>
|
||||
inline void f(T (&arr)[N]) noexcept(noexcept(f(*arr))) {}
|
||||
|
||||
void g() {
|
||||
int x[1];
|
||||
f(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -853,3 +853,18 @@ template <int... Ts>
|
||||
requires C<Ts...[0]>
|
||||
auto TplClass<int>::buggy() -> void {}
|
||||
}
|
||||
|
||||
namespace GH139476 {
|
||||
|
||||
namespace moo {
|
||||
template <typename T>
|
||||
constexpr bool baa = true;
|
||||
|
||||
template <typename T> requires baa<T>
|
||||
void caw();
|
||||
}
|
||||
|
||||
template <typename T> requires moo::baa<T>
|
||||
void moo::caw() {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user