blob: a0e2ecd8aa1bb91e3c682c4dcde4c1321f65d926 [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 Kyrtzidiseb3f04e2010-08-20 16:04:20 +000023TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
24
25template <typename IdxForTypeTy>
26TypeID MakeTypeID(QualType T, IdxForTypeTy IdxForType) {
27 if (T.isNull())
28 return PREDEF_TYPE_NULL_ID;
29
30 unsigned FastQuals = T.getLocalFastQualifiers();
31 T.removeFastQualifiers();
32
33 if (T.hasLocalNonFastQualifiers())
34 return IdxForType(T).asTypeID(FastQuals);
35
36 assert(!T.hasLocalQualifiers());
37
38 if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
39 return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
40
41 return IdxForType(T).asTypeID(FastQuals);
42}
43
Argyrios Kyrtzidis0eca89e2010-08-20 16:03:52 +000044unsigned ComputeHash(Selector Sel);
45
46} // namespace serialization
47
48} // namespace clang
49
50#endif