[clang] [Clang] prevent null explicit object argument from being deduced (PR #104328)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 15 01:22:09 PDT 2024
================
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++2b -verify %s
+
+namespace std {
+struct rv {};
+
+template <bool B, typename T> struct enable_if;
+template <typename T> struct enable_if<true, T> { typedef T type; };
+
+template <typename U, typename T>
+typename enable_if<__is_convertible(T, rv), U>::type forward(T &);
+template <typename U, typename T>
+typename enable_if<!__is_convertible(T, rv), U &>::type forward(T &);
+}
----------------
a-tarasyuk wrote:
@mizvekov Thanks for the feedback. I thought it would be better/safe to explicitly exclude cases where `ObjectType` is used as `ArgType` for the first parameter when the function has `HasExplicitObject`, as this could cause crashes...
https://github.com/llvm/llvm-project/blob/fa343be414f9364911b947f109f3df5539e23068/clang/lib/Sema/SemaTemplateDeduction.cpp#L4371
In other cases, `ArgType` will be based on the arg index. That’s why I added this condition before
https://github.com/llvm/llvm-project/blob/fa343be414f9364911b947f109f3df5539e23068/clang/lib/Sema/SemaTemplateDeduction.cpp#L4464
Or should we completely avoid using `DeduceTemplateArguments` with an empty `ObjectType`?
https://github.com/llvm/llvm-project/blob/6d9cae12bdfcaeb2be10866e20e8883242f02c6c/clang/lib/Sema/SemaOverload.cpp#L7730
I'd appreciate your perspective on that. Thanks
https://github.com/llvm/llvm-project/pull/104328
More information about the cfe-commits
mailing list