Skip to content

Commit

Permalink
[lldb][NFC] Test named operators like new and function names that mig…
Browse files Browse the repository at this point in the history
…ht confuse LLDB

llvm-svn: 370199
  • Loading branch information
Teemperor committed Aug 28, 2019
1 parent aba62e9 commit 4046e1e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <cstdlib>

struct B { int dummy = 2324; };
struct C {
void *operator new(size_t size) { C* r = ::new C; r->custom_new = true; return r; }

bool custom_new = false;
B b;
B* operator->() { return &b; }
int operator->*(int) { return 2; }
Expand Down Expand Up @@ -48,6 +53,11 @@ struct C {

operator int() { return 11; }
operator long() { return 12; }

// Make sure this doesn't collide with
// the real operator int.
int operatorint() { return 13; }
int operatornew() { return 14; }
};

int main(int argc, char **argv) {
Expand Down Expand Up @@ -99,6 +109,10 @@ int main(int argc, char **argv) {

result += static_cast<int>(c);
result += static_cast<long>(c);
result += c.operatorint();
result += c.operatornew();

C *c2 = new C();

//% self.expect("expr c->dummy", endstr=" 2324\n")
//% self.expect("expr c->*2", endstr=" 2\n")
Expand Down Expand Up @@ -141,5 +155,9 @@ int main(int argc, char **argv) {
//% self.expect("expr c[1]", endstr=" 92\n")
//% self.expect("expr static_cast<int>(c)", endstr=" 11\n")
//% self.expect("expr static_cast<long>(c)", endstr=" 12\n")
//% self.expect("expr c.operatorint()", endstr=" 13\n")
//% self.expect("expr c.operatornew()", endstr=" 14\n")
//% self.expect("expr (new C)->custom_new", endstr=" true\n")
delete c2;
return 0;
}

0 comments on commit 4046e1e

Please sign in to comment.