nicolas17 created this revision. nicolas17 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The code example for "RecursiveASTVisitor based ASTFrontendActions" was using unique_ptr<X>(new X) when creating the AST consumer; change it to use make_unique instead. The main function of the same example already used make_unique. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D93185 Files: clang/docs/RAVFrontendAction.rst Index: clang/docs/RAVFrontendAction.rst =================================================================== --- clang/docs/RAVFrontendAction.rst +++ clang/docs/RAVFrontendAction.rst @@ -27,8 +27,7 @@ public: virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer); + return std::make_unique<FindNamedClassConsumer>(); } }; @@ -114,8 +113,7 @@ virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer(&Compiler.getASTContext())); + return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext()); } Now that the ASTContext is available in the RecursiveASTVisitor, we can @@ -189,8 +187,7 @@ public: virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer(&Compiler.getASTContext())); + return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext()); } };
Index: clang/docs/RAVFrontendAction.rst =================================================================== --- clang/docs/RAVFrontendAction.rst +++ clang/docs/RAVFrontendAction.rst @@ -27,8 +27,7 @@ public: virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer); + return std::make_unique<FindNamedClassConsumer>(); } }; @@ -114,8 +113,7 @@ virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer(&Compiler.getASTContext())); + return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext()); } Now that the ASTContext is available in the RecursiveASTVisitor, we can @@ -189,8 +187,7 @@ public: virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( clang::CompilerInstance &Compiler, llvm::StringRef InFile) { - return std::unique_ptr<clang::ASTConsumer>( - new FindNamedClassConsumer(&Compiler.getASTContext())); + return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext()); } };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits