Skip to content

[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

Merged
merged 2 commits into from
Dec 18, 2024
Merged

Conversation

cor3ntin
Copy link
Contributor

@cor3ntin cor3ntin commented Sep 5, 2024

There are not a lot of outstanding known issues
with deducing this (besides #95112), so it
seems reasonable to claim full support.

Fixes #82780

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
@cor3ntin cor3ntin requested review from erichkeane, AaronBallman and Sirraide and removed request for erichkeane and AaronBallman September 5, 2024 19:05
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 5, 2024
@cor3ntin cor3ntin requested a review from erichkeane September 5, 2024 19:05
@llvmbot
Copy link
Member

llvmbot commented Sep 5, 2024

@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)

Changes

There are not a lot of outstanding known issues
with deducing this (besides #95112), so it
seems reasonable to claim full support.

Fixes #82780


Full diff: https://github.com/llvm/llvm-project/pull/107451.diff

3 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (+1)
  • (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1)
  • (modified) clang/test/Lexer/cxx-features.cpp (+1-1)
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
 

@erichkeane
Copy link
Collaborator

It appears that #95112 is actually pretty close... are we better off holding off on this until after that goes in?

@cor3ntin
Copy link
Contributor Author

cor3ntin commented Sep 5, 2024

There is no urgency. I made the pr so we don't forget (I certainly had...)

cor3ntin added a commit that referenced this pull request Dec 18, 2024
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]>
@cor3ntin
Copy link
Contributor Author

@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)
Copy link
Collaborator

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?

@cor3ntin cor3ntin merged commit 72e58e0 into llvm:main Dec 18, 2024
9 checks passed
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Dec 18, 2024
…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
H-G-Hristov added a commit to H-G-Hristov/llvm-project that referenced this pull request Feb 13, 2025
…TER macro

`__cpp_explicit_this_parameter` has been set in LLVM20
// llvm#107451
Zingam added a commit that referenced this pull request Feb 14, 2025
…TER macro (#127070)

`__cpp_explicit_this_parameter` has been set in LLVM20
#107451 /
72e58e0

---------

Co-authored-by: Hristo Hristov <[email protected]>
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 14, 2025
…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]>
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…TER macro (llvm#127070)

`__cpp_explicit_this_parameter` has been set in LLVM20
llvm#107451 /
llvm@72e58e0

---------

Co-authored-by: Hristo Hristov <[email protected]>
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…TER macro (llvm#127070)

`__cpp_explicit_this_parameter` has been set in LLVM20
llvm#107451 /
llvm@72e58e0

---------

Co-authored-by: Hristo Hristov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__cpp_explicit_this_parameter not set in clang-18
3 participants