blob: 36958c75009826b2b088996210e27f9b5aee27ad [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"
18
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000019namespace clang {
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000020
21namespace serialization {
22
Argyrios Kyrtzidis565bf302010-10-24 17:26:50 +000023enum DeclUpdateKind {
24 UPD_CXX_SET_DEFINITIONDATA
25};
26
Argyrios Kyrtzidiseb3f04e2010-08-20 16:04:20 +000027TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
28
29template <typename IdxForTypeTy>
30TypeID MakeTypeID(QualType T, IdxForTypeTy IdxForType) {
31 if (T.isNull())
32 return PREDEF_TYPE_NULL_ID;
33
34 unsigned FastQuals = T.getLocalFastQualifiers();
35 T.removeFastQualifiers();
36
37 if (T.hasLocalNonFastQualifiers())
38 return IdxForType(T).asTypeID(FastQuals);
39
40 assert(!T.hasLocalQualifiers());
41
42 if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
43 return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
44
45 return IdxForType(T).asTypeID(FastQuals);
46}
47
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000048unsigned ComputeHash(Selector Sel);
49
50} // namespace serialization
51
52} // namespace clang
53
54#endif