diff --git a/clang-modernize/AddOverride/AddOverrideActions.h b/clang-modernize/AddOverride/AddOverrideActions.h index bb59078..468dcd9 100644 --- a/clang-modernize/AddOverride/AddOverrideActions.h +++ b/clang-modernize/AddOverride/AddOverrideActions.h @@ -31,7 +31,8 @@ public: 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; } diff --git a/clang-modernize/Core/IncludeDirectives.cpp b/clang-modernize/Core/IncludeDirectives.cpp index 8ad1dc5..f5e2668 100644 --- a/clang-modernize/Core/IncludeDirectives.cpp +++ b/clang-modernize/Core/IncludeDirectives.cpp @@ -60,7 +60,7 @@ class IncludeDirectivesPPCallback : public clang::PPCallbacks { public: IncludeDirectivesPPCallback(IncludeDirectives *Self) : Self(Self), Guard(nullptr) {} - virtual ~IncludeDirectivesPPCallback() {} + ~IncludeDirectivesPPCallback() override {} private: void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, @@ -78,9 +78,9 @@ private: } // 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 @@ private: 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 @@ private: } } - 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 @@ private: 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 { diff --git a/clang-modernize/Core/Transform.cpp b/clang-modernize/Core/Transform.cpp index 41a7d45..114b525 100644 --- a/clang-modernize/Core/Transform.cpp +++ b/clang-modernize/Core/Transform.cpp @@ -54,8 +54,8 @@ private: 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; diff --git a/clang-modernize/LoopConvert/LoopActions.h b/clang-modernize/LoopConvert/LoopActions.h index a14125e..e6fadd2 100644 --- a/clang-modernize/LoopConvert/LoopActions.h +++ b/clang-modernize/LoopConvert/LoopActions.h @@ -71,7 +71,8 @@ public: 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; diff --git a/clang-modernize/UseNullptr/NullptrActions.h b/clang-modernize/UseNullptr/NullptrActions.h index 4e2d9b6..51dbb00 100644 --- a/clang-modernize/UseNullptr/NullptrActions.h +++ b/clang-modernize/UseNullptr/NullptrActions.h @@ -31,7 +31,8 @@ public: 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; diff --git a/clang-query/Query.cpp b/clang-query/Query.cpp index 3b49624..d5d7551 100644 --- a/clang-query/Query.cpp +++ b/clang-query/Query.cpp @@ -53,7 +53,7 @@ namespace { 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); } }; diff --git a/modularize/CoverageChecker.cpp b/modularize/CoverageChecker.cpp index 257dbca..204e2e4 100644 --- a/modularize/CoverageChecker.cpp +++ b/modularize/CoverageChecker.cpp @@ -83,14 +83,14 @@ namespace sys = llvm::sys; 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()); } @@ -129,7 +129,7 @@ public: CoverageCheckerFrontendActionFactory(CoverageChecker &Checker) : Checker(Checker) {} - virtual CoverageCheckerAction *create() { + CoverageCheckerAction *create() override { return new CoverageCheckerAction(Checker); } diff --git a/modularize/Modularize.cpp b/modularize/Modularize.cpp index 38f1f1a..61234e0 100644 --- a/modularize/Modularize.cpp +++ b/modularize/Modularize.cpp @@ -631,9 +631,9 @@ public: 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 @@ public: : Entities(Entities), PPTracker(preprocessorTracker), HadErrors(HadErrors) {} - virtual CollectEntitiesAction *create() { + CollectEntitiesAction *create() override { return new CollectEntitiesAction(Entities, PPTracker, HadErrors); } diff --git a/modularize/PreprocessorTracker.cpp b/modularize/PreprocessorTracker.cpp index c48f27e..bc348c9 100644 --- a/modularize/PreprocessorTracker.cpp +++ b/modularize/PreprocessorTracker.cpp @@ -747,7 +747,7 @@ public: 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 @@ public: 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,11 +813,11 @@ public: } } - ~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)); @@ -823,14 +825,15 @@ public: 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 @@ public: 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 @@ public: // 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 @@ public: // 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(), diff --git a/pp-trace/PPCallbacksTracker.h b/pp-trace/PPCallbacksTracker.h index dab29fe..65a03b2 100644 --- a/pp-trace/PPCallbacksTracker.h +++ b/pp-trace/PPCallbacksTracker.h @@ -76,7 +76,7 @@ public: std::vector &CallbackCalls, clang::Preprocessor &PP); - virtual ~PPCallbacksTracker(); + ~PPCallbacksTracker() override; // Overidden callback functions. diff --git a/pp-trace/PPTrace.cpp b/pp-trace/PPTrace.cpp index 5bfe186..51c844c 100644 --- a/pp-trace/PPTrace.cpp +++ b/pp-trace/PPTrace.cpp @@ -139,7 +139,7 @@ public: std::vector &CallbackCalls) : Ignore(Ignore), CallbackCalls(CallbackCalls) {} - virtual PPTraceAction *create() { + PPTraceAction *create() override { return new PPTraceAction(Ignore, CallbackCalls); } diff --git a/unittests/clang-modernize/IncludeDirectivesTest.cpp b/unittests/clang-modernize/IncludeDirectivesTest.cpp index b135288..1c6fc12 100644 --- a/unittests/clang-modernize/IncludeDirectivesTest.cpp +++ b/unittests/clang-modernize/IncludeDirectivesTest.cpp @@ -82,8 +82,8 @@ public: } 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 @@ private: return true; } - virtual void EndSourceFileAction() override { + void EndSourceFileAction() override { const tooling::Replacement &Replace = FileIncludes->addAngledInclude(FileToModify, Include); if (Replace.isApplicable()) diff --git a/unittests/clang-modernize/PerfSupportTest.cpp b/unittests/clang-modernize/PerfSupportTest.cpp index 083ff41..1cc116d 100644 --- a/unittests/clang-modernize/PerfSupportTest.cpp +++ b/unittests/clang-modernize/PerfSupportTest.cpp @@ -18,8 +18,8 @@ public: 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 @@ public: 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; } diff --git a/unittests/clang-modernize/TransformTest.cpp b/unittests/clang-modernize/TransformTest.cpp index 84f0641..960afff 100644 --- a/unittests/clang-modernize/TransformTest.cpp +++ b/unittests/clang-modernize/TransformTest.cpp @@ -25,8 +25,10 @@ public: 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 @@ class TimePassingASTConsumer : public ASTConsumer { 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 ConsumerFactory { 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; }; @@ -184,8 +184,8 @@ public: 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);