Skip to content

Commit ed05f89

Browse files
committed
[Clang] Fix LibTooling doc
Replace CommonOptionsParser ctor by factory method ::create.
1 parent 3526020 commit ed05f89

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/docs/LibTooling.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ and automatic location of the compilation database using source files paths.
7171
int main(int argc, const char **argv) {
7272
// CommonOptionsParser constructor will parse arguments and create a
7373
// CompilationDatabase. In case of error it will terminate the program.
74-
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
74+
auto OptionsParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
7575
76-
// Use OptionsParser.getCompilations() and OptionsParser.getSourcePathList()
76+
// Use OptionsParser->getCompilations() and OptionsParser->getSourcePathList()
7777
// to retrieve CompilationDatabase and the list of input file paths.
7878
}
7979

@@ -93,7 +93,7 @@ our ``FrontendAction`` over some code. For example, to run the
9393

9494
// We hand the CompilationDatabase we created and the sources to run over into
9595
// the tool constructor.
96-
ClangTool Tool(OptionsParser.getCompilations(), Sources);
96+
ClangTool Tool(OptionsParser->getCompilations(), Sources);
9797

9898
// The ClangTool needs a new FrontendAction for each translation unit we run
9999
// on. Thus, it takes a FrontendActionFactory as parameter. To create a
@@ -133,9 +133,9 @@ version of this example tool is also checked into the clang tree at
133133
static cl::extrahelp MoreHelp("\nMore help text...\n");
134134

135135
int main(int argc, const char **argv) {
136-
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
137-
ClangTool Tool(OptionsParser.getCompilations(),
138-
OptionsParser.getSourcePathList());
136+
auto OptionsParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
137+
ClangTool Tool(OptionsParser->getCompilations(),
138+
OptionsParser->getSourcePathList());
139139
return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>().get());
140140
}
141141

clang/include/clang/Tooling/CommonOptionsParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ namespace tooling {
5656
/// ...
5757
///
5858
/// int main(int argc, const char **argv) {
59-
/// CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
60-
/// ClangTool Tool(OptionsParser.getCompilations(),
61-
/// OptionsParser.getSourcePathList());
59+
/// auto OptionsParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
60+
/// ClangTool Tool(OptionsParser->getCompilations(),
61+
/// OptionsParser->getSourcePathList());
6262
/// return Tool.run(newFrontendActionFactory<SyntaxOnlyAction>().get());
6363
/// }
6464
/// \endcode

0 commit comments

Comments
 (0)