History log of /external/clang/test/CodeGenCXX/warn-padded-packed.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ddeb6fdc7063e935d2ac96e780f1ba305128f535 23-Sep-2010 Argiris Kirtzidis <akyrtzi@gmail.com> Use -emit-llvm-only in the test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114636 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/CodeGenCXX/warn-padded-packed.cpp
003a582e6b61ab0c76db684c90147f8aab723681 22-Sep-2010 Argiris Kirtzidis <akyrtzi@gmail.com> Implement -Wpadded and -Wpacked.

-Wpadded warns when undesired padding is introduced in a struct. (rdar://7469556)
-Wpacked warns if a struct is given the packed attribute, but the packed attribute has no effect
on the layout or the size of the struct. Such structs may be mis-aligned for little benefit.

The warnings are emitted at the point where layout is calculated, that is at RecordLayoutBuilder.
To avoid calculating the layouts of all structs regardless of whether they are needed or not,
I let the layouts be lazily constructed when needed. This has the disadvantage that the above warnings
will be emitted only when they are used for IR gen, and not e.g with -fsyntax-only:

$ cat t.c
struct S {
char c;
int i;
};
void f(struct S* s) {}

$ clang -fsyntax-only -Wpadded t.c
$ clang -c -Wpadded t.c -o t.o
t.c:3:7: warning: padding struct 'struct S' with 3 bytes to align 'i' [-Wpadded]
int i;
^
1 warning generated.

This is a good tradeoff between providing the warnings and not calculating layouts for all
structs in case the user has enabled a couple of rarely used warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114544 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/CodeGenCXX/warn-padded-packed.cpp