Skip to content
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

Add mangling for a call expression with semantically significant parentheses #196

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hubert-reinterpretcast
Copy link

@hubert-reinterpretcast
Copy link
Author

Notes re: CWG 2946:

  • Under the current wording of the ISO/IEC C++ Working Draft, the cp mangling is insufficient because (as reported in CWG 2946) the resolution of CWG 1321 does not apply to cases with parentheses.
  • Additional cases that use the cl mangling may require different manglings after CWG 2946 is resolved (e.g., for friend declarations); however, the case for using the cp mangling is expected to remain.
  • The implementation of cp mangling in Clang suffers from issues related to CWG 2946 because cases that mangle differently (between cl and cp) are considered to have equivalent types.

@@ -5675,6 +5675,7 @@ <h4><a href="#expressions">5.1.6 Expressions</a></h4>
::= pp_ &lt;<a href="#mangle.expression">expression</a>&gt; # prefix ++
::= mm_ &lt;<a href="#mangle.expression">expression</a>&gt; # prefix --
::= cl &lt;<a href="#mangle.expression">expression</a>&gt;+ E # expression (expr-list), call
::= cp &lt;<a href="#mangle.base-unresolved-name">base-unresolved-name</a>&gt; &lt;<a href="#mangle.expression">expression</a>&gt;* E # (name) (expr-list), call that would use argument-dependent lookup but for the parentheses
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this merits a paragraph below explaining the rule exactly. Maybe something like this:

In C++, a call expression where the callee operand is an unqualified name uses argument-dependent lookup unless unqualified lookup finds certain kinds of declarations; see [class.lookup.argdep]p3. Because this rule does not apply when the name is parenthesized, it is sometimes necessary to distinguish parenthesized and unparenthesized calls in the mangling, despite the general rule that parentheses can be ignored. This is encoded using the choice of cl or cp for the call expression. The cp mangling is used only when the callee operand is a parenthesized unresolved name and would have used ADL if it were not parenthesized. In particular, cl is still used when unqualified lookup finds a declaration that would suppress the use of ADL, such as a class member.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the paragraph. I indicated that the reference is to C++11 because the paragraph number for the rule was different before and has since changed. The wording around the block scope case was not present in C++03.

abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
abi.html Outdated Show resolved Hide resolved
Copy link
Collaborator

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. I'll leave this up for a week for further comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants