diff options
author | Frederic Riss <friss@apple.com> | 2018-06-01 20:14:21 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2018-06-01 20:14:21 +0000 |
commit | 9cd4def1c6affbfdec410c7e9bfa2fad15ccdaf8 (patch) | |
tree | c354b03e11a5fb2ba13f8661b9f93bc93bb0b3f4 /lldb/packages/Python/lldbsuite/test/lang | |
parent | 1943b49c99a3ea7df455788e9402a2501d618c05 (diff) | |
download | bcm5719-llvm-9cd4def1c6affbfdec410c7e9bfa2fad15ccdaf8.tar.gz bcm5719-llvm-9cd4def1c6affbfdec410c7e9bfa2fad15ccdaf8.zip |
Fix Module::FindTypes to return the correct number of matches.
In r331719, I changed Module::FindTypes not to limit the amount
of types returned by the Symbol provider, because we want all
possible matches to be able to filter them. In one code path,
the filtering was applied to the TypeList without changing the
number of types that gets returned. This is turn could cause
consumers to access beyond the end of the TypeList.
This patch fixes this case and also adds an assertion to
TypeList::GetTypeAtIndex to catch those obvious programming
mistakes.
Triggering the condition in which we performed the incorrect
access was not easy. It happened a lot in mixed Swift/ObjectiveC
code, but I was able to trigger it in pure Objective C++ although
in a contrieved way.
rdar://problem/40254997
llvm-svn: 333786
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang')
4 files changed, 41 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile new file mode 100644 index 00000000000..579600704dc --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make +OBJCXX_SOURCES := main.mm myobject.mm +include $(LEVEL)/Makefile.rules + +# myobject.o needs to be built without debug info +myobject.o: myobject.mm + $(CXX) -c -o $@ $< diff --git a/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py new file mode 100644 index 00000000000..9b0c1f5eaef --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py @@ -0,0 +1,6 @@ +from lldbsuite.test import decorators +from lldbsuite.test import lldbinline + +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.skipIfFreeBSD, decorators.skipIfLinux, decorators.skipIfWindows]) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm new file mode 100644 index 00000000000..b74871f4270 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm @@ -0,0 +1,21 @@ +#import <Foundation/Foundation.h> + +namespace NS { + class MyObject { int i = 42; }; + NS::MyObject globalObject; +} + +@interface MyObject: NSObject +@end + +int main () +{ + @autoreleasepool + { + MyObject *o = [MyObject alloc]; + return 0; //% self.expect("fr var o", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(MyObject"]); + //% self.expect("fr var globalObject", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"]); + } +} + + diff --git a/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm new file mode 100644 index 00000000000..051c4e5eb1d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm @@ -0,0 +1,7 @@ +#import <Foundation/Foundation.h> + +@interface MyObject : NSObject +@end + +@implementation MyObject +@end |