Skip to content

Add an API for clang dependency scanner to perform module lookup by name alone #3127

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 7 commits into from
Sep 7, 2021

Conversation

ahatanaka
Copy link

Rebase onto next branch. The old pull request is here: #3099.

Copy link

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

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

Nice work, this is getting closer!

Copy link

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

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

I think the tests need a bit more work, they don't need to test unrelated functionality. Besides that, I only have a couple of small nits.

…list of

module and file dependencies of a module for a particular compiler invocation

rdar://64538073
- Define a subclass of FrontendAction and call loadModule there.
- Remove the API for creating a worker just for
  clang_experimental_DependencyScannerWorkerByModName_getFileDependencies_v1.
- Add the capability to get the dependencies based on the module name to
  clang-scan-deps.
- Create a fake virtual source file instead of asking users to create
  one and pass it to the command line.
- Remove the "translation-units" output from test case
  modules-full-by-mod-name.cpp. The information isn't useful as the
  source file name isn't passed on the command line in this case.
- Inherit from `PreprocessOnlyAction`.
- Rebase.
- Rename functions.
- Remove unneeded test cases.
- Remove member `ModuleName` and thread it through functions. Remove
  member `FakeMemBuffer` too and make it a variable inside
  `computeDependencies`.
- Use `MemoryBufferRef` instead of `MemoryBuffer *`.
- Use `StringRef` instead of `const char *`.
Copy link

@jansvoboda11 jansvoboda11 left a comment

Choose a reason for hiding this comment

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

Left one last nit inline. Not sure how we usually treat PRs, but I think it'd be nice to squash the commits and give this PR more descriptive name.

- Use Optional<String> as the type of ModuleName.
- Add comments explaining what happens if the passed ModuleName isn't
  empty.
@jansvoboda11
Copy link

LGTM, thanks for working through this Akira! @Bigcheese, @hyp, @dexonsmith do you have any additional feedback?

@ahatanaka ahatanaka changed the title Fix rdar://64538073 Build an API for Clang dependency scanner to perform module lookup by name alone Sep 7, 2021
@ahatanaka ahatanaka changed the title Build an API for Clang dependency scanner to perform module lookup by name alone Add an API for clang dependency scanner to perform module lookup by name alone Sep 7, 2021
@ahatanaka ahatanaka merged commit 2a3e8df into next Sep 7, 2021
@ahatanaka ahatanaka deleted the PR-64538073-new branch September 7, 2021 05:24
ahatanaka added a commit that referenced this pull request Sep 7, 2021
…ame alone (#3127)

* [clang][clang-scan-deps] Add an experimental C API for returning the list of
module and file dependencies of a module for a particular compiler invocation

rdar://64538073

* Address review comments

- Define a subclass of FrontendAction and call loadModule there.
- Remove the API for creating a worker just for
  clang_experimental_DependencyScannerWorkerByModName_getFileDependencies_v1.
- Add the capability to get the dependencies based on the module name to
  clang-scan-deps.

* Address review comments

- Create a fake virtual source file instead of asking users to create
  one and pass it to the command line.
- Remove the "translation-units" output from test case
  modules-full-by-mod-name.cpp. The information isn't useful as the
  source file name isn't passed on the command line in this case.
- Inherit from `PreprocessOnlyAction`.

* Address review comments

* Address review comments

- Rebase.
- Rename functions.
- Remove unneeded test cases.

* Address review comments

- Remove member `ModuleName` and thread it through functions. Remove
  member `FakeMemBuffer` too and make it a variable inside
  `computeDependencies`.
- Use `MemoryBufferRef` instead of `MemoryBuffer *`.
- Use `StringRef` instead of `const char *`.

* Address review comments

- Use Optional<String> as the type of ModuleName.
- Add comments explaining what happens if the passed ModuleName isn't
  empty.

(cherry picked from commit 2a3e8df)

Conflicts:
	clang/tools/libclang/libclang.map
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.

4 participants