Index: clang-modernize/AddOverride/AddOverrideActions.h =================================================================== --- clang-modernize/AddOverride/AddOverrideActions.h +++ clang-modernize/AddOverride/AddOverrideActions.h @@ -31,7 +31,8 @@ Owner(Owner) {} /// \brief Entry point to the callback called when matches are made. - virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result); + void + run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override; void setPreprocessor(clang::Preprocessor &PP) { this->PP = &PP; } Index: clang-modernize/Core/IncludeDirectives.cpp =================================================================== --- clang-modernize/Core/IncludeDirectives.cpp +++ clang-modernize/Core/IncludeDirectives.cpp @@ -60,7 +60,7 @@ public: IncludeDirectivesPPCallback(IncludeDirectives *Self) : Self(Self), Guard(nullptr) {} - virtual ~IncludeDirectivesPPCallback() {} + ~IncludeDirectivesPPCallback() override {} private: void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, @@ -78,9 +78,9 @@ } // Keep track of the current file in the stack - virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, - SrcMgr::CharacteristicKind FileType, - FileID PrevFID) override { + void FileChanged(SourceLocation Loc, FileChangeReason Reason, + SrcMgr::CharacteristicKind FileType, + FileID PrevFID) override { SourceManager &SM = Self->Sources; switch (Reason) { case EnterFile: @@ -143,8 +143,8 @@ Self->HeaderToGuard[File] = Guard.DefineLoc; } - virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok, - const MacroDirective *MD) override { + void Ifndef(SourceLocation Loc, const Token &MacroNameTok, + const MacroDirective *MD) override { Guard->Count++; // If this #ifndef is the top-most directive and the symbol isn't defined @@ -160,8 +160,8 @@ } } - virtual void MacroDefined(const Token &MacroNameTok, - const MacroDirective *MD) override { + void MacroDefined(const Token &MacroNameTok, + const MacroDirective *MD) override { Guard->Count++; // If this #define is the second directive of the file and the symbol @@ -196,28 +196,24 @@ Guard->EndifLoc = Loc; } - virtual void MacroExpands(const Token &, const MacroDirective *, SourceRange, - const MacroArgs *) override { + void MacroExpands(const Token &, const MacroDirective *, SourceRange, + const MacroArgs *) override { Guard->Count++; } - virtual void MacroUndefined(const Token &, - const MacroDirective *) override { + void MacroUndefined(const Token &, const MacroDirective *) override { Guard->Count++; } - virtual void Defined(const Token &, const MacroDirective *, - SourceRange) override { + void Defined(const Token &, const MacroDirective *, SourceRange) override { Guard->Count++; } - virtual void If(SourceLocation, SourceRange, - ConditionValueKind) override { + void If(SourceLocation, SourceRange, ConditionValueKind) override { Guard->Count++; } - virtual void Elif(SourceLocation, SourceRange, ConditionValueKind, - SourceLocation) override { + void Elif(SourceLocation, SourceRange, ConditionValueKind, + SourceLocation) override { Guard->Count++; } - virtual void Ifdef(SourceLocation, const Token &, - const MacroDirective *) override { + void Ifdef(SourceLocation, const Token &, const MacroDirective *) override { Guard->Count++; } void Else(SourceLocation, SourceLocation) override { Index: clang-modernize/Core/Transform.cpp =================================================================== --- clang-modernize/Core/Transform.cpp +++ clang-modernize/Core/Transform.cpp @@ -54,8 +54,8 @@ return Finder.newASTConsumer(); } - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef Filename) override { + bool BeginSourceFileAction(CompilerInstance &CI, + StringRef Filename) override { if (!ASTFrontendAction::BeginSourceFileAction(CI, Filename)) return false; Index: clang-modernize/LoopConvert/LoopActions.h =================================================================== --- clang-modernize/LoopConvert/LoopActions.h +++ clang-modernize/LoopConvert/LoopActions.h @@ -71,7 +71,8 @@ DeferredChanges(DeferredChanges), RejectedChanges(RejectedChanges), MaxRisk(MaxRisk), FixerKind(FixerKind), Owner(Owner) {} - virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result); + void + run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override; private: TUTrackingInfo &TUInfo; Index: clang-modernize/UseNullptr/NullptrActions.h =================================================================== --- clang-modernize/UseNullptr/NullptrActions.h +++ clang-modernize/UseNullptr/NullptrActions.h @@ -31,7 +31,8 @@ llvm::ArrayRef UserMacros, Transform &Owner); /// \brief Entry point to the callback called when matches are made. - virtual void run(const clang::ast_matchers::MatchFinder::MatchResult &Result); + void + run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override; private: unsigned &AcceptedChanges; Index: clang-query/Query.cpp =================================================================== --- clang-query/Query.cpp +++ clang-query/Query.cpp @@ -53,7 +53,7 @@ struct CollectBoundNodes : MatchFinder::MatchCallback { std::vector &Bindings; CollectBoundNodes(std::vector &Bindings) : Bindings(Bindings) {} - void run(const MatchFinder::MatchResult &Result) { + void run(const MatchFinder::MatchResult &Result) override { Bindings.push_back(Result.Nodes); } }; Index: modularize/CoverageChecker.cpp =================================================================== --- modularize/CoverageChecker.cpp +++ modularize/CoverageChecker.cpp @@ -83,14 +83,14 @@ class CoverageCheckerCallbacks : public PPCallbacks { public: CoverageCheckerCallbacks(CoverageChecker &Checker) : Checker(Checker) {} - ~CoverageCheckerCallbacks() {} + ~CoverageCheckerCallbacks() override {} // Include directive callback. void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, - StringRef FileName, bool IsAngled, - CharSourceRange FilenameRange, const FileEntry *File, - StringRef SearchPath, StringRef RelativePath, - const Module *Imported) { + StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, + StringRef SearchPath, StringRef RelativePath, + const Module *Imported) override { Checker.collectUmbrellaHeaderHeader(File->getName()); } @@ -127,9 +127,9 @@ class CoverageCheckerFrontendActionFactory : public FrontendActionFactory { public: CoverageCheckerFrontendActionFactory(CoverageChecker &Checker) - : Checker(Checker) {} + : Checker(Checker) {} - virtual CoverageCheckerAction *create() { + CoverageCheckerAction *create() override { return new CoverageCheckerAction(Checker); } Index: modularize/Modularize.cpp =================================================================== --- modularize/Modularize.cpp +++ modularize/Modularize.cpp @@ -631,9 +631,9 @@ PPTracker.handlePreprocessorEntry(PP, InFile); } - ~CollectEntitiesConsumer() { PPTracker.handlePreprocessorExit(); } + ~CollectEntitiesConsumer() override { PPTracker.handlePreprocessorExit(); } - virtual void HandleTranslationUnit(ASTContext &Ctx) { + void HandleTranslationUnit(ASTContext &Ctx) override { SourceManager &SM = Ctx.getSourceManager(); // Collect declared entities. @@ -691,7 +691,7 @@ : Entities(Entities), PPTracker(preprocessorTracker), HadErrors(HadErrors) {} - virtual CollectEntitiesAction *create() { + CollectEntitiesAction *create() override { return new CollectEntitiesAction(Entities, PPTracker, HadErrors); } Index: modularize/PreprocessorTracker.cpp =================================================================== --- modularize/PreprocessorTracker.cpp +++ modularize/PreprocessorTracker.cpp @@ -747,7 +747,7 @@ PreprocessorCallbacks(PreprocessorTrackerImpl &ppTracker, clang::Preprocessor &PP, llvm::StringRef rootHeaderFile) : PPTracker(ppTracker), PP(PP), RootHeaderFile(rootHeaderFile) {} - ~PreprocessorCallbacks() {} + ~PreprocessorCallbacks() override {} // Overridden handlers. void InclusionDirective(clang::SourceLocation HashLoc, @@ -757,24 +757,26 @@ const clang::FileEntry *File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, - const clang::Module *Imported); + const clang::Module *Imported) override; void FileChanged(clang::SourceLocation Loc, clang::PPCallbacks::FileChangeReason Reason, clang::SrcMgr::CharacteristicKind FileType, - clang::FileID PrevFID = clang::FileID()); + clang::FileID PrevFID = clang::FileID()) override; void MacroExpands(const clang::Token &MacroNameTok, const clang::MacroDirective *MD, clang::SourceRange Range, - const clang::MacroArgs *Args); + const clang::MacroArgs *Args) override; void Defined(const clang::Token &MacroNameTok, - const clang::MacroDirective *MD, clang::SourceRange Range); + const clang::MacroDirective *MD, + clang::SourceRange Range) override; void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, - clang::PPCallbacks::ConditionValueKind ConditionResult); + clang::PPCallbacks::ConditionValueKind ConditionResult) override; void Elif(clang::SourceLocation Loc, clang::SourceRange ConditionRange, - clang::PPCallbacks::ConditionValueKind ConditionResult, clang::SourceLocation IfLoc); + clang::PPCallbacks::ConditionValueKind ConditionResult, + clang::SourceLocation IfLoc) override; void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, - const clang::MacroDirective *MD); + const clang::MacroDirective *MD) override; void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, - const clang::MacroDirective *MD); + const clang::MacroDirective *MD) override; private: PreprocessorTrackerImpl &PPTracker; @@ -811,26 +813,27 @@ } } - ~PreprocessorTrackerImpl() {} + ~PreprocessorTrackerImpl() override {} // Handle entering a preprocessing session. void handlePreprocessorEntry(clang::Preprocessor &PP, - llvm::StringRef rootHeaderFile) { + llvm::StringRef rootHeaderFile) override { HeadersInThisCompile.clear(); assert((HeaderStack.size() == 0) && "Header stack should be empty."); pushHeaderHandle(addHeader(rootHeaderFile)); - PP.addPPCallbacks(llvm::make_unique(*this, PP, - rootHeaderFile)); + PP.addPPCallbacks( + llvm::make_unique(*this, PP, rootHeaderFile)); } // Handle exiting a preprocessing session. - void handlePreprocessorExit() { HeaderStack.clear(); } + void handlePreprocessorExit() override { HeaderStack.clear(); } // Handle include directive. // This function is called every time an include directive is seen by the // preprocessor, for the purpose of later checking for 'extern "" {}' or // "namespace {}" blocks containing #include directives. void handleIncludeDirective(llvm::StringRef DirectivePath, int DirectiveLine, - int DirectiveColumn, llvm::StringRef TargetPath) { + int DirectiveColumn, + llvm::StringRef TargetPath) override { // If it's not a header in the header list, ignore it with respect to // the check. if (BlockCheckHeaderListOnly && !isHeaderListHeader(TargetPath)) @@ -855,7 +858,7 @@ bool checkForIncludesInBlock(clang::Preprocessor &PP, clang::SourceRange BlockSourceRange, const char *BlockIdentifierMessage, - llvm::raw_ostream &OS) { + llvm::raw_ostream &OS) override { clang::SourceLocation BlockStartLoc = BlockSourceRange.getBegin(); clang::SourceLocation BlockEndLoc = BlockSourceRange.getEnd(); // Use block location to get FileID of both the include directive @@ -1139,7 +1142,7 @@ // Report on inconsistent macro instances. // Returns true if any mismatches. - bool reportInconsistentMacros(llvm::raw_ostream &OS) { + bool reportInconsistentMacros(llvm::raw_ostream &OS) override { bool ReturnValue = false; // Walk all the macro expansion trackers in the map. for (MacroExpansionMapIter I = MacroExpansions.begin(), @@ -1200,7 +1203,7 @@ // Report on inconsistent conditional instances. // Returns true if any mismatches. - bool reportInconsistentConditionals(llvm::raw_ostream &OS) { + bool reportInconsistentConditionals(llvm::raw_ostream &OS) override { bool ReturnValue = false; // Walk all the conditional trackers in the map. for (ConditionalExpansionMapIter I = ConditionalExpansions.begin(), Index: pp-trace/PPCallbacksTracker.h =================================================================== --- pp-trace/PPCallbacksTracker.h +++ pp-trace/PPCallbacksTracker.h @@ -76,7 +76,7 @@ std::vector &CallbackCalls, clang::Preprocessor &PP); - virtual ~PPCallbacksTracker(); + ~PPCallbacksTracker() override; // Overidden callback functions. Index: pp-trace/PPTrace.cpp =================================================================== --- pp-trace/PPTrace.cpp +++ pp-trace/PPTrace.cpp @@ -139,7 +139,7 @@ std::vector &CallbackCalls) : Ignore(Ignore), CallbackCalls(CallbackCalls) {} - virtual PPTraceAction *create() { + PPTraceAction *create() override { return new PPTraceAction(Ignore, CallbackCalls); } Index: unittests/clang-modernize/IncludeDirectivesTest.cpp =================================================================== --- unittests/clang-modernize/IncludeDirectivesTest.cpp +++ unittests/clang-modernize/IncludeDirectivesTest.cpp @@ -82,8 +82,8 @@ } private: - virtual bool BeginSourceFileAction(CompilerInstance &CI, - StringRef FileName) override { + bool BeginSourceFileAction(CompilerInstance &CI, + StringRef FileName) override { if (!PreprocessOnlyAction::BeginSourceFileAction(CI, FileName)) return false; VFHelper.mapVirtualFiles(CI.getSourceManager()); @@ -95,7 +95,7 @@ return true; } - virtual void EndSourceFileAction() override { + void EndSourceFileAction() override { const tooling::Replacement &Replace = FileIncludes->addAngledInclude(FileToModify, Include); if (Replace.isApplicable()) Index: unittests/clang-modernize/PerfSupportTest.cpp =================================================================== --- unittests/clang-modernize/PerfSupportTest.cpp +++ unittests/clang-modernize/PerfSupportTest.cpp @@ -18,8 +18,8 @@ TransformA(const TransformOptions &Options) : Transform("TransformA", Options) {} - virtual int apply(const tooling::CompilationDatabase &, - const std::vector &) { + int apply(const tooling::CompilationDatabase &, + const std::vector &) override { return 0; } @@ -33,8 +33,8 @@ TransformB(const TransformOptions &Options) : Transform("TransformB", Options) {} - virtual int apply(const tooling::CompilationDatabase &, - const std::vector &) { + int apply(const tooling::CompilationDatabase &, + const std::vector &) override { return 0; } Index: unittests/clang-modernize/TransformTest.cpp =================================================================== --- unittests/clang-modernize/TransformTest.cpp +++ unittests/clang-modernize/TransformTest.cpp @@ -25,8 +25,10 @@ DummyTransform(llvm::StringRef Name, const TransformOptions &Options) : Transform(Name, Options) {} - virtual int apply(const tooling::CompilationDatabase &, - const std::vector &) { return 0; } + int apply(const tooling::CompilationDatabase &, + const std::vector &) override { + return 0; + } void setAcceptedChanges(unsigned Changes) { Transform::setAcceptedChanges(Changes); @@ -73,7 +75,7 @@ public: TimePassingASTConsumer(bool *Called) : Called(Called) {} - virtual bool HandleTopLevelDecl(DeclGroupRef DeclGroup) { + bool HandleTopLevelDecl(DeclGroupRef DeclGroup) override { llvm::sys::TimeValue UserStart; llvm::sys::TimeValue SystemStart; llvm::sys::TimeValue UserNow; @@ -102,13 +104,11 @@ struct CallbackForwarder : public clang::tooling::SourceFileCallbacks { CallbackForwarder(Transform &Callee) : Callee(Callee) {} - virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) { + bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { return Callee.handleBeginSource(CI, Filename); } - virtual void handleEndSource() { - Callee.handleEndSource(); - } + void handleEndSource() override { Callee.handleEndSource(); } Transform &Callee; }; @@ -181,11 +181,10 @@ class ModifiableCallback : public clang::ast_matchers::MatchFinder::MatchCallback { public: - ModifiableCallback(const Transform &Owner) - : Owner(Owner) {} + ModifiableCallback(const Transform &Owner) : Owner(Owner) {} - virtual void - run(const clang::ast_matchers::MatchFinder::MatchResult &Result) { + void + run(const clang::ast_matchers::MatchFinder::MatchResult &Result) override { const VarDecl *Decl = Result.Nodes.getNodeAs("decl"); ASSERT_TRUE(Decl != nullptr);