Example #1
0
bool ClangASTImporter::RequireCompleteType(clang::QualType type) {
  if (type.isNull())
    return false;

  if (const TagType *tag_type = type->getAs<TagType>()) {
    TagDecl *tag_decl = tag_type->getDecl();

    if (tag_decl->getDefinition() || tag_decl->isBeingDefined())
      return true;

    return CompleteTagDecl(tag_decl);
  }
  if (const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>()) {
    if (ObjCInterfaceDecl *objc_interface_decl =
            objc_object_type->getInterface())
      return CompleteObjCInterfaceDecl(objc_interface_decl);
    else
      return false;
  }
  if (const ArrayType *array_type = type->getAsArrayTypeUnsafe()) {
    return RequireCompleteType(array_type->getElementType());
  }
  if (const AtomicType *atomic_type = type->getAs<AtomicType>()) {
    return RequireCompleteType(atomic_type->getPointeeType());
  }

  return true;
}
Example #2
0
   void ValuePrinterInfo::Init(clang::QualType Ty) {
    assert(!Ty.isNull() && "Type must be valid!");
    assert(m_Context && "ASTContext cannot be null!");

    assert(sizeof(m_Type) >= sizeof(clang::QualType) && "m_Type too small!");
    m_Type = *reinterpret_cast<void**>(&Ty);

    // 1. Get the flags
    if (Ty.isLocalConstQualified() || Ty.isConstant(*m_Context)){
      m_Flags |= VPI_Const;
    }

    if (Ty->isPointerType()) {
      // treat arrary-to-pointer decay as array:
      QualType PQT = Ty->getPointeeType();
      const Type* PTT = PQT.getTypePtr();
      if (!PTT || !PTT->isArrayType()) {
        m_Flags |= VPI_Ptr;
        if (const RecordType* RT = dyn_cast<RecordType>(Ty.getTypePtr()))
          if (RecordDecl* RD = RT->getDecl()) {
            CXXRecordDecl* CRD = dyn_cast<CXXRecordDecl>(RD);
            if (CRD && CRD->isPolymorphic())
              m_Flags |= VPI_Polymorphic;
          }
      }
    }
  }
 bool TraverseType(clang::QualType type)
 {
     if (type.isNull())
     {
         return PARENT::TraverseType(type);
     }
     auto node = std::make_unique<GenericAstNode>();
     //node->myType = d;
     node->name = type->getTypeClassName();
     auto nodePtr = node.get();
     myStack.back()->attach(std::move(node));
     myStack.push_back(nodePtr);
     auto res = PARENT::TraverseType(type);
     myStack.pop_back();
     return res;
 }