本文整理汇总了C++中ASTContext::getRecordType方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext::getRecordType方法的具体用法?C++ ASTContext::getRecordType怎么用?C++ ASTContext::getRecordType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTContext
的用法示例。
在下文中一共展示了ASTContext::getRecordType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ActOnTypeName
/// \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());
}
示例2: printPretty
//.........这里部分代码省略.........
if (IsReference)
Out << ')';
}
return;
}
// We have an lvalue path. Print it out nicely.
if (!IsReference)
Out << '&';
else if (isLValueOnePastTheEnd())
Out << "*(&";
QualType ElemTy;
if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) {
Out << *VD;
ElemTy = VD->getType();
} else {
const Expr *E = Base.get<const Expr*>();
assert(E != nullptr && "Expecting non-null Expr");
E->printPretty(Out, nullptr, Ctx.getPrintingPolicy());
ElemTy = E->getType();
}
ArrayRef<LValuePathEntry> Path = getLValuePath();
const CXXRecordDecl *CastToBase = nullptr;
for (unsigned I = 0, N = Path.size(); I != N; ++I) {
if (ElemTy->getAs<RecordType>()) {
// The lvalue refers to a class type, so the next path entry is a base
// or member.
const Decl *BaseOrMember =
BaseOrMemberType::getFromOpaqueValue(Path[I].BaseOrMember).getPointer();
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(BaseOrMember)) {
CastToBase = RD;
ElemTy = Ctx.getRecordType(RD);
} else {
const ValueDecl *VD = cast<ValueDecl>(BaseOrMember);
Out << ".";
if (CastToBase)
Out << *CastToBase << "::";
Out << *VD;
ElemTy = VD->getType();
}
} else {
// The lvalue must refer to an array.
Out << '[' << Path[I].ArrayIndex << ']';
ElemTy = Ctx.getAsArrayType(ElemTy)->getElementType();
}
}
// Handle formatting of one-past-the-end lvalues.
if (isLValueOnePastTheEnd()) {
// FIXME: If CastToBase is non-0, we should prefix the output with
// "(CastToBase*)".
Out << " + 1";
if (IsReference)
Out << ')';
}
return;
}
case APValue::Array: {
const ArrayType *AT = Ctx.getAsArrayType(Ty);
QualType ElemTy = AT->getElementType();
Out << '{';
if (unsigned N = getArrayInitializedElts()) {
getArrayInitializedElt(0).printPretty(Out, Ctx, ElemTy);
for (unsigned I = 1; I != N; ++I) {