Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Modules][PCH] Serialize #pragma pack
This patch serializes the state of #pragma pack. It preserves the state of the pragma from a PCH/from modules in a file that uses that PCH/those modules. rdar://21359084 Differential Revision: https://reviews.llvm.org/D31241 llvm-svn: 299226
- Loading branch information
Showing
12 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
#pragma pack (push, 4) | ||
#pragma pack (push, 2) | ||
#pragma pack (push, 1) | ||
#pragma pack (pop) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
#pragma pack () | ||
#pragma pack (push, 4) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
#pragma pack (1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: rm -rf %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_set %S/Inputs/module.map | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_push %S/Inputs/module.map | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_empty %S/Inputs/module.map | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_reset_push %S/Inputs/module.map | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s | ||
// FIXME: When we have a syntax for modules in C, use that. | ||
|
||
@import pragma_pack_set; | ||
|
||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 1}} | ||
#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
|
||
@import pragma_pack_push; | ||
|
||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 2}} | ||
#pragma pack (pop) | ||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 4}} | ||
#pragma pack (pop) | ||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 1}} | ||
#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
|
||
#pragma pack (16) | ||
|
||
@import pragma_pack_empty; | ||
|
||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 16}} | ||
#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
|
||
@import pragma_pack_reset_push; | ||
|
||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 4}} | ||
#pragma pack (pop) | ||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Test this without pch. | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DSET | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DRESET | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH_POP | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH_POP_LABEL | ||
|
||
// Test with pch. | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DSET -emit-pch -o %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DSET -verify -include-pch %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DRESET -emit-pch -o %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DRESET -verify -include-pch %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH -emit-pch -o %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH -verify -include-pch %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP -emit-pch -o %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP -verify -include-pch %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP_LABEL -emit-pch -o %t | ||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP_LABEL -verify -include-pch %t | ||
|
||
#ifndef HEADER | ||
#define HEADER | ||
|
||
#ifdef SET | ||
#pragma pack(1) | ||
#endif | ||
|
||
#ifdef RESET | ||
#pragma pack(2) | ||
#pragma pack () | ||
#endif | ||
|
||
#ifdef PUSH | ||
#pragma pack(1) | ||
#pragma pack (push, 2) | ||
#endif | ||
|
||
#ifdef PUSH_POP | ||
#pragma pack (push, 4) | ||
#pragma pack (push, 2) | ||
#pragma pack (pop) | ||
#endif | ||
|
||
#ifdef PUSH_POP_LABEL | ||
#pragma pack (push, a, 4) | ||
#pragma pack (push, b, 1) | ||
#pragma pack (push, c, 2) | ||
#pragma pack (pop, b) | ||
#endif | ||
|
||
#else | ||
|
||
#ifdef SET | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 1}} | ||
#pragma pack(pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
#endif | ||
|
||
#ifdef RESET | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#pragma () | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#endif | ||
|
||
#ifdef PUSH | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 2}} | ||
#pragma pack(pop) | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 1}} | ||
#pragma pack () | ||
#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#pragma pack(pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
#endif | ||
|
||
#ifdef PUSH_POP | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}} | ||
#pragma pack(pop) | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#pragma pack(pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
#endif | ||
|
||
#ifdef PUSH_POP_LABEL | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}} | ||
#pragma pack(pop, c) | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 4}} | ||
#pragma pack(pop, a) | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#pragma pack(pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
#pragma pack(pop, b) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}} | ||
#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} | ||
#endif | ||
|
||
#endif |