diff options
author | Enrico Granata <egranata@apple.com> | 2016-05-25 23:19:01 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-05-25 23:19:01 +0000 |
commit | fee0aba00626744bd099cb4872f02379808fae2b (patch) | |
tree | 48631d0e9eed8b36b45e20c0bd64f87d05d5d8c5 /lldb/packages/Python/lldbsuite/test | |
parent | 5d122f872d5bb9164ae58eb5f79bbed2ede3f605 (diff) | |
download | bcm5719-llvm-fee0aba00626744bd099cb4872f02379808fae2b.tar.gz bcm5719-llvm-fee0aba00626744bd099cb4872f02379808fae2b.zip |
It has been brought to my attention that, given two variables
T x;
U y;
doing
x = *((T*)y)
is undefined behavior, even if sizeof(T) == sizeof(U), due to pointer aliasing rules
Fix up a couple of places in LLDB that were doing this, and transform them into a defined and safe memcpy() operation
Also, add a test case to ensure we didn't regress by doing this w.r.t. tagged pointer NSDate instances
llvm-svn: 270793
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
2 files changed, 9 insertions, 6 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index da389819fd4..d7d4118d1d6 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -271,16 +271,18 @@ class ObjCDataFormatterTestCase(TestBase): # this test might fail if we hit the breakpoint late on December 31st of some given year # and midnight comes between hitting the breakpoint and running this line of code # hopefully the output will be revealing enough in that case :-) - now_year = str(datetime.datetime.now().year) + now_year = '%s-' % str(datetime.datetime.now().year) - self.expect('frame variable date3 date4', - substrs = [now_year,'1970']) + self.expect('frame variable date3', substrs = [now_year]) + self.expect('frame variable date4', substrs = ['1970']) + self.expect('frame variable date5', substrs = [now_year]) self.expect('frame variable date1_abs date2_abs', substrs = ['1985-04','2011-01']) - self.expect('frame variable date3_abs date4_abs', - substrs = [now_year,'1970']) + self.expect('frame variable date3_abs', substrs = [now_year]) + self.expect('frame variable date4_abs', substrs = ['1970']) + self.expect('frame variable date5_abs', substrs = [now_year]) self.expect('frame variable cupertino home europe', substrs = ['@"America/Los_Angeles"', @@ -358,7 +360,6 @@ class ObjCDataFormatterTestCase(TestBase): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd('log timers disable', check=False) # Execute the cleanup function during test case tear down. diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m index 87a0e27a6b0..020e2fc6227 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m +++ b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -489,11 +489,13 @@ int main (int argc, const char * argv[]) NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"]; NSDate *date3 = [NSDate date]; NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60]; + NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: floor([[NSDate date] timeIntervalSinceReferenceDate])]; CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1); CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2); CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3); CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); + CFAbsoluteTime date5_abs = CFDateGetAbsoluteTime(date5); NSIndexSet *iset1 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)]; NSIndexSet *iset2 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; |