Skip to content

[Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) #70427

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 2 commits into from
Apr 29, 2024

Conversation

khei4
Copy link
Contributor

@khei4 khei4 commented Oct 27, 2023

This patch fixes the code example on CommonOptionParser on https://intel.github.io/llvm-docs/clang/LibTooling.html

CommonOptionParser's constructor is protected, and we can use CommonOptionParser::create instead of that.
It seems like the LibASTMatcher tutorial already uses that. https://clang.llvm.org/docs/LibASTMatchersTutorial.html

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 27, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 27, 2023

@llvm/pr-subscribers-clang

Author: Kohei Asano (khei4)

Changes

This patch fixes the code example on CommonOptionParser on https://intel.github.io/llvm-docs/clang/LibTooling.html

CommonOptionParser's constructor is protected and we can use CommonOptionParser::create instead of that.

I'm still not so sure whether other old examples are around there.


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

1 Files Affected:

  • (modified) clang/docs/LibTooling.rst (+1-1)
diff --git a/clang/docs/LibTooling.rst b/clang/docs/LibTooling.rst
index df50dcebf9b83c7..cf0e0d005f45e16 100644
--- a/clang/docs/LibTooling.rst
+++ b/clang/docs/LibTooling.rst
@@ -71,7 +71,7 @@ and automatic location of the compilation database using source files paths.
   int main(int argc, const char **argv) {
     // CommonOptionsParser constructor will parse arguments and create a
     // CompilationDatabase.  In case of error it will terminate the program.
-    CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
+    auto OptionsParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
 
     // Use OptionsParser.getCompilations() and OptionsParser.getSourcePathList()
     // to retrieve CompilationDatabase and the list of input file paths.

@khei4 khei4 marked this pull request as draft October 27, 2023 08:59
@khei4 khei4 force-pushed the khei4/fix-doc-on-commonParser branch 3 times, most recently from f9f61fd to 166f580 Compare October 27, 2023 09:45
@khei4 khei4 changed the title [Clang][Docs] use CommonOptionsParser::create instead of protected constructor (NFC) [Clang][Docs] use CommonOptionsParser::create instead of protected constructor on libTooling tutorial (NFC) Oct 27, 2023
@khei4 khei4 force-pushed the khei4/fix-doc-on-commonParser branch from d54e389 to 12e29c4 Compare October 27, 2023 10:22
@khei4 khei4 marked this pull request as ready for review October 27, 2023 12:12
@Xulei-NL
Copy link

Xulei-NL commented Apr 4, 2024

Nice that the author has created this PR for fixing the inconsistent LibTooling document. This PR is very important to clang LibTooling beginners. Could the reviewers please approve it soon? 😃

Copy link
Member

@Sirraide Sirraide left a comment

Choose a reason for hiding this comment

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

LGTM except for one minor issue.

@khei4 khei4 merged commit de6b2b9 into llvm:main Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants