Implement PCH support for offsetof(base-specifier).

llvm-svn: 109785
This commit is contained in:
Argyrios Kyrtzidis 2010-07-29 18:16:10 +00:00
parent c81af03fb3
commit d67d4cc82f
4 changed files with 13 additions and 5 deletions

View File

@ -502,11 +502,13 @@ void PCHStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
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)

View File

@ -483,8 +483,7 @@ void PCHStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
break;
case OffsetOfExpr::OffsetOfNode::Base:
// FIXME: Implement this!
llvm_unreachable("PCH for offsetof(base-specifier) not implemented");
Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
break;
}
}

View File

@ -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

View File

@ -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);