本文整理汇总了C++中Qualifiers类的典型用法代码示例。如果您正苦于以下问题:C++ Qualifiers类的具体用法?C++ Qualifiers怎么用?C++ Qualifiers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Qualifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Print
void TypePrinter::Print(QualType T, std::string &S) {
if (T.isNull()) {
S += "NULL TYPE";
return;
}
if (Policy.SuppressSpecifiers && T->isSpecifierType())
return;
// Print qualifiers as appropriate.
Qualifiers Quals = T.getLocalQualifiers();
if (!Quals.empty()) {
std::string TQS;
Quals.getAsStringInternal(TQS, Policy);
if (!S.empty()) {
TQS += ' ';
TQS += S;
}
std::swap(S, TQS);
}
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) case Type::CLASS: \
Print##CLASS(cast<CLASS##Type>(T.getTypePtr()), S); \
break;
#include "clang/AST/TypeNodes.def"
}
}
示例2: assert
LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) {
assert(hasAggregateLLVMType(E->getType()) && "Invalid argument!");
Qualifiers Q = MakeQualifiers(E->getType());
llvm::Value *Temp = CreateMemTemp(E->getType());
EmitAggExpr(E, Temp, Q.hasVolatile());
return LValue::MakeAddr(Temp, Q);
}
示例3: createImplicitParams
void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
const ObjCInterfaceDecl *OID) {
QualType selfTy;
if (isInstanceMethod()) {
// There may be no interface context due to error in declaration
// of the interface (which has been reported). Recover gracefully.
if (OID) {
selfTy = Context.getObjCInterfaceType(OID);
selfTy = Context.getObjCObjectPointerType(selfTy);
} else {
selfTy = Context.getObjCIdType();
}
} else // we have a factory method.
selfTy = Context.getObjCClassType();
bool selfIsPseudoStrong = false;
bool selfIsConsumed = false;
if (Context.getLangOpts().ObjCAutoRefCount) {
if (isInstanceMethod()) {
selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
// 'self' is always __strong. It's actually pseudo-strong except
// in init methods (or methods labeled ns_consumes_self), though.
Qualifiers qs;
qs.setObjCLifetime(Qualifiers::OCL_Strong);
selfTy = Context.getQualifiedType(selfTy, qs);
// In addition, 'self' is const unless this is an init method.
if (getMethodFamily() != OMF_init && !selfIsConsumed) {
selfTy = selfTy.withConst();
selfIsPseudoStrong = true;
}
}
else {
assert(isClassMethod());
// 'self' is always const in class methods.
selfTy = selfTy.withConst();
selfIsPseudoStrong = true;
}
}
ImplicitParamDecl *self
= ImplicitParamDecl::Create(Context, this, SourceLocation(),
&Context.Idents.get("self"), selfTy);
setSelfDecl(self);
if (selfIsConsumed)
self->addAttr(new (Context) NSConsumedAttr(SourceLocation(), Context));
if (selfIsPseudoStrong)
self->setARCPseudoStrong(true);
setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
&Context.Idents.get("_cmd"),
Context.getObjCSelType()));
}
示例4: BuildFieldReferenceExpr
static ExprResult
BuildFieldReferenceExpr(Sema &S, Expr *BaseExpr, bool IsArrow,
const CXXScopeSpec &SS, FieldDecl *Field,
DeclAccessPair FoundDecl,
const DeclarationNameInfo &MemberNameInfo) {
// x.a is an l-value if 'a' has a reference type. Otherwise:
// x.a is an l-value/x-value/pr-value if the base is (and note
// that *x is always an l-value), except that if the base isn't
// an ordinary object then we must have an rvalue.
ExprValueKind VK = VK_LValue;
ExprObjectKind OK = OK_Ordinary;
if (!IsArrow) {
if (BaseExpr->getObjectKind() == OK_Ordinary)
VK = BaseExpr->getValueKind();
else
VK = VK_RValue;
}
if (VK != VK_RValue && Field->isBitField())
OK = OK_BitField;
// Figure out the type of the member; see C99 6.5.2.3p3, C++ [expr.ref]
QualType MemberType = Field->getType();
if (const ReferenceType *Ref = MemberType->getAs<ReferenceType>()) {
MemberType = Ref->getPointeeType();
VK = VK_LValue;
} else {
QualType BaseType = BaseExpr->getType();
if (IsArrow) BaseType = BaseType->getAs<PointerType>()->getPointeeType();
Qualifiers BaseQuals = BaseType.getQualifiers();
// CVR attributes from the base are picked up by members,
// except that 'mutable' members don't pick up 'const'.
if (Field->isMutable()) BaseQuals.removeConst();
Qualifiers MemberQuals
= S.Context.getCanonicalType(MemberType).getQualifiers();
assert(!MemberQuals.hasAddressSpace());
Qualifiers Combined = BaseQuals + MemberQuals;
if (Combined != MemberQuals)
MemberType = S.Context.getQualifiedType(MemberType, Combined);
}
S.UnusedPrivateFields.remove(Field);
ExprResult Base =
S.PerformObjectMemberConversion(BaseExpr, SS.getScopeRep(),
FoundDecl, Field);
if (Base.isInvalid())
return ExprError();
return S.Owned(BuildMemberExpr(S, S.Context, Base.take(), IsArrow,
Field, FoundDecl, MemberNameInfo,
MemberType, VK, OK));
}
示例5: ComputeQualifierFlags
/// ComputeQualifierFlags - Compute the pointer type info flags from the
/// given qualifier.
static unsigned ComputeQualifierFlags(Qualifiers Quals) {
unsigned Flags = 0;
if (Quals.hasConst())
Flags |= RTTIBuilder::PTI_Const;
if (Quals.hasVolatile())
Flags |= RTTIBuilder::PTI_Volatile;
if (Quals.hasRestrict())
Flags |= RTTIBuilder::PTI_Restrict;
return Flags;
}
示例6: EmitUPCPointerGetPhase
llvm::Value *CodeGenFunction::EmitUPCPointerDiff(
llvm::Value *Pointer1, llvm::Value *Pointer2, const Expr *E) {
const BinaryOperator *expr = cast<BinaryOperator>(E);
Expr *LHSOperand = expr->getLHS();
QualType PtrTy = LHSOperand->getType();
llvm::Value *Phase1 = EmitUPCPointerGetPhase(Pointer1);
llvm::Value *Thread1 = EmitUPCPointerGetThread(Pointer1);
llvm::Value *Addr1 = EmitUPCPointerGetAddr(Pointer1);
llvm::Value *Phase2 = EmitUPCPointerGetPhase(Pointer2);
llvm::Value *Thread2 = EmitUPCPointerGetThread(Pointer2);
llvm::Value *Addr2 = EmitUPCPointerGetAddr(Pointer2);
QualType PointeeTy = PtrTy->getAs<PointerType>()->getPointeeType();
QualType ElemTy;
llvm::Value *Dim;
llvm::tie(ElemTy, Dim) = unwrapArray(*this, PointeeTy);
Qualifiers Quals = ElemTy.getQualifiers();
llvm::Constant *ElemSize =
llvm::ConstantInt::get(SizeTy, getContext().getTypeSizeInChars(ElemTy).getQuantity());
llvm::Value *AddrByteDiff = Builder.CreateSub(Addr1, Addr2, "addr.diff");
llvm::Value *AddrDiff = Builder.CreateExactSDiv(AddrByteDiff, ElemSize);
llvm::Value *Result;
if (Quals.getLayoutQualifier() == 0) {
Result = AddrDiff;
} else {
llvm::Constant *B = llvm::ConstantInt::get(SizeTy, Quals.getLayoutQualifier());
llvm::Value *Threads = Builder.CreateZExt(EmitUPCThreads(), SizeTy);
llvm::Value *ThreadDiff = Builder.CreateMul(Builder.CreateSub(Thread1, Thread2, "thread.diff"), B);
llvm::Value *PhaseDiff = Builder.CreateSub(Phase1, Phase2, "phase.diff");
llvm::Value *BlockDiff =
Builder.CreateMul(Builder.CreateSub(AddrDiff, PhaseDiff), Threads, "block.diff");
Result = Builder.CreateAdd(BlockDiff, Builder.CreateAdd(ThreadDiff, PhaseDiff), "ptr.diff");
}
if (Dim) {
Result = Builder.CreateExactSDiv(Result, Dim, "diff.dim");
}
// FIXME: Divide by the array dimension
return Result;
}
示例7: TypeInfoIsInStandardLibrary
static bool TypeInfoIsInStandardLibrary(const PointerType *PointerTy) {
QualType PointeeTy = PointerTy->getPointeeType();
const BuiltinType *BuiltinTy = dyn_cast<BuiltinType>(PointeeTy);
if (!BuiltinTy)
return false;
// Check the qualifiers.
Qualifiers Quals = PointeeTy.getQualifiers();
Quals.removeConst();
if (!Quals.empty())
return false;
return TypeInfoIsInStandardLibrary(BuiltinTy);
}
示例8: rewriteToObjCProperty
static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
const ObjCMethodDecl *Setter,
const NSAPI &NS, edit::Commit &commit) {
ASTContext &Context = NS.getASTContext();
std::string PropertyString = "@property";
const ParmVarDecl *argDecl = *Setter->param_begin();
QualType ArgType = Context.getCanonicalType(argDecl->getType());
Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
if (ArgType->isObjCRetainableType() &&
propertyLifetime == Qualifiers::OCL_Strong) {
if (const ObjCObjectPointerType *ObjPtrTy =
ArgType->getAs<ObjCObjectPointerType>()) {
ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
if (IDecl &&
IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
PropertyString += "(copy)";
}
}
else if (propertyLifetime == Qualifiers::OCL_Weak)
// TODO. More precise determination of 'weak' attribute requires
// looking into setter's implementation for backing weak ivar.
PropertyString += "(weak)";
else
PropertyString += "(unsafe_unretained)";
// strip off any ARC lifetime qualifier.
QualType CanResultTy = Context.getCanonicalType(Getter->getResultType());
if (CanResultTy.getQualifiers().hasObjCLifetime()) {
Qualifiers Qs = CanResultTy.getQualifiers();
Qs.removeObjCLifetime();
CanResultTy = Context.getQualifiedType(CanResultTy.getUnqualifiedType(), Qs);
}
PropertyString += " ";
PropertyString += CanResultTy.getAsString(Context.getPrintingPolicy());
PropertyString += " ";
PropertyString += Getter->getNameAsString();
commit.replace(CharSourceRange::getCharRange(Getter->getLocStart(),
Getter->getDeclaratorEndLoc()),
PropertyString);
SourceLocation EndLoc = Setter->getDeclaratorEndLoc();
// Get location past ';'
EndLoc = EndLoc.getLocWithOffset(1);
commit.remove(CharSourceRange::getCharRange(Setter->getLocStart(), EndLoc));
return true;
}
示例9: getASTContext
void MicrosoftCXXNameMangler::mangleType(QualType T) {
// Only operate on the canonical type!
T = getASTContext().getCanonicalType(T);
Qualifiers Quals = T.getLocalQualifiers();
if (Quals) {
// We have to mangle these now, while we still have enough information.
// <pointer-cvr-qualifiers> ::= P # pointer
// ::= Q # const pointer
// ::= R # volatile pointer
// ::= S # const volatile pointer
if (T->isAnyPointerType() || T->isMemberPointerType() ||
T->isBlockPointerType()) {
if (!Quals.hasVolatile())
Out << 'Q';
else {
if (!Quals.hasConst())
Out << 'R';
else
Out << 'S';
}
} else
// Just emit qualifiers like normal.
// NB: When we mangle a pointer/reference type, and the pointee
// type has no qualifiers, the lack of qualifier gets mangled
// in there.
mangleQualifiers(Quals, false);
} else if (T->isAnyPointerType() || T->isMemberPointerType() ||
T->isBlockPointerType()) {
Out << 'P';
}
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define NON_CANONICAL_TYPE(CLASS, PARENT) \
case Type::CLASS: \
llvm_unreachable("can't mangle non-canonical type " #CLASS "Type"); \
return;
#define TYPE(CLASS, PARENT) \
case Type::CLASS: \
mangleType(static_cast<const CLASS##Type*>(T.getTypePtr())); \
break;
#include "clang/AST/TypeNodes.def"
}
}
示例10: switch
/// \brief Convert the specified DeclSpec to the appropriate type object.
QualType Sema::ActOnTypeName(ASTContext &C, DeclSpec &DS) {
QualType Result;
switch (DS.getTypeSpecType()) {
case DeclSpec::TST_integer:
Result = C.IntegerTy;
break;
case DeclSpec::TST_unspecified: // FIXME: Correct?
case DeclSpec::TST_real:
Result = C.RealTy;
break;
case DeclSpec::TST_doubleprecision:
Result = C.DoublePrecisionTy;
break;
case DeclSpec::TST_character:
Result = C.CharacterTy;
break;
case DeclSpec::TST_logical:
Result = C.LogicalTy;
break;
case DeclSpec::TST_complex:
Result = C.ComplexTy;
break;
case DeclSpec::TST_struct:
// FIXME: Finish this.
break;
}
if (!DS.hasAttributes())
return Result;
const Type *TypeNode = Result.getTypePtr();
Qualifiers Quals = Qualifiers::fromOpaqueValue(DS.getAttributeSpecs());
Quals.setIntentAttr(DS.getIntentSpec());
Quals.setAccessAttr(DS.getAccessSpec());
QualType EQs = C.getExtQualType(TypeNode, Quals, DS.getKindSelector(),
DS.getLengthSelector());
if (!Quals.hasAttributeSpec(Qualifiers::AS_dimension))
return EQs;
return ActOnArraySpec(C, EQs, DS.getDimensions());
}
示例11: EmitDeclInit
static void EmitDeclInit(CodeGenFunction &CGF, const VarDecl &D,
ConstantAddress DeclPtr) {
assert(D.hasGlobalStorage() && "VarDecl must have global storage!");
assert(!D.getType()->isReferenceType() &&
"Should not call EmitDeclInit on a reference!");
QualType type = D.getType();
// Deduce UPC strict or relaxed from context, if needed
if (CGF.getContext().getLangOpts().UPC) {
Qualifiers Quals = type.getQualifiers();
if (Quals.hasShared() && !Quals.hasStrict() && !Quals.hasRelaxed()) {
if (D.isUPCInitStrict())
Quals.addStrict();
else
Quals.addRelaxed();
type = CGF.getContext().getQualifiedType(type.getUnqualifiedType(), Quals);
}
}
LValue lv;
if(type.getQualifiers().hasShared())
lv = CGF.EmitSharedVarDeclLValue(DeclPtr, type);
else
lv = CGF.MakeAddrLValue(DeclPtr, type);
const Expr *Init = D.getInit();
switch (CGF.getEvaluationKind(type)) {
case TEK_Scalar: {
CodeGenModule &CGM = CGF.CGM;
if (lv.isObjCStrong())
CGM.getObjCRuntime().EmitObjCGlobalAssign(CGF, CGF.EmitScalarExpr(Init),
DeclPtr, D.getTLSKind());
else if (lv.isObjCWeak())
CGM.getObjCRuntime().EmitObjCWeakAssign(CGF, CGF.EmitScalarExpr(Init),
DeclPtr);
else
CGF.EmitScalarInit(Init, &D, lv, false);
return;
}
case TEK_Complex:
CGF.EmitComplexExprIntoLValue(Init, lv, /*isInit*/ true);
return;
case TEK_Aggregate:
CGF.EmitAggExpr(Init, AggValueSlot::forLValue(lv,AggValueSlot::IsDestructed,
AggValueSlot::DoesNotNeedGCBarriers,
AggValueSlot::IsNotAliased));
return;
}
llvm_unreachable("bad evaluation kind");
}
示例12: PrevPHIsEmpty
/// \brief Prints the part of the type string before an identifier, e.g. for
/// "int foo[10]" it prints "int ".
void TypePrinter::printBefore(const Type *T,Qualifiers Quals, raw_ostream &OS) {
if (Policy.SuppressSpecifiers && T->isSpecifierType())
return;
SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder);
// Print qualifiers as appropriate.
bool CanPrefixQualifiers = false;
bool NeedARCStrongQualifier = false;
CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
if (CanPrefixQualifiers && !Quals.empty()) {
if (NeedARCStrongQualifier) {
IncludeStrongLifetimeRAII Strong(Policy);
Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/true);
} else {
Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/true);
}
}
bool hasAfterQuals = false;
if (!CanPrefixQualifiers && !Quals.empty()) {
hasAfterQuals = !Quals.isEmptyWhenPrinted(Policy);
if (hasAfterQuals)
HasEmptyPlaceHolder = false;
}
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) case Type::CLASS: \
print##CLASS##Before(cast<CLASS##Type>(T), OS); \
break;
#include "clang/AST/TypeNodes.def"
}
if (hasAfterQuals) {
if (NeedARCStrongQualifier) {
IncludeStrongLifetimeRAII Strong(Policy);
Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/!PrevPHIsEmpty.get());
} else {
Quals.print(OS, Policy, /*appendSpaceIfNonEmpty=*/!PrevPHIsEmpty.get());
}
}
}
示例13: VisitType
void USRGenerator::VisitType(QualType T) {
// This method mangles in USR information for types. It can possibly
// just reuse the naming-mangling logic used by codegen, although the
// requirements for USRs might not be the same.
ASTContext &Ctx = *Context;
do {
T = Ctx.getCanonicalType(T);
Qualifiers Q = T.getQualifiers();
unsigned qVal = 0;
if (Q.hasConst())
qVal |= 0x1;
if (Q.hasVolatile())
qVal |= 0x2;
if (Q.hasRestrict())
qVal |= 0x4;
if(qVal)
Out << ((char) ('0' + qVal));
// Mangle in ObjC GC qualifiers?
if (const PackExpansionType *Expansion = T->getAs<PackExpansionType>()) {
Out << 'P';
T = Expansion->getPattern();
}
if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
unsigned char c = '\0';
switch (BT->getKind()) {
case BuiltinType::Void:
c = 'v'; break;
case BuiltinType::Bool:
c = 'b'; break;
case BuiltinType::Char_U:
case BuiltinType::UChar:
c = 'c'; break;
case BuiltinType::Char16:
c = 'q'; break;
case BuiltinType::Char32:
c = 'w'; break;
case BuiltinType::UShort:
c = 's'; break;
case BuiltinType::UInt:
c = 'i'; break;
case BuiltinType::ULong:
c = 'l'; break;
case BuiltinType::ULongLong:
c = 'k'; break;
case BuiltinType::UInt128:
c = 'j'; break;
case BuiltinType::Char_S:
case BuiltinType::SChar:
c = 'C'; break;
case BuiltinType::WChar_S:
case BuiltinType::WChar_U:
c = 'W'; break;
case BuiltinType::Short:
c = 'S'; break;
case BuiltinType::Int:
c = 'I'; break;
case BuiltinType::Long:
c = 'L'; break;
case BuiltinType::LongLong:
c = 'K'; break;
case BuiltinType::Int128:
c = 'J'; break;
case BuiltinType::Half:
c = 'h'; break;
case BuiltinType::Float:
c = 'f'; break;
case BuiltinType::Double:
c = 'd'; break;
case BuiltinType::LongDouble:
c = 'D'; break;
case BuiltinType::NullPtr:
c = 'n'; break;
#define BUILTIN_TYPE(Id, SingletonId)
#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
#include "clang/AST/BuiltinTypes.def"
case BuiltinType::Dependent:
case BuiltinType::OCLImage1d:
case BuiltinType::OCLImage1dArray:
case BuiltinType::OCLImage1dBuffer:
case BuiltinType::OCLImage2d:
case BuiltinType::OCLImage2dArray:
case BuiltinType::OCLImage3d:
case BuiltinType::OCLEvent:
case BuiltinType::OCLSampler:
IgnoreResults = true;
return;
case BuiltinType::ObjCId:
c = 'o'; break;
case BuiltinType::ObjCClass:
c = 'O'; break;
case BuiltinType::ObjCSel:
c = 'e'; break;
}
Out << c;
return;
}
//.........这里部分代码省略.........
示例14: switch
/// \brief Convert the specified DeclSpec to the appropriate type object.
QualType Sema::ActOnTypeName(ASTContext &C, DeclSpec &DS) {
QualType Result;
switch (DS.getTypeSpecType()) {
case DeclSpec::TST_integer:
Result = C.IntegerTy;
break;
case DeclSpec::TST_unspecified: // FIXME: Correct?
case DeclSpec::TST_real:
Result = C.RealTy;
break;
case DeclSpec::TST_character:
if(DS.isStarLengthSelector())
Result = C.NoLengthCharacterTy;
else if(DS.hasLengthSelector())
Result = QualType(C.getCharacterType(
EvalAndCheckCharacterLength(DS.getLengthSelector())), 0);
else Result = C.CharacterTy;
break;
case DeclSpec::TST_logical:
Result = C.LogicalTy;
break;
case DeclSpec::TST_complex:
Result = C.ComplexTy;
break;
case DeclSpec::TST_struct:
if(!DS.getRecord())
Result = C.RealTy;
else
Result = C.getRecordType(DS.getRecord());
break;
}
Type::TypeKind Kind = Type::NoKind;
if(DS.hasKindSelector())
Kind = EvalAndCheckTypeKind(Result, DS.getKindSelector());
if(Kind != Type::NoKind || DS.isDoublePrecision() || DS.isByte()) {
switch (DS.getTypeSpecType()) {
case DeclSpec::TST_integer:
Result = Kind == Type::NoKind? C.IntegerTy :
QualType(C.getBuiltinType(BuiltinType::Integer, Kind, true), 0);
break;
case DeclSpec::TST_real:
Result = Kind == Type::NoKind? (DS.isDoublePrecision()? C.DoublePrecisionTy : C.RealTy) :
QualType(C.getBuiltinType(BuiltinType::Real, Kind, true), 0);
break;
case DeclSpec::TST_logical:
Result = Kind == Type::NoKind? (DS.isByte()? C.ByteTy : C.LogicalTy) :
QualType(C.getBuiltinType(BuiltinType::Logical, Kind, true), 0);
break;
case DeclSpec::TST_complex:
Result = Kind == Type::NoKind? (DS.isDoublePrecision()? C.DoubleComplexTy : C.ComplexTy) :
QualType(C.getBuiltinType(BuiltinType::Complex, Kind, true), 0);
break;
default:
break;
}
}
if (!DS.hasAttributes())
return Result;
const Type *TypeNode = Result.getTypePtr();
Qualifiers Quals = Qualifiers::fromOpaqueValue(DS.getAttributeSpecs());
Quals.setIntentAttr(DS.getIntentSpec());
Quals.setAccessAttr(DS.getAccessSpec());
Result = C.getExtQualType(TypeNode, Quals);
if (!Quals.hasAttributeSpec(Qualifiers::AS_dimension))
return Result;
return ActOnArraySpec(C, Result, DS.getDimensions());
}
示例15: VisitType
void USRGenerator::VisitType(QualType T) {
// This method mangles in USR information for types. It can possibly
// just reuse the naming-mangling logic used by codegen, although the
// requirements for USRs might not be the same.
ASTContext &Ctx = *Context;
do {
T = Ctx.getCanonicalType(T);
Qualifiers Q = T.getQualifiers();
unsigned qVal = 0;
if (Q.hasConst())
qVal |= 0x1;
if (Q.hasVolatile())
qVal |= 0x2;
if (Q.hasRestrict())
qVal |= 0x4;
if(qVal)
Out << ((char) ('0' + qVal));
// Mangle in ObjC GC qualifiers?
if (const PackExpansionType *Expansion = T->getAs<PackExpansionType>()) {
Out << 'P';
T = Expansion->getPattern();
}
if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
unsigned char c = '\0';
switch (BT->getKind()) {
case BuiltinType::Void:
c = 'v'; break;
case BuiltinType::Bool:
c = 'b'; break;
case BuiltinType::UChar:
c = 'c'; break;
case BuiltinType::Char16:
c = 'q'; break;
case BuiltinType::Char32:
c = 'w'; break;
case BuiltinType::UShort:
c = 's'; break;
case BuiltinType::UInt:
c = 'i'; break;
case BuiltinType::ULong:
c = 'l'; break;
case BuiltinType::ULongLong:
c = 'k'; break;
case BuiltinType::UInt128:
c = 'j'; break;
case BuiltinType::Char_U:
case BuiltinType::Char_S:
c = 'C'; break;
case BuiltinType::SChar:
c = 'r'; break;
case BuiltinType::WChar_S:
case BuiltinType::WChar_U:
c = 'W'; break;
case BuiltinType::Short:
c = 'S'; break;
case BuiltinType::Int:
c = 'I'; break;
case BuiltinType::Long:
c = 'L'; break;
case BuiltinType::LongLong:
c = 'K'; break;
case BuiltinType::Int128:
c = 'J'; break;
case BuiltinType::Half:
c = 'h'; break;
case BuiltinType::Float:
c = 'f'; break;
case BuiltinType::Double:
c = 'd'; break;
case BuiltinType::LongDouble:
c = 'D'; break;
case BuiltinType::NullPtr:
c = 'n'; break;
#define BUILTIN_TYPE(Id, SingletonId)
#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
#include "clang/AST/BuiltinTypes.def"
case BuiltinType::Dependent:
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/AST/OpenCLImageTypes.def"
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
case BuiltinType::OCLQueue:
case BuiltinType::OCLNDRange:
case BuiltinType::OCLReserveID:
case BuiltinType::OCLSampler:
IgnoreResults = true;
return;
case BuiltinType::ObjCId:
c = 'o'; break;
case BuiltinType::ObjCClass:
c = 'O'; break;
case BuiltinType::ObjCSel:
c = 'e'; break;
}
Out << c;
//.........这里部分代码省略.........