summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-29 18:16:10 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-29 18:16:10 +0000
commitd67d4cc82ff01ca919eb25c09c40df421a8a39ea (patch)
treec964735b0f38f841908b0616d85f1b54650040d8 /clang
parentc81af03fb39c879f1713224b29ac0fc10470ea89 (diff)
downloadbcm5719-llvm-d67d4cc82ff01ca919eb25c09c40df421a8a39ea.tar.gz
bcm5719-llvm-d67d4cc82ff01ca919eb25c09c40df421a8a39ea.zip
Implement PCH support for offsetof(base-specifier).
llvm-svn: 109785
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Frontend/PCHReaderStmt.cpp8
-rw-r--r--clang/lib/Frontend/PCHWriterStmt.cpp3
-rw-r--r--clang/test/PCH/cxx-offsetof-base.cpp2
-rw-r--r--clang/test/PCH/cxx-offsetof-base.h5
4 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/Frontend/PCHReaderStmt.cpp b/clang/lib/Frontend/PCHReaderStmt.cpp
index 86dfd879ca6..6a11529b02c 100644
--- a/clang/lib/Frontend/PCHReaderStmt.cpp
+++ b/clang/lib/Frontend/PCHReaderStmt.cpp
@@ -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)
diff --git a/clang/lib/Frontend/PCHWriterStmt.cpp b/clang/lib/Frontend/PCHWriterStmt.cpp
index e807ddff098..eee409b047d 100644
--- a/clang/lib/Frontend/PCHWriterStmt.cpp
+++ b/clang/lib/Frontend/PCHWriterStmt.cpp
@@ -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;
}
}
diff --git a/clang/test/PCH/cxx-offsetof-base.cpp b/clang/test/PCH/cxx-offsetof-base.cpp
new file mode 100644
index 00000000000..18265deecc2
--- /dev/null
+++ b/clang/test/PCH/cxx-offsetof-base.cpp
@@ -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
diff --git a/clang/test/PCH/cxx-offsetof-base.h b/clang/test/PCH/cxx-offsetof-base.h
new file mode 100644
index 00000000000..7c7810185d4
--- /dev/null
+++ b/clang/test/PCH/cxx-offsetof-base.h
@@ -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);
OpenPOWER on IntegriCloud