[cfe-commits] r109785 - in /cfe/trunk: lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp test/PCH/cxx-offsetof-base.cpp test/PCH/cxx-offsetof-base.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Jul 29 11:16:10 PDT 2010
Author: akirtzidis
Date: Thu Jul 29 13:16:10 2010
New Revision: 109785
URL: http://llvm.org/viewvc/llvm-project?rev=109785&view=rev
Log:
Implement PCH support for offsetof(base-specifier).
Added:
cfe/trunk/test/PCH/cxx-offsetof-base.cpp
cfe/trunk/test/PCH/cxx-offsetof-base.h
Modified:
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=109785&r1=109784&r2=109785&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Thu Jul 29 13:16:10 2010
@@ -502,11 +502,13 @@
E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End));
break;
- case Node::Base:
- // FIXME: Implement this!
- llvm_unreachable("PCH for offsetof(base-specifier) not implemented");
+ case Node::Base: {
+ CXXBaseSpecifier *Base = new (*Reader.getContext()) CXXBaseSpecifier();
+ *Base = Reader.ReadCXXBaseSpecifier(DeclsCursor, Record, Idx);
+ E->setComponent(I, Node(Base));
break;
}
+ }
}
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=109785&r1=109784&r2=109785&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Thu Jul 29 13:16:10 2010
@@ -483,8 +483,7 @@
break;
case OffsetOfExpr::OffsetOfNode::Base:
- // FIXME: Implement this!
- llvm_unreachable("PCH for offsetof(base-specifier) not implemented");
+ Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
break;
}
}
Added: cfe/trunk/test/PCH/cxx-offsetof-base.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-offsetof-base.cpp?rev=109785&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-offsetof-base.cpp (added)
+++ cfe/trunk/test/PCH/cxx-offsetof-base.cpp Thu Jul 29 13:16:10 2010
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-offsetof-base.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
Added: cfe/trunk/test/PCH/cxx-offsetof-base.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-offsetof-base.h?rev=109785&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-offsetof-base.h (added)
+++ cfe/trunk/test/PCH/cxx-offsetof-base.h Thu Jul 29 13:16:10 2010
@@ -0,0 +1,5 @@
+// Header for PCH test cxx-offsetof-base.cpp
+
+struct Base { int x; };
+struct Derived : Base { int y; };
+int o = __builtin_offsetof(Derived, x);
More information about the cfe-commits
mailing list