blob: 2e3d70b853d27c529cf58ce8a85b3fa1d5b2838a [file] [log] [blame]
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +00001//===- ASTCommon.h - Common stuff for ASTReader/ASTWriter -*- C++ -*-=========//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines common functions that both ASTReader and ASTWriter use.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
15#define LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
16
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000017#include "clang/Serialization/ASTBitCodes.h"
Douglas Gregor3b8043b2011-08-09 15:13:55 +000018#include "clang/AST/ASTContext.h"
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000019
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000020namespace clang {
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000021
22namespace serialization {
23
Argyrios Kyrtzidis565bf302010-10-24 17:26:50 +000024enum DeclUpdateKind {
Argyrios Kyrtzidisb6cc0e12010-10-24 17:26:54 +000025 UPD_CXX_SET_DEFINITIONDATA,
Argyrios Kyrtzidisbef1a7b2010-10-28 07:38:42 +000026 UPD_CXX_ADDED_IMPLICIT_MEMBER,
Sebastian Redl7c0837f2011-04-24 16:28:13 +000027 UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION,
Sebastian Redlf79a7192011-04-29 08:19:30 +000028 UPD_CXX_ADDED_ANONYMOUS_NAMESPACE,
Douglas Gregor53df7a12011-12-15 18:03:09 +000029 UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER,
30 UPD_OBJC_SET_CLASS_DEFINITIONDATA
Argyrios Kyrtzidis565bf302010-10-24 17:26:50 +000031};
32
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000033TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
34
35template <typename IdxForTypeTy>
Douglas Gregor3b8043b2011-08-09 15:13:55 +000036TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000037 if (T.isNull())
38 return PREDEF_TYPE_NULL_ID;
39
40 unsigned FastQuals = T.getLocalFastQualifiers();
John McCall49f4e1c2010-12-10 11:01:00 +000041 T.removeLocalFastQualifiers();
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000042
43 if (T.hasLocalNonFastQualifiers())
44 return IdxForType(T).asTypeID(FastQuals);
45
46 assert(!T.hasLocalQualifiers());
47
48 if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
49 return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
50
Douglas Gregor3b8043b2011-08-09 15:13:55 +000051 if (T == Context.AutoDeductTy)
52 return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
53 if (T == Context.AutoRRefDeductTy)
54 return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
55
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000056 return IdxForType(T).asTypeID(FastQuals);
57}
58
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000059unsigned ComputeHash(Selector Sel);
60
61} // namespace serialization
62
63} // namespace clang
64
65#endif