r204002 - [C++11] Add 'override' keyword to virtual methods that override their base class.
Craig Topper
craig.topper at gmail.com
Sat Mar 15 00:47:46 PDT 2014
Author: ctopper
Date: Sat Mar 15 02:47:46 2014
New Revision: 204002
URL: http://llvm.org/viewvc/llvm-project?rev=204002&view=rev
Log:
[C++11] Add 'override' keyword to virtual methods that override their base class.
Modified:
cfe/trunk/tools/arcmt-test/arcmt-test.cpp
cfe/trunk/tools/clang-check/ClangCheck.cpp
cfe/trunk/tools/diagtool/DiagTool.h
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
cfe/trunk/tools/libclang/CIndexDiagnostic.h
cfe/trunk/tools/libclang/CXLoadedDiagnostic.h
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/tools/arcmt-test/arcmt-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/arcmt-test/arcmt-test.cpp?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/arcmt-test/arcmt-test.cpp (original)
+++ cfe/trunk/tools/arcmt-test/arcmt-test.cpp Sat Mar 15 02:47:46 2014
@@ -83,17 +83,17 @@ public:
PrintTransforms(raw_ostream &OS)
: Ctx(0), OS(OS) { }
- virtual void start(ASTContext &ctx) { Ctx = &ctx; }
- virtual void finish() { Ctx = 0; }
+ void start(ASTContext &ctx) override { Ctx = &ctx; }
+ void finish() override { Ctx = 0; }
- virtual void insert(SourceLocation loc, StringRef text) {
+ void insert(SourceLocation loc, StringRef text) override {
assert(Ctx);
OS << "Insert: ";
printSourceLocation(loc, *Ctx, OS);
OS << " \"" << text << "\"\n";
}
- virtual void remove(CharSourceRange range) {
+ void remove(CharSourceRange range) override {
assert(Ctx);
OS << "Remove: ";
printSourceRange(range, *Ctx, OS);
Modified: cfe/trunk/tools/clang-check/ClangCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-check/ClangCheck.cpp?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/clang-check/ClangCheck.cpp (original)
+++ cfe/trunk/tools/clang-check/ClangCheck.cpp Sat Mar 15 02:47:46 2014
@@ -96,7 +96,7 @@ public:
FixWhatYouCan = ::FixWhatYouCan;
}
- std::string RewriteFilename(const std::string& filename, int &fd) {
+ std::string RewriteFilename(const std::string& filename, int &fd) override {
assert(llvm::sys::path::is_absolute(filename) &&
"clang-fixit expects absolute paths only.");
@@ -123,15 +123,15 @@ public:
: clang::FixItRewriter(Diags, SourceMgr, LangOpts, FixItOpts) {
}
- virtual bool IncludeInDiagnosticCounts() const { return false; }
+ bool IncludeInDiagnosticCounts() const override { return false; }
};
/// \brief Subclasses \c clang::FixItAction so that we can install the custom
/// \c FixItRewriter.
class FixItAction : public clang::FixItAction {
public:
- virtual bool BeginSourceFileAction(clang::CompilerInstance& CI,
- StringRef Filename) {
+ bool BeginSourceFileAction(clang::CompilerInstance& CI,
+ StringRef Filename) override {
FixItOpts.reset(new FixItOptions);
Rewriter.reset(new FixItRewriter(CI.getDiagnostics(), CI.getSourceManager(),
CI.getLangOpts(), FixItOpts.get()));
Modified: cfe/trunk/tools/diagtool/DiagTool.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/DiagTool.h?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/diagtool/DiagTool.h (original)
+++ cfe/trunk/tools/diagtool/DiagTool.h Sat Mar 15 02:47:46 2014
@@ -62,7 +62,7 @@ class CLSNAME : public diagtool::DiagToo
public:\
CLSNAME() : DiagTool(NAME, DESC) {}\
virtual ~CLSNAME() {}\
- virtual int run(unsigned argc, char *argv[], llvm::raw_ostream &out);\
+ int run(unsigned argc, char *argv[], llvm::raw_ostream &out) override;\
};\
diagtool::RegisterDiagTool<CLSNAME> Register##CLSNAME;\
}
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Sat Mar 15 02:47:46 2014
@@ -537,11 +537,11 @@ namespace {
AllocatedResults(Results), CCTUInfo(Results.CodeCompletionAllocator),
TU(TranslationUnit) { }
~CaptureCompletionResults() { Finish(); }
-
- virtual void ProcessCodeCompleteResults(Sema &S,
- CodeCompletionContext Context,
- CodeCompletionResult *Results,
- unsigned NumResults) {
+
+ void ProcessCodeCompleteResults(Sema &S,
+ CodeCompletionContext Context,
+ CodeCompletionResult *Results,
+ unsigned NumResults) override {
StoredResults.reserve(StoredResults.size() + NumResults);
for (unsigned I = 0; I != NumResults; ++I) {
CodeCompletionString *StoredCompletion
@@ -614,10 +614,10 @@ namespace {
AllocatedResults.ContainerIsIncomplete = 1;
}
}
-
- virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
- OverloadCandidate *Candidates,
- unsigned NumCandidates) {
+
+ void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
+ OverloadCandidate *Candidates,
+ unsigned NumCandidates) override {
StoredResults.reserve(StoredResults.size() + NumCandidates);
for (unsigned I = 0; I != NumCandidates; ++I) {
CodeCompletionString *StoredCompletion
@@ -630,13 +630,13 @@ namespace {
StoredResults.push_back(R);
}
}
-
- virtual CodeCompletionAllocator &getAllocator() {
+
+ CodeCompletionAllocator &getAllocator() override {
return *AllocatedResults.CodeCompletionAllocator;
}
- virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() { return CCTUInfo; }
-
+ CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo;}
+
private:
void Finish() {
AllocatedResults.Results = new CXCompletionResult [StoredResults.size()];
Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.cpp?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.cpp Sat Mar 15 02:47:46 2014
@@ -51,32 +51,35 @@ public:
Message(Msg), Loc(L) {}
virtual ~CXDiagnosticCustomNoteImpl() {}
-
- CXDiagnosticSeverity getSeverity() const {
+
+ CXDiagnosticSeverity getSeverity() const override {
return CXDiagnostic_Note;
}
-
- CXSourceLocation getLocation() const {
+
+ CXSourceLocation getLocation() const override {
return Loc;
}
-
- CXString getSpelling() const {
+
+ CXString getSpelling() const override {
return cxstring::createRef(Message.c_str());
}
-
- CXString getDiagnosticOption(CXString *Disable) const {
+
+ CXString getDiagnosticOption(CXString *Disable) const override {
if (Disable)
*Disable = cxstring::createEmpty();
return cxstring::createEmpty();
}
-
- unsigned getCategory() const { return 0; }
- CXString getCategoryText() const { return cxstring::createEmpty(); }
- unsigned getNumRanges() const { return 0; }
- CXSourceRange getRange(unsigned Range) const { return clang_getNullRange(); }
- unsigned getNumFixIts() const { return 0; }
- CXString getFixIt(unsigned FixIt, CXSourceRange *ReplacementRange) const {
+ unsigned getCategory() const override { return 0; }
+ CXString getCategoryText() const override { return cxstring::createEmpty(); }
+
+ unsigned getNumRanges() const override { return 0; }
+ CXSourceRange getRange(unsigned Range) const override {
+ return clang_getNullRange();
+ }
+ unsigned getNumFixIts() const override { return 0; }
+ CXString getFixIt(unsigned FixIt,
+ CXSourceRange *ReplacementRange) const override {
if (ReplacementRange)
*ReplacementRange = clang_getNullRange();
return cxstring::createEmpty();
@@ -93,9 +96,9 @@ public:
virtual ~CXDiagnosticRenderer() {}
- virtual void beginDiagnostic(DiagOrStoredDiag D,
- DiagnosticsEngine::Level Level) {
-
+ void beginDiagnostic(DiagOrStoredDiag D,
+ DiagnosticsEngine::Level Level) override {
+
const StoredDiagnostic *SD = D.dyn_cast<const StoredDiagnostic*>();
if (!SD)
return;
@@ -109,13 +112,13 @@ public:
if (Level != DiagnosticsEngine::Note)
CurrentSet = &CD->getChildDiagnostics();
}
-
- virtual void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- StringRef Message,
- ArrayRef<CharSourceRange> Ranges,
- const SourceManager *SM,
- DiagOrStoredDiag D) {
+
+ void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
+ DiagnosticsEngine::Level Level,
+ StringRef Message,
+ ArrayRef<CharSourceRange> Ranges,
+ const SourceManager *SM,
+ DiagOrStoredDiag D) override {
if (!D.isNull())
return;
@@ -127,20 +130,20 @@ public:
CXDiagnosticImpl *CD = new CXDiagnosticCustomNoteImpl(Message, L);
CurrentSet->appendDiagnostic(CD);
}
-
- virtual void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- ArrayRef<CharSourceRange> Ranges,
- const SourceManager &SM) {}
-
- virtual void emitCodeContext(SourceLocation Loc,
- DiagnosticsEngine::Level Level,
- SmallVectorImpl<CharSourceRange>& Ranges,
- ArrayRef<FixItHint> Hints,
- const SourceManager &SM) {}
-
- virtual void emitNote(SourceLocation Loc, StringRef Message,
- const SourceManager *SM) {
+
+ void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
+ DiagnosticsEngine::Level Level,
+ ArrayRef<CharSourceRange> Ranges,
+ const SourceManager &SM) override {}
+
+ void emitCodeContext(SourceLocation Loc,
+ DiagnosticsEngine::Level Level,
+ SmallVectorImpl<CharSourceRange>& Ranges,
+ ArrayRef<FixItHint> Hints,
+ const SourceManager &SM) override {}
+
+ void emitNote(SourceLocation Loc, StringRef Message,
+ const SourceManager *SM) override {
CXSourceLocation L;
if (SM)
L = translateSourceLocation(*SM, LangOpts, Loc);
Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.h?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexDiagnostic.h (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.h Sat Mar 15 02:47:46 2014
@@ -121,35 +121,35 @@ struct CXStoredDiagnostic : public CXDia
virtual ~CXStoredDiagnostic() {}
/// \brief Return the severity of the diagnostic.
- virtual CXDiagnosticSeverity getSeverity() const;
-
+ CXDiagnosticSeverity getSeverity() const override;
+
/// \brief Return the location of the diagnostic.
- virtual CXSourceLocation getLocation() const;
+ CXSourceLocation getLocation() const override;
/// \brief Return the spelling of the diagnostic.
- virtual CXString getSpelling() const;
+ CXString getSpelling() const override;
/// \brief Return the text for the diagnostic option.
- virtual CXString getDiagnosticOption(CXString *Disable) const;
-
+ CXString getDiagnosticOption(CXString *Disable) const override;
+
/// \brief Return the category of the diagnostic.
- virtual unsigned getCategory() const;
-
+ unsigned getCategory() const override;
+
/// \brief Return the category string of the diagnostic.
- virtual CXString getCategoryText() const;
+ CXString getCategoryText() const override;
/// \brief Return the number of source ranges for the diagnostic.
- virtual unsigned getNumRanges() const;
-
+ unsigned getNumRanges() const override;
+
/// \brief Return the source ranges for the diagnostic.
- virtual CXSourceRange getRange(unsigned Range) const;
+ CXSourceRange getRange(unsigned Range) const override;
/// \brief Return the number of FixIts.
- virtual unsigned getNumFixIts() const;
+ unsigned getNumFixIts() const override;
/// \brief Return the FixIt information (source range and inserted text).
- virtual CXString getFixIt(unsigned FixIt,
- CXSourceRange *ReplacementRange) const;
+ CXString getFixIt(unsigned FixIt,
+ CXSourceRange *ReplacementRange) const override;
static bool classof(const CXDiagnosticImpl *D) {
return D->getKind() == StoredDiagnosticKind;
Modified: cfe/trunk/tools/libclang/CXLoadedDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXLoadedDiagnostic.h?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXLoadedDiagnostic.h (original)
+++ cfe/trunk/tools/libclang/CXLoadedDiagnostic.h Sat Mar 15 02:47:46 2014
@@ -29,36 +29,36 @@ public:
virtual ~CXLoadedDiagnostic();
/// \brief Return the severity of the diagnostic.
- virtual CXDiagnosticSeverity getSeverity() const;
-
+ CXDiagnosticSeverity getSeverity() const override;
+
/// \brief Return the location of the diagnostic.
- virtual CXSourceLocation getLocation() const;
-
+ CXSourceLocation getLocation() const override;
+
/// \brief Return the spelling of the diagnostic.
- virtual CXString getSpelling() const;
-
+ CXString getSpelling() const override;
+
/// \brief Return the text for the diagnostic option.
- virtual CXString getDiagnosticOption(CXString *Disable) const;
-
+ CXString getDiagnosticOption(CXString *Disable) const override;
+
/// \brief Return the category of the diagnostic.
- virtual unsigned getCategory() const;
-
+ unsigned getCategory() const override;
+
/// \brief Return the category string of the diagnostic.
- virtual CXString getCategoryText() const;
-
+ CXString getCategoryText() const override;
+
/// \brief Return the number of source ranges for the diagnostic.
- virtual unsigned getNumRanges() const;
-
+ unsigned getNumRanges() const override;
+
/// \brief Return the source ranges for the diagnostic.
- virtual CXSourceRange getRange(unsigned Range) const;
-
+ CXSourceRange getRange(unsigned Range) const override;
+
/// \brief Return the number of FixIts.
- virtual unsigned getNumFixIts() const;
-
+ unsigned getNumFixIts() const override;
+
/// \brief Return the FixIt information (source range and inserted text).
- virtual CXString getFixIt(unsigned FixIt,
- CXSourceRange *ReplacementRange) const;
-
+ CXString getFixIt(unsigned FixIt,
+ CXSourceRange *ReplacementRange) const override;
+
static bool classof(const CXDiagnosticImpl *D) {
return D->getKind() == LoadedDiagnosticKind;
}
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=204002&r1=204001&r2=204002&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Sat Mar 15 02:47:46 2014
@@ -253,8 +253,8 @@ public:
IndexPPCallbacks(Preprocessor &PP, IndexingContext &indexCtx)
: PP(PP), IndexCtx(indexCtx), IsMainFileEntered(false) { }
- virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
- SrcMgr::CharacteristicKind FileType, FileID PrevFID) {
+ void FileChanged(SourceLocation Loc, FileChangeReason Reason,
+ SrcMgr::CharacteristicKind FileType, FileID PrevFID) override {
if (IsMainFileEntered)
return;
@@ -267,15 +267,11 @@ public:
}
}
- virtual void InclusionDirective(SourceLocation HashLoc,
- const Token &IncludeTok,
- StringRef FileName,
- bool IsAngled,
- CharSourceRange FilenameRange,
- const FileEntry *File,
- StringRef SearchPath,
- StringRef RelativePath,
- const Module *Imported) {
+ void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+ StringRef FileName, bool IsAngled,
+ CharSourceRange FilenameRange, const FileEntry *File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported) override {
bool isImport = (IncludeTok.is(tok::identifier) &&
IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import);
IndexCtx.ppIncludedFile(HashLoc, FileName, File, isImport, IsAngled,
@@ -283,25 +279,21 @@ public:
}
/// MacroDefined - This hook is called whenever a macro definition is seen.
- virtual void MacroDefined(const Token &Id, const MacroDirective *MD) {
- }
+ void MacroDefined(const Token &Id, const MacroDirective *MD) override {}
/// MacroUndefined - This hook is called whenever a macro #undef is seen.
/// MI is released immediately following this callback.
- virtual void MacroUndefined(const Token &MacroNameTok,
- const MacroDirective *MD) {
- }
+ void MacroUndefined(const Token &MacroNameTok,
+ const MacroDirective *MD) override {}
/// MacroExpands - This is called by when a macro invocation is found.
- virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
- SourceRange Range, const MacroArgs *Args) {
- }
+ void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
+ SourceRange Range, const MacroArgs *Args) override {}
/// SourceRangeSkipped - This hook is called when a source range is skipped.
/// \param Range The SourceRange that was skipped. The range begins at the
/// #if/#else directive and ends after the #endif/#else directive.
- virtual void SourceRangeSkipped(SourceRange Range) {
- }
+ void SourceRangeSkipped(SourceRange Range) override {}
};
//===----------------------------------------------------------------------===//
@@ -318,24 +310,24 @@ public:
// ASTConsumer Implementation
- virtual void Initialize(ASTContext &Context) {
+ void Initialize(ASTContext &Context) override {
IndexCtx.setASTContext(Context);
IndexCtx.startedTranslationUnit();
}
- virtual void HandleTranslationUnit(ASTContext &Ctx) {
+ void HandleTranslationUnit(ASTContext &Ctx) override {
if (SKCtrl)
SKCtrl->finished();
}
- virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
+ bool HandleTopLevelDecl(DeclGroupRef DG) override {
IndexCtx.indexDeclGroupRef(DG);
return !IndexCtx.shouldAbort();
}
/// \brief Handle the specified top-level declaration that occurred inside
/// and ObjC container.
- virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {
+ void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override {
// They will be handled after the interface is seen first.
IndexCtx.addTUDeclInObjCContainer(D);
}
@@ -343,9 +335,9 @@ public:
/// \brief This is called by the AST reader when deserializing things.
/// The default implementation forwards to HandleTopLevelDecl but we don't
/// care about them when indexing, so have an empty definition.
- virtual void HandleInterestingDecl(DeclGroupRef D) {}
+ void HandleInterestingDecl(DeclGroupRef D) override {}
- virtual void HandleTagDeclDefinition(TagDecl *D) {
+ void HandleTagDeclDefinition(TagDecl *D) override {
if (!IndexCtx.shouldIndexImplicitTemplateInsts())
return;
@@ -353,14 +345,14 @@ public:
IndexCtx.indexDecl(D);
}
- virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {
+ void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) override {
if (!IndexCtx.shouldIndexImplicitTemplateInsts())
return;
IndexCtx.indexDecl(D);
}
- virtual bool shouldSkipFunctionBody(Decl *D) {
+ bool shouldSkipFunctionBody(Decl *D) override {
if (!SKCtrl) {
// Always skip bodies.
return true;
@@ -395,8 +387,8 @@ class CaptureDiagnosticConsumer : public
SmallVector<StoredDiagnostic, 4> Errors;
public:
- virtual void HandleDiagnostic(DiagnosticsEngine::Level level,
- const Diagnostic &Info) {
+ void HandleDiagnostic(DiagnosticsEngine::Level level,
+ const Diagnostic &Info) override {
if (level >= DiagnosticsEngine::Error)
Errors.push_back(StoredDiagnostic(level, Info));
}
@@ -422,8 +414,8 @@ public:
: IndexCtx(clientData, indexCallbacks, indexOptions, cxTU),
CXTU(cxTU), SKData(skData) { }
- virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+ ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override {
PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
if (!PPOpts.ImplicitPCHInclude.empty()) {
@@ -446,17 +438,17 @@ public:
return new IndexingConsumer(IndexCtx, SKCtrl.get());
}
- virtual void EndSourceFileAction() {
+ void EndSourceFileAction() override {
indexDiagnostics(CXTU, IndexCtx);
}
- virtual TranslationUnitKind getTranslationUnitKind() {
+ TranslationUnitKind getTranslationUnitKind() override {
if (IndexCtx.shouldIndexImplicitTemplateInsts())
return TU_Complete;
else
return TU_Prefix;
}
- virtual bool hasCodeCompletionSupport() const { return false; }
+ bool hasCodeCompletionSupport() const override { return false; }
};
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list