[clang] 9c1c221 - [Clang] Correctly handle callees whose type is a Record type when classifying expressions (#68078)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 3 10:38:51 PDT 2023


Author: cor3ntin
Date: 2023-10-03T19:38:45+02:00
New Revision: 9c1c2211693cd14b23c3899e95af1ba3129ab5db

URL: https://github.com/llvm/llvm-project/commit/9c1c2211693cd14b23c3899e95af1ba3129ab5db
DIFF: https://github.com/llvm/llvm-project/commit/9c1c2211693cd14b23c3899e95af1ba3129ab5db.diff

LOG: [Clang] Correctly handle callees whose type is a Record type when classifying expressions (#68078)

when the callee is an object.

When implementing deducing this, we changed
`DeduceTemplateArgumentsFromCallArgument` to take an argument
classification because we need to deduce the type of argument for which
we might not have an expression yet.

However classifying a dependent call expression whose type is just some
sort of record or elaborated type was not supported.

Fixes #68024

Added: 
    

Modified: 
    clang/lib/AST/Expr.cpp
    clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 99e89aeafc24217..4bfc4f082cd6a69 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1621,6 +1621,10 @@ QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
     // This should never be overloaded and so should never return null.
     CalleeType = Expr::findBoundMemberType(Callee);
     assert(!CalleeType.isNull());
+  } else if (CalleeType->isRecordType()) {
+    // If the Callee is a record type, then it is a not-yet-resolved
+    // dependent call to the call operator of that type.
+    return Ctx.DependentTy;
   } else if (CalleeType->isDependentType() ||
              CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
     return Ctx.DependentTy;

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
index 6ab9ecbfd573b25..22788e1c1ffb3ac 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -603,3 +603,15 @@ namespace PR47792 {
   template void bar<>();    // expected-note {{previous explicit instantiation is here}}
   template void bar<foo>(); // expected-error {{duplicate explicit instantiation of 'bar<&PR47792::foo>'}}
 }
+
+namespace GH68024 {
+template<auto>
+struct s {};
+
+struct {
+  void operator()(int);
+} f;
+
+template<typename T>
+using a = s<f(T::x)>;
+}


        


More information about the cfe-commits mailing list