clang API Documentation

Defines | Enumerations | Functions
ASTContext.cpp File Reference
#include "clang/AST/ASTContext.h"
#include "CXXABI.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Comment.h"
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/MangleNumberingContext.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TypeLoc.h"
#include "clang/AST/VTableBuilder.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Capacity.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
#include "clang/AST/TypeNodes.def"
#include "clang/AST/BuiltinTypes.def"
Include dependency graph for ASTContext.cpp:

Go to the source code of this file.

Defines

#define TYPE(Name, Parent)   0,
#define ABSTRACT_TYPE(Name, Parent)
#define TYPE(Name, Parent)
#define ABSTRACT_TYPE(Name, Parent)
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)
#define DEPENDENT_TYPE(Class, Base)   case Type::Class:
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_TYPE(Class, Base)   case Type::Class:
#define BUILTIN_TYPE(KIND, ID)
#define PLACEHOLDER_TYPE(KIND, ID)   case BuiltinType::KIND:
#define ABSTRACT_TYPE(KIND, BASE)
#define TYPE(KIND, BASE)
#define DEPENDENT_TYPE(KIND, BASE)   case Type::KIND:
#define NON_CANONICAL_TYPE(KIND, BASE)   case Type::KIND:
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(KIND, BASE)   case Type::KIND:
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)   case Type::Class:
#define NON_CANONICAL_TYPE(Class, Base)   case Type::Class:
#define DEPENDENT_TYPE(Class, Base)   case Type::Class:

Enumerations

enum  FloatingRank { HalfRank, FloatRank, DoubleRank, LongDoubleRank }

Functions

static void addRedeclaredMethods (const ObjCMethodDecl *ObjCMethod, SmallVectorImpl< const NamedDecl * > &Redeclared)
static const LangAS::Map * getAddressSpaceMap (const TargetInfo &T, const LangOptions &LOpts)
static bool isAddrSpaceMapManglingEnabled (const TargetInfo &TI, const LangOptions &LangOpts)
static std::pair< CharUnits,
CharUnits
getConstantArrayInfoInChars (const ASTContext &Context, const ConstantArrayType *CAT)
static QualType getFunctionTypeWithExceptionSpec (ASTContext &Context, QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI)
static bool isCanonicalResultType (QualType T)
 Determine whether T is canonical as the result type of a function.
static bool NeedsInjectedClassNameType (const RecordDecl *D)
static bool hasAnyPackExpansions (const TemplateArgument *Args, unsigned NumArgs)
static bool CmpProtocolNames (const ObjCProtocolDecl *LHS, const ObjCProtocolDecl *RHS)
static bool areSortedAndUniqued (ObjCProtocolDecl *const *Protocols, unsigned NumProtocols)
static void SortAndUniqueProtocols (ObjCProtocolDecl **Protocols, unsigned &NumProtocols)
static FloatingRank getFloatingRank (QualType T)
static const TypegetIntegerTypeForEnum (const EnumType *ET)
static bool isTypeTypedefedAsBOOL (QualType T)
static std::string charUnitsToString (const CharUnits &CU)
static char getObjCEncodingForPrimitiveKind (const ASTContext *C, BuiltinType::Kind kind)
static char ObjCEncodingForEnumType (const ASTContext *C, const EnumType *ET)
static void EncodeBitField (const ASTContext *Ctx, std::string &S, QualType T, const FieldDecl *FD)
static TypedefDeclCreateCharPtrBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateVoidPtrBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateAArch64ABIBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreatePowerABIBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateX86_64ABIBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreatePNaClABIBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateAAPCSABIBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateSystemZBuiltinVaListDecl (const ASTContext *Context)
static TypedefDeclCreateVaListDecl (const ASTContext *Context, TargetInfo::BuiltinVaListKind Kind)
static bool areCompatVectorTypes (const VectorType *LHS, const VectorType *RHS)
static void getIntersectionOfProtocols (ASTContext &Context, const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT, SmallVectorImpl< ObjCProtocolDecl * > &IntersectionOfProtocols)
static QualType mergeEnumWithInteger (ASTContext &Context, const EnumType *ET, QualType other, bool isBlockReturnType)
 Given that we have an enum type and a non-enum type, try to merge them.
static QualType DecodeTypeFromStr (const char *&Str, const ASTContext &Context, ASTContext::GetBuiltinTypeError &Error, bool &RequiresICE, bool AllowTypeModifiers)
static GVALinkage basicGVALinkageForFunction (const ASTContext &Context, const FunctionDecl *FD)
static GVALinkage adjustGVALinkageForDLLAttribute (GVALinkage L, const Decl *D)
static GVALinkage basicGVALinkageForVariable (const ASTContext &Context, const VarDecl *VD)

Define Documentation

#define ABSTRACT_TYPE (   Name,
  Parent 
)
#define ABSTRACT_TYPE (   Name,
  Parent 
)
#define ABSTRACT_TYPE (   Class,
  Base 
)
#define ABSTRACT_TYPE (   Class,
  Base 
)
#define ABSTRACT_TYPE (   KIND,
  BASE 
)
#define ABSTRACT_TYPE (   Class,
  Base 
)
#define BUILTIN_TYPE (   KIND,
  ID 
)
#define DEPENDENT_TYPE (   Class,
  Base 
)    case Type::Class:
#define DEPENDENT_TYPE (   KIND,
  BASE 
)    case Type::KIND:
#define DEPENDENT_TYPE (   Class,
  Base 
)    case Type::Class:
#define NON_CANONICAL_TYPE (   Class,
  Base 
)
#define NON_CANONICAL_TYPE (   Class,
  Base 
)    case Type::Class:
#define NON_CANONICAL_TYPE (   KIND,
  BASE 
)    case Type::KIND:
#define NON_CANONICAL_TYPE (   Class,
  Base 
)    case Type::Class:
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE (   Class,
  Base 
)
Value:
case Type::Class:                                                            \
  assert(!T->isDependentType() && "should not see dependent types here");      \
  return getTypeInfo(cast<Class##Type>(T)->desugar().getTypePtr());
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE (   KIND,
  BASE 
)    case Type::KIND:
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE (   Class,
  Base 
)    case Type::Class:
#define PLACEHOLDER_TYPE (   KIND,
  ID 
)    case BuiltinType::KIND:
#define TYPE (   Name,
  Parent 
)    0,
#define TYPE (   Name,
  Parent 
)
Value:
if (counts[Idx])                                                      \
    llvm::errs() << "    " << counts[Idx] << " " << #Name               \
                 << " types\n";                                         \
  TotalBytes += counts[Idx] * sizeof(Name##Type);                       \
  ++Idx;
#define TYPE (   Class,
  Base 
)
#define TYPE (   Class,
  Base 
)
#define TYPE (   KIND,
  BASE 
)
#define TYPE (   Class,
  Base 
)

Enumeration Type Documentation

Enumerator:
HalfRank 
FloatRank 
DoubleRank 
LongDoubleRank 

Definition at line 59 of file ASTContext.cpp.


Function Documentation

static void addRedeclaredMethods ( const ObjCMethodDecl ObjCMethod,
SmallVectorImpl< const NamedDecl * > &  Redeclared 
) [static]
static GVALinkage adjustGVALinkageForDLLAttribute ( GVALinkage  L,
const Decl D 
) [static]
static bool areCompatVectorTypes ( const VectorType LHS,
const VectorType RHS 
) [static]

areCompatVectorTypes - Return true if the two specified vector types are compatible.

Definition at line 6450 of file ASTContext.cpp.

References clang::VectorType::getElementType(), clang::VectorType::getNumElements(), and clang::Type::isCanonicalUnqualified().

Referenced by clang::ASTContext::mergeTypes().

static bool areSortedAndUniqued ( ObjCProtocolDecl *const *  Protocols,
unsigned  NumProtocols 
) [static]

Definition at line 3506 of file ASTContext.cpp.

References CmpProtocolNames().

Referenced by clang::ASTContext::getObjCObjectType().

static GVALinkage basicGVALinkageForFunction ( const ASTContext Context,
const FunctionDecl FD 
) [static]
static GVALinkage basicGVALinkageForVariable ( const ASTContext Context,
const VarDecl VD 
) [static]
static std::string charUnitsToString ( const CharUnits CU) [inline, static]
static bool CmpProtocolNames ( const ObjCProtocolDecl LHS,
const ObjCProtocolDecl RHS 
) [static]

CmpProtocolNames - Comparison predicate for sorting protocols alphabetically.

Definition at line 3501 of file ASTContext.cpp.

References clang::NamedDecl::getDeclName().

Referenced by areSortedAndUniqued(), and SortAndUniqueProtocols().

static TypedefDecl* CreateAAPCSABIBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreateAArch64ABIBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreateCharPtrBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreatePNaClABIBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreatePowerABIBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreateSystemZBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreateVaListDecl ( const ASTContext Context,
TargetInfo::BuiltinVaListKind  Kind 
) [static]
static TypedefDecl* CreateVoidPtrBuiltinVaListDecl ( const ASTContext Context) [static]
static TypedefDecl* CreateX86_64ABIBuiltinVaListDecl ( const ASTContext Context) [static]
static QualType DecodeTypeFromStr ( const char *&  Str,
const ASTContext Context,
ASTContext::GetBuiltinTypeError Error,
bool RequiresICE,
bool  AllowTypeModifiers 
) [static]

DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the pointer over the consumed characters. This returns the resultant type. If AllowTypeModifiers is false then modifier like * are not parsed, just basic types. This allows "v2i*" to be parsed as a pointer to a v2i instead of a vector of "i*".

RequiresICE is filled in on return to indicate whether the value is required to be an Integer Constant Expression.

Definition at line 7521 of file ASTContext.cpp.

References clang::ASTContext::BoolTy, clang::ASTContext::CharTy, clang::ASTContext::DoubleTy, clang::ASTContext::FloatTy, clang::ASTContext::GE_Missing_setjmp, clang::ASTContext::GE_Missing_stdio, clang::ASTContext::GE_Missing_ucontext, clang::VectorType::GenericVector, clang::ASTContext::getAddrSpaceQualType(), clang::ASTContext::getArrayDecayedType(), clang::ASTContext::getBuiltinVaListType(), clang::ASTContext::getCFConstantStringType(), clang::ASTContext::getComplexType(), clang::ASTContext::getExtVectorType(), clang::ASTContext::getFILEType(), clang::TargetInfo::getInt64Type(), clang::ASTContext::getjmp_bufType(), clang::ASTContext::getLValueReferenceType(), clang::ASTContext::getObjCIdType(), clang::ASTContext::getObjCSelType(), clang::ASTContext::getObjCSuperType(), clang::ASTContext::getPointerDiffType(), clang::ASTContext::getPointerType(), clang::ASTContext::getProcessIDType(), clang::ASTContext::getsigjmp_bufType(), clang::ASTContext::getSizeType(), clang::ASTContext::getTargetInfo(), clang::ASTContext::getucontext_tType(), clang::ASTContext::getVectorType(), clang::ASTContext::getVolatileType(), clang::ASTContext::HalfTy, clang::ASTContext::Int128Ty, clang::ASTContext::IntTy, clang::Type::isArrayType(), clang::Type::isIntegralOrEnumerationType(), clang::QualType::isNull(), clang::ASTContext::LongDoubleTy, clang::ASTContext::LongLongTy, clang::ASTContext::LongTy, clang::ASTContext::ShortTy, clang::ASTContext::SignedCharTy, clang::TargetInfo::SignedLong, clang::TargetInfo::SignedLongLong, clang::ASTContext::UnsignedCharTy, clang::ASTContext::UnsignedInt128Ty, clang::ASTContext::UnsignedIntTy, clang::ASTContext::UnsignedLongLongTy, clang::ASTContext::UnsignedLongTy, clang::ASTContext::UnsignedShortTy, clang::ASTContext::VoidTy, clang::QualType::withConst(), and clang::QualType::withRestrict().

Referenced by clang::ASTContext::GetBuiltinType().

static void EncodeBitField ( const ASTContext Ctx,
std::string &  S,
QualType  T,
const FieldDecl FD 
) [static]
static const LangAS::Map* getAddressSpaceMap ( const TargetInfo T,
const LangOptions LOpts 
) [static]
static std::pair<CharUnits, CharUnits> getConstantArrayInfoInChars ( const ASTContext Context,
const ConstantArrayType CAT 
) [static]

getConstantArrayInfoInChars - Performing the computation in CharUnits instead of in bits prevents overflowing the uint64_t for some large arrays.

Definition at line 1388 of file ASTContext.cpp.

References clang::CharUnits::fromQuantity(), clang::TargetInfo::getCXXABI(), clang::ArrayType::getElementType(), clang::TargetInfo::getPointerWidth(), clang::ConstantArrayType::getSize(), clang::ASTContext::getTargetInfo(), clang::ASTContext::getTypeInfoInChars(), and clang::TargetCXXABI::isMicrosoft().

Referenced by clang::ASTContext::getTypeInfoInChars().

static FloatingRank getFloatingRank ( QualType  T) [static]

getFloatingRank - Return a relative rank for floating point types. This routine will assert if passed a built-in type that isn't a float.

Definition at line 4378 of file ASTContext.cpp.

References DoubleRank, FloatRank, clang::Type::getAs(), clang::BuiltinType::getKind(), HalfRank, and LongDoubleRank.

Referenced by clang::ASTContext::getFloatingTypeOfSizeWithinDomain(), and clang::ASTContext::getFloatingTypeOrder().

static QualType getFunctionTypeWithExceptionSpec ( ASTContext Context,
QualType  Orig,
const FunctionProtoType::ExceptionSpecInfo ESI 
) [static]

Get a function type and produce the equivalent function type with the specified exception specification. Type sugar that can be present on a declaration of a function with an exception specification is permitted and preserved. Other type sugar (for instance, typedefs) is not.

Definition at line 2118 of file ASTContext.cpp.

References clang::ASTContext::getAttributedType(), clang::FunctionProtoType::getExtProtoInfo(), clang::ASTContext::getFunctionType(), clang::FunctionProtoType::getParamTypes(), clang::ASTContext::getParenType(), clang::FunctionType::getReturnType(), and clang::FunctionProtoType::ExtProtoInfo::withExceptionSpec().

Referenced by clang::ASTContext::adjustExceptionSpec().

static const Type* getIntegerTypeForEnum ( const EnumType ET) [static]
static void getIntersectionOfProtocols ( ASTContext Context,
const ObjCObjectPointerType LHSOPT,
const ObjCObjectPointerType RHSOPT,
SmallVectorImpl< ObjCProtocolDecl * > &  IntersectionOfProtocols 
) [static]

getIntersectionOfProtocols - This routine finds the intersection of set of protocols inherited from two distinct objective-c pointer objects. It is used to build composite qualifier list of the composite type of the conditional expression involving two objective-c pointer objects.

Definition at line 6709 of file ASTContext.cpp.

References clang::ASTContext::CollectInheritedProtocols(), clang::ObjCObjectType::getInterface(), clang::ObjCObjectType::getNumProtocols(), clang::ObjCObjectPointerType::getObjectType(), clang::ObjCObjectType::qual_begin(), and clang::ObjCObjectType::qual_end().

Referenced by clang::ASTContext::areCommonBaseCompatible().

static char getObjCEncodingForPrimitiveKind ( const ASTContext C,
BuiltinType::Kind  kind 
) [static]
static bool hasAnyPackExpansions ( const TemplateArgument Args,
unsigned  NumArgs 
) [static]

Definition at line 3221 of file ASTContext.cpp.

Referenced by clang::ASTContext::getTemplateSpecializationType().

static bool isAddrSpaceMapManglingEnabled ( const TargetInfo TI,
const LangOptions LangOpts 
) [static]
static bool isCanonicalResultType ( QualType  T) [static]

Determine whether T is canonical as the result type of a function.

Definition at line 2876 of file ASTContext.cpp.

References clang::QualType::getObjCLifetime(), clang::QualType::isCanonical(), clang::Qualifiers::OCL_ExplicitNone, and clang::Qualifiers::OCL_None.

Referenced by clang::ASTContext::getFunctionType().

static bool isTypeTypedefedAsBOOL ( QualType  T) [static]
static QualType mergeEnumWithInteger ( ASTContext Context,
const EnumType ET,
QualType  other,
bool  isBlockReturnType 
) [static]
static bool NeedsInjectedClassNameType ( const RecordDecl D) [static]
static char ObjCEncodingForEnumType ( const ASTContext C,
const EnumType ET 
) [static]
static void SortAndUniqueProtocols ( ObjCProtocolDecl **  Protocols,
unsigned NumProtocols 
) [static]

Definition at line 3520 of file ASTContext.cpp.

References CmpProtocolNames().

Referenced by clang::ASTContext::getObjCObjectType().