1 //===- ASTCommon.h - Common stuff for ASTReader/ASTWriter -*- C++ -*-=========//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines common functions that both ASTReader and ASTWriter use.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
15 #define LLVM_CLANG_SERIALIZATION_LIB_AST_COMMON_H
17 #include "clang/AST/ASTContext.h"
18 #include "clang/Serialization/ASTBitCodes.h"
22 namespace serialization {
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
31 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
33 template <typename IdxForTypeTy>
34 TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
36 return PREDEF_TYPE_NULL_ID;
38 unsigned FastQuals = T.getLocalFastQualifiers();
39 T.removeLocalFastQualifiers();
41 if (T.hasLocalNonFastQualifiers())
42 return IdxForType(T).asTypeID(FastQuals);
44 assert(!T.hasLocalQualifiers());
46 if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
47 return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
49 if (T == Context.AutoDeductTy)
50 return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
51 if (T == Context.AutoRRefDeductTy)
52 return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
53 if (T == Context.VaListTagTy)
54 return TypeIdx(PREDEF_TYPE_VA_LIST_TAG).asTypeID(FastQuals);
56 return IdxForType(T).asTypeID(FastQuals);
59 unsigned ComputeHash(Selector Sel);
61 /// \brief Retrieve the "definitive" declaration that provides all of the
62 /// visible entries for the given declaration context, if there is one.
64 /// The "definitive" declaration is the only place where we need to look to
65 /// find information about the declarations within the given declaration
66 /// context. For example, C++ and Objective-C classes, C structs/unions, and
67 /// Objective-C protocols, categories, and extensions are all defined in a
68 /// single place in the source code, so they have definitive declarations
69 /// associated with them. C++ namespaces, on the other hand, can have
70 /// multiple definitions.
71 const DeclContext *getDefinitiveDeclContext(const DeclContext *DC);
73 /// \brief Determine whether the given declaration kind is redeclarable.
74 bool isRedeclarableDeclKind(unsigned Kind);
76 } // namespace serialization