Use 'override/final' instead of 'virtual' for overridden methods
Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix svn diff | clang-format-diff -i Reviewers: dblaikie Reviewed By: dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8927 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@234681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
11f43a2e50
Коммит
1daf9da86e
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
llvm::ArrayRef<llvm::StringRef> 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;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace {
|
|||
struct CollectBoundNodes : MatchFinder::MatchCallback {
|
||||
std::vector<BoundNodes> &Bindings;
|
||||
CollectBoundNodes(std::vector<BoundNodes> &Bindings) : Bindings(Bindings) {}
|
||||
void run(const MatchFinder::MatchResult &Result) {
|
||||
void run(const MatchFinder::MatchResult &Result) override {
|
||||
Bindings.push_back(Result.Nodes);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
std::vector<CallbackCall> &CallbackCalls,
|
||||
clang::Preprocessor &PP);
|
||||
|
||||
virtual ~PPCallbacksTracker();
|
||||
~PPCallbacksTracker() override;
|
||||
|
||||
// Overidden callback functions.
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
std::vector<CallbackCall> &CallbackCalls)
|
||||
: Ignore(Ignore), CallbackCalls(CallbackCalls) {}
|
||||
|
||||
virtual PPTraceAction *create() {
|
||||
PPTraceAction *create() override {
|
||||
return new PPTraceAction(Ignore, CallbackCalls);
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -18,8 +18,8 @@ public:
|
|||
TransformA(const TransformOptions &Options)
|
||||
: Transform("TransformA", Options) {}
|
||||
|
||||
virtual int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) {
|
||||
int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ public:
|
|||
TransformB(const TransformOptions &Options)
|
||||
: Transform("TransformB", Options) {}
|
||||
|
||||
virtual int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) {
|
||||
int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,10 @@ public:
|
|||
DummyTransform(llvm::StringRef Name, const TransformOptions &Options)
|
||||
: Transform(Name, Options) {}
|
||||
|
||||
virtual int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) { return 0; }
|
||||
int apply(const tooling::CompilationDatabase &,
|
||||
const std::vector<std::string> &) 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<VarDecl>("decl");
|
||||
ASSERT_TRUE(Decl != nullptr);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче