当前位置: 首页>>代码示例>>C++>>正文


C++ QualType::isValid方法代码示例

本文整理汇总了C++中QualType::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QualType::isValid方法的具体用法?C++ QualType::isValid怎么用?C++ QualType::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QualType的用法示例。


在下文中一共展示了QualType::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkType

int FileScope::checkType(QualType type, bool used_public) {
    assert(type.isValid());

    const Type* T = type.getTypePtr();
    switch (T->getKind()) {
    case Type::BUILTIN:
        return 1;
    case Type::STRUCT:
    case Type::UNION:
        assert(0);
        break;
    case Type::ENUM:
        {
            QualType qt = T->getRefType();
            if (qt.isValid()) return checkType(qt, used_public);
            return 1;
        }
    case Type::USER:
        // TEMP CONST CAST
        return checkUserType((Type*)T, type->getBaseUserType(), used_public);
    case Type::FUNC:
        // TODO
        assert(0 && "TODO");
        break;
    case Type::POINTER:
    case Type::ARRAY:
        return checkType(T->getRefType(), used_public);
    }
}
开发者ID:vfr-nl,项目名称:c2compiler,代码行数:29,代码来源:Scope.cpp

示例2: setSize

void ArrayType::setSize(const llvm::APInt& value) {
    Size = value;
    arrayTypeBits.hasSize = 1;
    // also set on Canonical
    QualType canonical = getCanonicalType();
    assert(canonical.isValid());
    Type* T = canonical.getTypePtr();
    if (T != this) {
        ArrayType* AT = cast<ArrayType>(T);
        AT->setSize(value);
    }
}
开发者ID:DawidvC,项目名称:c2compiler,代码行数:12,代码来源:Type.cpp

示例3: getPointerType

QualType TypeContext::getPointerType(QualType ref) {
    assert(ref.isValid());
    for (unsigned i=0; i<types.size(); i++) {
        Type* t = types[i];
        if (isa<PointerType>(t)) {
            PointerType* P = cast<PointerType>(t);
            if (P->getPointeeType() == ref) return t;
        }
    }
    Type* N = new PointerType(ref);
    if (ref->hasCanonicalType()) N->setCanonicalType(N);
    return add(N);
}
开发者ID:Davidbrcz,项目名称:c2compiler,代码行数:13,代码来源:Type.cpp

示例4: checkCanonicals

QualType TypeResolver::checkCanonicals(Decls& decls, QualType Q, bool set) const {
    if (Q->hasCanonicalType()) return Q.getCanonicalType();

    const Type* T = Q.getTypePtr();
    switch (Q->getTypeClass()) {
    case TC_BUILTIN:
        return Q;
    case TC_POINTER:
        {
            const PointerType* P = cast<PointerType>(T);
            QualType t1 = P->getPointeeType();
            // Pointee will always be in same TypeContext (file), since it's either built-in or UnresolvedType
            QualType t2 = checkCanonicals(decls, t1, set);
            if (!t2.isValid()) return t2;
            QualType canon;
            if (t1 == t2) canon = Q;
            else {
                canon = typeContext.getPointerType(t2);
                if (!canon->hasCanonicalType()) canon->setCanonicalType(canon);
            }
            assert(Q.isValid());
            if (set) P->setCanonicalType(canon);
            return canon;
        }
    case TC_ARRAY:
        {
            const ArrayType* A = cast<ArrayType>(T);
            QualType t1 = A->getElementType();
            // NOTE: qualifiers are lost here!
            QualType t2 = checkCanonicals(decls, t1, set);
            if (!t2.isValid()) return t2;
            QualType canon;
            if (t1 == t2) canon = Q;
            // NOTE: need size Expr, but set ownership to none
            else {
                canon = typeContext.getArrayType(t2, A->getSizeExpr(), false, A->isIncremental());
                if (!canon->hasCanonicalType()) canon->setCanonicalType(canon);
            }

            if (set) A->setCanonicalType(canon);
            return canon;
        }
    case TC_UNRESOLVED:
        {
            const UnresolvedType* U = cast<UnresolvedType>(T);
            TypeDecl* TD = U->getDecl();
            assert(TD);
            // check if exists
            if (!checkDecls(decls, TD)) {
                return QualType();
            }
            QualType canonical = checkCanonicals(decls, TD->getType(), false);
            if (set) U->setCanonicalType(canonical);
            return canonical;
        }
    case TC_ALIAS:
        {
            const AliasType* A = cast<AliasType>(T);
            if (!checkDecls(decls, A->getDecl())) {
                return QualType();
            }
            QualType canonical = checkCanonicals(decls, A->getRefType(), set);
            assert(Q.isValid());
            if (set) A->setCanonicalType(canonical);
            return canonical;
        }
    case TC_STRUCT:
        return Q.getCanonicalType();
    case TC_ENUM:
        {
            assert(0 && "TODO");
            return 0;
        }
    case TC_FUNCTION:
        return Q.getCanonicalType();
    case TC_MODULE:
        assert(0 && "TBD");
        return 0;
    }
    assert(0);
}
开发者ID:unixaaa,项目名称:c2compiler,代码行数:81,代码来源:TypeResolver.cpp


注:本文中的QualType::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。