Skip to content

Commit

Permalink
Fix crashing on user-defined conversion.
Browse files Browse the repository at this point in the history
Summary: Fix the assertion failure for the user-defined conversion method. e.g.: operator bool()

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Patch by Cong Liu!

Differential Revision: http://reviews.llvm.org/D16536

llvm-svn: 258801
  • Loading branch information
alexfh committed Jan 26, 2016
1 parent b649b00 commit dc84150
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions clang-tools-extra/clang-tidy/misc/VirtualNearMissCheck.cpp
Expand Up @@ -178,7 +178,8 @@ bool VirtualNearMissCheck::isPossibleToBeOverridden(

bool IsPossible = !BaseMD->isImplicit() && !isa<CXXConstructorDecl>(BaseMD) &&
!isa<CXXDestructorDecl>(BaseMD) && BaseMD->isVirtual() &&
!BaseMD->isOverloadedOperator();
!BaseMD->isOverloadedOperator() &&
!isa<CXXConversionDecl>(BaseMD);
PossibleMap[Id] = IsPossible;
return IsPossible;
}
Expand Down Expand Up @@ -210,8 +211,9 @@ void VirtualNearMissCheck::registerMatchers(MatchFinder *Finder) {
return;

Finder->addMatcher(
cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(),
cxxConstructorDecl(), cxxDestructorDecl())))
cxxMethodDecl(
unless(anyOf(isOverride(), isImplicit(), cxxConstructorDecl(),
cxxDestructorDecl(), cxxConversionDecl())))
.bind("method"),
this);
}
Expand Down
Expand Up @@ -69,6 +69,7 @@ class Child : private Father, private Mother {
int decaz(const char str[]);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay'

operator bool();
private:
void funk();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func'
Expand Down

0 comments on commit dc84150

Please sign in to comment.