]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Serialization/ASTCommon.h
Install the liblzma pkg-config file
[FreeBSD/FreeBSD.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_INSTANTIATED_FUNCTION_DEFINITION,
30   UPD_CXX_INSTANTIATED_CLASS_DEFINITION,
31   UPD_CXX_RESOLVED_EXCEPTION_SPEC,
32   UPD_CXX_DEDUCED_RETURN_TYPE,
33   UPD_DECL_MARKED_USED,
34   UPD_MANGLING_NUMBER,
35   UPD_STATIC_LOCAL_NUMBER
36 };
37
38 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
39
40 template <typename IdxForTypeTy>
41 TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
42   if (T.isNull())
43     return PREDEF_TYPE_NULL_ID;
44
45   unsigned FastQuals = T.getLocalFastQualifiers();
46   T.removeLocalFastQualifiers();
47
48   if (T.hasLocalNonFastQualifiers())
49     return IdxForType(T).asTypeID(FastQuals);
50
51   assert(!T.hasLocalQualifiers());
52
53   if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
54     return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
55
56   if (T == Context.AutoDeductTy)
57     return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
58   if (T == Context.AutoRRefDeductTy)
59     return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
60   if (T == Context.VaListTagTy)
61     return TypeIdx(PREDEF_TYPE_VA_LIST_TAG).asTypeID(FastQuals);
62
63   return IdxForType(T).asTypeID(FastQuals);
64 }
65
66 unsigned ComputeHash(Selector Sel);
67
68 /// \brief Retrieve the "definitive" declaration that provides all of the
69 /// visible entries for the given declaration context, if there is one.
70 ///
71 /// The "definitive" declaration is the only place where we need to look to
72 /// find information about the declarations within the given declaration
73 /// context. For example, C++ and Objective-C classes, C structs/unions, and
74 /// Objective-C protocols, categories, and extensions are all defined in a
75 /// single place in the source code, so they have definitive declarations
76 /// associated with them. C++ namespaces, on the other hand, can have
77 /// multiple definitions.
78 const DeclContext *getDefinitiveDeclContext(const DeclContext *DC);
79
80 /// \brief Determine whether the given declaration kind is redeclarable.
81 bool isRedeclarableDeclKind(unsigned Kind);
82
83 } // namespace serialization
84
85 } // namespace clang
86
87 #endif