[cfe-commits] r43558 - in /cfe/trunk: AST/ASTContext.cpp include/clang/AST/ASTContext.h
Ted Kremenek
kremenek at apple.com
Wed Oct 31 10:10:14 PDT 2007
Author: kremenek
Date: Wed Oct 31 12:10:13 2007
New Revision: 43558
URL: http://llvm.org/viewvc/llvm-project?rev=43558&view=rev
Log:
Renamed ivar "ArrayTypes" in ASTContext to "ComplexArrayTypes".
Added skeleton code for serialization of ASTContext.
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/include/clang/AST/ASTContext.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=43558&r1=43557&r2=43558&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Wed Oct 31 12:10:13 2007
@@ -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 @@
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 @@
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 @@
}
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.
+
+}
+
+
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=43558&r1=43557&r2=43558&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Oct 31 12:10:13 2007
@@ -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 @@
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 @@
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
More information about the cfe-commits
mailing list