forked from OSchip/llvm-project
[clang] Add 'override' to virtual function overrides generated by ClangAttrEmitter
ClangAttrEmitter.cpp generates ParsedAttr derived classes with virtual overrides in them (which end up in AttrParsedAttrImpl.inc); this patch ensures these generated functions are marked override, and not (redundantly) virtual. I hesitate to say NFC since this does of course affect the behavior of the generator code, but the generated code behaves the same as it did before, so it's NFC in that sense. Differential Revision: https://reviews.llvm.org/D83616
This commit is contained in:
parent
e2b716105b
commit
fbb30c31fe
|
@ -2012,10 +2012,10 @@ PragmaClangAttributeSupport::generateStrictConformsTo(const Record &Attr,
|
|||
return;
|
||||
// Generate a function that constructs a set of matching rules that describe
|
||||
// to which declarations the attribute should apply to.
|
||||
OS << "virtual void getPragmaAttributeMatchRules("
|
||||
OS << "void getPragmaAttributeMatchRules("
|
||||
<< "llvm::SmallVectorImpl<std::pair<"
|
||||
<< AttributeSubjectMatchRule::EnumName
|
||||
<< ", bool>> &MatchRules, const LangOptions &LangOpts) const {\n";
|
||||
<< ", bool>> &MatchRules, const LangOptions &LangOpts) const override {\n";
|
||||
const Record *SubjectObj = Attr.getValueAsDef("Subjects");
|
||||
std::vector<Record *> Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
|
||||
for (const auto *Subject : Subjects) {
|
||||
|
@ -3519,8 +3519,8 @@ static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
|
|||
// at all (for instance because it was applied to a type), or that the caller
|
||||
// has determined that the check should fail (perhaps prior to the creation
|
||||
// of the declaration).
|
||||
OS << "virtual bool diagAppertainsToDecl(Sema &S, ";
|
||||
OS << "const ParsedAttr &Attr, const Decl *D) const {\n";
|
||||
OS << "bool diagAppertainsToDecl(Sema &S, ";
|
||||
OS << "const ParsedAttr &Attr, const Decl *D) const override {\n";
|
||||
OS << " if (";
|
||||
for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
|
||||
// If the subject has custom code associated with it, use the generated
|
||||
|
@ -3594,8 +3594,8 @@ static void GenerateLangOptRequirements(const Record &R,
|
|||
if (LangOpts.empty())
|
||||
return;
|
||||
|
||||
OS << "virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) ";
|
||||
OS << "const {\n";
|
||||
OS << "bool diagLangOpts(Sema &S, const ParsedAttr &Attr) ";
|
||||
OS << "const override {\n";
|
||||
OS << " auto &LangOpts = S.LangOpts;\n";
|
||||
OS << " if (" << GenerateTestExpression(LangOpts) << ")\n";
|
||||
OS << " return true;\n\n";
|
||||
|
@ -3639,7 +3639,7 @@ static void GenerateTargetRequirements(const Record &Attr,
|
|||
std::string Test;
|
||||
bool UsesT = GenerateTargetSpecificAttrChecks(R, Arches, Test, &FnName);
|
||||
|
||||
OS << "virtual bool existsInTarget(const TargetInfo &Target) const {\n";
|
||||
OS << "bool existsInTarget(const TargetInfo &Target) const override {\n";
|
||||
if (UsesT)
|
||||
OS << " const llvm::Triple &T = Target.getTriple(); (void)T;\n";
|
||||
OS << " return " << Test << ";\n";
|
||||
|
@ -3664,8 +3664,8 @@ static void GenerateSpellingIndexToSemanticSpelling(const Record &Attr,
|
|||
std::string Enum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
|
||||
std::string Name = Attr.getName().str() + "AttrSpellingMap";
|
||||
|
||||
OS << "virtual unsigned spellingIndexToSemanticSpelling(";
|
||||
OS << "const ParsedAttr &Attr) const {\n";
|
||||
OS << "unsigned spellingIndexToSemanticSpelling(";
|
||||
OS << "const ParsedAttr &Attr) const override {\n";
|
||||
OS << Enum;
|
||||
OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n";
|
||||
WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS);
|
||||
|
@ -3678,8 +3678,8 @@ static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
|
|||
return;
|
||||
|
||||
// Generate a function which just converts from ParsedAttr to the Attr type.
|
||||
OS << "virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D,";
|
||||
OS << "const ParsedAttr &Attr) const {\n";
|
||||
OS << "AttrHandling handleDeclAttribute(Sema &S, Decl *D,";
|
||||
OS << "const ParsedAttr &Attr) const override {\n";
|
||||
OS << " D->addAttr(::new (S.Context) " << Attr.getName();
|
||||
OS << "Attr(S.Context, Attr));\n";
|
||||
OS << " return AttributeApplied;\n";
|
||||
|
|
Loading…
Reference in New Issue