diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-02-03 19:31:51 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-02-03 19:31:51 +0000 |
| commit | 3dd5fe2006d26fca4fcd5c07d660c34f0835f510 (patch) | |
| tree | 38b615aa9d4c90ed141d2b72f5abec9503ab198d /clang | |
| parent | 92afda06d7f9265c5ac88aff72da332279033496 (diff) | |
| download | bcm5719-llvm-3dd5fe2006d26fca4fcd5c07d660c34f0835f510.tar.gz bcm5719-llvm-3dd5fe2006d26fca4fcd5c07d660c34f0835f510.zip | |
Make sure that the layout-override parser grabs the size, not the data
size. Otherwise, we can end up with bogus layouts.
llvm-svn: 149703
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Frontend/LayoutOverrideSource.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/override-layout.cpp | 36 |
2 files changed, 28 insertions, 14 deletions
diff --git a/clang/lib/Frontend/LayoutOverrideSource.cpp b/clang/lib/Frontend/LayoutOverrideSource.cpp index 3af2cc2bbe7..9cc06678505 100644 --- a/clang/lib/Frontend/LayoutOverrideSource.cpp +++ b/clang/lib/Frontend/LayoutOverrideSource.cpp @@ -73,10 +73,10 @@ LayoutOverrideSource::LayoutOverrideSource(llvm::StringRef Filename) { } // Check for the size of the type. - StringRef::size_type Pos = LineStr.find("Size:"); + StringRef::size_type Pos = LineStr.find(" Size:"); if (Pos != StringRef::npos) { - // Skip past the "Size:" prefix. - LineStr = LineStr.substr(Pos + strlen("Size:")); + // Skip past the " Size:" prefix. + LineStr = LineStr.substr(Pos + strlen(" Size:")); unsigned long long Size = 0; (void)LineStr.getAsInteger(10, Size); diff --git a/clang/test/CodeGenCXX/override-layout.cpp b/clang/test/CodeGenCXX/override-layout.cpp index c09dbeff703..d432885c584 100644 --- a/clang/test/CodeGenCXX/override-layout.cpp +++ b/clang/test/CodeGenCXX/override-layout.cpp @@ -35,16 +35,30 @@ struct PACKED X3 : virtual public X1, public X0 { int y; }; -void use_structs() { - struct X0 x0; - x0.x[5] = sizeof(struct X0); - - struct X1 x1; - x1.x[5] = sizeof(struct X1); - - struct X2 x2; - x2.y = sizeof(struct X2); +// CHECK: Type: struct X4 +struct PACKED X4 { + unsigned int a : 1; + unsigned int b : 1; + unsigned int c : 1; + unsigned int d : 1; + unsigned int e : 1; + unsigned int f : 1; + unsigned int g : 1; + unsigned int h : 1; + unsigned int i : 1; + unsigned int j : 1; + unsigned int k : 1; + unsigned int l : 1; + unsigned int m : 1; + unsigned int n : 1; + X4(); +}; - struct X3 x3; - x3.y = sizeof(struct X3); +void use_structs() { + X0 x0s[sizeof(X0)]; + X1 x1s[sizeof(X1)]; + X2 x2s[sizeof(X2)]; + X3 x3s[sizeof(X3)]; + X4 x4s[sizeof(X4)]; + x4s[1].a = 1; } |

