forked from OSchip/llvm-project
Renamed ivar "ArrayTypes" in ASTContext to "ComplexArrayTypes".
Added skeleton code for serialization of ASTContext. llvm-svn: 43558
This commit is contained in:
parent
ac0216385f
commit
fc581a9a89
|
@ -17,6 +17,8 @@
|
||||||
#include "clang/Basic/TargetInfo.h"
|
#include "clang/Basic/TargetInfo.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/Bitcode/Serialize.h"
|
||||||
|
#include "llvm/Bitcode/Deserialize.h"
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
|
@ -428,7 +430,8 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
|
||||||
ConstantArrayType::Profile(ID, EltTy, ArySize);
|
ConstantArrayType::Profile(ID, EltTy, ArySize);
|
||||||
|
|
||||||
void *InsertPos = 0;
|
void *InsertPos = 0;
|
||||||
if (ConstantArrayType *ATP = ArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
|
if (ConstantArrayType *ATP =
|
||||||
|
ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
|
||||||
return QualType(ATP, 0);
|
return QualType(ATP, 0);
|
||||||
|
|
||||||
// If the element type isn't canonical, this won't be a canonical type either,
|
// 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,
|
Canonical = getConstantArrayType(EltTy.getCanonicalType(), ArySize,
|
||||||
ASM, EltTypeQuals);
|
ASM, EltTypeQuals);
|
||||||
// Get the new insert position for the node we care about.
|
// 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!");
|
assert(NewIP == 0 && "Shouldn't be in the map!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantArrayType *New = new ConstantArrayType(EltTy, Canonical, ArySize,
|
ConstantArrayType *New = new ConstantArrayType(EltTy, Canonical, ArySize,
|
||||||
ASM, EltTypeQuals);
|
ASM, EltTypeQuals);
|
||||||
ArrayTypes.InsertNode(New, InsertPos);
|
ConstantArrayTypes.InsertNode(New, InsertPos);
|
||||||
Types.push_back(New);
|
Types.push_back(New);
|
||||||
return QualType(New, 0);
|
return QualType(New, 0);
|
||||||
}
|
}
|
||||||
|
@ -1279,3 +1284,43 @@ bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
|
||||||
}
|
}
|
||||||
return true; // should never get here...
|
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/DenseMap.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/FoldingSet.h"
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
|
#include "llvm/Bitcode/SerializationFwd.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
@ -34,7 +35,7 @@ class ASTContext {
|
||||||
llvm::FoldingSet<ComplexType> ComplexTypes;
|
llvm::FoldingSet<ComplexType> ComplexTypes;
|
||||||
llvm::FoldingSet<PointerType> PointerTypes;
|
llvm::FoldingSet<PointerType> PointerTypes;
|
||||||
llvm::FoldingSet<ReferenceType> ReferenceTypes;
|
llvm::FoldingSet<ReferenceType> ReferenceTypes;
|
||||||
llvm::FoldingSet<ConstantArrayType> ArrayTypes;
|
llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
|
||||||
llvm::FoldingSet<VariableArrayType> IncompleteVariableArrayTypes;
|
llvm::FoldingSet<VariableArrayType> IncompleteVariableArrayTypes;
|
||||||
std::vector<VariableArrayType*> CompleteVariableArrayTypes;
|
std::vector<VariableArrayType*> CompleteVariableArrayTypes;
|
||||||
llvm::FoldingSet<VectorType> VectorTypes;
|
llvm::FoldingSet<VectorType> VectorTypes;
|
||||||
|
@ -286,6 +287,13 @@ private:
|
||||||
|
|
||||||
void InitBuiltinTypes();
|
void InitBuiltinTypes();
|
||||||
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
|
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Serialization
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
void Emit(llvm::Serializer& S) const;
|
||||||
|
static ASTContext* Materialize(llvm::Deserializer& D);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace clang
|
} // end namespace clang
|
||||||
|
|
Loading…
Reference in New Issue