File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,12 @@ class DataLayout {
398398 PS.HasExternalState ;
399399 }
400400
401+ // / Returns if the null pointer for this address space has an all-zero bit
402+ // / representation.
403+ bool isNullPointerAllZeroes (unsigned AddrSpace) const {
404+ return AddrSpace == 0 ;
405+ }
406+
401407 // / Returns whether this address space has an "unstable" pointer
402408 // / representation. The bitwise pattern of such pointers is allowed to change
403409 // / in a target-specific way. For example, this could be used for copying
Original file line number Diff line number Diff line change @@ -700,6 +700,15 @@ TEST(DataLayout, NonIntegralHelpers) {
700700 }
701701}
702702
703+ TEST (DataLayoutTest, IsNullPointerAllZeroes) {
704+ EXPECT_TRUE (DataLayout (" " ).isNullPointerAllZeroes (0 ));
705+ EXPECT_FALSE (DataLayout (" " ).isNullPointerAllZeroes (1 ));
706+ EXPECT_TRUE (DataLayout (" p:32:32" ).isNullPointerAllZeroes (0 ));
707+ EXPECT_FALSE (DataLayout (" p:32:32" ).isNullPointerAllZeroes (1 ));
708+ EXPECT_TRUE (DataLayout (" p:64:64" ).isNullPointerAllZeroes (0 ));
709+ EXPECT_FALSE (DataLayout (" p:64:64" ).isNullPointerAllZeroes (1 ));
710+ }
711+
703712TEST (DataLayoutTest, CopyAssignmentInvalidatesStructLayout) {
704713 DataLayout DL1 = cantFail (DataLayout::parse (" p:32:32" ));
705714 DataLayout DL2 = cantFail (DataLayout::parse (" p:64:64" ));
You can’t perform that action at this time.
0 commit comments