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

[сlang] Representation of ellipsis in AST #63106

Open
Endilll opened this issue Jun 4, 2023 · 4 comments · May be fixed by #80976
Open

[сlang] Representation of ellipsis in AST #63106

Endilll opened this issue Jun 4, 2023 · 4 comments · May be fixed by #80976
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@Endilll
Copy link
Contributor

Endilll commented Jun 4, 2023

Consider the following snippet with different usages of ellipsis:

void foo() {
  try {}
  catch(...){} // #1
}

void bar(int, ...); // #2

clang -Xclang -ast-dump outputs the following (omitting built-in typedefs):

TranslationUnitDecl
|-FunctionDecl <line:1:1, line:4:1> line:1:6 foo 'void ()'
| `-CompoundStmt <col:12, line:4:1>
|   `-CXXTryStmt <line:2:3, line:3:14>
|     |-CompoundStmt <line:2:7, col:8>
|     `-CXXCatchStmt <line:3:3, col:14>
|       |-<<<NULL>>>
|       `-CompoundStmt <col:13, col:14>
`-FunctionDecl <line:6:1, col:18> col:6 bar 'void (int, ...)'
  `-ParmVarDecl <col:10> col:13 'int'

The first ellipsis (catch-all) is represented by <<<NULL>>> which comes from

OS << "<<<NULL>>>";

The second ellipsis (vararg) is not represented at all.
Are those representations (or lack of thereof) by design? Is this inconsistency intentional?
https://godbolt.org/z/EafKE5KWs

@Endilll Endilll added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Jun 4, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 4, 2023

@llvm/issue-subscribers-clang-frontend

@Endilll Endilll changed the title [Clang] Representation of ellipsis in AST [сlang] Representation of ellipsis in AST Jun 4, 2023
@AaronBallman AaronBallman added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Jun 12, 2023
@AaronBallman
Copy link
Collaborator

I believe the null pointers are by design, but I don't think that design is a particularly good one. For example, having NULL pointer child nodes in the AST makes it harder to write a correct recursive AST visitor because you have to watch out for instances where NULL occurs with special meaning. I think it would be better to use a concrete AST node instead of an in-band indicator.

@shahidiqbal13
Copy link
Contributor

Hi @Endilll, @AaronBallman Can anyone of you assign this task to me so that I could work

@Endilll Endilll added confirmed Verified by a second party and removed question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! labels Jan 13, 2024
@Endilll
Copy link
Contributor Author

Endilll commented Jan 13, 2024

@shahidiqbal13 Sure! But assignment is not formal or binding in any way: everyone can work on anything they want in LLVM project.

shahidiqbal13 added a commit to shahidiqbal13/llvm-project that referenced this issue Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants