File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -6241,10 +6241,14 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) {
6241
6241
if (const CXXDestructorDecl *dtor = Record->getDestructor()) {
6242
6242
if (const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
6243
6243
Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
6244
- << FA->isSpelledAsSealed();
6245
- Diag(Record->getLocation(), diag::note_final_dtor_non_final_class_silence)
6246
- << Context.getRecordType(Record)
6247
- << FA->isSpelledAsSealed();
6244
+ << FA->isSpelledAsSealed()
6245
+ << FixItHint::CreateRemoval(FA->getLocation())
6246
+ << FixItHint::CreateInsertion(
6247
+ getLocForEndOfToken(Record->getLocation()),
6248
+ (FA->isSpelledAsSealed() ? " sealed" : " final"));
6249
+ Diag(Record->getLocation(),
6250
+ diag::note_final_dtor_non_final_class_silence)
6251
+ << Context.getRecordType(Record) << FA->isSpelledAsSealed();
6248
6252
}
6249
6253
}
6250
6254
}
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wfinal-dtor-non-final-class
2
+ // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -Wfinal-dtor-non-final-class -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
2
3
3
4
class A {
4
5
~A ();
5
6
};
6
7
7
8
class B { // expected-note {{mark 'B' as 'final' to silence this warning}}
9
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:8-[[@LINE-1]]:8}:" final"
8
10
virtual ~B () final ; // expected-warning {{class with destructor marked 'final' cannot be inherited from}}
11
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:23}:""
9
12
};
10
13
11
14
class C final {
You can’t perform that action at this time.
0 commit comments