[clang-tools-extra] r370379 - Changed FrontendActionFactory::create to return a std::unique_ptr
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 09:38:36 PDT 2019
Author: gribozavr
Date: Thu Aug 29 09:38:36 2019
New Revision: 370379
URL: http://llvm.org/viewvc/llvm-project?rev=370379&view=rev
Log:
Changed FrontendActionFactory::create to return a std::unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66947
Modified:
clang-tools-extra/trunk/clang-doc/ClangDoc.cpp
clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/FindAllSymbolsAction.h
clang-tools-extra/trunk/clang-move/Move.h
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/pp-trace/PPTrace.cpp
Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/ClangDoc.cpp?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/ClangDoc.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/ClangDoc.cpp Thu Aug 29 09:38:36 2019
@@ -29,13 +29,13 @@ namespace doc {
class MapperActionFactory : public tooling::FrontendActionFactory {
public:
MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
- clang::FrontendAction *create() override;
+ std::unique_ptr<FrontendAction> create() override;
private:
ClangDocContext CDCtx;
};
-clang::FrontendAction *MapperActionFactory::create() {
+std::unique_ptr<FrontendAction> MapperActionFactory::create() {
class ClangDocAction : public clang::ASTFrontendAction {
public:
ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
@@ -49,7 +49,7 @@ clang::FrontendAction *MapperActionFacto
private:
ClangDocContext CDCtx;
};
- return new ClangDocAction(CDCtx);
+ return std::make_unique<ClangDocAction>(CDCtx);
}
std::unique_ptr<tooling::FrontendActionFactory>
Modified: clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/FindAllSymbolsAction.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/FindAllSymbolsAction.h?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/FindAllSymbolsAction.h (original)
+++ clang-tools-extra/trunk/clang-include-fixer/find-all-symbols/FindAllSymbolsAction.h Thu Aug 29 09:38:36 2019
@@ -47,8 +47,8 @@ public:
const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
: Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
- clang::FrontendAction *create() override {
- return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
+ std::unique_ptr<FrontendAction> create() override {
+ return std::make_unique<FindAllSymbolsAction>(Reporter, RegexHeaderMap);
}
private:
Modified: clang-tools-extra/trunk/clang-move/Move.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/Move.h?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-move/Move.h (original)
+++ clang-tools-extra/trunk/clang-move/Move.h Thu Aug 29 09:38:36 2019
@@ -224,8 +224,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 std::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=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Aug 29 09:38:36 2019
@@ -530,7 +530,9 @@ runClangTidy(clang::tidy::ClangTidyConte
ActionFactory(ClangTidyContext &Context,
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS)
: ConsumerFactory(Context, BaseFS) {}
- FrontendAction *create() override { return new Action(&ConsumerFactory); }
+ std::unique_ptr<FrontendAction> create() override {
+ return std::make_unique<Action>(&ConsumerFactory);
+ }
bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
FileManager *Files,
Modified: clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp Thu Aug 29 09:38:36 2019
@@ -39,37 +39,36 @@ class IndexActionFactory : public toolin
public:
IndexActionFactory(IndexFileIn &Result) : Result(Result) {}
- clang::FrontendAction *create() override {
+ std::unique_ptr<FrontendAction> create() override {
SymbolCollector::Options Opts;
Opts.CountReferences = true;
return createStaticIndexingAction(
- Opts,
- [&](SymbolSlab S) {
- // Merge as we go.
- std::lock_guard<std::mutex> Lock(SymbolsMu);
- for (const auto &Sym : S) {
- if (const auto *Existing = Symbols.find(Sym.ID))
- Symbols.insert(mergeSymbol(*Existing, Sym));
- else
- Symbols.insert(Sym);
- }
- },
- [&](RefSlab S) {
- std::lock_guard<std::mutex> Lock(SymbolsMu);
- for (const auto &Sym : S) {
- // Deduplication happens during insertion.
- for (const auto &Ref : Sym.second)
- Refs.insert(Sym.first, Ref);
- }
- },
- [&](RelationSlab S) {
- std::lock_guard<std::mutex> Lock(SymbolsMu);
- for (const auto &R : S) {
- Relations.insert(R);
- }
- },
- /*IncludeGraphCallback=*/nullptr)
- .release();
+ Opts,
+ [&](SymbolSlab S) {
+ // Merge as we go.
+ std::lock_guard<std::mutex> Lock(SymbolsMu);
+ for (const auto &Sym : S) {
+ if (const auto *Existing = Symbols.find(Sym.ID))
+ Symbols.insert(mergeSymbol(*Existing, Sym));
+ else
+ Symbols.insert(Sym);
+ }
+ },
+ [&](RefSlab S) {
+ std::lock_guard<std::mutex> Lock(SymbolsMu);
+ for (const auto &Sym : S) {
+ // Deduplication happens during insertion.
+ for (const auto &Ref : Sym.second)
+ Refs.insert(Sym.first, Ref);
+ }
+ },
+ [&](RelationSlab S) {
+ std::lock_guard<std::mutex> Lock(SymbolsMu);
+ for (const auto &R : S) {
+ Relations.insert(R);
+ }
+ },
+ /*IncludeGraphCallback=*/nullptr);
}
// Awkward: we write the result in the destructor, because the executor
Modified: clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp Thu Aug 29 09:38:36 2019
@@ -200,7 +200,7 @@ public:
CommentHandler *PragmaHandler)
: COpts(std::move(COpts)), PragmaHandler(PragmaHandler) {}
- clang::FrontendAction *create() override {
+ std::unique_ptr<FrontendAction> create() override {
class IndexAction : public ASTFrontendAction {
public:
IndexAction(std::shared_ptr<index::IndexDataConsumer> DataConsumer,
@@ -232,7 +232,8 @@ public:
index::IndexingOptions::SystemSymbolFilterKind::All;
IndexOpts.IndexFunctionLocals = false;
Collector = std::make_shared<SymbolCollector>(COpts);
- return new IndexAction(Collector, std::move(IndexOpts), PragmaHandler);
+ return std::make_unique<IndexAction>(Collector, std::move(IndexOpts),
+ PragmaHandler);
}
std::shared_ptr<SymbolCollector> Collector;
Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Thu Aug 29 09:38:36 2019
@@ -58,6 +58,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
@@ -129,8 +130,8 @@ public:
CoverageCheckerFrontendActionFactory(CoverageChecker &Checker)
: Checker(Checker) {}
- CoverageCheckerAction *create() override {
- return new CoverageCheckerAction(Checker);
+ std::unique_ptr<FrontendAction> create() override {
+ return std::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=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
+++ clang-tools-extra/trunk/modularize/Modularize.cpp Thu Aug 29 09:38:36 2019
@@ -233,6 +233,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/CompilationDatabase.h"
@@ -721,8 +722,9 @@ public:
: Entities(Entities), PPTracker(preprocessorTracker),
HadErrors(HadErrors) {}
- CollectEntitiesAction *create() override {
- return new CollectEntitiesAction(Entities, PPTracker, HadErrors);
+ std::unique_ptr<FrontendAction> create() override {
+ return std::make_unique<CollectEntitiesAction>(Entities, PPTracker,
+ HadErrors);
}
private:
@@ -801,8 +803,8 @@ class CompileCheckFrontendActionFactory
public:
CompileCheckFrontendActionFactory() {}
- CompileCheckAction *create() override {
- return new CompileCheckAction();
+ std::unique_ptr<FrontendAction> create() override {
+ return std::make_unique<CompileCheckAction>();
}
};
@@ -886,6 +888,7 @@ int main(int Argc, const char **Argv) {
CompileCheckTool.appendArgumentsAdjuster(
getModularizeArgumentsAdjuster(ModUtil->Dependencies));
int CompileCheckFileErrors = 0;
+ // FIXME: use newFrontendActionFactory.
CompileCheckFrontendActionFactory CompileCheckFactory;
CompileCheckFileErrors |= CompileCheckTool.run(&CompileCheckFactory);
if (CompileCheckFileErrors != 0) {
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=370379&r1=370378&r2=370379&view=diff
==============================================================================
--- clang-tools-extra/trunk/pp-trace/PPTrace.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPTrace.cpp Thu Aug 29 09:38:36 2019
@@ -30,6 +30,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Driver/Options.h"
#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/Execution.h"
@@ -112,7 +113,9 @@ public:
PPTraceFrontendActionFactory(const FilterType &Filters, raw_ostream &OS)
: Filters(Filters), OS(OS) {}
- PPTraceAction *create() override { return new PPTraceAction(Filters, OS); }
+ std::unique_ptr<FrontendAction> create() override {
+ return std::make_unique<PPTraceAction>(Filters, OS);
+ }
private:
const FilterType &Filters;
More information about the cfe-commits
mailing list