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