[cfe-commits] r127315 - in /cfe/trunk: lib/Serialization/ASTReader.cpp test/PCH/chain-cxx.cpp
Anders Carlsson
andersca at mac.com
Tue Mar 8 21:09:32 PST 2011
Author: andersca
Date: Tue Mar 8 23:09:32 2011
New Revision: 127315
URL: http://llvm.org/viewvc/llvm-project?rev=127315&view=rev
Log:
When deserializing CXXBaseSpecifiers (and offsets), make sure to walk the chain in the correct order.
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/PCH/chain-cxx.cpp
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=127315&r1=127314&r2=127315&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Mar 8 23:09:32 2011
@@ -3730,11 +3730,13 @@
--ID;
uint64_t Offset = 0;
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
- if (ID < Chain[I]->LocalNumCXXBaseSpecifiers)
- return Offset + Chain[I]->CXXBaseSpecifiersOffsets[ID];
+ PerFileData &F = *Chain[N - I - 1];
+
+ if (ID < F.LocalNumCXXBaseSpecifiers)
+ return Offset + F.CXXBaseSpecifiersOffsets[ID];
- ID -= Chain[I]->LocalNumCXXBaseSpecifiers;
- Offset += Chain[I]->SizeInBits;
+ ID -= F.LocalNumCXXBaseSpecifiers;
+ Offset += F.SizeInBits;
}
assert(false && "CXXBaseSpecifiers not found");
@@ -3745,14 +3747,14 @@
// Figure out which AST file contains this offset.
PerFileData *F = 0;
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
- if (Offset < Chain[I]->SizeInBits) {
- F = Chain[I];
+ if (Offset < Chain[N - I - 1]->SizeInBits) {
+ F = Chain[N - I - 1];
break;
}
- Offset -= Chain[I]->SizeInBits;
+ Offset -= Chain[N - I - 1]->SizeInBits;
}
-
+
if (!F) {
Error("Malformed AST file: C++ base specifiers at impossible offset");
return 0;
Modified: cfe/trunk/test/PCH/chain-cxx.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-cxx.cpp?rev=127315&r1=127314&r2=127315&view=diff
==============================================================================
--- cfe/trunk/test/PCH/chain-cxx.cpp (original)
+++ cfe/trunk/test/PCH/chain-cxx.cpp Tue Mar 8 23:09:32 2011
@@ -34,6 +34,9 @@
template <typename T> struct TS2;
typedef TS2<int> TS2int;
+template <typename T> struct TestBaseSpecifiers { };
+template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
+
//===----------------------------------------------------------------------===//
#elif not defined(HEADER2)
#define HEADER2
@@ -73,6 +76,9 @@
template <typename T> struct TS2 { };
+struct TestBaseSpecifiers3 { };
+struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
+
struct A { };
struct B : A { };
More information about the cfe-commits
mailing list