diff options
author | Younan Zhang <zyn7109@gmail.com> | 2024-05-05 11:38:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-05 11:38:49 +0800 |
commit | 7a484d3a1f630ba9ce7b22e744818be974971470 (patch) | |
tree | 7740392465eb15567a964270f8ec5d6b670433a5 /clang/lib/Basic/Module.cpp | |
parent | ffc9a30938ae5c42c03f9c563db1465876b4def6 (diff) | |
download | llvm-7a484d3a1f630ba9ce7b22e744818be974971470.zip llvm-7a484d3a1f630ba9ce7b22e744818be974971470.tar.gz llvm-7a484d3a1f630ba9ce7b22e744818be974971470.tar.bz2 |
[clang] Distinguish unresolved templates in UnresolvedLookupExpr (#89019)
This patch revolves around the misuse of UnresolvedLookupExpr in
BuildTemplateIdExpr.
Basically, we build up an UnresolvedLookupExpr not only for function
overloads but for "unresolved" templates wherever we need an expression
for template decls. For example, a dependent VarTemplateDecl can be
wrapped with such an expression before template instantiation. (See
https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9)
Also, one important thing is that UnresolvedLookupExpr uses a
"canonical"
QualType to describe the containing unresolved decls: a DependentTy is
for dependent expressions and an OverloadTy otherwise. Therefore, this
modeling for non-dependent templates leaves a problem in that the
expression
is marked and perceived as if describing overload functions. The
consumer then
expects functions for every such expression, although the fact is the
reverse.
Hence, we run into crashes.
As to the patch, I added a new canonical type "UnresolvedTemplateTy" to
model these cases. Given that we have been using this model
(intentionally or
accidentally) and it is pretty baked in throughout the code, I think
extending the role of UnresolvedLookupExpr is reasonable. Further, I
added
some diagnostics for the direct occurrence of these expressions, which
are supposed to be ill-formed.
As a bonus, this patch also fixes some typos in the diagnostics and
creates
RecoveryExprs rather than nothing in the hope of a better error-recovery
for clangd.
Fixes https://github.com/llvm/llvm-project/issues/88832
Fixes https://github.com/llvm/llvm-project/issues/63243
Fixes https://github.com/llvm/llvm-project/issues/48673
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
0 files changed, 0 insertions, 0 deletions