mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-05 23:52:45 +00:00
Read/write CastExpr's CXXBaseSpecifierArray for PCH.
llvm-svn: 107542
This commit is contained in:
parent
4259ebcdac
commit
3701fcd759
@ -2024,6 +2024,7 @@ public:
|
||||
}
|
||||
|
||||
const CXXBaseSpecifierArray& getBasePath() const { return BasePath; }
|
||||
CXXBaseSpecifierArray& getBasePath() { return BasePath; }
|
||||
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() >= firstCastExprConstant &&
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
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 @@ UsuallyTinyPtrVector<T>::begin() const {
|
||||
return &Vec->front();
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
typename UsuallyTinyPtrVector<T>::iterator
|
||||
UsuallyTinyPtrVector<T>::end() const {
|
||||
@ -71,6 +71,15 @@ UsuallyTinyPtrVector<T>::end() const {
|
||||
return &Vec->front() + Vec->size();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -747,6 +747,9 @@ public:
|
||||
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++]);
|
||||
|
@ -346,6 +346,9 @@ public:
|
||||
/// \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);
|
||||
|
||||
|
@ -3101,6 +3101,16 @@ void PCHReader::ReadUnresolvedSet(UnresolvedSetImpl &Set,
|
||||
}
|
||||
}
|
||||
|
||||
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++];
|
||||
|
@ -39,8 +39,6 @@ namespace clang {
|
||||
unsigned &Idx)
|
||||
: Reader(Reader), Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { }
|
||||
|
||||
CXXBaseSpecifier ReadCXXBaseSpecifier();
|
||||
|
||||
void Visit(Decl *D);
|
||||
|
||||
void VisitDecl(Decl *D);
|
||||
@ -635,15 +633,6 @@ void PCHDeclReader::VisitUnresolvedUsingTypenameDecl(
|
||||
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 @@ void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
||||
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);
|
||||
|
@ -537,6 +537,14 @@ void PCHStmtReader::VisitCastExpr(CastExpr *E) {
|
||||
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) {
|
||||
|
@ -2632,3 +2632,12 @@ PCHWriter::AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record) {
|
||||
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);
|
||||
}
|
||||
|
@ -109,8 +109,6 @@ namespace clang {
|
||||
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
|
||||
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
|
||||
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
|
||||
|
||||
void WriteCXXBaseSpecifier(const CXXBaseSpecifier *Base);
|
||||
};
|
||||
}
|
||||
|
||||
@ -634,14 +632,6 @@ void PCHDeclWriter::VisitUnresolvedUsingTypenameDecl(
|
||||
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 @@ void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
||||
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);
|
||||
|
@ -529,6 +529,11 @@ void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user