]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / clang / lib / Serialization / ASTCommon.h
1 //===- 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
17 #include "clang/AST/ASTContext.h"
18 #include "clang/Serialization/ASTBitCodes.h"
19
20 namespace clang {
21
22 namespace serialization {
23
24 enum DeclUpdateKind {
25   UPD_CXX_ADDED_IMPLICIT_MEMBER,
26   UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION,
27   UPD_CXX_ADDED_ANONYMOUS_NAMESPACE,
28   UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER,
29   UPD_CXX_DEDUCED_RETURN_TYPE,
30   UPD_DECL_MARKED_USED
31 };
32
33 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
34
35 template <typename IdxForTypeTy>
36 TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
37   if (T.isNull())
38     return PREDEF_TYPE_NULL_ID;
39
40   unsigned FastQuals = T.getLocalFastQualifiers();
41   T.removeLocalFastQualifiers();
42
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
51   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   if (T == Context.VaListTagTy)
56     return TypeIdx(PREDEF_TYPE_VA_LIST_TAG).asTypeID(FastQuals);
57
58   return IdxForType(T).asTypeID(FastQuals);
59 }
60
61 unsigned ComputeHash(Selector Sel);
62
63 /// \brief Retrieve the "definitive" declaration that provides all of the
64 /// visible entries for the given declaration context, if there is one.
65 ///
66 /// The "definitive" declaration is the only place where we need to look to
67 /// find information about the declarations within the given declaration
68 /// context. For example, C++ and Objective-C classes, C structs/unions, and
69 /// Objective-C protocols, categories, and extensions are all defined in a
70 /// single place in the source code, so they have definitive declarations
71 /// associated with them. C++ namespaces, on the other hand, can have
72 /// multiple definitions.
73 const DeclContext *getDefinitiveDeclContext(const DeclContext *DC);
74
75 /// \brief Determine whether the given declaration kind is redeclarable.
76 bool isRedeclarableDeclKind(unsigned Kind);
77
78 } // namespace serialization
79
80 } // namespace clang
81
82 #endif