[cfe-commits] r107542 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/UsuallyTinyPtrVector.h include/clang/Frontend/PCHReader.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriter.cpp lib/Frontend/PCHWriterDecl.cpp lib/Frontend/PCHWriterStmt.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jul 2 16:30:27 PDT 2010
Author: akirtzidis
Date: Fri Jul 2 18:30:27 2010
New Revision: 107542
URL: http://llvm.org/viewvc/llvm-project?rev=107542&view=rev
Log:
Read/write CastExpr's CXXBaseSpecifierArray for PCH.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/UsuallyTinyPtrVector.h
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/include/clang/Frontend/PCHWriter.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Jul 2 18:30:27 2010
@@ -2024,6 +2024,7 @@
}
const CXXBaseSpecifierArray& getBasePath() const { return BasePath; }
+ CXXBaseSpecifierArray& getBasePath() { return BasePath; }
static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstCastExprConstant &&
Modified: cfe/trunk/include/clang/AST/UsuallyTinyPtrVector.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/UsuallyTinyPtrVector.h?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/UsuallyTinyPtrVector.h (original)
+++ cfe/trunk/include/clang/AST/UsuallyTinyPtrVector.h Fri Jul 2 18:30:27 2010
@@ -41,6 +41,7 @@
typedef const T **iterator;
iterator begin() const;
iterator end() const;
+ size_t size() const;
void push_back(T *Method);
void Destroy();
@@ -56,7 +57,6 @@
return &Vec->front();
}
-
template<typename T>
typename UsuallyTinyPtrVector<T>::iterator
UsuallyTinyPtrVector<T>::end() const {
@@ -72,6 +72,15 @@
}
template<typename T>
+size_t UsuallyTinyPtrVector<T>::size() const {
+ if ((Storage & 0x01) == 0)
+ return (Storage == 0) ? 0 : 1;
+
+ vector_type *Vec = reinterpret_cast<vector_type *>(Storage & ~0x01);
+ return Vec->size();
+}
+
+template<typename T>
void UsuallyTinyPtrVector<T>::push_back(T *Element) {
if (Storage == 0) {
// 0 -> 1 element.
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Fri Jul 2 18:30:27 2010
@@ -747,6 +747,9 @@
void ReadUnresolvedSet(UnresolvedSetImpl &Set,
const RecordData &Record, unsigned &Idx);
+ /// \brief Read a C++ base specifier.
+ CXXBaseSpecifier ReadCXXBaseSpecifier(const RecordData &Record,unsigned &Idx);
+
/// \brief Read a source location.
SourceLocation ReadSourceLocation(const RecordData &Record, unsigned& Idx) {
return SourceLocation::getFromRawEncoding(Record[Idx++]);
Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Fri Jul 2 18:30:27 2010
@@ -346,6 +346,9 @@
/// \brief Emit a UnresolvedSet structure.
void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record);
+ /// brief Emit a C++ base specifier.
+ void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordData &Record);
+
/// \brief Add a string to the given record.
void AddString(const std::string &Str, RecordData &Record);
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Fri Jul 2 18:30:27 2010
@@ -3101,6 +3101,16 @@
}
}
+CXXBaseSpecifier
+PCHReader::ReadCXXBaseSpecifier(const RecordData &Record, unsigned &Idx) {
+ bool isVirtual = static_cast<bool>(Record[Idx++]);
+ bool isBaseOfClass = static_cast<bool>(Record[Idx++]);
+ AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]);
+ QualType T = GetType(Record[Idx++]);
+ SourceRange Range = ReadSourceRange(Record, Idx);
+ return CXXBaseSpecifier(Range, isVirtual, isBaseOfClass, AS, T);
+}
+
NestedNameSpecifier *
PCHReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) {
unsigned N = Record[Idx++];
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Fri Jul 2 18:30:27 2010
@@ -39,8 +39,6 @@
unsigned &Idx)
: Reader(Reader), Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { }
- CXXBaseSpecifier ReadCXXBaseSpecifier();
-
void Visit(Decl *D);
void VisitDecl(Decl *D);
@@ -635,15 +633,6 @@
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
}
-CXXBaseSpecifier PCHDeclReader::ReadCXXBaseSpecifier() {
- bool isVirtual = static_cast<bool>(Record[Idx++]);
- bool isBaseOfClass = static_cast<bool>(Record[Idx++]);
- AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]);
- QualType T = Reader.GetType(Record[Idx++]);
- SourceRange Range = Reader.ReadSourceRange(Record, Idx);
- return CXXBaseSpecifier(Range, isVirtual, isBaseOfClass, AS, T);
-}
-
void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
VisitRecordDecl(D);
@@ -676,13 +665,13 @@
Data.NumBases = Record[Idx++];
Data.Bases = new(C) CXXBaseSpecifier [Data.NumBases];
for (unsigned i = 0; i != Data.NumBases; ++i)
- Data.Bases[i] = ReadCXXBaseSpecifier();
+ Data.Bases[i] = Reader.ReadCXXBaseSpecifier(Record, Idx);
// FIXME: Make VBases lazily computed when needed to avoid storing them.
Data.NumVBases = Record[Idx++];
Data.VBases = new(C) CXXBaseSpecifier [Data.NumVBases];
for (unsigned i = 0; i != Data.NumVBases; ++i)
- Data.VBases[i] = ReadCXXBaseSpecifier();
+ Data.VBases[i] = Reader.ReadCXXBaseSpecifier(Record, Idx);
Reader.ReadUnresolvedSet(Data.Conversions, Record, Idx);
Reader.ReadUnresolvedSet(Data.VisibleConversions, Record, Idx);
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Fri Jul 2 18:30:27 2010
@@ -537,6 +537,14 @@
VisitExpr(E);
E->setSubExpr(Reader.ReadSubExpr());
E->setCastKind((CastExpr::CastKind)Record[Idx++]);
+ CXXBaseSpecifierArray &BasePath = E->getBasePath();
+ unsigned NumBaseSpecs = Record[Idx++];
+ while (NumBaseSpecs--) {
+ // FIXME: These gets leaked.
+ CXXBaseSpecifier *BaseSpec = new (*Reader.getContext()) CXXBaseSpecifier;
+ *BaseSpec = Reader.ReadCXXBaseSpecifier(Record, Idx);
+ BasePath.push_back(BaseSpec);
+ }
}
void PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Fri Jul 2 18:30:27 2010
@@ -2632,3 +2632,12 @@
Record.push_back(I.getAccess());
}
}
+
+void PCHWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
+ RecordData &Record) {
+ Record.push_back(Base.isVirtual());
+ Record.push_back(Base.isBaseOfClass());
+ Record.push_back(Base.getAccessSpecifierAsWritten());
+ AddTypeRef(Base.getType(), Record);
+ AddSourceRange(Base.getSourceRange(), Record);
+}
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Fri Jul 2 18:30:27 2010
@@ -109,8 +109,6 @@
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
-
- void WriteCXXBaseSpecifier(const CXXBaseSpecifier *Base);
};
}
@@ -634,14 +632,6 @@
Code = pch::DECL_UNRESOLVED_USING_TYPENAME;
}
-void PCHDeclWriter::WriteCXXBaseSpecifier(const CXXBaseSpecifier *Base) {
- Record.push_back(Base->isVirtual());
- Record.push_back(Base->isBaseOfClass());
- Record.push_back(Base->getAccessSpecifierAsWritten());
- Writer.AddTypeRef(Base->getType(), Record);
- Writer.AddSourceRange(Base->getSourceRange(), Record);
-}
-
void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
VisitRecordDecl(D);
@@ -670,13 +660,13 @@
Record.push_back(D->getNumBases());
for (CXXRecordDecl::base_class_iterator I = D->bases_begin(),
E = D->bases_end(); I != E; ++I)
- WriteCXXBaseSpecifier(&*I);
+ Writer.AddCXXBaseSpecifier(*I, Record);
// FIXME: Make VBases lazily computed when needed to avoid storing them.
Record.push_back(D->getNumVBases());
for (CXXRecordDecl::base_class_iterator I = D->vbases_begin(),
E = D->vbases_end(); I != E; ++I)
- WriteCXXBaseSpecifier(&*I);
+ Writer.AddCXXBaseSpecifier(*I, Record);
Writer.AddUnresolvedSet(Data.Conversions, Record);
Writer.AddUnresolvedSet(Data.VisibleConversions, Record);
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=107542&r1=107541&r2=107542&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Fri Jul 2 18:30:27 2010
@@ -529,6 +529,11 @@
VisitExpr(E);
Writer.AddStmt(E->getSubExpr());
Record.push_back(E->getCastKind()); // FIXME: stable encoding
+ CXXBaseSpecifierArray &BasePath = E->getBasePath();
+ Record.push_back(BasePath.size());
+ for (CXXBaseSpecifierArray::iterator I = BasePath.begin(), E = BasePath.end();
+ I != E; ++I)
+ Writer.AddCXXBaseSpecifier(**I, Record);
}
void PCHStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
More information about the cfe-commits
mailing list