[Lldb-commits] [lldb] r370186 - [lldb][NFC] Test custom C++ operators

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 28 04:18:47 PDT 2019


Author: teemperor
Date: Wed Aug 28 04:18:47 2019
New Revision: 370186

URL: http://llvm.org/viewvc/llvm-project?rev=370186&view=rev
Log:
[lldb][NFC] Test custom C++ operators

Added:
    lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/
    lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/TestCppOperators.py
    lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile?rev=370186&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/Makefile Wed Aug 28 04:18:47 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/TestCppOperators.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/TestCppOperators.py?rev=370186&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/TestCppOperators.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/TestCppOperators.py Wed Aug 28 04:18:47 2019
@@ -0,0 +1,5 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(),
+                          lldbinline.expectedFailureAll(oslist=["windows"]))

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp?rev=370186&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/operators/main.cpp Wed Aug 28 04:18:47 2019
@@ -0,0 +1,142 @@
+struct B { int dummy = 2324; };
+struct C {
+  B b;
+  B* operator->() { return &b; }
+  int operator->*(int) { return 2; }
+  int operator+(int) { return 44; }
+  int operator+=(int) { return 42; }
+  int operator++(int) { return 123; }
+  int operator++() { return 1234; }
+  int operator-(int) { return 34; }
+  int operator-=(int) { return 32; }
+  int operator--() { return 321; }
+  int operator--(int) { return 4321; }
+
+  int operator*(int) { return 51; }
+  int operator*=(int) { return 52; }
+  int operator%(int) { return 53; }
+  int operator%=(int) { return 54; }
+  int operator/(int) { return 55; }
+  int operator/=(int) { return 56; }
+  int operator^(int) { return 57; }
+  int operator^=(int) { return 58; }
+
+  int operator|(int) { return 61; }
+  int operator|=(int) { return 62; }
+  int operator||(int) { return 63; }
+  int operator&(int) { return 64; }
+  int operator&=(int) { return 65; }
+  int operator&&(int) { return 66; }
+
+  int operator~() { return 71; }
+  int operator!() { return 72; }
+  int operator!=(int) { return 73; }
+  int operator=(int) { return 74; }
+  int operator==(int) { return 75; }
+
+  int operator<(int) { return 81; }
+  int operator<<(int) { return 82; }
+  int operator<=(int) { return 83; }
+  int operator<<=(int) { return 84; }
+  int operator>(int) { return 85; }
+  int operator>>(int) { return 86; }
+  int operator>=(int) { return 87; }
+  int operator>>=(int) { return 88; }
+
+  int operator[](int) { return 91; }
+  int operator()(int) { return 92; }
+};
+
+int main(int argc, char **argv) {
+  C c;
+  int result = c->dummy;
+  result = c->*4;
+  result += c+1;
+  result += c+=1;
+  result += c++;
+  result += ++c;
+  result += c-1;
+  result += c-=1;
+  result += c--;
+  result += --c;
+
+  result += c * 4;
+  result += c *= 4;
+  result += c % 4;
+  result += c %= 4;
+  result += c / 4;
+  result += c /= 4;
+  result += c ^ 4;
+  result += c ^= 4;
+
+  result += c | 4;
+  result += c |= 4;
+  result += c || 4;
+  result += c & 4;
+  result += c &= 4;
+  result += c && 4;
+
+  result += ~c;
+  result += !c;
+  result += c!=1;
+  result += c=2;
+  result += c==2;
+
+  result += c<2;
+  result += c<<2;
+  result += c<=2;
+  result += c<<=2;
+  result += c>2;
+  result += c>>2;
+  result += c>=2;
+  result += c>>=2;
+
+  result += c(1);
+  result += c[1];
+  //% self.expect("expr c->dummy", endstr=" 2324\n")
+  //% self.expect("expr c->*2", endstr=" 2\n")
+  //% self.expect("expr c + 44", endstr=" 44\n")
+  //% self.expect("expr c += 42", endstr=" 42\n")
+  //% self.expect("expr c++", endstr=" 123\n")
+  //% self.expect("expr ++c", endstr=" 1234\n")
+
+  //% self.expect("expr c - 34", endstr=" 34\n")
+  //% self.expect("expr c -= 32", endstr=" 32\n")
+  //% self.expect("expr c--", endstr=" 321\n")
+  //% self.expect("expr --c", endstr=" 4321\n")
+
+  //% self.expect("expr c * 3", endstr=" 51\n")
+  //% self.expect("expr c *= 3", endstr=" 52\n")
+  //% self.expect("expr c % 3", endstr=" 53\n")
+  //% self.expect("expr c %= 3", endstr=" 54\n")
+  //% self.expect("expr c / 3", endstr=" 55\n")
+  //% self.expect("expr c /= 3", endstr=" 56\n")
+  //% self.expect("expr c ^ 3", endstr=" 57\n")
+  //% self.expect("expr c ^= 3", endstr=" 58\n")
+
+  //% self.expect("expr c | 3", endstr=" 61\n")
+  //% self.expect("expr c |= 3", endstr=" 62\n")
+  //% self.expect("expr c || 3", endstr=" 63\n")
+  //% self.expect("expr c & 3", endstr=" 64\n")
+  //% self.expect("expr c &= 3", endstr=" 65\n")
+  //% self.expect("expr c && 3", endstr=" 66\n")
+
+  //% self.expect("expr ~c", endstr=" 71\n")
+  //% self.expect("expr !c", endstr=" 72\n")
+  //% self.expect("expr c!=1", endstr=" 73\n")
+  //% self.expect("expr c=1", endstr=" 74\n")
+  //% self.expect("expr c==1", endstr=" 75\n")
+
+  //% self.expect("expr c<1", endstr=" 81\n")
+  //% self.expect("expr c<<1", endstr=" 82\n")
+  //% self.expect("expr c<=1", endstr=" 83\n")
+  //% self.expect("expr c<<=1", endstr=" 84\n")
+  //% self.expect("expr c>1", endstr=" 85\n")
+  //% self.expect("expr c>>1", endstr=" 86\n")
+  //% self.expect("expr c>=1", endstr=" 87\n")
+  //% self.expect("expr c>>=1", endstr=" 88\n")
+
+  //% self.expect("expr c(1)", endstr=" 91\n")
+  //% self.expect("expr c[1]", endstr=" 92\n")
+  return 0;
+}




More information about the lldb-commits mailing list