-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang] Set __cpp_explicit_this_parameter
#107451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There are not a lot of outstanding known issues with deducing this (besides llvm#95112), so it seems reasonable to claim full support. Fixes llvm#82780
@llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) ChangesThere are not a lot of outstanding known issues Fixes #82780 Full diff: https://github.com/llvm/llvm-project/pull/107451.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ab3c3e6049f602..d57fef62b4bcfd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -365,6 +365,7 @@ Bug Fixes to C++ Support
- Fixed a bug in the substitution of empty pack indexing types. (#GH105903)
- Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048)
- Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
+- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
Bug Fixes to AST Handling
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 61260a3379828d..c0460889086d94 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -753,6 +753,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
Builder.defineMacro("__cpp_if_consteval", "202106L");
Builder.defineMacro("__cpp_multidimensional_subscript", "202211L");
Builder.defineMacro("__cpp_auto_cast", "202110L");
+ Builder.defineMacro("__cpp_explicit_this_parameter", "202110L");
}
// We provide those C++23 features as extensions in earlier language modes, so
diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index 4a06d29ae9dbc6..34a9d56c581fcd 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -81,7 +81,7 @@
#error "wrong value for __cpp_named_character_escapes"
#endif
-#if check(explicit_this_parameter, 0, 0, 0, 0, 0, 0, 0)
+#if check(explicit_this_parameter, 0, 0, 0, 0, 0, 202110L, 202110L)
#error "wrong value for __cpp_explicit_this_parameter"
#endif
|
It appears that #95112 is actually pretty close... are we better off holding off on this until after that goes in? |
There is no urgency. I made the pr so we don't forget (I certainly had...) |
This is a rebase of #95112 with my own feedback apply as @MitalAshok has been inactive for a while. It's fairly important this makes clang 20 as it is a blocker for #107451 --- [CWG2813](https://cplusplus.github.io/CWG/issues/2813.html) prvalue.member_fn(expression-list) now will not materialize a temporary for prvalue if member_fn is an explicit object member function, and prvalue will bind directly to the object parameter. The E1 in E1.static_member is now a discarded-value expression, so if E1 was a call to a [[nodiscard]] function, there will now be a warning. This also affects C++98 with [[gnu::warn_unused_result]] functions. This should not affect C where TemporaryMaterializationConversion is a no-op. Closes #100314 Fixes #100341 --------- Co-authored-by: Mital Ashok <[email protected]>
@erichkeane ping |
@@ -272,6 +272,8 @@ C++23 Feature Support | |||
|
|||
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully | |||
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_. | |||
|
|||
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a nit, "is now defined to the value specified in the C++X specification."
perhaps?
…0223) This is a rebase of llvm#95112 with my own feedback apply as @MitalAshok has been inactive for a while. It's fairly important this makes clang 20 as it is a blocker for llvm#107451 Change-Id: I2261810f7c8d7dd8b3e3412c0814a528d7c7b91c --- [CWG2813](https://cplusplus.github.io/CWG/issues/2813.html) prvalue.member_fn(expression-list) now will not materialize a temporary for prvalue if member_fn is an explicit object member function, and prvalue will bind directly to the object parameter. The E1 in E1.static_member is now a discarded-value expression, so if E1 was a call to a [[nodiscard]] function, there will now be a warning. This also affects C++98 with [[gnu::warn_unused_result]] functions. This should not affect C where TemporaryMaterializationConversion is a no-op. Closes llvm#100314 Fixes llvm#100341 --------- Co-authored-by: Mital Ashok <[email protected]> (cherry picked from commit db93ef1) Change-Id: Ic277d16bc8611b9d383cb890da3eda0ef1646555
…TER macro `__cpp_explicit_this_parameter` has been set in LLVM20 // llvm#107451
…TER macro (#127070) `__cpp_explicit_this_parameter` has been set in LLVM20 #107451 / 72e58e0 --------- Co-authored-by: Hristo Hristov <[email protected]>
…THIS_PARAMETER macro (#127070) `__cpp_explicit_this_parameter` has been set in LLVM20 llvm/llvm-project#107451 / llvm/llvm-project@72e58e0 --------- Co-authored-by: Hristo Hristov <[email protected]>
…TER macro (llvm#127070) `__cpp_explicit_this_parameter` has been set in LLVM20 llvm#107451 / llvm@72e58e0 --------- Co-authored-by: Hristo Hristov <[email protected]>
…TER macro (llvm#127070) `__cpp_explicit_this_parameter` has been set in LLVM20 llvm#107451 / llvm@72e58e0 --------- Co-authored-by: Hristo Hristov <[email protected]>
There are not a lot of outstanding known issues
with deducing this (besides #95112), so it
seems reasonable to claim full support.
Fixes #82780