gAlfonso-bit created this revision. gAlfonso-bit added projects: LLVM, clang-format, clang-tools-extra. Herald added subscribers: kadircet, carlosgalvezp, arphaman, zzheng, javed.absar, kbarton, nemanjai. Herald added a reviewer: njames93. Herald added a project: All. gAlfonso-bit requested review of this revision. Herald added a subscriber: cfe-commits.
This commit basically runs the very commands on themselves, with the warnings that make sense fixed. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139580 Files: clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp clang-tools-extra/clang-doc/BitcodeReader.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-include-fixer/SymbolIndexManager.h clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/clang-move/tool/ClangMove.cpp clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/clang-tidy/ClangTidyModule.h clang-tools-extra/clang-tidy/ClangTidyOptions.h clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/DraftStore.cpp clang-tools-extra/clangd/FileDistance.cpp clang-tools-extra/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/clangd/InlayHints.cpp clang-tools-extra/clangd/ParsedAST.h clang-tools-extra/clangd/Preamble.cpp clang-tools-extra/clangd/RIFF.h clang-tools-extra/clangd/TUScheduler.cpp clang-tools-extra/clangd/index/MemIndex.h clang-tools-extra/clangd/index/Ref.cpp clang-tools-extra/clangd/index/dex/Dex.h clang-tools-extra/clangd/index/dex/Iterator.h clang-tools-extra/clangd/indexer/IndexerMain.cpp clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp clang-tools-extra/clangd/support/FileCache.cpp clang-tools-extra/clangd/support/Function.h clang-tools-extra/clangd/support/Markup.cpp clang-tools-extra/clangd/support/Markup.h clang-tools-extra/clangd/support/ThreadCrashReporter.cpp clang-tools-extra/clangd/support/ThreadsafeFS.cpp clang-tools-extra/clangd/support/Trace.cpp clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp clang-tools-extra/clangd/unittests/DexTests.cpp clang-tools-extra/clangd/unittests/FileDistanceTests.cpp clang-tools-extra/clangd/unittests/IndexActionTests.cpp clang-tools-extra/clangd/unittests/LSPClient.cpp clang-tools-extra/clangd/unittests/SyncAPI.cpp clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp clang-tools-extra/clangd/unittests/TestFS.cpp clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp clang-tools-extra/clangd/xpc/XPCTransport.cpp clang-tools-extra/clangd/xpc/test-client/ClangdXPCTestClient.cpp clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h clang-tools-extra/modularize/CoverageChecker.cpp clang-tools-extra/modularize/Modularize.cpp clang-tools-extra/modularize/ModuleAssistant.cpp clang-tools-extra/modularize/PreprocessorTracker.cpp clang-tools-extra/pp-trace/PPCallbacksTracker.cpp clang-tools-extra/pp-trace/PPCallbacksTracker.h clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h clang-tools-extra/pseudo/lib/Forest.cpp clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
Index: clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp =================================================================== --- clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp +++ clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp @@ -95,8 +95,8 @@ for (const auto &T : Graph.edges()) Build.Transition.try_emplace({T.Src, T.Label}, T.Dst); for (const auto &Entry : Graph.recoveries()) - Build.Recoveries.push_back( - {Entry.Src, Recovery{Entry.Strategy, Entry.Result}}); + Build.Recoveries.emplace_back(Entry.Src, + Recovery{Entry.Strategy, Entry.Result}); Build.FollowSets = followSets(G); assert(Graph.states().size() <= (1 << StateBits) && "Graph states execceds the maximum limit!"); Index: clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp =================================================================== --- clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp +++ clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp @@ -115,7 +115,7 @@ Next.push_back(I.advance()); // sort the set to keep order determinism for hash computation. llvm::sort(Next); - Results.push_back({AdvancedSymbol, std::move(Next)}); + Results.emplace_back(AdvancedSymbol, std::move(Next)); } return Results; } @@ -127,7 +127,7 @@ const auto &Rule = G.lookupRule(I.rule()); if (I.dot() != Rule.RecoveryIndex) continue; - Result.push_back({Rule.Recovery, Rule.seq()[Rule.RecoveryIndex]}); + Result.emplace_back(Rule.Recovery, Rule.seq()[Rule.RecoveryIndex]); } llvm::sort(Result); Result.erase(std::unique(Result.begin(), Result.end()), Result.end()); @@ -207,7 +207,7 @@ } void addStartState(SymbolID Sym, StateID State) { - StartStates.push_back({Sym, State}); + StartStates.emplace_back(Sym, State); } LRGraph build() && { @@ -249,7 +249,8 @@ while (!PendingStates.empty()) { auto StateID = PendingStates.back(); PendingStates.pop_back(); - for (auto Next : nextAvailableKernelItems(Builder.find(StateID), G)) { + for (const auto &Next : + nextAvailableKernelItems(Builder.find(StateID), G)) { auto Insert = Builder.insert(Next.second); if (Insert.second) // new state, insert to the pending queue. PendingStates.push_back(Insert.first); Index: clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp =================================================================== --- clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp +++ clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp @@ -51,7 +51,8 @@ llvm::DenseSet<llvm::StringRef> UniqueAttributeValues; for (uint16_t I = 0; I < NumTerminals; ++I) - SymbolIds.try_emplace(T->Terminals[I], tokenSymbol(tok::TokenKind(I))); + SymbolIds.try_emplace(T->Terminals[I], + tokenSymbol(static_cast<tok::TokenKind>(I))); auto Consider = [&](llvm::StringRef Name) { if (!SymbolIds.count(Name)) UniqueNonterminals.insert(Name); @@ -60,8 +61,8 @@ Consider(Spec.Target); for (const RuleSpec::Element &Elt : Spec.Sequence) { Consider(Elt.Symbol); - for (const auto& KV : Elt.Attributes) - UniqueAttributeValues.insert(KV.second); + for (const auto &KV : Elt.Attributes) + UniqueAttributeValues.insert(KV.second); } } for (llvm::StringRef Name : UniqueNonterminals) { @@ -75,7 +76,7 @@ return L.Name < R.Name; }); // Add an empty string for the corresponding sentinel unset attribute. - T->AttributeValues.push_back(""); + T->AttributeValues.emplace_back(""); UniqueAttributeValues.erase(""); for (llvm::StringRef Name : UniqueAttributeValues) { T->AttributeValues.emplace_back(); @@ -101,7 +102,7 @@ Symbols.clear(); for (const RuleSpec::Element &Elt : Spec.Sequence) Symbols.push_back(Lookup(Elt.Symbol)); - T->Rules.push_back(Rule(Lookup(Spec.Target), Symbols)); + T->Rules.emplace_back(Lookup(Spec.Target), Symbols); applyAttributes(Spec, *T, T->Rules.back()); } @@ -183,13 +184,14 @@ struct Element { llvm::StringRef Symbol; // Name of the symbol // Attributes that are associated to the sequence symbol or rule. - std::vector<std::pair<llvm::StringRef/*Key*/, llvm::StringRef/*Value*/>> + std::vector<std::pair<llvm::StringRef /*Key*/, llvm::StringRef /*Value*/>> Attributes; }; std::vector<Element> Sequence; std::string toString() const { std::vector<llvm::StringRef> Body; + Body.reserve(Sequence.size()); for (const auto &E : Sequence) Body.push_back(E.Symbol); return llvm::formatv("{0} := {1}", Target, llvm::join(Body, " ")); @@ -243,12 +245,12 @@ std::vector<std::pair<llvm::StringRef, llvm::StringRef>> &Out) { assert(Content.startswith("[") && Content.endswith("]")); auto KV = Content.drop_front().drop_back().split('='); - Out.push_back({KV.first, KV.second.trim()}); + Out.emplace_back(KV.first, KV.second.trim()); return true; } // Apply the parsed extensions (stored in RuleSpec) to the grammar Rule. - void applyAttributes(const RuleSpec& Spec, const GrammarTable& T, Rule& R) { + void applyAttributes(const RuleSpec &Spec, const GrammarTable &T, Rule &R) { auto LookupExtensionID = [&T](llvm::StringRef Name) { const auto It = llvm::partition_point( T.AttributeValues, [&](llvm::StringRef X) { return X < Name; }); Index: clang-tools-extra/pseudo/lib/Forest.cpp =================================================================== --- clang-tools-extra/pseudo/lib/Forest.cpp +++ clang-tools-extra/pseudo/lib/Forest.cpp @@ -77,7 +77,8 @@ }; CountVisits(this); - unsigned IndexWidth = std::max(3, (int)std::to_string(MaxToken).size()); + unsigned IndexWidth = + std::max(3U, static_cast<unsigned>(std::to_string(MaxToken).size())); // e.g. "[{0,4}, {1,4})" if MaxToken is 5742. std::string RangeFormat = formatv("[{{0,{0}}, {{1,{0}}) ", IndexWidth); Index: clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h =================================================================== --- clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h +++ clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h @@ -99,7 +99,7 @@ llvm::ArrayRef<RuleID> getReduceRules(StateID State) const { assert(State + 1u < ReduceOffset.size()); return llvm::makeArrayRef(Reduces.data() + ReduceOffset[State], - Reduces.data() + ReduceOffset[State+1]); + Reduces.data() + ReduceOffset[State + 1]); } // Returns whether Terminal can follow Nonterminal in a valid source file. bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const { @@ -144,8 +144,8 @@ // Helper for building a table with specified actions/states. struct Builder { Builder() = default; - Builder(const Grammar &G) { - NumNonterminals = G.table().Nonterminals.size(); + Builder(const Grammar &G) : NumNonterminals(G.table().Nonterminals.size()) { + FollowSets = followSets(G); } @@ -211,7 +211,7 @@ Checkpoints.push_back(Values.size()); auto It = Entries.find(I); if (It != Entries.end()) { - HasValue[I / WordBits] |= (Word(1) << (I % WordBits)); + HasValue[I / WordBits] |= (static_cast<Word>(1) << (I % WordBits)); Values.push_back(It->second); } } @@ -219,7 +219,7 @@ llvm::Optional<StateID> get(unsigned Key) const { // Do we have a value for this key? - Word KeyMask = Word(1) << (Key % WordBits); + Word KeyMask = static_cast<Word>(1) << (Key % WordBits); unsigned KeyWord = Key / WordBits; if ((HasValue[KeyWord] & KeyMask) == 0) return std::nullopt; Index: clang-tools-extra/pp-trace/PPCallbacksTracker.h =================================================================== --- clang-tools-extra/pp-trace/PPCallbacksTracker.h +++ clang-tools-extra/pp-trace/PPCallbacksTracker.h @@ -21,9 +21,9 @@ #ifndef PPTRACE_PPCALLBACKSTRACKER_H #define PPTRACE_PPCALLBACKSTRACKER_H +#include "clang/Basic/SourceManager.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" -#include "clang/Basic/SourceManager.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" @@ -216,7 +216,7 @@ void appendFilePathArgument(const char *Name, llvm::StringRef Value); /// Get the raw source string of the range. - llvm::StringRef getSourceString(CharSourceRange Range); + llvm::StringRef getSourceString(CharSourceRange Range) const; /// Callback trace information. /// We use a reference so the trace will be preserved for the caller Index: clang-tools-extra/pp-trace/PPCallbacksTracker.cpp =================================================================== --- clang-tools-extra/pp-trace/PPCallbacksTracker.cpp +++ clang-tools-extra/pp-trace/PPCallbacksTracker.cpp @@ -101,7 +101,7 @@ Preprocessor &PP) : CallbackCalls(CallbackCalls), Filters(Filters), PP(PP) {} -PPCallbacksTracker::~PPCallbacksTracker() {} +PPCallbacksTracker::~PPCallbacksTracker() = default; // Callback functions. @@ -245,7 +245,7 @@ beginCallback("PragmaDiagnostic"); appendArgument("Loc", Loc); appendArgument("Namespace", Namespace); - appendArgument("Mapping", (unsigned)Mapping, MappingStrings); + appendArgument("Mapping", static_cast<unsigned>(Mapping), MappingStrings); appendArgument("Str", Str); } @@ -259,7 +259,7 @@ appendArgument("NameLoc", NameLoc); appendArgument("Name", Name); appendArgument("StateLoc", StateLoc); - appendArgument("State", (int)State); + appendArgument("State", static_cast<int>(State)); } // Callback invoked when a #pragma warning directive is read. @@ -273,7 +273,7 @@ std::string Str; llvm::raw_string_ostream SS(Str); SS << "["; - for (int i = 0, e = Ids.size(); i != e; ++i) { + for (size_t i = 0, e = Ids.size(); i != e; ++i) { if (i) SS << ", "; SS << Ids[i]; @@ -655,7 +655,8 @@ } // Get the raw source string of the range. -llvm::StringRef PPCallbacksTracker::getSourceString(CharSourceRange Range) { +llvm::StringRef +PPCallbacksTracker::getSourceString(CharSourceRange Range) const { const char *B = PP.getSourceManager().getCharacterData(Range.getBegin()); const char *E = PP.getSourceManager().getCharacterData(Range.getEnd()); return llvm::StringRef(B, E - B); Index: clang-tools-extra/modularize/PreprocessorTracker.cpp =================================================================== --- clang-tools-extra/modularize/PreprocessorTracker.cpp +++ clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -481,9 +481,7 @@ } PPItemKey(StringHandle Name, HeaderHandle File, int Line, int Column) : Name(Name), File(File), Line(Line), Column(Column) {} - PPItemKey(const PPItemKey &Other) - : Name(Other.Name), File(Other.File), Line(Other.Line), - Column(Other.Column) {} + PPItemKey(const PPItemKey &Other) = default; PPItemKey() : File(HeaderHandleInvalid), Line(0), Column(0) {} bool operator==(const PPItemKey &Other) const { if (Name != Other.Name) @@ -521,7 +519,7 @@ HeaderInclusionPath(std::vector<HeaderHandle> HeaderInclusionPath) : Path(HeaderInclusionPath) {} HeaderInclusionPath(const HeaderInclusionPath &Other) : Path(Other.Path) {} - HeaderInclusionPath() {} + HeaderInclusionPath() = default; std::vector<HeaderHandle> Path; }; @@ -540,7 +538,7 @@ DefinitionSourceLine(DefinitionSourceLine) { InclusionPathHandles.push_back(H); } - MacroExpansionInstance() {} + MacroExpansionInstance() = default; // Check for the presence of a header inclusion path handle entry. // Return false if not found. @@ -587,7 +585,7 @@ addMacroExpansionInstance(MacroExpanded, DefinitionLocation, DefinitionSourceLine, InclusionPathHandle); } - MacroExpansionTracker() {} + MacroExpansionTracker() = default; // Find a matching macro expansion instance. MacroExpansionInstance * @@ -638,7 +636,7 @@ : ConditionValue(ConditionValue) { InclusionPathHandles.push_back(H); } - ConditionalExpansionInstance() {} + ConditionalExpansionInstance() = default; // Check for the presence of a header inclusion path handle entry. // Return false if not found. @@ -678,7 +676,7 @@ : DirectiveKind(DirectiveKind), ConditionUnexpanded(ConditionUnexpanded) { addConditionalExpansionInstance(ConditionValue, InclusionPathHandle); } - ConditionalTracker() {} + ConditionalTracker() = default; // Find a matching condition expansion instance. ConditionalExpansionInstance * @@ -727,7 +725,7 @@ PreprocessorCallbacks(PreprocessorTrackerImpl &ppTracker, clang::Preprocessor &PP, llvm::StringRef rootHeaderFile) : PPTracker(ppTracker), PP(PP), RootHeaderFile(rootHeaderFile) {} - ~PreprocessorCallbacks() override {} + ~PreprocessorCallbacks() override = default; // Overridden handlers. void InclusionDirective(clang::SourceLocation HashLoc, @@ -782,7 +780,7 @@ class PreprocessorTrackerImpl : public PreprocessorTracker { public: PreprocessorTrackerImpl(llvm::SmallVector<std::string, 32> &Headers, - bool DoBlockCheckHeaderListOnly) + bool DoBlockCheckHeaderListOnly) : BlockCheckHeaderListOnly(DoBlockCheckHeaderListOnly), CurrentInclusionPathHandle(InclusionPathHandleInvalid), InNestedHeader(false) { @@ -794,7 +792,7 @@ } } - ~PreprocessorTrackerImpl() override {} + ~PreprocessorTrackerImpl() override = default; // Handle entering a preprocessing session. void handlePreprocessorEntry(clang::Preprocessor &PP, @@ -1152,8 +1150,8 @@ EIP = MacroInfo.InclusionPathHandles.end(); IIP != EIP; ++IIP) { const std::vector<HeaderHandle> &ip = getInclusionPath(*IIP); - auto Count = (int)ip.size(); - for (int Index = 0; Index < Count; ++Index) { + auto Count = ip.size(); + for (size_t Index = 0; Index < Count; ++Index) { HeaderHandle H = ip[Index]; OS << std::string((Index * 2) + 4, ' ') << getHeaderFilePath(H) << "\n"; @@ -1213,8 +1211,8 @@ EIP = MacroInfo.InclusionPathHandles.end(); IIP != EIP; ++IIP) { const std::vector<HeaderHandle> &ip = getInclusionPath(*IIP); - auto Count = (int)ip.size(); - for (int Index = 0; Index < Count; ++Index) { + auto Count = ip.size(); + for (size_t Index = 0; Index < Count; ++Index) { HeaderHandle H = ip[Index]; OS << std::string((Index * 2) + 4, ' ') << getHeaderFilePath(H) << "\n"; @@ -1262,7 +1260,7 @@ // PreprocessorTracker functions. // PreprocessorTracker destructor. -PreprocessorTracker::~PreprocessorTracker() {} +PreprocessorTracker::~PreprocessorTracker() = default; // Create instance of PreprocessorTracker. PreprocessorTracker *PreprocessorTracker::create( Index: clang-tools-extra/modularize/ModuleAssistant.cpp =================================================================== --- clang-tools-extra/modularize/ModuleAssistant.cpp +++ clang-tools-extra/modularize/ModuleAssistant.cpp @@ -49,7 +49,6 @@ bool output(llvm::raw_fd_ostream &OS, int Indent); Module *findSubModule(llvm::StringRef SubName); -public: std::string Name; std::vector<std::string> HeaderFileNames; std::vector<Module *> SubModules; @@ -84,19 +83,18 @@ } // Output submodules. - for (auto I = SubModules.begin(), E = SubModules.end(); I != E; ++I) { - if (!(*I)->output(OS, Indent)) + for (auto &SubModule : SubModules) { + if (!SubModule->output(OS, Indent)) return false; } // Output header files. - for (auto I = HeaderFileNames.begin(), E = HeaderFileNames.end(); I != E; - ++I) { + for (auto &HeaderFileName : HeaderFileNames) { OS.indent(Indent); - if (IsProblem || strstr((*I).c_str(), ".inl")) - OS << "exclude header \"" << *I << "\"\n"; + if (IsProblem || strstr(HeaderFileName.c_str(), ".inl")) + OS << "exclude header \"" << HeaderFileName << "\"\n"; else - OS << "header \"" << *I << "\"\n"; + OS << "header \"" << HeaderFileName << "\"\n"; } // If this module has header files, output export directive. @@ -117,9 +115,9 @@ // Lookup a sub-module. Module *Module::findSubModule(llvm::StringRef SubName) { - for (auto I = SubModules.begin(), E = SubModules.end(); I != E; ++I) { - if ((*I)->Name == SubName) - return *I; + for (auto &SubModule : SubModules) { + if (SubModule->Name == SubName) + return SubModule; } return nullptr; } @@ -140,7 +138,7 @@ static std::string ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) { std::string SafeName(MightBeReservedName); - for (int Index = 0; ReservedNames[Index] != nullptr; ++Index) { + for (size_t Index = 0; ReservedNames[Index] != nullptr; ++Index) { if (MightBeReservedName == ReservedNames[Index]) { SafeName.insert(0, "_"); break; @@ -179,10 +177,9 @@ FilePath = std::string(NativePath.substr(NativePrefix.size() + 1)); else FilePath = std::string(HeaderFilePath); - int Count = FileDependents.size(); // Headers that go into modules must not depend on other files being // included first. If there are any dependents, warn user and omit. - if (Count != 0) { + if (FileDependents.size() != 0) { llvm::errs() << "warning: " << FilePath << " depends on other headers being included first," " meaning the module.modulemap won't compile." @@ -229,10 +226,7 @@ HeaderPrefix = CurrentDirectory; // Walk the header file names and output the module map. - for (llvm::ArrayRef<std::string>::iterator I = HeaderFileNames.begin(), - E = HeaderFileNames.end(); - I != E; ++I) { - std::string Header(*I); + for (const auto &Header : HeaderFileNames) { bool IsProblemFile = false; for (auto &ProblemFile : ProblemFileNames) { if (ProblemFile == Header) { @@ -305,7 +299,7 @@ loadModuleDescriptions( RootModuleName, HeaderFileNames, ProblemFileNames, Dependencies, HeaderPrefix)); - if (!RootModule.get()) + if (!RootModule) return false; // Write module map file. Index: clang-tools-extra/modularize/Modularize.cpp =================================================================== --- clang-tools-extra/modularize/Modularize.cpp +++ clang-tools-extra/modularize/Modularize.cpp @@ -435,7 +435,7 @@ Location Loc; - StringRef getKindName() { return getKindName(Kind); } + StringRef getKindName() const { return getKindName(Kind); } static StringRef getKindName(EntryKind kind); }; @@ -730,7 +730,7 @@ class CompileCheckVisitor : public RecursiveASTVisitor<CompileCheckVisitor> { public: - CompileCheckVisitor() {} + CompileCheckVisitor() = default; bool TraverseStmt(Stmt *S) { return true; } bool TraverseType(QualType T) { return true; } @@ -772,7 +772,7 @@ class CompileCheckConsumer : public ASTConsumer { public: - CompileCheckConsumer() {} + CompileCheckConsumer() = default; void HandleTranslationUnit(ASTContext &Ctx) override { CompileCheckVisitor().TraverseDecl(Ctx.getTranslationUnitDecl()); @@ -781,7 +781,7 @@ class CompileCheckAction : public SyntaxOnlyAction { public: - CompileCheckAction() {} + CompileCheckAction() = default; protected: std::unique_ptr<clang::ASTConsumer> @@ -792,7 +792,7 @@ class CompileCheckFrontendActionFactory : public FrontendActionFactory { public: - CompileCheckFrontendActionFactory() {} + CompileCheckFrontendActionFactory() = default; std::unique_ptr<FrontendAction> create() override { return std::make_unique<CompileCheckAction>(); Index: clang-tools-extra/modularize/CoverageChecker.cpp =================================================================== --- clang-tools-extra/modularize/CoverageChecker.cpp +++ clang-tools-extra/modularize/CoverageChecker.cpp @@ -83,7 +83,7 @@ class CoverageCheckerCallbacks : public PPCallbacks { public: CoverageCheckerCallbacks(CoverageChecker &Checker) : Checker(Checker) {} - ~CoverageCheckerCallbacks() override {} + ~CoverageCheckerCallbacks() override = default; // Include directive callback. void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h =================================================================== --- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h +++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h @@ -71,7 +71,7 @@ // Order must match Kind enum! std::variant<const Decl *, struct Macro> Storage; - Symbol(decltype(Storage) Sentinel) : Storage(std::move(Sentinel)) {} + Symbol(decltype(Storage) Sentinel) : Storage(Sentinel) {} friend llvm::DenseMapInfo<Symbol>; }; llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &); Index: clang-tools-extra/clangd/xpc/test-client/ClangdXPCTestClient.cpp =================================================================== --- clang-tools-extra/clangd/xpc/test-client/ClangdXPCTestClient.cpp +++ clang-tools-extra/clangd/xpc/test-client/ClangdXPCTestClient.cpp @@ -13,8 +13,8 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include <cstdio> #include <dlfcn.h> -#include <stdio.h> #include <string> #include <xpc/xpc.h> @@ -56,8 +56,8 @@ // Lookup the XPC service bundle name, and launch it. clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier = - (clangd_xpc_get_bundle_identifier_t)dlsym( - dlHandle, "clangd_xpc_get_bundle_identifier"); + static_cast<clangd_xpc_get_bundle_identifier_t>( + dlsym(dlHandle, "clangd_xpc_get_bundle_identifier")); xpc_connection_t conn = xpc_connection_create( clangd_xpc_get_bundle_identifier(), dispatch_get_main_queue()); Index: clang-tools-extra/clangd/xpc/XPCTransport.cpp =================================================================== --- clang-tools-extra/clangd/xpc/XPCTransport.cpp +++ clang-tools-extra/clangd/xpc/XPCTransport.cpp @@ -32,7 +32,7 @@ return json::Object{ {"message", std::move(Message)}, - {"code", int64_t(Code)}, + {"code", static_cast<int64_t>(Code)}, }; } @@ -40,7 +40,7 @@ std::string Msg = std::string(O.getString("message").value_or("Unspecified error")); if (auto Code = O.getInteger("code")) - return make_error<LSPError>(std::move(Msg), ErrorCode(*Code)); + return make_error<LSPError>(std::move(Msg), static_cast<ErrorCode>(*Code)); return error("{0}", Msg); } @@ -51,7 +51,7 @@ class XPCTransport : public Transport { public: - XPCTransport() {} + XPCTransport() = default; void notify(StringRef Method, json::Value Params) override { sendMessage(json::Object{ @@ -175,7 +175,7 @@ vlog("<<< {0}\n", Doc); - if (!TransportObject->handleMessage(std::move(Doc), *HandlerPtr)) { + if (!TransportObject->handleMessage(Doc, *HandlerPtr)) { log("Received exit notification - cancelling connection."); xpc_connection_cancel(xpc_dictionary_get_remote_connection(message)); xpc_transaction_end(); Index: clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp +++ clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp @@ -56,7 +56,7 @@ SignalCurrentThread(); EXPECT_FALSE(Called); - std::string Order = ""; + std::string Order; { ThreadCrashReporter ScopedReporter([&Order] { Order.push_back('a'); }); { Index: clang-tools-extra/clangd/unittests/TestFS.cpp =================================================================== --- clang-tools-extra/clangd/unittests/TestFS.cpp +++ clang-tools-extra/clangd/unittests/TestFS.cpp @@ -68,12 +68,12 @@ CommandLine.insert(CommandLine.begin(), "clang"); if (RelPathPrefix.empty()) { // Use the absolute path in the compile command. - CommandLine.push_back(std::string(File)); + CommandLine.emplace_back(File); } else { // Build a relative path using RelPathPrefix. llvm::SmallString<32> RelativeFilePath(RelPathPrefix); llvm::sys::path::append(RelativeFilePath, FileName); - CommandLine.push_back(std::string(RelativeFilePath.str())); + CommandLine.emplace_back(RelativeFilePath.str()); } return {tooling::CompileCommand(Directory != llvm::StringRef() Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -135,9 +135,8 @@ if (!D) return; Publish([&]() { - const_cast< - llvm::unique_function<void(PathRef, std::vector<Diag>)> &> (*D)( - File, std::move(Diags)); + const_cast<llvm::unique_function<void(PathRef, std::vector<Diag>)> &>( + *D)(File, std::move(Diags)); }); } }; @@ -436,9 +435,8 @@ std::atomic<int> Actions(0); Notification Start; - updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector<Diag>) { - Start.wait(); - }); + updateWithDiags(S, Path, "a", WantDiagnostics::Yes, + [&](std::vector<Diag>) { Start.wait(); }); S.runWithAST( "invalidatable", Path, [&](llvm::Expected<InputsAndAST> AST) { @@ -1090,7 +1088,6 @@ } TEST(DebouncePolicy, Compute) { - namespace c = std::chrono; DebouncePolicy::clock::duration History[] = { c::seconds(0), c::seconds(5), @@ -1467,8 +1464,7 @@ // The throttler saw all files, and we built them. EXPECT_THAT(Throttler.Acquires, testing::UnorderedElementsAreArray(Filenames)); - EXPECT_THAT(BuiltFilenames, - testing::UnorderedElementsAreArray(Filenames)); + EXPECT_THAT(BuiltFilenames, testing::UnorderedElementsAreArray(Filenames)); // We built the files in reverse order that the throttler saw them. EXPECT_THAT(BuiltFilenames, testing::ElementsAreArray(Throttler.Acquires.rbegin(), Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SyncAPI.cpp +++ clang-tools-extra/clangd/unittests/SyncAPI.cpp @@ -32,7 +32,7 @@ CaptureProxy(const CaptureProxy &) = delete; CaptureProxy &operator=(const CaptureProxy &) = delete; // We need move ctor to return a value from the 'capture' helper. - CaptureProxy(CaptureProxy &&Other) : Target(Other.Target) { + CaptureProxy(CaptureProxy &&Other) noexcept : Target(Other.Target) { Other.Target = nullptr; } CaptureProxy &operator=(CaptureProxy &&) = delete; Index: clang-tools-extra/clangd/unittests/LSPClient.cpp =================================================================== --- clang-tools-extra/clangd/unittests/LSPClient.cpp +++ clang-tools-extra/clangd/unittests/LSPClient.cpp @@ -147,7 +147,7 @@ T->enqueue([ID(Slot.first), Method(Method.str()), Params(std::move(Params))](Transport::MessageHandler &H) { logBody(Method, Params, /*Send=*/true); - H.onCall(Method, std::move(Params), ID); + H.onCall(Method, Params, ID); }); return *Slot.second; } @@ -156,7 +156,7 @@ T->enqueue([Method(Method.str()), Params(std::move(Params))](Transport::MessageHandler &H) { logBody(Method, Params, /*Send=*/true); - H.onNotify(Method, std::move(Params)); + H.onNotify(Method, Params); }); } Index: clang-tools-extra/clangd/unittests/IndexActionTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/IndexActionTests.cpp +++ clang-tools-extra/clangd/unittests/IndexActionTests.cpp @@ -67,7 +67,8 @@ class IndexActionTest : public ::testing::Test { public: - IndexActionTest() : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem) {} + IndexActionTest() + : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem) = default; IndexFileIn runIndexingAction(llvm::StringRef MainFilePath, Index: clang-tools-extra/clangd/unittests/FileDistanceTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FileDistanceTests.cpp +++ clang-tools-extra/clangd/unittests/FileDistanceTests.cpp @@ -69,7 +69,7 @@ URIDistance D({{testPath("foo"), CostLots}, {"/not/a/testpath", SourceParams()}, - {"C:\\not\\a\\testpath", SourceParams()}}, + {R"(C:\not\a\testpath)", SourceParams()}}, Opts); #ifdef _WIN32 EXPECT_EQ(D.distance("file:///C%3a/not/a/testpath/either"), 3u); Index: clang-tools-extra/clangd/unittests/DexTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/DexTests.cpp +++ clang-tools-extra/clangd/unittests/DexTests.cpp @@ -353,7 +353,7 @@ tokensAre(std::initializer_list<std::string> Strings, Token::Kind Kind) { std::vector<Token> Tokens; for (const auto &TokenData : Strings) { - Tokens.push_back(Token(Kind, TokenData)); + Tokens.emplace_back(Kind, TokenData); } return ::testing::UnorderedElementsAreArray(Tokens); } @@ -367,6 +367,7 @@ std::vector<Trigram> Trigrams; generateIdentifierTrigrams(S, Trigrams); std::vector<Token> Tokens; + Tokens.reserve(Trigrams.size()); for (Trigram T : Trigrams) Tokens.emplace_back(Token::Kind::Trigram, T.str()); return Tokens; Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp +++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp @@ -36,7 +36,7 @@ DC(llvm::SMDiagnostic("", llvm::SourceMgr::DK_Error, Prefix)); CompiledFragment F = [Arg(Prefix + std::to_string(++Index))](const Params &P, Config &C) { - C.CompileFlags.Edits.push_back( + C.CompileFlags.Edits.emplace_back( [Arg](std::vector<std::string> &Argv) { Argv.push_back(Arg); }); return true; }; Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp +++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp @@ -185,12 +185,12 @@ Cmd.CommandLine = {"clang++", "foo.cc"}; { Config Cfg; - Cfg.CompileFlags.Edits.push_back([](std::vector<std::string> &Argv) { + Cfg.CompileFlags.Edits.emplace_back([](std::vector<std::string> &Argv) { for (auto &Arg : Argv) for (char &C : Arg) C = llvm::toUpper(C); }); - Cfg.CompileFlags.Edits.push_back([](std::vector<std::string> &Argv) { + Cfg.CompileFlags.Edits.emplace_back([](std::vector<std::string> &Argv) { Argv = tooling::getInsertArgumentAdjuster("--hello")(Argv, ""); }); WithContextValue WithConfig(Config::Key, std::move(Cfg)); Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp +++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp @@ -20,7 +20,7 @@ public: CompletionStringTest() : Allocator(std::make_shared<clang::GlobalCodeCompletionAllocator>()), - CCTUInfo(Allocator), Builder(*Allocator, CCTUInfo) {} + CCTUInfo(Allocator), Builder(*Allocator, CCTUInfo) = default; protected: void computeSignature(const CodeCompletionString &CCS, Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -81,7 +81,7 @@ HadErrorInLastDiags = HadError; } - bool hadErrorInLastDiags() { + bool hadErrorInLastDiags() const { std::lock_guard<std::mutex> Lock(Mutex); return HadErrorInLastDiags; } @@ -685,7 +685,7 @@ class TestDiagConsumer : public ClangdServer::Callbacks { public: - TestDiagConsumer() : Stats(FilesCount, FileStat()) {} + TestDiagConsumer() : Stats(FilesCount, FileStat()) = default; void onDiagnosticsReady(PathRef File, llvm::StringRef Version, std::vector<Diag> Diagnostics) override { Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -63,7 +63,7 @@ ServerThread.reset(); } - ~LSPTest() { + ~LSPTest() override { if (Server) stop(); } @@ -314,7 +314,7 @@ public: AsyncCounter() : Thread([this] { run(); }) {} - ~AsyncCounter() { + ~AsyncCounter() override { // Verify shutdown sequence was performed. // Real modules would not do this, to be robust to no ClangdServer. { @@ -335,7 +335,7 @@ // Get the current value, bypassing the queue. // Used to verify that sync->blockUntilIdle avoids races in tests. - int getSync() { + int getSync() const { std::lock_guard<std::mutex> Lock(Mu); return State; } Index: clang-tools-extra/clangd/support/Trace.cpp =================================================================== --- clang-tools-extra/clangd/support/Trace.cpp +++ clang-tools-extra/clangd/support/Trace.cpp @@ -43,7 +43,7 @@ }); } - ~JSONTracer() { + ~JSONTracer() override { Out.arrayEnd(); Out.attributeEnd(); Out.objectEnd(); @@ -79,7 +79,7 @@ void jsonEvent(llvm::StringRef Phase, llvm::json::Object &&Contents, uint64_t TID = llvm::get_threadid(), double Timestamp = 0) { Contents["ts"] = Timestamp ? Timestamp : timestamp(); - Contents["tid"] = int64_t(TID); + Contents["tid"] = static_cast<int64_t>(TID); std::lock_guard<std::mutex> Lock(Mu); rawEvent(Phase, Contents); } @@ -173,7 +173,7 @@ llvm::get_thread_name(Name); if (!Name.empty()) { rawEvent("M", llvm::json::Object{ - {"tid", int64_t(TID)}, + {"tid", static_cast<int64_t>(TID)}, {"name", "thread_name"}, {"args", llvm::json::Object{{"name", Name}}}, }); @@ -247,7 +247,6 @@ return Result; } -private: std::mutex Mu; llvm::raw_ostream &Out /*GUARDED_BY(Mu)*/; std::chrono::steady_clock::time_point Start; Index: clang-tools-extra/clangd/support/ThreadsafeFS.cpp =================================================================== --- clang-tools-extra/clangd/support/ThreadsafeFS.cpp +++ clang-tools-extra/clangd/support/ThreadsafeFS.cpp @@ -41,7 +41,7 @@ llvm::StringRef FileName = llvm::sys::path::filename(Path); if (FileName.startswith("preamble-") && FileName.endswith(".pch")) return File; - return std::unique_ptr<VolatileFile>(new VolatileFile(std::move(*File))); + return std::make_unique<VolatileFile>(std::move(*File)); } private: Index: clang-tools-extra/clangd/support/ThreadCrashReporter.cpp =================================================================== --- clang-tools-extra/clangd/support/ThreadCrashReporter.cpp +++ clang-tools-extra/clangd/support/ThreadCrashReporter.cpp @@ -34,8 +34,8 @@ } ThreadCrashReporter::ThreadCrashReporter(SignalCallback ThreadLocalCallback) - : Callback(std::move(ThreadLocalCallback)), Next(nullptr) { - this->Next = CurrentReporter; + : Callback(std::move(ThreadLocalCallback)), Next(CurrentReporter) { + CurrentReporter = this; // Don't reorder subsequent operations: whatever comes after might crash and // we want the crash handler to see the reporter values we just set. Index: clang-tools-extra/clangd/support/Markup.h =================================================================== --- clang-tools-extra/clangd/support/Markup.h +++ clang-tools-extra/clangd/support/Markup.h @@ -80,7 +80,7 @@ class BulletList : public Block { public: BulletList(); - ~BulletList(); + ~BulletList() override; void renderMarkdown(llvm::raw_ostream &OS) const override; void renderPlainText(llvm::raw_ostream &OS) const override; Index: clang-tools-extra/clangd/support/Markup.cpp =================================================================== --- clang-tools-extra/clangd/support/Markup.cpp +++ clang-tools-extra/clangd/support/Markup.cpp @@ -436,7 +436,7 @@ Paragraph &Paragraph::appendCode(llvm::StringRef Code, bool Preserve) { bool AdjacentCode = !Chunks.empty() && Chunks.back().Kind == Chunk::InlineCode; - std::string Norm = canonicalizeSpaces(std::move(Code)); + std::string Norm = canonicalizeSpaces(Code); if (Norm.empty()) return *this; Chunks.emplace_back(); Index: clang-tools-extra/clangd/support/Function.h =================================================================== --- clang-tools-extra/clangd/support/Function.h +++ clang-tools-extra/clangd/support/Function.h @@ -45,10 +45,10 @@ public: Subscription() : Parent(nullptr) {} - Subscription(Subscription &&Other) : Parent(nullptr) { + Subscription(Subscription &&Other) noexcept : Parent(nullptr) { *this = std::move(Other); } - Subscription &operator=(Subscription &&Other) { + Subscription &operator=(Subscription &&Other) noexcept { // If *this is active, unsubscribe. if (Parent) { std::lock_guard<std::recursive_mutex> Lock(Parent->ListenersMu); Index: clang-tools-extra/clangd/support/FileCache.cpp =================================================================== --- clang-tools-extra/clangd/support/FileCache.cpp +++ clang-tools-extra/clangd/support/FileCache.cpp @@ -23,7 +23,7 @@ FileCache::FileCache(llvm::StringRef Path) : Path(Path), ValidTime(std::chrono::steady_clock::time_point::min()), - ModifiedTime(), Size(CacheDiskMismatch) { + Size(CacheDiskMismatch) { assert(llvm::sys::path::is_absolute(Path)); } Index: clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp +++ clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp @@ -73,17 +73,17 @@ // Assignment target (LHS). std::string Assignee; - MethodParameter(const ObjCIvarDecl &ID) { + MethodParameter(const ObjCIvarDecl &ID) : Name(ID.getName()) { // Convention maps `@property int foo` to ivar `int _foo`, so drop the // leading `_` if there is one. - Name = ID.getName(); Name.consume_front("_"); Type = getTypeStr(ID.getType(), ID, ObjCPropertyAttribute::kind_noattr); Assignee = ID.getName().str(); } - MethodParameter(const ObjCPropertyDecl &PD) { - Name = PD.getName(); - Type = getTypeStr(PD.getType(), PD, PD.getPropertyAttributes()); + MethodParameter(const ObjCPropertyDecl &PD) + : Name(PD.getName()), + Type(getTypeStr(PD.getType(), PD, PD.getPropertyAttributes())) { + if (const auto *ID = PD.getPropertyIvarDecl()) Assignee = ID->getName().str(); else // Could be a dynamic property or a property in a header. Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp +++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp @@ -240,7 +240,7 @@ SelectedOperands.clear(); if (const BinaryOperator *Op = - llvm::dyn_cast_or_null<BinaryOperator>(N.ASTNode.get<Expr>())) { + llvm::dyn_cast_or_null<BinaryOperator>(N.ASTNode.get<Expr>())) { Kind = Op->getOpcode(); ExprLoc = Op->getExprLoc(); SelectedOperands = N.Children; @@ -255,7 +255,7 @@ Kind = BinaryOperator::getOverloadedOpcode(Op->getOperator()); ExprLoc = Op->getExprLoc(); // Not all children are args, there's also the callee (operator). - for (const auto* Child : N.Children) { + for (const auto *Child : N.Children) { const Expr *E = Child->ASTNode.get<Expr>(); assert(E && "callee and args should be Exprs!"); if (E == Op->getArg(0) || E == Op->getArg(1)) @@ -282,7 +282,7 @@ } } - bool crossesMacroBoundary(const SourceManager &SM) { + bool crossesMacroBoundary(const SourceManager &SM) const { FileID F = SM.getFileID(ExprLoc); for (const SelectionTree::Node *Child : SelectedOperands) if (SM.getFileID(Child->ASTNode.get<Expr>()->getExprLoc()) != F) @@ -376,15 +376,15 @@ if (llvm::isa<SwitchCase>(Outer)) return true; // Control flow statements use condition etc, but not the body. - if (const auto* WS = llvm::dyn_cast<WhileStmt>(Outer)) + if (const auto *WS = llvm::dyn_cast<WhileStmt>(Outer)) return Inner == WS->getBody(); - if (const auto* DS = llvm::dyn_cast<DoStmt>(Outer)) + if (const auto *DS = llvm::dyn_cast<DoStmt>(Outer)) return Inner == DS->getBody(); - if (const auto* FS = llvm::dyn_cast<ForStmt>(Outer)) + if (const auto *FS = llvm::dyn_cast<ForStmt>(Outer)) return Inner == FS->getBody(); - if (const auto* FS = llvm::dyn_cast<CXXForRangeStmt>(Outer)) + if (const auto *FS = llvm::dyn_cast<CXXForRangeStmt>(Outer)) return Inner == FS->getBody(); - if (const auto* IS = llvm::dyn_cast<IfStmt>(Outer)) + if (const auto *IS = llvm::dyn_cast<IfStmt>(Outer)) return Inner == IS->getThen() || Inner == IS->getElse(); // Assume all other cases may be actual expressions. // This includes the important case of subexpressions (where Outer is Expr). Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp =================================================================== --- clang-tools-extra/clangd/indexer/IndexerMain.cpp +++ clang-tools-extra/clangd/indexer/IndexerMain.cpp @@ -95,7 +95,7 @@ // Awkward: we write the result in the destructor, because the executor // takes ownership so it's the easiest way to get our data back out. - ~IndexActionFactory() { + ~IndexActionFactory() override { Result.Symbols = std::move(Symbols).build(); Result.Refs = std::move(Refs).build(); Result.Relations = std::move(Relations).build(); Index: clang-tools-extra/clangd/index/dex/Iterator.h =================================================================== --- clang-tools-extra/clangd/index/dex/Iterator.h +++ clang-tools-extra/clangd/index/dex/Iterator.h @@ -80,7 +80,7 @@ /// Returns an estimate of advance() calls before the iterator is exhausted. virtual size_t estimateSize() const = 0; - virtual ~Iterator() {} + virtual ~Iterator() = default; /// Prints a convenient human-readable iterator representation by recursively /// dumping iterators in the following format: Index: clang-tools-extra/clangd/index/dex/Dex.h =================================================================== --- clang-tools-extra/clangd/index/dex/Dex.h +++ clang-tools-extra/clangd/index/dex/Dex.h @@ -20,9 +20,9 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H -#include "index/dex/Iterator.h" #include "index/Index.h" #include "index/Relation.h" +#include "index/dex/Iterator.h" #include "index/dex/PostingList.h" #include "index/dex/Token.h" #include "llvm/ADT/StringSet.h" @@ -54,10 +54,10 @@ Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, Payload &&BackingData, size_t BackingDataSize) : Dex(std::forward<SymbolRange>(Symbols), std::forward<RefsRange>(Refs), - std::forward<RelationsRange>(Relations)) { + std::forward<RelationsRange>(Relations)), + BackingDataSize(BackingDataSize) { KeepAlive = std::shared_ptr<void>( std::make_shared<Payload>(std::move(BackingData)), nullptr); - this->BackingDataSize = BackingDataSize; } template <typename SymbolRange, typename RefsRange, typename RelationsRange, @@ -67,10 +67,8 @@ size_t BackingDataSize) : Dex(std::forward<SymbolRange>(Symbols), std::forward<RefsRange>(Refs), std::forward<RelationsRange>(Relations), - std::forward<Payload>(BackingData), BackingDataSize) { - this->Files = std::forward<FileRange>(Files); - this->IdxContents = IdxContents; - } + std::forward<Payload>(BackingData), BackingDataSize), + Files(std::forward<FileRange>(Files)), IdxContents(IdxContents) {} /// Builds an index from slabs. The index takes ownership of the slab. static std::unique_ptr<SymbolIndex> build(SymbolSlab, RefSlab, RelationSlab); Index: clang-tools-extra/clangd/index/Ref.cpp =================================================================== --- clang-tools-extra/clangd/index/Ref.cpp +++ clang-tools-extra/clangd/index/Ref.cpp @@ -36,7 +36,7 @@ void RefSlab::Builder::insert(const SymbolID &ID, const Ref &S) { Entry E = {ID, S}; E.Reference.Location.FileURI = UniqueStrings.save(S.Location.FileURI).data(); - Entries.insert(std::move(E)); + Entries.insert(E); } RefSlab RefSlab::Builder::build() && { Index: clang-tools-extra/clangd/index/MemIndex.h =================================================================== --- clang-tools-extra/clangd/index/MemIndex.h +++ clang-tools-extra/clangd/index/MemIndex.h @@ -39,10 +39,10 @@ Payload &&BackingData, size_t BackingDataSize) : MemIndex(std::forward<SymbolRange>(Symbols), std::forward<RefRange>(Refs), - std::forward<RelationRange>(Relations)) { + std::forward<RelationRange>(Relations)), + BackingDataSize(BackingDataSize) { KeepAlive = std::shared_ptr<void>( std::make_shared<Payload>(std::move(BackingData)), nullptr); - this->BackingDataSize = BackingDataSize; } template <typename SymbolRange, typename RefRange, typename RelationRange, @@ -53,10 +53,8 @@ : MemIndex(std::forward<SymbolRange>(Symbols), std::forward<RefRange>(Refs), std::forward<RelationRange>(Relations), - std::forward<Payload>(BackingData), BackingDataSize) { - this->Files = std::forward<FileRange>(Files); - this->IdxContents = IdxContents; - } + std::forward<Payload>(BackingData), BackingDataSize), + Files(std::forward<FileRange>(Files)), IdxContents(IdxContents) {} /// Builds an index from slabs. The index takes ownership of the data. static std::unique_ptr<SymbolIndex> build(SymbolSlab Symbols, RefSlab Refs, Index: clang-tools-extra/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/clangd/TUScheduler.cpp +++ clang-tools-extra/clangd/TUScheduler.cpp @@ -390,8 +390,7 @@ PreambleThrottlerRequest(llvm::StringRef Filename, PreambleThrottler *Throttler, std::condition_variable &CV) - : Throttler(Throttler), - Satisfied(Throttler == nullptr) { + : Throttler(Throttler), Satisfied(Throttler == nullptr) { // If there is no throttler, this dummy request is always satisfied. if (!Throttler) return; @@ -553,7 +552,7 @@ Context Ctx; }; - bool isDone() { + bool isDone() const { std::lock_guard<std::mutex> Lock(Mutex); return Done; } Index: clang-tools-extra/clangd/RIFF.h =================================================================== --- clang-tools-extra/clangd/RIFF.h +++ clang-tools-extra/clangd/RIFF.h @@ -44,7 +44,7 @@ return FourCC{{Literal[0], Literal[1], Literal[2], Literal[3]}}; } inline constexpr llvm::StringRef fourCCStr(const FourCC &Data) { - return llvm::StringRef(&Data[0], Data.size()); + return llvm::StringRef(Data.data(), Data.size()); } // A chunk is a section in a RIFF container. struct Chunk { Index: clang-tools-extra/clangd/Preamble.cpp =================================================================== --- clang-tools-extra/clangd/Preamble.cpp +++ clang-tools-extra/clangd/Preamble.cpp @@ -157,7 +157,7 @@ return false; } - bool shouldSkipFunctionBody(Decl *D) override { + bool shouldSkipFunctionBody(Decl *D) const override { // Usually we don't need to look inside the bodies of header functions // to understand the program. However when forwarding function like // emplace() forward their arguments to some other function, the @@ -552,8 +552,8 @@ if (BuiltPreamble) { log("Built preamble of size {0} for file {1} version {2} in {3} seconds", - BuiltPreamble->getSize(), FileName, Inputs.Version, - PreambleTimer.getTime()); + BuiltPreamble->getSize(), FileName, Inputs.Version, + PreambleTimer.getTime()); std::vector<Diag> Diags = PreambleDiagnostics.take(); auto Result = std::make_shared<PreambleData>(std::move(*BuiltPreamble)); Result->Version = Inputs.Version; Index: clang-tools-extra/clangd/ParsedAST.h =================================================================== --- clang-tools-extra/clangd/ParsedAST.h +++ clang-tools-extra/clangd/ParsedAST.h @@ -54,8 +54,8 @@ llvm::ArrayRef<Diag> CompilerInvocationDiags, std::shared_ptr<const PreambleData> Preamble); - ParsedAST(ParsedAST &&Other); - ParsedAST &operator=(ParsedAST &&Other); + ParsedAST(ParsedAST &&Other) noexcept; + ParsedAST &operator=(ParsedAST &&Other) noexcept; ~ParsedAST(); Index: clang-tools-extra/clangd/InlayHints.cpp =================================================================== --- clang-tools-extra/clangd/InlayHints.cpp +++ clang-tools-extra/clangd/InlayHints.cpp @@ -55,7 +55,7 @@ } } // Returns false if the type was not an aggregate. - operator bool() { return Valid; } + operator bool() const { return Valid; } // Advance to the next element in the aggregate. void next() { if (IsArray) Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp =================================================================== --- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -796,9 +796,7 @@ } DelegatingCDB::DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base) - : DelegatingCDB(Base.get()) { - BaseOwner = std::move(Base); -} + : DelegatingCDB(Base.get()), BaseOwner(std::move(Base)) {} llvm::Optional<tooling::CompileCommand> DelegatingCDB::getCompileCommand(PathRef File) const { Index: clang-tools-extra/clangd/FileDistance.cpp =================================================================== --- clang-tools-extra/clangd/FileDistance.cpp +++ clang-tools-extra/clangd/FileDistance.cpp @@ -35,6 +35,7 @@ #include "support/Logger.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Path.h" +#include <memory> #include <queue> namespace clang { @@ -172,7 +173,7 @@ } dlog("FileDistance for scheme {0}: {1}/{2} sources", Scheme, SchemeSources.size(), Sources.size()); - Delegate.reset(new FileDistance(std::move(SchemeSources), Opts)); + Delegate = std::make_unique<FileDistance>(std::move(SchemeSources), Opts); } return *Delegate; } @@ -207,7 +208,7 @@ auto Path = scopeToPath(S); // The global namespace is not 'near' its children. Param.MaxUpTraversals = std::max(Path.second - 1, 0); - Sources[Path.first] = std::move(Param); + Sources[Path.first] = Param; } return FileDistance(std::move(Sources), Opts); } Index: clang-tools-extra/clangd/DraftStore.cpp =================================================================== --- clang-tools-extra/clangd/DraftStore.cpp +++ clang-tools-extra/clangd/DraftStore.cpp @@ -30,7 +30,7 @@ std::vector<Path> ResultVector; for (auto DraftIt = Drafts.begin(); DraftIt != Drafts.end(); DraftIt++) - ResultVector.push_back(std::string(DraftIt->getKey())); + ResultVector.emplace_back(DraftIt->getKey()); return ResultVector; } Index: clang-tools-extra/clangd/CodeComplete.cpp =================================================================== --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -1642,7 +1642,7 @@ } private: - void populateContextWords(llvm::StringRef Content) { + void populateContextWords(llvm::StringRef Content) const { // Take last 3 lines before the completion point. unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(), RangeBegin = RangeEnd; Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -850,7 +850,7 @@ } void ClangdServer::foldingRanges(llvm::StringRef File, - Callback<std::vector<FoldingRange>> CB) { + Callback<std::vector<FoldingRange>> CB) const { auto Code = getDraft(File); if (!Code) return CB(llvm::make_error<LSPError>( @@ -969,7 +969,7 @@ return CB(dumpAST(Node, Inputs->AST.getTokens(), Inputs->AST.getASTContext())); } - unsigned Start, End; + size_t Start, End; if (auto Offset = positionToOffset(Inputs->Inputs.Contents, R->start)) Start = *Offset; else Index: clang-tools-extra/clangd/ClangdLSPServer.h =================================================================== --- clang-tools-extra/clangd/ClangdLSPServer.h +++ clang-tools-extra/clangd/ClangdLSPServer.h @@ -65,13 +65,13 @@ ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS, const ClangdLSPServer::Options &Opts); /// The destructor blocks on any outstanding background tasks. - ~ClangdLSPServer(); + ~ClangdLSPServer() override; /// Run LSP server loop, communicating with the Transport provided in the /// constructor. This method must not be executed more than once. /// /// \return Whether we shut down cleanly with a 'shutdown' -> 'exit' sequence. - bool run(); + bool run() const; /// Profiles resource-usage. void profile(MemoryTree &MT) const; @@ -206,7 +206,7 @@ /// Runs profiling and exports memory usage metrics if tracing is enabled and /// profiling hasn't happened recently. - void maybeExportMemoryProfile(); + void maybeExportMemoryProfile() const; PeriodicThrottler ShouldProfile; /// Run the MemoryCleanup callback if it's time. Index: clang-tools-extra/clangd/ClangdLSPServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdLSPServer.cpp +++ clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -289,7 +289,7 @@ Server(Server), TraceArgs(TraceArgs) { assert(Server); } - ReplyOnce(ReplyOnce &&Other) + ReplyOnce(ReplyOnce &&Other) noexcept : Replied(Other.Replied.load()), Start(Other.Start), ID(std::move(Other.ID)), Method(std::move(Other.Method)), Server(Other.Server), TraceArgs(Other.TraceArgs) { @@ -525,7 +525,7 @@ {"textDocumentSync", llvm::json::Object{ {"openClose", true}, - {"change", (int)TextDocumentSyncKind::Incremental}, + {"change", static_cast<int>(TextDocumentSyncKind::Incremental)}, {"save", true}, }}, {"documentFormattingProvider", true}, @@ -613,7 +613,6 @@ CodeAction::INFO_KIND}}} : llvm::json::Value(true); - std::vector<llvm::StringRef> Commands; for (llvm::StringRef Command : Handlers.CommandHandlers.keys()) Commands.push_back(Command); @@ -1351,7 +1350,7 @@ [&](llvm::StringRef File) { return ModifiedFiles.count(File) != 0; }); } -void ClangdLSPServer::maybeExportMemoryProfile() { +void ClangdLSPServer::maybeExportMemoryProfile() const { if (!trace::enabled() || !ShouldProfile()) return; @@ -1537,7 +1536,7 @@ } void ClangdLSPServer::onMemoryUsage(const NoParams &, - Callback<MemoryTree> Reply) { + Callback<MemoryTree> Reply) const { llvm::BumpPtrAllocator DetailAlloc; MemoryTree MT(&DetailAlloc); profile(MT); @@ -1640,7 +1639,7 @@ Server.reset(); } -bool ClangdLSPServer::run() { +bool ClangdLSPServer::run() const { // Run the Language Server loop. bool CleanExit = true; if (auto Err = Transp.loop(*MsgHandler)) { Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp +++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp @@ -29,11 +29,11 @@ } // Now replace the " with '. auto Pos = Result.find_first_of('"'); - if (Pos == Result.npos) + if (Pos == std::string::npos) return std::nullopt; Result[Pos] = '\''; Pos = Result.find_last_of('"'); - if (Pos == Result.npos) + if (Pos == std::string::npos) return std::nullopt; Result[Pos] = '\''; return Result; Index: clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -72,7 +72,7 @@ const std::string &DelimiterStem) { const StringRef Bytes = Literal->getBytes(); std::string Delimiter; - for (int I = 0; containsDelimiter(Bytes, Delimiter); ++I) { + for (size_t I = 0; containsDelimiter(Bytes, Delimiter); ++I) { Delimiter = (I == 0) ? DelimiterStem : DelimiterStem + std::to_string(I); } Index: clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -135,7 +135,7 @@ // The parameter is passed by value. return false; } - const int ParamIdx = Param->getFunctionScopeIndex(); + const unsigned ParamIdx = Param->getFunctionScopeIndex(); const CXXRecordDecl *Record = Ctor->getParent(); // Check whether a ctor `C` forms a pair with `Ctor` under the aforementioned @@ -144,7 +144,7 @@ if (C == Ctor || C->isDeleted() || C->getNumParams() != Ctor->getNumParams()) return false; - for (int I = 0, E = C->getNumParams(); I < E; ++I) { + for (unsigned I = 0, E = C->getNumParams(); I < E; ++I) { const clang::QualType CandidateParamType = C->parameters()[I]->getType().getCanonicalType(); const clang::QualType CtorParamType = Index: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -366,7 +366,7 @@ llvm::raw_ostream &Stream) { StringRef Delimiter = ""; - for (int I = 0, Size = Args.size(); I < Size; ++I) { + for (size_t I = 0, Size = Args.size(); I < Size; ++I) { const BindArgument &B = Args[I]; Stream << Delimiter; Index: clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp +++ clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp @@ -49,7 +49,7 @@ // one parameter with the first parameter being a pointer. However, the // second parameter can be a size_t for sized deallocation, and that is never // a placement delete operator. - if (Node.getNumParams() <= 1 || Node.getNumParams() > 2) + if (Node.getNumParams() != 2) return true; const auto *FPT = Node.getType()->castAs<FunctionProtoType>(); Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp @@ -62,7 +62,7 @@ } static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) { - llvm::APSInt Val = EnumConst->getInitVal(); + const llvm::APSInt &Val = EnumConst->getInitVal(); if (Val.isPowerOf2() || !Val.getBoolValue()) return false; const Expr *InitExpr = EnumConst->getInitExpr(); @@ -102,7 +102,7 @@ return NonPowOfTwoCounter >= 1 && NonPowOfTwoCounter <= 2 && NonPowOfTwoCounter < EnumLen / 2 && (VR.MaxVal - VR.MinVal != EnumLen - 1) && - !(NonPowOfTwoCounter == 1 && isMaxValAllBitSetLiteral(EnumDec)); + (NonPowOfTwoCounter != 1 || !isMaxValAllBitSetLiteral(EnumDec)); } SuspiciousEnumUsageCheck::SuspiciousEnumUsageCheck(StringRef Name, Index: clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp @@ -1958,8 +1958,9 @@ FormattedConversionSequence(const PrintingPolicy &PP, StringRef StartTypeAsDiagnosed, const model::ConversionSequence &Conv, - StringRef DestinationTypeAsDiagnosed) { - Trivial = true; + StringRef DestinationTypeAsDiagnosed) + : Trivial(true) { + llvm::raw_string_ostream OS{DiagnosticText}; // Print the type name as it is printed in other places in the diagnostic. Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp +++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp @@ -13,7 +13,7 @@ #include "clang/AST/OperationKinds.h" #include "clang/AST/ParentMapContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include <math.h> +#include <cmath> using namespace clang::ast_matchers; Index: clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp +++ clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp @@ -10,7 +10,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/RecordLayout.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include <math.h> +#include <cmath> using namespace clang::ast_matchers; Index: clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp +++ clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp @@ -44,11 +44,11 @@ // Now replace the " with '. std::string::size_type Pos = Result.find_first_of('"'); - if (Pos == Result.npos) + if (Pos == std::string::npos) return std::nullopt; Result[Pos] = '\''; Pos = Result.find_last_of('"'); - if (Pos == Result.npos) + if (Pos == std::string::npos) return std::nullopt; Result[Pos] = '\''; return Result; Index: clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h =================================================================== --- clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h +++ clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h @@ -45,7 +45,7 @@ ExpandModularHeadersPPCallbacks( CompilerInstance *Compiler, IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS); - ~ExpandModularHeadersPPCallbacks(); + ~ExpandModularHeadersPPCallbacks() override; /// Returns the preprocessor that provides callbacks for the whole /// translation unit, including the main file, textual headers, and modular Index: clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp +++ clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp @@ -43,8 +43,8 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) { OS << "{\n"; - OS << "\"file\": \"" << Storage->SourceFilename << "\",\n"; - OS << "\"timestamp\": \"" << Storage->Timestamp << "\",\n"; + OS << R"("file": ")" << Storage->SourceFilename << "\",\n"; + OS << R"("timestamp": ")" << Storage->Timestamp << "\",\n"; OS << "\"profile\": {\n"; TG->printJSONValues(OS, ""); OS << "\n}\n"; Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -102,7 +102,7 @@ /// Helper structure for storing option value with priority of the value. struct ClangTidyValue { - ClangTidyValue() : Value(), Priority(0) {} + ClangTidyValue() : Priority(0) {} ClangTidyValue(const char *Value) : Value(Value), Priority(0) {} ClangTidyValue(llvm::StringRef Value, unsigned Priority = 0) : Value(Value), Priority(Priority) {} @@ -146,7 +146,7 @@ static const char OptionsSourceTypeCheckCommandLineOption[]; static const char OptionsSourceTypeConfigCommandLineOption[]; - virtual ~ClangTidyOptionsProvider() {} + virtual ~ClangTidyOptionsProvider() = default; /// Returns global options, which are independent of the file. virtual const ClangTidyGlobalOptions &getGlobalOptions() = 0; @@ -226,7 +226,6 @@ ClangTidyOptions OverrideOptions, ConfigFileHandlers ConfigHandlers); -protected: void addRawFileOptions(llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions); Index: clang-tools-extra/clang-tidy/ClangTidyModule.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyModule.h +++ clang-tools-extra/clang-tidy/ClangTidyModule.h @@ -84,7 +84,7 @@ /// them a prefixed name. class ClangTidyModule { public: - virtual ~ClangTidyModule() {} + virtual ~ClangTidyModule() = default; /// Implement this function in order to register all \c CheckFactories /// belonging to this module. Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -635,7 +635,7 @@ removeDuplicatedDiagnosticsOfAliasCheckers(); // Compute error sizes. - std::vector<int> Sizes; + std::vector<unsigned> Sizes; std::vector< std::pair<ClangTidyError *, llvm::StringMap<tooling::Replacements> *>> ErrorFixes; @@ -645,7 +645,7 @@ &Error, const_cast<llvm::StringMap<tooling::Replacements> *>(Fix)); } for (const auto &ErrorAndFix : ErrorFixes) { - int Size = 0; + unsigned Size = 0; for (const auto &FileAndReplaces : *ErrorAndFix.second) { for (const auto &Replace : FileAndReplaces.second) Size += Replace.getLength(); Index: clang-tools-extra/clang-move/tool/ClangMove.cpp =================================================================== --- clang-tools-extra/clang-move/tool/ClangMove.cpp +++ clang-tools-extra/clang-move/tool/ClangMove.cpp @@ -145,9 +145,9 @@ const auto &Declarations = Reporter.getDeclarationList(); for (auto I = Declarations.begin(), E = Declarations.end(); I != E; ++I) { llvm::outs() << " {\n"; - llvm::outs() << " \"DeclarationName\": \"" << I->QualifiedName + llvm::outs() << R"( "DeclarationName": ")" << I->QualifiedName << "\",\n"; - llvm::outs() << " \"DeclarationType\": \"" << I->Kind << "\",\n"; + llvm::outs() << R"( "DeclarationType": ")" << I->Kind << "\",\n"; llvm::outs() << " \"Templated\": " << (I->Templated ? "true" : "false") << "\n"; llvm::outs() << " }"; @@ -198,13 +198,13 @@ OS << "[\n"; for (auto I = Files.begin(), E = Files.end(); I != E; ++I) { OS << " {\n"; - OS << " \"FilePath\": \"" << *I << "\",\n"; + OS << R"( "FilePath": ")" << *I << "\",\n"; const auto Entry = FileMgr.getFile(*I); auto ID = SM.translateFile(*Entry); std::string Content; llvm::raw_string_ostream ContentStream(Content); Rewrite.getEditBuffer(ID).write(ContentStream); - OS << " \"SourceText\": \"" + OS << R"( "SourceText": ")" << llvm::yaml::escape(ContentStream.str()) << "\"\n"; OS << " }"; if (I != std::prev(E)) Index: clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp =================================================================== --- clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp +++ clang-tools-extra/clang-include-fixer/tool/ClangIncludeFixer.cpp @@ -40,7 +40,7 @@ NormalizedRange(const IO &, const tooling::Range &R) : Offset(R.getOffset()), Length(R.getLength()) {} - tooling::Range denormalize(const IO &) { + tooling::Range denormalize(const IO &) const { return tooling::Range(Offset, Length); } @@ -237,8 +237,8 @@ void writeToJson(llvm::raw_ostream &OS, const IncludeFixerContext& Context) { OS << "{\n" - << " \"FilePath\": \"" - << llvm::yaml::escape(Context.getFilePath()) << "\",\n" + << R"( "FilePath": ")" << llvm::yaml::escape(Context.getFilePath()) + << "\",\n" << " \"QuerySymbolInfos\": [\n"; for (const auto &Info : Context.getQuerySymbolInfos()) { OS << " {\"RawIdentifier\": \"" << Info.RawIdentifier << "\",\n"; Index: clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h =================================================================== --- clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h +++ clang-tools-extra/clang-include-fixer/find-all-symbols/SymbolInfo.h @@ -50,7 +50,7 @@ // Signals are signals gathered by observing how a symbol is used. // These are used to rank results. struct Signals { - Signals() {} + Signals() = default; Signals(unsigned Seen, unsigned Used) : Seen(Seen), Used(Used) {} // Number of times this symbol was visible to a TU. Index: clang-tools-extra/clang-include-fixer/SymbolIndexManager.h =================================================================== --- clang-tools-extra/clang-include-fixer/SymbolIndexManager.h +++ clang-tools-extra/clang-include-fixer/SymbolIndexManager.h @@ -38,7 +38,7 @@ #else auto Strategy = std::launch::deferred; #endif - SymbolIndices.push_back(std::async(Strategy, F)); + SymbolIndices.emplace_back(std::async(Strategy, F)); } /// Search for header files to be included for an identifier. Index: clang-tools-extra/clang-doc/Representation.h =================================================================== --- clang-tools-extra/clang-doc/Representation.h +++ clang-tools-extra/clang-doc/Representation.h @@ -370,7 +370,7 @@ }; struct BaseRecordInfo : public RecordInfo { - BaseRecordInfo() : RecordInfo() {} + BaseRecordInfo() = default; BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual, AccessSpecifier Access, bool IsParent) : RecordInfo(USR, Name, Path), IsVirtual(IsVirtual), Access(Access), Index: clang-tools-extra/clang-doc/BitcodeReader.cpp =================================================================== --- clang-tools-extra/clang-doc/BitcodeReader.cpp +++ clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -783,11 +783,11 @@ "premature end of stream"); // Sniff for the signature. - for (int Idx = 0; Idx != 4; ++Idx) { + for (unsigned char Idx : BitCodeConstants::Signature) { Expected<llvm::SimpleBitstreamCursor::word_t> MaybeRead = Stream.Read(8); if (!MaybeRead) return MaybeRead.takeError(); - else if (MaybeRead.get() != BitCodeConstants::Signature[Idx]) + else if (MaybeRead.get() != Idx) return llvm::createStringError(llvm::inconvertibleErrorCode(), "invalid bitcode signature"); } Index: clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp =================================================================== --- clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp +++ clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp @@ -151,7 +151,7 @@ OS << "[\n"; for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) { OS << " {\n"; - OS << " \"FilePath\": \"" << *I << "\",\n"; + OS << R"( "FilePath": ")" << *I << "\",\n"; const auto Entry = FileMgr.getFile(*I); auto ID = Sources.getOrCreateFileID(*Entry, SrcMgr::C_User); std::string Content;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits