[PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.
Cong Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 15 15:34:14 PST 2016
congliu added a comment.
> - Ignore qualifiers.
I don't think we should ignore qualifiers. Please see my inline comment for line 52 of the test file.
================
Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
unsigned EditDistance =
- BaseMD->getName().edit_distance(DerivedMD->getName());
+ StringRef(BaseMD->getNameAsString())
+ .edit_distance(DerivedMD->getNameAsString());
----------------
NamedDecl::getName() directly returns a StringRef. Why using "getNameAsString()"?
================
Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:52
@@ -49,2 +51,3 @@
- int methoe(int x); // Should not warn: method is not const.
+ int methoe(int x);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has {{.*}} 'Mother::method'
----------------
If a function in derived class has a same name but different cv-qualifiers as a function in base class, they are not regarded as overriding. For example,
```
class Mother{
virtual int method(int argc) const;
};
class Child : Mother{
int method(int x);
};
```
In this case, Child::method does not overrides Mother::method, but hides it. So I think we should not warn for "methoe", because even if the programmer changes "methoe" to "method", it's not an overriding.
http://reviews.llvm.org/D16179
More information about the cfe-commits
mailing list