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

[SR-7904] AST dump - can't distinguish files #50439

Closed
swift-ci opened this issue Jun 6, 2018 · 3 comments
Closed

[SR-7904] AST dump - can't distinguish files #50439

swift-ci opened this issue Jun 6, 2018 · 3 comments
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 6, 2018

Previous ID SR-7904
Radar None
Original Reporter vinivendra (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee federicotrimboli (JIRA)
Priority Medium

md5: e0db89054e670caf17f75713f2da79ff

is duplicated by:

  • SR-513 Add file name for dumped files in AST

Issue Description:

The Swift compiler's -dump-ast functionality prints an output that doesn't include the file names, which can make it impossible to distinguish between different files.

For instance, when compiling two files a.swift and b.swift, both containing the code "private func foo() { }", with the command "$ swiftc b.swift a.swift -dump-ast", we get this output:

(source_file
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))
(source_file
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))

It would be very useful if this information included the file name (or, even better, the file path). Something like this:

(source_file "/path/to/a.swift"
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))
(source_file "/path/to/b.swift"
  (func_decl "foo()" interface type='() -> ()' access=private
    (parameter_list)
    (brace_stmt)))
@beccadax
Copy link
Contributor

This looks feasible—you'd just use the SourceFile::getFilename() method. Beware that getFilename() can return nullptr.

@swift-ci
Copy link
Collaborator Author

Comment by Vinicius Vendramini (JIRA)

Great, thanks! Out of curiosity, do you know any real cases in which that method would return nullptr?

I wanted to have finished this already but I just can't seem to compile the swift compiler 🙁

@swift-ci
Copy link
Collaborator Author

Comment by Federico Trimboli (JIRA)

I'm giving this issue a try with #17219. Let me know what you guys think!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

2 participants