Author: Nathan James Date: 2020-12-17T14:09:08Z New Revision: 64badecd447f2358812a2e747b2683d34071f5a5
URL: https://github.com/llvm/llvm-project/commit/64badecd447f2358812a2e747b2683d34071f5a5 DIFF: https://github.com/llvm/llvm-project/commit/64badecd447f2358812a2e747b2683d34071f5a5.diff LOG: [clang-tidy][NFC] Reduce copies of Intrusive..FileSystem Swapped a few instances where a move is more optimal or the target doesn't need to hold a reference. Added: Modified: clang-tools-extra/clang-tidy/ClangTidy.cpp clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index b5f2a1c0fbdb..633655e5e24a 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -101,7 +101,8 @@ class ErrorReporter { public: ErrorReporter(ClangTidyContext &Context, bool ApplyFixes, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) - : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()), + : Files(FileSystemOptions(), std::move(BaseFS)), + DiagOpts(new DiagnosticOptions()), DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)), Diags(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, DiagPrinter), @@ -319,7 +320,7 @@ class ClangTidyASTConsumer : public MultiplexConsumer { ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory( ClangTidyContext &Context, IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS) - : Context(Context), OverlayFS(OverlayFS), + : Context(Context), OverlayFS(std::move(OverlayFS)), CheckFactories(new ClangTidyCheckFactories) { for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) { std::unique_ptr<ClangTidyModule> Module = E.instantiate(); @@ -328,15 +329,16 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory( } #if CLANG_TIDY_ENABLE_STATIC_ANALYZER -static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts, - AnalyzerOptionsRef AnalyzerOptions) { +static void +setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts, + clang::AnalyzerOptions &AnalyzerOptions) { StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix); for (const auto &Opt : Opts.CheckOptions) { StringRef OptName(Opt.getKey()); if (!OptName.consume_front(AnalyzerPrefix)) continue; // Analyzer options are always local options so we can ignore priority. - AnalyzerOptions->Config[OptName] = Opt.getValue().Value; + AnalyzerOptions.Config[OptName] = Opt.getValue().Value; } } @@ -432,7 +434,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer( AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages( Context, Context.canEnableAnalyzerAlphaCheckers()); if (!AnalyzerOptions->CheckersAndPackages.empty()) { - setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions); + setStaticAnalyzerCheckerOpts(Context.getOptions(), *AnalyzerOptions); AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel; AnalyzerOptions->AnalysisDiagOpt = PD_NONE; AnalyzerOptions->AnalyzeNestedBlocks = true; @@ -539,7 +541,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context, public: ActionFactory(ClangTidyContext &Context, IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS) - : ConsumerFactory(Context, BaseFS) {} + : ConsumerFactory(Context, std::move(BaseFS)) {} std::unique_ptr<FrontendAction> create() override { return std::make_unique<Action>(&ConsumerFactory); } @@ -570,7 +572,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context, ClangTidyASTConsumerFactory ConsumerFactory; }; - ActionFactory Factory(Context, BaseFS); + ActionFactory Factory(Context, std::move(BaseFS)); Tool.run(&Factory); return DiagConsumer.take(); } @@ -579,7 +581,7 @@ void handleErrors(llvm::ArrayRef<ClangTidyError> Errors, ClangTidyContext &Context, bool Fix, unsigned &WarningsAsErrorsCount, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) { - ErrorReporter Reporter(Context, Fix, BaseFS); + ErrorReporter Reporter(Context, Fix, std::move(BaseFS)); llvm::vfs::FileSystem &FileSystem = Reporter.getSourceManager().getFileManager().getVirtualFileSystem(); auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory(); diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp index 2748fd9f74a5..2466b647c68c 100644 --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -393,7 +393,7 @@ int clangTidyMain(int argc, const char **argv) { getVfsFromFile(VfsOverlay, BaseFS); if (!VfsFromFile) return 1; - BaseFS->pushOverlay(VfsFromFile); + BaseFS->pushOverlay(std::move(VfsFromFile)); } auto OwningOptionsProvider = createOptionsProvider(BaseFS); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits