Skip to content

Add clang-tidy external examples #106675

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

Conversation

MichelleCDjunaidi
Copy link
Contributor

@MichelleCDjunaidi MichelleCDjunaidi commented Aug 30, 2024

Motivation: Clang has a page where they list out external examples: https://clang.llvm.org/docs/ExternalClangExamples.html. While I was writing an out-of-tree clang-tidy plugin, I wanted such a page to exist also as it would have helped development. The example repo listed in the proposed page has been useful for me.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Aug 30, 2024

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: None (MichelleCDjunaidi)

Changes

Motivation: Clang has a page where they list out external examples: https://clang.llvm.org/docs/ExternalClangExamples.html. While I was writing an out-of-tree clang-tidy plugin, I wanted such a page to exist also as it would have helped development. The example repo listed in the proposed page has been useful for me.


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

1 Files Affected:

  • (added) clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst (+31)
diff --git a/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
new file mode 100644
index 00000000000000..735f99b30c7b7d
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/ExternalClang-TidyExamples.rst
@@ -0,0 +1,31 @@
+=======================
+External Clang-Tidy Examples
+=======================
+
+Introduction
+============
+
+This page provides examples of what people have done with clang-tidy that 
+might serve as useful guides (or starting points) to develop your own checks. 
+They may be helpful even for necessary things such as how to write CMakeLists.txt 
+for an out-of-tree plugin of clang-tidy checks.
+
+If you know of (or wrote!) a tool or project using clang-tidy, please post on
+`the Discourse forums (Clang Frontend category)
+<https://discourse.llvm.org/c/clang/6>`_ to have it added.
+(or if you are already a clang-tidy contributor, feel free to directly commit
+additions). Since the primary purpose of this page is to provide examples
+that can help developers, generally they must have code available.
+
+As clang-tidy shares C++ AST Matchers with Clang diagnostics, `External Clang Examples`_ 
+may also be useful to look at.
+
+.. _External Clang Examples: https://clang.llvm.org/docs/ExternalClangExamples.html
+
+https://clang.llvm.org/docs/ExternalClangExamples.html
+
+List of projects and tools
+==========================
+
+`<https://github.com/coveooss/clang-tidy-plugin-examples/tree/main>`_
+    "This folder contains clang-tidy plugins."
\ No newline at end of file

Copy link
Contributor

@5chmidti 5chmidti left a comment

Choose a reason for hiding this comment

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

Great idea to add this. Although, we should be careful to not end up with abandoned projects. I sampled three from the page in Clang, and they had their last activity at around ~10 years. At that point, API's have changed. Either way, adding external examples is a good idea IMO
(I should clean up my external clang-tidy template that's still private :) )

@MichelleCDjunaidi
Copy link
Contributor Author

Side note, but I don't have write permissions, so once the PR looks great feel free to land it on my behalf.

@MichelleCDjunaidi
Copy link
Contributor Author

@EugeneZelenko @5chmidti Thoughts on the fixed formatting? I followed index.rst convention.

Copy link
Member

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

One more nit. Otherwise looks good to me.

@MichelleCDjunaidi
Copy link
Contributor Author

I will need help to merge this once approved. Thank you so much!

@MichelleCDjunaidi
Copy link
Contributor Author

@5chmidti @SimplyDanny can anyone help merge this into main?

@SimplyDanny
Copy link
Member

There is an error in doc generation. Is it caused by the new file being added? Is there a configuration that needs adaption?

@MichelleCDjunaidi
Copy link
Contributor Author

I asked in the forums. https://discourse.llvm.org/t/fix-error-in-upstream-doc-generation-due-to-addition-of-new-section/81368. Hopefully someone knows what to add...

@HerrCai0907
Copy link
Contributor

You can add toctree in clang-tools-extra/docs/clang-tidy/index.rst
example commit: https://reviews.llvm.org/D54945

@MichelleCDjunaidi
Copy link
Contributor Author

Well, the documentation builds now thanks to @HerrCai0907. Does it look fine @SimplyDanny @5chmidti ?

@SimplyDanny SimplyDanny merged commit ce9a2c6 into llvm:main Sep 23, 2024
9 checks passed
Copy link

@MichelleCDjunaidi Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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

Successfully merging this pull request may close these issues.

6 participants