forked from OSchip/llvm-project
Fix a crash when resolving overloads of C++ virtual methods.
The isOverload() method needs to account for situations where the two methods being compared don't have the same number of arguments. rdar://problem/39542960 llvm-svn: 330450
This commit is contained in:
parent
6c7fe30a1c
commit
690c828b0b
|
@ -0,0 +1,5 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
CXX_SOURCES := main.cpp
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
|
@ -0,0 +1,3 @@
|
|||
from lldbsuite.test import lldbinline
|
||||
|
||||
lldbinline.MakeInlineTest(__file__, globals())
|
|
@ -0,0 +1,17 @@
|
|||
// Test that lldb doesn't get confused by an overload of a virtual
|
||||
// function of the same name.
|
||||
struct Base {
|
||||
virtual void f(int i) {}
|
||||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
struct Derived : Base {
|
||||
virtual void f(int i, int j) {}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Derived obj;
|
||||
obj.f(1, 2); //% self.expect("fr var", "not crashing", substrs = ["obj"])
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2170,7 +2170,10 @@ static bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
|
|||
m2p.getUnqualifiedType());
|
||||
};
|
||||
|
||||
return !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
|
||||
// FIXME: In C++14 and later, we can just pass m2Type->param_type_end()
|
||||
// as a fourth parameter to std::equal().
|
||||
return (m1->getNumParams() != m2->getNumParams()) ||
|
||||
!std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
|
||||
m2Type->param_type_begin(), compareArgTypes);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue