diff options
author | Davide Italiano <davide@freebsd.org> | 2018-03-20 19:46:32 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-03-20 19:46:32 +0000 |
commit | 7e3ef4df2dc93795246a402c654a07e26e4bdbbe (patch) | |
tree | 920cd1c897d617420257a4697bb53ecc75bb1eb5 /lldb/packages/Python/lldbsuite/test/lang/cpp | |
parent | 3b24ed7f21e9872e26ebabaa36c708270231e7ad (diff) | |
download | bcm5719-llvm-7e3ef4df2dc93795246a402c654a07e26e4bdbbe.tar.gz bcm5719-llvm-7e3ef4df2dc93795246a402c654a07e26e4bdbbe.zip |
[ExpressionParser] Re-implement r327356 in a less disruptive way.
Instead of applying the sledgehammer of refusing to insert any
C++ symbol in the ASTContext, try to validate the decl if what
we have is an operator. There was other code in lldb which was
responsible for this, just not really exposed (or used) in this
codepath. Also, add a better/more comprehensive test.
<rdar://problem/35645893>
llvm-svn: 328025
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp')
4 files changed, 61 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile new file mode 100644 index 00000000000..7d85a3a81f8 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile @@ -0,0 +1,20 @@ +LEVEL = ../../../make + +CXX_SOURCES = a.cpp b.cpp +CXXFLAGS_NO_DEBUGINFO = -c +CXXFLAGS_DEBUGINFO = -c -g + +all: main + +main: a.o b.o + $(CXX) a.o b.o -o main $(LDFLAGS) + +a.o: a.cpp + $(CXX) $(SRCDIR)/a.cpp $(CXXFLAGS_NO_DEBUGINFO) -o a.o + +b.o: b.cpp + $(CXX) $(SRCDIR)/b.cpp $(CXXFLAGS_DEBUGINFO) -o b.o + +clean: OBJECTS += a.o b.o main + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py new file mode 100644 index 00000000000..0191e08d29f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py @@ -0,0 +1,22 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestOperatorOverload(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def test_overload(self): + self.build() + (target, process, thread, + main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec("b.cpp"), exe_name = "main") + frame = thread.GetSelectedFrame() + value = frame.EvaluateExpression("x == nil") + self.assertTrue(str(value.GetError()) + .find("comparison between NULL and non-pointer ('Tinky' and NULL)") + != -1) + self.assertTrue(str(value.GetError()) + .find("invalid operands to binary expression ('Tinky' and 'long')") + != -1) + self.assertFalse(value.GetError().Success()) diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp new file mode 100644 index 00000000000..77b2f6ace82 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp @@ -0,0 +1,9 @@ +class Patatino { +public: + double _blah; + Patatino(int blah) : _blah(blah) {} +}; + +bool operator==(const Patatino& a, const Patatino& b) { + return a._blah < b._blah; +} diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp new file mode 100644 index 00000000000..c0eb29bb79f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp @@ -0,0 +1,10 @@ +class Tinky { +public: + int _meh; + Tinky(int meh) : _meh(meh) {} +}; + +int main(void) { + Tinky x(12); + return 0; // break here +} |