clang API Documentation

ASTCommon.h
Go to the documentation of this file.
00001 //===- ASTCommon.h - Common stuff for ASTReader/ASTWriter -*- C++ -*-=========//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This file defines common functions that both ASTReader and ASTWriter use.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_LIB_SERIALIZATION_ASTCOMMON_H
00015 #define LLVM_CLANG_LIB_SERIALIZATION_ASTCOMMON_H
00016 
00017 #include "clang/AST/ASTContext.h"
00018 #include "clang/Serialization/ASTBitCodes.h"
00019 
00020 namespace clang {
00021 
00022 namespace serialization {
00023 
00024 enum DeclUpdateKind {
00025   UPD_CXX_ADDED_IMPLICIT_MEMBER,
00026   UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION,
00027   UPD_CXX_ADDED_ANONYMOUS_NAMESPACE,
00028   UPD_CXX_ADDED_FUNCTION_DEFINITION,
00029   UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER,
00030   UPD_CXX_INSTANTIATED_CLASS_DEFINITION,
00031   UPD_CXX_RESOLVED_EXCEPTION_SPEC,
00032   UPD_CXX_DEDUCED_RETURN_TYPE,
00033   UPD_DECL_MARKED_USED,
00034   UPD_MANGLING_NUMBER,
00035   UPD_STATIC_LOCAL_NUMBER,
00036   UPD_DECL_MARKED_OPENMP_THREADPRIVATE
00037 };
00038 
00039 TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);
00040 
00041 template <typename IdxForTypeTy>
00042 TypeID MakeTypeID(ASTContext &Context, QualType T, IdxForTypeTy IdxForType) {
00043   if (T.isNull())
00044     return PREDEF_TYPE_NULL_ID;
00045 
00046   unsigned FastQuals = T.getLocalFastQualifiers();
00047   T.removeLocalFastQualifiers();
00048 
00049   if (T.hasLocalNonFastQualifiers())
00050     return IdxForType(T).asTypeID(FastQuals);
00051 
00052   assert(!T.hasLocalQualifiers());
00053 
00054   if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
00055     return TypeIdxFromBuiltin(BT).asTypeID(FastQuals);
00056 
00057   if (T == Context.AutoDeductTy)
00058     return TypeIdx(PREDEF_TYPE_AUTO_DEDUCT).asTypeID(FastQuals);
00059   if (T == Context.AutoRRefDeductTy)
00060     return TypeIdx(PREDEF_TYPE_AUTO_RREF_DEDUCT).asTypeID(FastQuals);
00061   if (T == Context.VaListTagTy)
00062     return TypeIdx(PREDEF_TYPE_VA_LIST_TAG).asTypeID(FastQuals);
00063 
00064   return IdxForType(T).asTypeID(FastQuals);
00065 }
00066 
00067 unsigned ComputeHash(Selector Sel);
00068 
00069 /// \brief Retrieve the "definitive" declaration that provides all of the
00070 /// visible entries for the given declaration context, if there is one.
00071 ///
00072 /// The "definitive" declaration is the only place where we need to look to
00073 /// find information about the declarations within the given declaration
00074 /// context. For example, C++ and Objective-C classes, C structs/unions, and
00075 /// Objective-C protocols, categories, and extensions are all defined in a
00076 /// single place in the source code, so they have definitive declarations
00077 /// associated with them. C++ namespaces, on the other hand, can have
00078 /// multiple definitions.
00079 const DeclContext *getDefinitiveDeclContext(const DeclContext *DC);
00080 
00081 /// \brief Determine whether the given declaration kind is redeclarable.
00082 bool isRedeclarableDeclKind(unsigned Kind);
00083 
00084 /// \brief Determine whether the given declaration needs an anonymous
00085 /// declaration number.
00086 bool needsAnonymousDeclarationNumber(const NamedDecl *D);
00087 
00088 } // namespace serialization
00089 
00090 } // namespace clang
00091 
00092 #endif