Renamed ivar "ArrayTypes" in ASTContext to "ComplexArrayTypes".

Added skeleton code for serialization of ASTContext.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43558 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2007-10-31 17:10:13 +00:00
Родитель 498856cb30
Коммит 7192f8e959
2 изменённых файлов: 57 добавлений и 4 удалений

Просмотреть файл

@ -17,6 +17,8 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Bitcode/Serialize.h"
#include "llvm/Bitcode/Deserialize.h"
using namespace clang;
@ -428,7 +430,8 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
ConstantArrayType::Profile(ID, EltTy, ArySize);
void *InsertPos = 0;
if (ConstantArrayType *ATP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
if (ConstantArrayType *ATP =
ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(ATP, 0);
// If the element type isn't canonical, this won't be a canonical type either,
@ -438,13 +441,15 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
Canonical = getConstantArrayType(EltTy.getCanonicalType(), ArySize,
ASM, EltTypeQuals);
// Get the new insert position for the node we care about.
ConstantArrayType *NewIP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
ConstantArrayType *NewIP =
ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!");
}
ConstantArrayType *New = new ConstantArrayType(EltTy, Canonical, ArySize,
ASM, EltTypeQuals);
ArrayTypes.InsertNode(New, InsertPos);
ConstantArrayTypes.InsertNode(New, InsertPos);
Types.push_back(New);
return QualType(New, 0);
}
@ -1279,3 +1284,43 @@ bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
}
return true; // should never get here...
}
template <typename T>
static inline void EmitSet(const llvm::FoldingSet<T>& set, llvm::Serializer& S) {
S.EmitInt(set.size());
llvm::FoldingSet<T>& Set = const_cast<llvm::FoldingSet<T>&>(set);
for (typename llvm::FoldingSet<T>::iterator I=Set.begin(), E=Set.end();
I!=E; ++I)
S.Emit(*I);
}
/// Emit - Serialize an ASTContext object to Bitcode.
void ASTContext::Emit(llvm::Serializer& S) const {
// FIXME: S.EmitRef(SourceMgr);
// FIXME: S.EmitRef(Target);
// FIXME: S.EmitRef(Idents);
// FIXME: S.EmitRef(Selectors);
// FIXME: BuildinInfo
EmitSet(ComplexTypes,S);
EmitSet(PointerTypes,S);
EmitSet(ReferenceTypes,S);
EmitSet(ConstantArrayTypes,S);
// FIXME EmitSet(IncompleteVariableArrayTypes,S);
/* FIXME: Emit for VLAs
S.EmitInt(CompleteVariableArrayTypes.size());
for (unsigned i = 0; i < CompleteVariableArrayTypes.size(); ++i)
S.Emit(*CompleteVariableArrayTypes[i]); */
EmitSet(VectorTypes,S);
// FIXME: EmitSet(FunctionTypeNoProtos);
// FIXME: EmitSet(FunctionTypeProtos);
// FIXME: EmitSet(ObjcQualifiedInterfaceTypes,S);
// FIXME: RecourdLayoutInfo
// FIXME: Builtins.
}

Просмотреть файл

@ -21,6 +21,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/Bitcode/SerializationFwd.h"
#include <vector>
namespace clang {
@ -34,7 +35,7 @@ class ASTContext {
llvm::FoldingSet<ComplexType> ComplexTypes;
llvm::FoldingSet<PointerType> PointerTypes;
llvm::FoldingSet<ReferenceType> ReferenceTypes;
llvm::FoldingSet<ConstantArrayType> ArrayTypes;
llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
llvm::FoldingSet<VariableArrayType> IncompleteVariableArrayTypes;
std::vector<VariableArrayType*> CompleteVariableArrayTypes;
llvm::FoldingSet<VectorType> VectorTypes;
@ -286,6 +287,13 @@ private:
void InitBuiltinTypes();
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
//===--------------------------------------------------------------------===//
// Serialization
//===--------------------------------------------------------------------===//
void Emit(llvm::Serializer& S) const;
static ASTContext* Materialize(llvm::Deserializer& D);
};
} // end namespace clang