diff options
| author | Enrico Granata <egranata@apple.com> | 2014-09-19 18:21:05 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2014-09-19 18:21:05 +0000 |
| commit | 47caf9a95618142a03316f91a72eed1910a79b14 (patch) | |
| tree | b6268e1cc325cd52932f921b50b2a2df9ca0036a /lldb/test/python_api/class_members | |
| parent | 4505f3a73db80414c9fed0049b8a75b6c4d1b1d8 (diff) | |
| download | bcm5719-llvm-47caf9a95618142a03316f91a72eed1910a79b14.tar.gz bcm5719-llvm-47caf9a95618142a03316f91a72eed1910a79b14.zip | |
Extend the member function discovery APIs to also support Objective-C as well as C++
For the Objective-C case, we do not have a "function type" notion, so we actually end up wrapping the clang ObjCMethodDecl in the Impl object, and ask function-y questions of it
In general, you can always ask for return type, number of arguments, and type of each argument using the TypeMemberFunction layer - but in the C++ case, you can also acquire a Type object for the function itself, which instead you can't do in the Objective-C case
llvm-svn: 218132
Diffstat (limited to 'lldb/test/python_api/class_members')
| -rw-r--r-- | lldb/test/python_api/class_members/Makefile | 2 | ||||
| -rw-r--r-- | lldb/test/python_api/class_members/TestSBTypeClassMembers.py | 11 | ||||
| -rw-r--r-- | lldb/test/python_api/class_members/main.mm (renamed from lldb/test/python_api/class_members/main.cpp) | 19 |
3 files changed, 30 insertions, 2 deletions
diff --git a/lldb/test/python_api/class_members/Makefile b/lldb/test/python_api/class_members/Makefile index 8a7102e347a..0d7550f9f28 100644 --- a/lldb/test/python_api/class_members/Makefile +++ b/lldb/test/python_api/class_members/Makefile @@ -1,5 +1,5 @@ LEVEL = ../../make -CXX_SOURCES := main.cpp +OBJCXX_SOURCES := main.mm include $(LEVEL)/Makefile.rules diff --git a/lldb/test/python_api/class_members/TestSBTypeClassMembers.py b/lldb/test/python_api/class_members/TestSBTypeClassMembers.py index f60b58ec956..867114d059e 100644 --- a/lldb/test/python_api/class_members/TestSBTypeClassMembers.py +++ b/lldb/test/python_api/class_members/TestSBTypeClassMembers.py @@ -37,7 +37,7 @@ class SBTypeMemberFunctionsTest(TestBase): # We'll use the test method name as the exe_name. self.exe_name = self.testMethodName # Find the line number to break at. - self.source = 'main.cpp' + self.source = 'main.mm' self.line = line_number(self.source, '// set breakpoint here') def type_api(self, exe_name): @@ -76,6 +76,15 @@ class SBTypeMemberFunctionsTest(TestBase): self.assertTrue(Base.GetMemberFunctionAtIndex(2).GetType().GetFunctionArgumentTypes().GetSize() == 0, "Base::dat takes no arguments") self.assertTrue(Base.GetMemberFunctionAtIndex(1).GetType().GetFunctionArgumentTypes().GetTypeAtIndex(1).GetName() == "char", "Base::bar takes a second 'char' argument") self.assertTrue(Base.GetMemberFunctionAtIndex(1).GetName() == "bar", "Base::bar not found") + + variable = frame0.FindVariable("thingy") + Thingy = variable.GetType() + + self.assertTrue(Thingy.GetNumberOfMemberFunctions() == 2, "Thingy declares two methods") + + self.assertTrue(Thingy.GetMemberFunctionAtIndex(0).GetReturnType().GetName() == "id", "Thingy::init returns an id") + self.assertTrue(Thingy.GetMemberFunctionAtIndex(1).GetNumberOfArguments() == 2, "Thingy::foo takes two arguments") + self.assertTrue(Thingy.GetMemberFunctionAtIndex(1).GetArgumentTypeAtIndex(0).GetName() == "int", "Thingy::foo takes an int") if __name__ == '__main__': import atexit diff --git a/lldb/test/python_api/class_members/main.cpp b/lldb/test/python_api/class_members/main.mm index 86392a219cc..ff61b369ee1 100644 --- a/lldb/test/python_api/class_members/main.cpp +++ b/lldb/test/python_api/class_members/main.mm @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#import <Foundation/Foundation.h> + class Base { public: int foo(int x, int y) { return 1; } @@ -22,7 +24,24 @@ public: float baz(float b) { return b + 1.0; } }; +@interface Thingy: NSObject { +} +- (id)init; +- (id)fooWithBar: (int)bar andBaz:(id)baz; +@end + +@implementation Thingy { +} +- (id)init { + return (self = [super init]); +} +- (id)fooWithBar: (int)bar andBaz:(id)baz { + return nil; +} +@end + int main() { Derived d; + Thingy *thingy = [[Thingy alloc] init]; return 0; // set breakpoint here } |

