Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 583adb0

Browse files
committed
[C++11] Add 'override' keyword to virtual methods that override their base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203641 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 34e9e13 commit 583adb0

File tree

8 files changed

+56
-57
lines changed

8 files changed

+56
-57
lines changed

include/clang/Parse/Parser.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,10 @@ class Parser : public CodeCompletionHandler {
878878
LateParsedClass(Parser *P, ParsingClass *C);
879879
virtual ~LateParsedClass();
880880

881-
virtual void ParseLexedMethodDeclarations();
882-
virtual void ParseLexedMemberInitializers();
883-
virtual void ParseLexedMethodDefs();
884-
virtual void ParseLexedAttributes();
881+
void ParseLexedMethodDeclarations() override;
882+
void ParseLexedMemberInitializers() override;
883+
void ParseLexedMethodDefs() override;
884+
void ParseLexedAttributes() override;
885885

886886
private:
887887
Parser *Self;
@@ -905,7 +905,7 @@ class Parser : public CodeCompletionHandler {
905905
SourceLocation Loc)
906906
: Self(P), AttrName(Name), AttrNameLoc(Loc) {}
907907

908-
virtual void ParseLexedAttributes();
908+
void ParseLexedAttributes() override;
909909

910910
void addDecl(Decl *D) { Decls.push_back(D); }
911911
};
@@ -937,7 +937,7 @@ class Parser : public CodeCompletionHandler {
937937
explicit LexedMethod(Parser* P, Decl *MD)
938938
: Self(P), D(MD), TemplateScope(false) {}
939939

940-
virtual void ParseLexedMethodDefs();
940+
void ParseLexedMethodDefs() override;
941941
};
942942

943943
/// LateParsedDefaultArgument - Keeps track of a parameter that may
@@ -967,7 +967,7 @@ class Parser : public CodeCompletionHandler {
967967
explicit LateParsedMethodDeclaration(Parser *P, Decl *M)
968968
: Self(P), Method(M), TemplateScope(false), ExceptionSpecTokens(0) { }
969969

970-
virtual void ParseLexedMethodDeclarations();
970+
void ParseLexedMethodDeclarations() override;
971971

972972
Parser* Self;
973973

@@ -998,7 +998,7 @@ class Parser : public CodeCompletionHandler {
998998
LateParsedMemberInitializer(Parser *P, Decl *FD)
999999
: Self(P), Field(FD) { }
10001000

1001-
virtual void ParseLexedMemberInitializers();
1001+
void ParseLexedMemberInitializers() override;
10021002

10031003
Parser *Self;
10041004

@@ -2399,14 +2399,13 @@ class Parser : public CodeCompletionHandler {
23992399

24002400
//===--------------------------------------------------------------------===//
24012401
// Preprocessor code-completion pass-through
2402-
virtual void CodeCompleteDirective(bool InConditional);
2403-
virtual void CodeCompleteInConditionalExclusion();
2404-
virtual void CodeCompleteMacroName(bool IsDefinition);
2405-
virtual void CodeCompletePreprocessorExpression();
2406-
virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro,
2407-
MacroInfo *MacroInfo,
2408-
unsigned ArgumentIndex);
2409-
virtual void CodeCompleteNaturalLanguage();
2402+
void CodeCompleteDirective(bool InConditional) override;
2403+
void CodeCompleteInConditionalExclusion() override;
2404+
void CodeCompleteMacroName(bool IsDefinition) override;
2405+
void CodeCompletePreprocessorExpression() override;
2406+
void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
2407+
unsigned ArgumentIndex) override;
2408+
void CodeCompleteNaturalLanguage() override;
24102409
};
24112410

24122411
} // end namespace clang

lib/Parse/ParseAST.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PrettyStackTraceParserEntry : public llvm::PrettyStackTraceEntry {
3636
const Parser &P;
3737
public:
3838
PrettyStackTraceParserEntry(const Parser &p) : P(p) {}
39-
virtual void print(raw_ostream &OS) const;
39+
void print(raw_ostream &OS) const override;
4040
};
4141

4242
/// If a crash happens while the parser is active, print out a line indicating

lib/Parse/ParseDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
33593359
SmallVectorImpl<Decl *> &FieldDecls) :
33603360
P(P), TagDecl(TagDecl), FieldDecls(FieldDecls) {}
33613361

3362-
void invoke(ParsingFieldDeclarator &FD) {
3362+
void invoke(ParsingFieldDeclarator &FD) override {
33633363
// Install the declarator into the current TagDecl.
33643364
Decl *Field = P.Actions.ActOnField(P.getCurScope(), TagDecl,
33653365
FD.D.getDeclSpec().getSourceRange().getBegin(),

lib/Parse/ParseExpr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback {
428428
WantTypeSpecifiers = AllowTypes;
429429
}
430430

431-
virtual bool ValidateCandidate(const TypoCorrection &candidate) {
431+
bool ValidateCandidate(const TypoCorrection &candidate) override {
432432
NamedDecl *ND = candidate.getCorrectionDecl();
433433
if (!ND)
434434
return candidate.isKeyword();

lib/Parse/ParseObjc.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ struct Parser::ObjCPropertyCallback : FieldCallback {
329329
MethodImplKind(MethodImplKind) {
330330
}
331331

332-
void invoke(ParsingFieldDeclarator &FD) {
332+
void invoke(ParsingFieldDeclarator &FD) override {
333333
if (FD.D.getIdentifier() == 0) {
334334
P.Diag(AtLoc, diag::err_objc_property_requires_field_name)
335335
<< FD.D.getSourceRange();
@@ -1348,7 +1348,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl,
13481348
P(P), IDecl(IDecl), visibility(V), AllIvarDecls(AllIvarDecls) {
13491349
}
13501350

1351-
void invoke(ParsingFieldDeclarator &FD) {
1351+
void invoke(ParsingFieldDeclarator &FD) override {
13521352
P.Actions.ActOnObjCContainerStartDefinition(IDecl);
13531353
// Install the declarator into the interface decl.
13541354
Decl *Field

lib/Parse/ParsePragma.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -22,106 +22,106 @@ namespace {
2222

2323
struct PragmaAlignHandler : public PragmaHandler {
2424
explicit PragmaAlignHandler() : PragmaHandler("align") {}
25-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
26-
Token &FirstToken);
25+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
26+
Token &FirstToken) override;
2727
};
2828

2929
struct PragmaGCCVisibilityHandler : public PragmaHandler {
3030
explicit PragmaGCCVisibilityHandler() : PragmaHandler("visibility") {}
31-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
32-
Token &FirstToken);
31+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
32+
Token &FirstToken) override;
3333
};
3434

3535
struct PragmaOptionsHandler : public PragmaHandler {
3636
explicit PragmaOptionsHandler() : PragmaHandler("options") {}
37-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
38-
Token &FirstToken);
37+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
38+
Token &FirstToken) override;
3939
};
4040

4141
struct PragmaPackHandler : public PragmaHandler {
4242
explicit PragmaPackHandler() : PragmaHandler("pack") {}
43-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
44-
Token &FirstToken);
43+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
44+
Token &FirstToken) override;
4545
};
4646

4747
struct PragmaMSStructHandler : public PragmaHandler {
4848
explicit PragmaMSStructHandler() : PragmaHandler("ms_struct") {}
49-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
50-
Token &FirstToken);
49+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
50+
Token &FirstToken) override;
5151
};
5252

5353
struct PragmaUnusedHandler : public PragmaHandler {
5454
PragmaUnusedHandler() : PragmaHandler("unused") {}
55-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
56-
Token &FirstToken);
55+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
56+
Token &FirstToken) override;
5757
};
5858

5959
struct PragmaWeakHandler : public PragmaHandler {
6060
explicit PragmaWeakHandler() : PragmaHandler("weak") {}
61-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
62-
Token &FirstToken);
61+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
62+
Token &FirstToken) override;
6363
};
6464

6565
struct PragmaRedefineExtnameHandler : public PragmaHandler {
6666
explicit PragmaRedefineExtnameHandler() : PragmaHandler("redefine_extname") {}
67-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
68-
Token &FirstToken);
67+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
68+
Token &FirstToken) override;
6969
};
7070

7171
struct PragmaOpenCLExtensionHandler : public PragmaHandler {
7272
PragmaOpenCLExtensionHandler() : PragmaHandler("EXTENSION") {}
73-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
74-
Token &FirstToken);
73+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
74+
Token &FirstToken) override;
7575
};
7676

7777

7878
struct PragmaFPContractHandler : public PragmaHandler {
7979
PragmaFPContractHandler() : PragmaHandler("FP_CONTRACT") {}
80-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
81-
Token &FirstToken);
80+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
81+
Token &FirstToken) override;
8282
};
8383

8484
struct PragmaNoOpenMPHandler : public PragmaHandler {
8585
PragmaNoOpenMPHandler() : PragmaHandler("omp") { }
86-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
87-
Token &FirstToken);
86+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
87+
Token &FirstToken) override;
8888
};
8989

9090
struct PragmaOpenMPHandler : public PragmaHandler {
9191
PragmaOpenMPHandler() : PragmaHandler("omp") { }
92-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
93-
Token &FirstToken);
92+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
93+
Token &FirstToken) override;
9494
};
9595

9696
/// PragmaCommentHandler - "\#pragma comment ...".
9797
struct PragmaCommentHandler : public PragmaHandler {
9898
PragmaCommentHandler(Sema &Actions)
9999
: PragmaHandler("comment"), Actions(Actions) {}
100-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
101-
Token &FirstToken);
100+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
101+
Token &FirstToken) override;
102102
private:
103103
Sema &Actions;
104104
};
105105

106106
struct PragmaDetectMismatchHandler : public PragmaHandler {
107107
PragmaDetectMismatchHandler(Sema &Actions)
108108
: PragmaHandler("detect_mismatch"), Actions(Actions) {}
109-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
110-
Token &FirstToken);
109+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
110+
Token &FirstToken) override;
111111
private:
112112
Sema &Actions;
113113
};
114114

115115
struct PragmaMSPointersToMembers : public PragmaHandler {
116116
explicit PragmaMSPointersToMembers() : PragmaHandler("pointers_to_members") {}
117-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
118-
Token &FirstToken);
117+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
118+
Token &FirstToken) override;
119119
};
120120

121121
struct PragmaMSVtorDisp : public PragmaHandler {
122122
explicit PragmaMSVtorDisp() : PragmaHandler("vtordisp") {}
123-
virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
124-
Token &FirstToken);
123+
void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
124+
Token &FirstToken) override;
125125
};
126126

127127
} // end namespace

lib/Parse/ParseStmt.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class StatementFilterCCC : public CorrectionCandidateCallback {
142142
WantCXXNamedCasts = false;
143143
}
144144

145-
virtual bool ValidateCandidate(const TypoCorrection &candidate) {
145+
bool ValidateCandidate(const TypoCorrection &candidate) override {
146146
if (FieldDecl *FD = candidate.getCorrectionDeclAs<FieldDecl>())
147147
return !candidate.getCorrectionSpecifier() || isa<ObjCIvarDecl>(FD);
148148
if (NextToken.is(tok::equal))
@@ -1766,7 +1766,7 @@ namespace {
17661766

17671767
void *LookupInlineAsmIdentifier(StringRef &LineBuf,
17681768
InlineAsmIdentifierInfo &Info,
1769-
bool IsUnevaluatedContext) {
1769+
bool IsUnevaluatedContext) override {
17701770
// Collect the desired tokens.
17711771
SmallVector<Token, 16> LineToks;
17721772
const Token *FirstOrigToken = 0;
@@ -1806,7 +1806,7 @@ namespace {
18061806
}
18071807

18081808
bool LookupInlineAsmField(StringRef Base, StringRef Member,
1809-
unsigned &Offset) {
1809+
unsigned &Offset) override {
18101810
return TheParser.getActions().LookupInlineAsmField(Base, Member,
18111811
Offset, AsmLoc);
18121812
}

lib/Parse/Parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ActionCommentHandler : public CommentHandler {
3333
public:
3434
explicit ActionCommentHandler(Sema &S) : S(S) { }
3535

36-
virtual bool HandleComment(Preprocessor &PP, SourceRange Comment) {
36+
bool HandleComment(Preprocessor &PP, SourceRange Comment) override {
3737
S.ActOnComment(Comment);
3838
return false;
3939
}

0 commit comments

Comments
 (0)