[cfe-commits] r149703 - in /cfe/trunk: lib/Frontend/LayoutOverrideSource.cpp test/CodeGenCXX/override-layout.cpp
Douglas Gregor
dgregor at apple.com
Fri Feb 3 11:31:51 PST 2012
Author: dgregor
Date: Fri Feb 3 13:31:51 2012
New Revision: 149703
URL: http://llvm.org/viewvc/llvm-project?rev=149703&view=rev
Log:
Make sure that the layout-override parser grabs the size, not the data
size. Otherwise, we can end up with bogus layouts.
Modified:
cfe/trunk/lib/Frontend/LayoutOverrideSource.cpp
cfe/trunk/test/CodeGenCXX/override-layout.cpp
Modified: cfe/trunk/lib/Frontend/LayoutOverrideSource.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/LayoutOverrideSource.cpp?rev=149703&r1=149702&r2=149703&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/LayoutOverrideSource.cpp (original)
+++ cfe/trunk/lib/Frontend/LayoutOverrideSource.cpp Fri Feb 3 13:31:51 2012
@@ -73,10 +73,10 @@
}
// 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);
Modified: cfe/trunk/test/CodeGenCXX/override-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/override-layout.cpp?rev=149703&r1=149702&r2=149703&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/override-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/override-layout.cpp Fri Feb 3 13:31:51 2012
@@ -35,16 +35,30 @@
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;
}
More information about the cfe-commits
mailing list