From: Benjamin Kramer Date: Fri, 27 May 2016 14:27:13 +0000 (+0000) Subject: Apply clang-tidy's misc-move-constructor-init throughout Clang. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ff480f17cff1d8d1b366fba7123493498c7667b;p=clang Apply clang-tidy's misc-move-constructor-init throughout Clang. No functionality change intended, maybe a tiny performance improvement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270996 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index d4e9f65e91..305dba2504 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -22,6 +22,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/TrailingObjects.h" #include +#include namespace clang { @@ -2332,9 +2333,9 @@ class ClassScopeFunctionSpecializationDecl : public Decl { ClassScopeFunctionSpecializationDecl(DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool Args, TemplateArgumentListInfo TemplArgs) - : Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc), - Specialization(FD), HasExplicitTemplateArgs(Args), - TemplateArgs(TemplArgs) {} + : Decl(Decl::ClassScopeFunctionSpecialization, DC, Loc), + Specialization(FD), HasExplicitTemplateArgs(Args), + TemplateArgs(std::move(TemplArgs)) {} ClassScopeFunctionSpecializationDecl(EmptyShell Empty) : Decl(Decl::ClassScopeFunctionSpecialization, Empty) {} diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index 6c7127f280..bc09e67878 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -20,6 +20,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" +#include namespace llvm { class MemoryBuffer; @@ -116,7 +117,8 @@ class directory_iterator { std::shared_ptr Impl; // Input iterator semantics on copy public: - directory_iterator(std::shared_ptr I) : Impl(I) { + directory_iterator(std::shared_ptr I) + : Impl(std::move(I)) { assert(Impl.get() != nullptr && "requires non-null implementation"); if (!Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h index 903d70cc3b..cf943a5960 100644 --- a/include/clang/Frontend/Utils.h +++ b/include/clang/Frontend/Utils.h @@ -20,6 +20,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Option/OptSpecifier.h" +#include namespace llvm { class raw_fd_ostream; @@ -141,7 +142,8 @@ public: void writeFileMap(); bool hasErrors() { return HasErrors; } - ModuleDependencyCollector(std::string DestDir) : DestDir(DestDir) {} + ModuleDependencyCollector(std::string DestDir) + : DestDir(std::move(DestDir)) {} ~ModuleDependencyCollector() { writeFileMap(); } }; diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 768fe52a49..014ea5d61d 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -23,6 +23,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include +#include namespace clang { @@ -517,8 +518,8 @@ class CodeCompletionTUInfo { public: explicit CodeCompletionTUInfo( - IntrusiveRefCntPtr Allocator) - : AllocatorRef(Allocator) { } + IntrusiveRefCntPtr Allocator) + : AllocatorRef(std::move(Allocator)) {} IntrusiveRefCntPtr getAllocatorRef() const { return AllocatorRef; diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h index 612e1056a7..b06b74d326 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -20,6 +20,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" +#include #include namespace clang { @@ -105,10 +106,8 @@ class CheckerManager { CheckName CurrentCheckName; public: - CheckerManager(const LangOptions &langOpts, - AnalyzerOptionsRef AOptions) - : LangOpts(langOpts), - AOptions(AOptions) {} + CheckerManager(const LangOptions &langOpts, AnalyzerOptionsRef AOptions) + : LangOpts(langOpts), AOptions(std::move(AOptions)) {} ~CheckerManager(); diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 0bd53e6059..89610ef5c1 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -24,6 +24,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/PointerIntPair.h" +#include namespace clang { class ProgramPoint; @@ -165,10 +166,10 @@ protected: friend class CallEventManager; CallEvent(const Expr *E, ProgramStateRef state, const LocationContext *lctx) - : State(state), LCtx(lctx), Origin(E), RefCount(0) {} + : State(std::move(state)), LCtx(lctx), Origin(E), RefCount(0) {} CallEvent(const Decl *D, ProgramStateRef state, const LocationContext *lctx) - : State(state), LCtx(lctx), Origin(D), RefCount(0) {} + : State(std::move(state)), LCtx(lctx), Origin(D), RefCount(0) {} // DO NOT MAKE PUBLIC CallEvent(const CallEvent &Original) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h index cfb1b921e9..a4e9226616 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -32,6 +32,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include +#include #include namespace clang { @@ -121,10 +122,9 @@ class ExplodedNode : public llvm::FoldingSetNode { NodeGroup Succs; public: - explicit ExplodedNode(const ProgramPoint &loc, ProgramStateRef state, bool IsSink) - : Location(loc), State(state), Succs(IsSink) { + : Location(loc), State(std::move(state)), Succs(IsSink) { assert(isSink() == IsSink); } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index c4a62ecbdd..f89747ee17 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -26,6 +26,7 @@ #include "llvm/ADT/ImmutableMap.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/Allocator.h" +#include namespace llvm { class APSInt; @@ -836,9 +837,8 @@ class ScanReachableSymbols { ProgramStateRef state; SymbolVisitor &visitor; public: - - ScanReachableSymbols(ProgramStateRef st, SymbolVisitor& v) - : state(st), visitor(v) {} + ScanReachableSymbols(ProgramStateRef st, SymbolVisitor &v) + : state(std::move(st)), visitor(v) {} bool scan(nonloc::LazyCompoundVal val); bool scan(nonloc::CompoundVal val); diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 8c04c8371c..da93d8418e 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -21,6 +21,7 @@ #include "clang/Serialization/ASTReader.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/MemoryBuffer.h" +#include using namespace clang; using namespace arcmt; @@ -508,8 +509,8 @@ MigrationProcess::MigrationProcess( const CompilerInvocation &CI, std::shared_ptr PCHContainerOps, DiagnosticConsumer *diagClient, StringRef outputDir) - : OrigCI(CI), PCHContainerOps(PCHContainerOps), DiagClient(diagClient), - HadARCErrors(false) { + : OrigCI(CI), PCHContainerOps(std::move(PCHContainerOps)), + DiagClient(diagClient), HadARCErrors(false) { if (!outputDir.empty()) { IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); IntrusiveRefCntPtr Diags( diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 34d1b0592d..d64c4e3d8c 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -16,15 +16,16 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/YAMLParser.h" -#include "llvm/Config/llvm-config.h" #include #include +#include // For chdir. #ifdef LLVM_ON_WIN32 @@ -867,7 +868,7 @@ class RedirectingFileSystem : public vfs::FileSystem { private: RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS) - : ExternalFS(ExternalFS) {} + : ExternalFS(std::move(ExternalFS)) {} /// \brief Looks up \p Path in \c Roots. ErrorOr lookupPath(const Twine &Path); @@ -1530,7 +1531,7 @@ class FileWithFixedStatus : public File { public: FileWithFixedStatus(std::unique_ptr InnerFile, Status S) - : InnerFile(std::move(InnerFile)), S(S) {} + : InnerFile(std::move(InnerFile)), S(std::move(S)) {} ErrorOr status() override { return S; } ErrorOr> diff --git a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 2fa390279a..bdb4f67e73 100644 --- a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/TargetRegistry.h" #include +#include using namespace clang; @@ -145,7 +146,7 @@ public: HeaderSearchOpts(CI.getHeaderSearchOpts()), PreprocessorOpts(CI.getPreprocessorOpts()), TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()), OS(OS), - Buffer(Buffer) { + Buffer(std::move(Buffer)) { // The debug info output isn't affected by CodeModel and // ThreadModel, but the backend expects them to be nonempty. CodeGenOpts.CodeModel = "default"; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index be2971de59..f7e15309ac 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -41,6 +41,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include using namespace clang::driver; using namespace clang; @@ -49,9 +50,9 @@ using namespace llvm::opt; Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, DiagnosticsEngine &Diags, IntrusiveRefCntPtr VFS) - : Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode), - SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None), - ClangExecutable(ClangExecutable), + : Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)), + Mode(GCCMode), SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), + LTOMode(LTOK_None), ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT), UseStdLib(true), DefaultTargetTriple(DefaultTargetTriple), DriverTitle("clang LLVM compiler"), CCPrintOptionsFilename(nullptr), diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index d6f4749db2..5648b90be8 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -48,6 +48,7 @@ #include #include #include +#include using namespace clang; @@ -55,7 +56,8 @@ CompilerInstance::CompilerInstance( std::shared_ptr PCHContainerOps, bool BuildingModule) : ModuleLoader(BuildingModule), Invocation(new CompilerInvocation()), - ModuleManager(nullptr), ThePCHContainerOperations(PCHContainerOps), + ModuleManager(nullptr), + ThePCHContainerOperations(std::move(PCHContainerOps)), BuildGlobalModuleIndex(false), HaveFullGlobalModuleIndex(false), ModuleBuildFailed(false) {} diff --git a/lib/Frontend/PCHContainerOperations.cpp b/lib/Frontend/PCHContainerOperations.cpp index fd84678b80..d41d90e1e5 100644 --- a/lib/Frontend/PCHContainerOperations.cpp +++ b/lib/Frontend/PCHContainerOperations.cpp @@ -13,9 +13,10 @@ #include "clang/Frontend/PCHContainerOperations.h" #include "clang/AST/ASTConsumer.h" +#include "clang/Lex/ModuleLoader.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/raw_ostream.h" -#include "clang/Lex/ModuleLoader.h" +#include using namespace clang; @@ -32,7 +33,7 @@ class RawPCHContainerGenerator : public ASTConsumer { public: RawPCHContainerGenerator(llvm::raw_pwrite_stream *OS, std::shared_ptr Buffer) - : Buffer(Buffer), OS(OS) {} + : Buffer(std::move(Buffer)), OS(OS) {} ~RawPCHContainerGenerator() override = default; diff --git a/lib/Frontend/Rewrite/FrontendActions.cpp b/lib/Frontend/Rewrite/FrontendActions.cpp index d6e1568923..24aa98c211 100644 --- a/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/lib/Frontend/Rewrite/FrontendActions.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +#include using namespace clang; @@ -60,8 +61,8 @@ class FixItActionSuffixInserter : public FixItOptions { public: FixItActionSuffixInserter(std::string NewSuffix, bool FixWhatYouCan) - : NewSuffix(NewSuffix) { - this->FixWhatYouCan = FixWhatYouCan; + : NewSuffix(std::move(NewSuffix)) { + this->FixWhatYouCan = FixWhatYouCan; } std::string RewriteFilename(const std::string &Filename, int &fd) override { diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp index 1bf10d2769..5c42406876 100644 --- a/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -24,6 +24,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" +#include #include using namespace clang; @@ -147,7 +148,7 @@ class SDiagsWriter : public DiagnosticConsumer { explicit SDiagsWriter(IntrusiveRefCntPtr State) : LangOpts(nullptr), OriginalInstance(false), MergeChildRecords(false), - State(State) {} + State(std::move(State)) {} public: SDiagsWriter(StringRef File, DiagnosticOptions *Diags, bool MergeChildRecords) diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index beaef7636c..f7fc0b0f65 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +#include #if defined(LLVM_ON_UNIX) #include #endif @@ -55,8 +56,9 @@ HeaderSearch::HeaderSearch(IntrusiveRefCntPtr HSOpts, SourceManager &SourceMgr, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const TargetInfo *Target) - : HSOpts(HSOpts), Diags(Diags), FileMgr(SourceMgr.getFileManager()), - FrameworkMap(64), ModMap(SourceMgr, Diags, LangOpts, Target, *this) { + : HSOpts(std::move(HSOpts)), Diags(Diags), + FileMgr(SourceMgr.getFileManager()), FrameworkMap(64), + ModMap(SourceMgr, Diags, LangOpts, Target, *this) { AngledDirIdx = 0; SystemDirIdx = 0; NoCurDirSearch = false; diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 297b556015..78179dd798 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -51,6 +51,7 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" +#include using namespace clang; template class llvm::Registry; @@ -64,7 +65,7 @@ Preprocessor::Preprocessor(IntrusiveRefCntPtr PPOpts, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup, bool OwnsHeaders, TranslationUnitKind TUKind) - : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(nullptr), + : PPOpts(std::move(PPOpts)), Diags(&diags), LangOpts(opts), Target(nullptr), AuxTarget(nullptr), FileMgr(Headers.getFileMgr()), SourceMgr(SM), ScratchBuf(new ScratchBuffer(SourceMgr)), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(nullptr), diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index f365e53667..cf4c011d5a 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -31,6 +31,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include +#include using namespace clang; using namespace ento; @@ -520,7 +521,7 @@ namespace { class StopTrackingCallback final : public SymbolVisitor { ProgramStateRef state; public: - StopTrackingCallback(ProgramStateRef st) : state(st) {} + StopTrackingCallback(ProgramStateRef st) : state(std::move(st)) {} ProgramStateRef getState() const { return state; } bool VisitSymbol(SymbolRef sym) override { diff --git a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index 99ba90d7a2..8c4c7cde55 100644 --- a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -25,6 +25,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h" +#include using namespace clang; using namespace ento; @@ -38,7 +39,7 @@ struct MallocOverflowCheck { APSInt maxVal; MallocOverflowCheck(const BinaryOperator *m, const Expr *v, APSInt val) - : mulop(m), variable(v), maxVal(val) {} + : mulop(m), variable(v), maxVal(std::move(val)) {} }; class MallocOverflowSecurityChecker : public Checker { diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index f983c30856..c344bb1709 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "ClangSACheckers.h" #include "AllocationDiagnostics.h" +#include "ClangSACheckers.h" #include "SelectorExtras.h" #include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" @@ -39,6 +39,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include +#include using namespace clang; using namespace ento; @@ -2683,7 +2684,7 @@ namespace { class StopTrackingCallback final : public SymbolVisitor { ProgramStateRef state; public: - StopTrackingCallback(ProgramStateRef st) : state(st) {} + StopTrackingCallback(ProgramStateRef st) : state(std::move(st)) {} ProgramStateRef getState() const { return state; } bool VisitSymbol(SymbolRef sym) override { diff --git a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp index 62e6f02fe3..ab4b4d3bd9 100644 --- a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -20,6 +20,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include using namespace clang; using namespace ento; @@ -92,7 +93,7 @@ namespace { class StopTrackingCallback final : public SymbolVisitor { ProgramStateRef state; public: - StopTrackingCallback(ProgramStateRef st) : state(st) {} + StopTrackingCallback(ProgramStateRef st) : state(std::move(st)) {} ProgramStateRef getState() const { return state; } bool VisitSymbol(SymbolRef sym) override { diff --git a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp index ed17610e41..0a274292aa 100644 --- a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp @@ -17,6 +17,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include using namespace clang; using namespace ento; @@ -31,7 +32,7 @@ class UndefBranchChecker : public Checker { const LocationContext *LCtx; FindUndefExpr(ProgramStateRef S, const LocationContext *L) - : St(S), LCtx(L) {} + : St(std::move(S)), LCtx(L) {} const Expr *FindExpr(const Expr *Ex) { if (!MatchesCriteria(Ex)) diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index 9b450ddf89..0d173c4644 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -14,6 +14,7 @@ // parameters are created lazily. // //===----------------------------------------------------------------------===// + #include "clang/AST/Attr.h" #include "clang/AST/CharUnits.h" #include "clang/Analysis/Analyses/LiveVariables.h" @@ -29,6 +30,7 @@ #include "llvm/ADT/ImmutableMap.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/raw_ostream.h" +#include using namespace clang; using namespace ento; @@ -665,10 +667,9 @@ protected: public: ClusterAnalysis(RegionStoreManager &rm, ProgramStateManager &StateMgr, - RegionBindingsRef b ) - : RM(rm), Ctx(StateMgr.getContext()), - svalBuilder(StateMgr.getSValBuilder()), - B(b) {} + RegionBindingsRef b) + : RM(rm), Ctx(StateMgr.getContext()), + svalBuilder(StateMgr.getSValBuilder()), B(std::move(b)) {} RegionBindingsRef getRegionBindings() const { return B; } diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 083ee51a99..bbf451f8ae 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -14,11 +14,11 @@ #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" #include "ModelInjector.h" #include "clang/AST/ASTConsumer.h" -#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/ParentMap.h" +#include "clang/AST/RecursiveASTVisitor.h" #include "clang/Analysis/Analyses/LiveVariables.h" #include "clang/Analysis/CFG.h" #include "clang/Analysis/CallGraph.h" @@ -47,6 +47,7 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include using namespace clang; using namespace ento; @@ -185,13 +186,12 @@ public: /// translation unit. FunctionSummariesTy FunctionSummaries; - AnalysisConsumer(const Preprocessor& pp, - const std::string& outdir, - AnalyzerOptionsRef opts, - ArrayRef plugins, + AnalysisConsumer(const Preprocessor &pp, const std::string &outdir, + AnalyzerOptionsRef opts, ArrayRef plugins, CodeInjector *injector) - : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr), PP(pp), - OutDir(outdir), Opts(opts), Plugins(plugins), Injector(injector) { + : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr), PP(pp), + OutDir(outdir), Opts(std::move(opts)), Plugins(plugins), + Injector(injector) { DigestAnalyzerOptions(); if (Opts->PrintStats) { llvm::EnableStatistics(); diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index 15700e9204..69a4611e64 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -31,6 +31,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/raw_ostream.h" +#include #define DEBUG_TYPE "clang-tooling" @@ -208,14 +209,16 @@ ToolInvocation::ToolInvocation( std::vector CommandLine, ToolAction *Action, FileManager *Files, std::shared_ptr PCHContainerOps) : CommandLine(std::move(CommandLine)), Action(Action), OwnsAction(false), - Files(Files), PCHContainerOps(PCHContainerOps), DiagConsumer(nullptr) {} + Files(Files), PCHContainerOps(std::move(PCHContainerOps)), + DiagConsumer(nullptr) {} ToolInvocation::ToolInvocation( std::vector CommandLine, FrontendAction *FAction, FileManager *Files, std::shared_ptr PCHContainerOps) : CommandLine(std::move(CommandLine)), Action(new SingleFrontendActionFactory(FAction)), OwnsAction(true), - Files(Files), PCHContainerOps(PCHContainerOps), DiagConsumer(nullptr) {} + Files(Files), PCHContainerOps(std::move(PCHContainerOps)), + DiagConsumer(nullptr) {} ToolInvocation::~ToolInvocation() { if (OwnsAction) @@ -311,7 +314,7 @@ ClangTool::ClangTool(const CompilationDatabase &Compilations, ArrayRef SourcePaths, std::shared_ptr PCHContainerOps) : Compilations(Compilations), SourcePaths(SourcePaths), - PCHContainerOps(PCHContainerOps), + PCHContainerOps(std::move(PCHContainerOps)), OverlayFileSystem(new vfs::OverlayFileSystem(vfs::getRealFileSystem())), InMemoryFileSystem(new vfs::InMemoryFileSystem), Files(new FileManager(FileSystemOptions(), OverlayFileSystem)), diff --git a/tools/libclang/CIndexer.h b/tools/libclang/CIndexer.h index 94c27a0560..47e30c30ba 100644 --- a/tools/libclang/CIndexer.h +++ b/tools/libclang/CIndexer.h @@ -20,6 +20,7 @@ #include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Path.h" +#include #include namespace llvm { @@ -46,7 +47,8 @@ public: CIndexer(std::shared_ptr PCHContainerOps = std::make_shared()) : OnlyLocalDecls(false), DisplayDiagnostics(false), - Options(CXGlobalOpt_None), PCHContainerOps(PCHContainerOps) {} + Options(CXGlobalOpt_None), PCHContainerOps(std::move(PCHContainerOps)) { + } /// \brief Whether we only want to see "local" declarations (that did not /// come from a previous precompiled header). If false, we want to see all diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 64f4b147d9..fe14cb2664 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CXIndexDataConsumer.h" #include "CIndexDiagnostic.h" #include "CIndexer.h" #include "CLog.h" #include "CXCursor.h" +#include "CXIndexDataConsumer.h" #include "CXSourceLocation.h" #include "CXString.h" #include "CXTranslationUnit.h" @@ -32,6 +32,7 @@ #include "llvm/Support/Mutex.h" #include "llvm/Support/MutexGuard.h" #include +#include using namespace clang; using namespace clang::index; @@ -356,7 +357,7 @@ class IndexingFrontendAction : public ASTFrontendAction { public: IndexingFrontendAction(std::shared_ptr dataConsumer, SessionSkipBodyData *skData) - : DataConsumer(dataConsumer), SKData(skData) { } + : DataConsumer(std::move(dataConsumer)), SKData(skData) {} std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index cb29b21c4a..2c25932bc7 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -241,8 +241,7 @@ namespace { public: SimpleArgument(const Record &Arg, StringRef Attr, std::string T) - : Argument(Arg, Attr), type(T) - {} + : Argument(Arg, Attr), type(std::move(T)) {} std::string getType() const { return type; } @@ -586,8 +585,9 @@ namespace { public: VariadicArgument(const Record &Arg, StringRef Attr, std::string T) - : Argument(Arg, Attr), Type(T), ArgName(getLowerName().str() + "_"), - ArgSizeName(ArgName + "Size"), RangeName(getLowerName()) {} + : Argument(Arg, Attr), Type(std::move(T)), + ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"), + RangeName(getLowerName()) {} const std::string &getType() const { return Type; } const std::string &getArgName() const { return ArgName; } diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index 002134f31c..b5313a073d 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include using namespace llvm; @@ -146,9 +147,10 @@ public: NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {} Type(TypeSpec TS, char CharMod) - : TS(TS), Float(false), Signed(false), Immediate(false), Void(false), - Poly(false), Constant(false), Pointer(false), ScalarForMangling(false), - NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) { + : TS(std::move(TS)), Float(false), Signed(false), Immediate(false), + Void(false), Poly(false), Constant(false), Pointer(false), + ScalarForMangling(false), NoManglingQ(false), Bitwidth(0), + ElementBitwidth(0), NumVectors(0) { applyModifier(CharMod); } @@ -257,7 +259,7 @@ class Variable { public: Variable() : T(Type::getVoid()), N("") {} - Variable(Type T, std::string N) : T(T), N(N) {} + Variable(Type T, std::string N) : T(std::move(T)), N(std::move(N)) {} Type getType() const { return T; } std::string getName() const { return "__" + N; }