[clang-tools-extra] r326202 - [Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Roman Lebedev via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 27 07:19:28 PST 2018
Author: lebedevri
Date: Tue Feb 27 07:19:28 2018
New Revision: 326202
URL: http://llvm.org/viewvc/llvm-project?rev=326202&view=rev
Log:
[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Summary:
I'm not sure whether there are any principal reasons why it returns raw owning pointer,
or it is just a old code that was not updated post-C++11.
I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason,
but it does not //appear// asif those failures are related to these changes.
This is Clang-tools-extra part.
Clang part is D43779.
Reviewers: klimek, bkramer, alexfh, pcc
Reviewed By: alexfh
Subscribers: ioeric, jkorous-apple, cfe-commits
Tags: #clang, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D43780
Modified:
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/pp-trace/PPTrace.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Tue Feb 27 07:19:28 2018
@@ -217,8 +217,8 @@ public:
DeclarationReporter *const Reporter = nullptr)
: Context(Context), Reporter(Reporter) {}
- clang::FrontendAction *create() override {
- return new ClangMoveAction(Context, Reporter);
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<ClangMoveAction>(Context, Reporter);
}
private:
Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Tue Feb 27 07:19:28 2018
@@ -527,7 +527,9 @@ void runClangTidy(clang::tidy::ClangTidy
class ActionFactory : public FrontendActionFactory {
public:
ActionFactory(ClangTidyContext &Context) : ConsumerFactory(Context) {}
- FrontendAction *create() override { return new Action(&ConsumerFactory); }
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<Action>(&ConsumerFactory);
+ }
private:
class Action : public ASTFrontendAction {
Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp Tue Feb 27 07:19:28 2018
@@ -53,7 +53,7 @@ class SymbolIndexActionFactory : public
public:
SymbolIndexActionFactory(tooling::ExecutionContext *Ctx) : Ctx(Ctx) {}
- clang::FrontendAction *create() override {
+ std::unique_ptr<clang::FrontendAction> create() override {
// Wraps the index action and reports collected symbols to the execution
// context at the end of each translation unit.
class WrappedIndexAction : public WrapperFrontendAction {
@@ -102,7 +102,8 @@ public:
auto Includes = llvm::make_unique<CanonicalIncludes>();
addSystemHeadersMapping(Includes.get());
CollectorOpts.Includes = Includes.get();
- return new WrappedIndexAction(
+
+ return llvm::make_unique<WrappedIndexAction>(
std::make_shared<SymbolCollector>(std::move(CollectorOpts)),
std::move(Includes), IndexOpts, Ctx);
}
Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h Tue Feb 27 07:19:28 2018
@@ -48,8 +48,8 @@ public:
const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
: Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
- clang::FrontendAction *create() override {
- return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<FindAllSymbolsAction>(Reporter, RegexHeaderMap);
}
private:
Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Tue Feb 27 07:19:28 2018
@@ -129,8 +129,8 @@ public:
CoverageCheckerFrontendActionFactory(CoverageChecker &Checker)
: Checker(Checker) {}
- CoverageCheckerAction *create() override {
- return new CoverageCheckerAction(Checker);
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<CoverageCheckerAction>(Checker);
}
private:
Modified: clang-tools-extra/trunk/modularize/Modularize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/Modularize.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
+++ clang-tools-extra/trunk/modularize/Modularize.cpp Tue Feb 27 07:19:28 2018
@@ -722,8 +722,9 @@ public:
: Entities(Entities), PPTracker(preprocessorTracker),
HadErrors(HadErrors) {}
- CollectEntitiesAction *create() override {
- return new CollectEntitiesAction(Entities, PPTracker, HadErrors);
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<CollectEntitiesAction>(Entities, PPTracker,
+ HadErrors);
}
private:
@@ -802,8 +803,8 @@ class CompileCheckFrontendActionFactory
public:
CompileCheckFrontendActionFactory() {}
- CompileCheckAction *create() override {
- return new CompileCheckAction();
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<CompileCheckAction>();
}
};
Modified: clang-tools-extra/trunk/pp-trace/PPTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPTrace.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPTrace.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPTrace.cpp Tue Feb 27 07:19:28 2018
@@ -139,8 +139,8 @@ public:
std::vector<CallbackCall> &CallbackCalls)
: Ignore(Ignore), CallbackCalls(CallbackCalls) {}
- PPTraceAction *create() override {
- return new PPTraceAction(Ignore, CallbackCalls);
+ std::unique_ptr<clang::FrontendAction> create() override {
+ return llvm::make_unique<PPTraceAction>(Ignore, CallbackCalls);
}
private:
Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h Tue Feb 27 07:19:28 2018
@@ -107,7 +107,8 @@ runCheckOnCode(StringRef Code, std::vect
SmallVector<std::unique_ptr<ClangTidyCheck>, 1> Checks;
CheckFactory<CheckList...>::createChecks(&Context, Checks);
tooling::ToolInvocation Invocation(
- Args, new TestClangTidyAction(Checks, Finder, Context), Files.get());
+ Args, llvm::make_unique<TestClangTidyAction>(Checks, Finder, Context),
+ Files.get());
InMemoryFileSystem->addFile(Filename, 0,
llvm::MemoryBuffer::getMemBuffer(Code));
for (const auto &FileContent : PathsToContent) {
Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=326202&r1=326201&r2=326202&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Tue Feb 27 07:19:28 2018
@@ -69,7 +69,7 @@ public:
CommentHandler *PragmaHandler)
: COpts(std::move(COpts)), PragmaHandler(PragmaHandler) {}
- clang::FrontendAction *create() override {
+ std::unique_ptr<clang::FrontendAction> create() override {
class WrappedIndexAction : public WrapperFrontendAction {
public:
WrappedIndexAction(std::shared_ptr<SymbolCollector> C,
@@ -95,8 +95,9 @@ public:
index::IndexingOptions::SystemSymbolFilterKind::All;
IndexOpts.IndexFunctionLocals = false;
Collector = std::make_shared<SymbolCollector>(COpts);
- return new WrappedIndexAction(Collector, std::move(IndexOpts),
- PragmaHandler);
+
+ return llvm::make_unique<WrappedIndexAction>(
+ Collector, std::move(IndexOpts), PragmaHandler);
}
std::shared_ptr<SymbolCollector> Collector;
More information about the cfe-commits
mailing list