本文整理汇总了C++中clang::QualType类的典型用法代码示例。如果您正苦于以下问题:C++ QualType类的具体用法?C++ QualType怎么用?C++ QualType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QualType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RequireCompleteType
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;
}
开发者ID:llvm-project,项目名称:lldb,代码行数:28,代码来源:ClangASTImporter.cpp
示例2: reportTypeMismatch
/**
* Reports mismatch between buffer type and mpi datatype.
* @param callExpr
*/
void MPIBugReporter::reportTypeMismatch(
const CallExpr *callExpr, const std::pair<size_t, size_t> &idxPair,
clang::QualType bufferType, std::string mpiType) const {
auto adc = analysisManager_.getAnalysisDeclContext(currentFunctionDecl_);
PathDiagnosticLocation location = PathDiagnosticLocation::createBegin(
callExpr, bugReporter_.getSourceManager(), adc);
// deref buffer type
while (bufferType->isPointerType()) {
bufferType = bufferType->getPointeeType();
}
// remove qualifiers
bufferType = bufferType.getUnqualifiedType();
SourceRange callRange = callExpr->getCallee()->getSourceRange();
std::string bugType{"type mismatch"};
std::string errorText{"Buffer type '" + bufferType.getAsString() +
+"' and specified MPI type '" + mpiType +
"' do not match. "};
llvm::SmallVector<SourceRange, 3> sourceRanges;
sourceRanges.push_back(callRange);
sourceRanges.push_back(callExpr->getArg(idxPair.first)->getSourceRange());
sourceRanges.push_back(callExpr->getArg(idxPair.second)->getSourceRange());
bugReporter_.EmitBasicReport(adc->getDecl(), &checkerBase_, bugType,
MPIError, errorText, location, sourceRanges);
}
开发者ID:harite,项目名称:MPI-Checker,代码行数:32,代码来源:MPIBugReporter.cpp
示例3: StreamArr
static void StreamArr(llvm::raw_ostream& o, const void* V, clang::QualType Ty,
cling::Interpreter& interp) {
clang::ASTContext& C = interp.getCI()->getASTContext();
const clang::ArrayType* ArrTy = Ty->getAsArrayTypeUnsafe();
clang::QualType ElementTy = ArrTy->getElementType();
if (ElementTy->isCharType())
StreamCharPtr(o, (const char*)V);
else if (Ty->isConstantArrayType()) {
// Stream a constant array by streaming up to 5 elements.
const clang::ConstantArrayType* CArrTy
= C.getAsConstantArrayType(Ty);
const llvm::APInt& APSize = CArrTy->getSize();
size_t ElBytes = C.getTypeSize(ElementTy) / C.getCharWidth();
size_t Size = (size_t)APSize.getZExtValue();
o << "{ ";
for (size_t i = 0; i < Size; ++i) {
// Handle the case of constant size array of pointers. Eg. const char*[]
if (ElementTy->isPointerType())
StreamValue(o, *(const char* const *)V + i * ElBytes, ElementTy, interp);
else
StreamValue(o, (const char*)V + i * ElBytes, ElementTy, interp);
if (i + 1 < Size) {
if (i == 4) {
o << "...";
break;
}
else o << ", ";
}
}
o << " }";
} else
StreamPtr(o, V);
}
开发者ID:kirbyherm,项目名称:root-r-tools,代码行数:34,代码来源:ValuePrinter.cpp
示例4: error
bool WebCLRestrictor::handleParmVarDecl(clang::ParmVarDecl *decl)
{
const clang::TypeSourceInfo *info = decl->getTypeSourceInfo();
if (!info) {
error(decl->getSourceRange().getBegin(), "Invalid parameter type.\n");
return true;
}
clang::SourceLocation typeLocation = info->getTypeLoc().getBeginLoc();
const clang::QualType qualType = info->getType();
const clang::Type *type = qualType.getTypePtrOrNull();
if (!info) {
error(typeLocation, "Invalid parameter type.\n");
return true;
}
const clang::DeclContext *context = decl->getParentFunctionOrMethod();
if (!context) {
error(typeLocation, "Invalid parameter context.\n");
return true;
}
clang::FunctionDecl *function = clang::FunctionDecl::castFromDeclContext(context);
if (!function) {
error(typeLocation, "Invalid parameter context.\n");
return true;
}
checkStructureParameter(function, typeLocation, type);
check3dImageParameter(function, typeLocation, type);
checkUnsupportedBuiltinParameter(function, typeLocation, qualType);
return true;
}
开发者ID:eras,项目名称:webcl-validator,代码行数:32,代码来源:WebCLVisitor.cpp
示例5: roughlyEqual
// A loose type equality check that disregards all sugar, qualification, looks
// through pointers, etc.
static bool roughlyEqual(clang::QualType left, clang::QualType right) {
auto leftPointee = left->getPointeeType();
if (leftPointee != clang::QualType())
left = leftPointee;
auto rightPointee = right->getPointeeType();
if (rightPointee != clang::QualType())
right = rightPointee;
return left->getUnqualifiedDesugaredType() ==
right->getUnqualifiedDesugaredType();
}
开发者ID:007Indian,项目名称:swift,代码行数:12,代码来源:IAMInference.cpp
示例6: slangAssert
// updates S.Ok; and, depending on Kind, possibly S.FnAccumulatorOk or S.FnOutConverterOk
void RSExportReduce::checkVoidReturn(StateOfAnalyzeTranslationUnit &S,
FnIdent Kind, clang::FunctionDecl *Fn) {
slangAssert(Fn);
const clang::QualType ReturnTy = Fn->getReturnType().getCanonicalType();
if (!ReturnTy->isVoidType()) {
S.RSC.ReportError(Fn->getLocation(),
"%0 must return void not '%1'")
<< S.DiagnosticDescription(getKey(Kind), Fn->getName()) << ReturnTy.getAsString();
notOk(S, Kind);
}
}
开发者ID:MIPS,项目名称:frameworks-compile-slang,代码行数:12,代码来源:slang_rs_export_reduce.cpp
示例7: IsStructuralType
bool IsStructuralType(const clang::QualType& type, const clang::ASTContext *context) {
// If it is struct, check if all fields are of structural type
if (type.getCanonicalType().getTypePtr()->isStructureType()) {
clang::RecordDecl* struct_decl = type.getCanonicalType().getTypePtr()->getAsStructureType()->getDecl();
for (const auto* field : struct_decl->fields()) {
if (!IsStructuralType(field->getType(),context))
return false;
}
return true;
} else { // Else check if it is of integral type
return type.getCanonicalType().getTypePtr()->isBuiltinType();
}
}
开发者ID:assasim,项目名称:assasim,代码行数:13,代码来源:analyze_class.cpp
示例8: TraverseType
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;
}
开发者ID:CAST-projects,项目名称:Clang-ast-viewer,代码行数:16,代码来源:AstReader.cpp
示例9: ManagedAllocate
Value::Value(clang::QualType clangTy, Interpreter& Interp):
m_StorageType(determineStorageType(clangTy)),
m_Type(clangTy.getAsOpaquePtr()),
m_Interpreter(&Interp) {
if (needsManagedAllocation())
ManagedAllocate();
}
开发者ID:gbitzes,项目名称:root,代码行数:7,代码来源:Value.cpp
示例10: sizeOfPointer
int TypeUtils::sizeOfPointer(const clang::CompilerInstance &ci, clang::QualType qt)
{
if (!qt.getTypePtrOrNull())
return -1;
// HACK: What's a better way of getting the size of a pointer ?
auto &astContext = ci.getASTContext();
return astContext.getTypeSize(astContext.getPointerType(qt));
}
开发者ID:EugeneZelenko,项目名称:clazy,代码行数:8,代码来源:TypeUtils.cpp
示例11: assert
CompilerType::CompilerType(clang::ASTContext *ast, clang::QualType qual_type)
: m_type(qual_type.getAsOpaquePtr()),
m_type_system(ClangASTContext::GetASTContext(ast)) {
#ifdef LLDB_CONFIGURATION_DEBUG
if (m_type)
assert(m_type_system != nullptr);
#endif
}
开发者ID:sas,项目名称:lldb,代码行数:8,代码来源:CompilerType.cpp
示例12: ShouldRegisterMetaType
bool MocNg::ShouldRegisterMetaType(clang::QualType T)
{
if (T->isVoidType() || (T->isReferenceType() && !T.getNonReferenceType().isConstQualified()))
return false;
if (registered_meta_type.count(T->getCanonicalTypeUnqualified().getTypePtr()))
return true;
T = T.getNonReferenceType();
if (T->isPointerType()) {
// registering pointer to forward declared type fails.
const clang::CXXRecordDecl* Pointee = T->getPointeeCXXRecordDecl();
if (Pointee && !Pointee->hasDefinition())
return false;
return true;
}
const clang::ClassTemplateSpecializationDecl* TD = llvm::dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>(T->getAsCXXRecordDecl());
if (TD) {
if (!TD->hasDefinition())
return false;
for (uint I = 0; I < TD->getTemplateArgs().size(); ++I) {
const auto &Arg = TD->getTemplateArgs().get(I);
if (Arg.getKind() == clang::TemplateArgument::Type) {
if (!ShouldRegisterMetaType(Arg.getAsType()))
return false;
}
}
}
return true;
}
开发者ID:gmrehbein,项目名称:moc-ng,代码行数:32,代码来源:mocng.cpp
示例13: StreamObj
static void StreamObj(llvm::raw_ostream& o, const void* V, clang::QualType Ty) {
if (clang::CXXRecordDecl* CXXRD = Ty->getAsCXXRecordDecl()) {
std::string QualName = CXXRD->getQualifiedNameAsString();
if (QualName == "cling::Value"){
StreamClingValue(o, (const cling::Value*)V);
return;
}
} // if CXXRecordDecl
// TODO: Print the object members.
o << "@" << V;
}
开发者ID:kirbyherm,项目名称:root-r-tools,代码行数:12,代码来源:ValuePrinter.cpp
示例14: assert
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;
}
}
}
}
开发者ID:aamedina,项目名称:cling,代码行数:27,代码来源:ValuePrinterInfo.cpp
示例15: GetTypeAsString
std::string GetTypeAsString(const clang::QualType &type) {
std::stringstream stream;
std::string name = type.getAsString();
// If it is an anonymous structure, print all the fields recursively
if (name.substr(0,11) == "struct (ano") {
stream << "struct { ";
clang::RecordDecl* struct_decl = type.getTypePtr()->getAsStructureType()->getDecl();
// Print the types of all the fields
for (const auto* field : struct_decl->fields()) {
std::string type = GetTypeAsString(field->getType().getCanonicalType());
std::string name = field->getName();
stream << type;
stream << " " << name << "; ";
}
stream << "}";
} else if (type.getTypePtr()->isBooleanType()) {
return "bool";
} else {
stream << type.getAsString(); //just print the type
}
return stream.str();
}
开发者ID:assasim,项目名称:assasim,代码行数:22,代码来源:analyze_class.cpp
示例16: getTypeName
static StringRef getTypeName(clang::QualType qt) {
if (auto typedefTy = qt->getAs<clang::TypedefType>()) {
// Check for a CF type name (drop the "Ref")
auto cfName = getCFTypeName(typedefTy->getDecl()->getCanonicalDecl());
if (cfName != StringRef())
return cfName;
}
auto identInfo = qt.getBaseTypeIdentifier();
if (identInfo)
return identInfo->getName();
// Otherwise, no name
return {};
}
开发者ID:ahti,项目名称:swift,代码行数:15,代码来源:IAMInference.cpp
示例17: createVectorValue
// GET VECTOR TYPE FROM STRING
rapidjson::Value SuperastCPP::createVectorValue(const clang::QualType qualType) {
assert(isSTLVectorType(qualType));
//rapidjson::Value vectorValue(rapidjson::kObjectType);
//vectorValue.AddMember("id", currentId++, allocator);
const std::string& typeName = qualType.getAsString();
std::size_t actPos = 0;
bool finished = false;
unsigned depth = 0;
std::string innerMostType;
while (!finished) {
// find next vector or comma
std::size_t vectorPos = typeName.find(VECTOR_TYPE, actPos);
std::size_t commaPos = typeName.find(",", actPos);
std::string type = "vector";
if (commaPos < vectorPos) {
finished = true;
innerMostType = typeName.substr(actPos, commaPos-actPos);
auto it = VECTOR_TYPE_MAPPING.find(type);
if (it != VECTOR_TYPE_MAPPING.end()) innerMostType = it->second;
}
else {
actPos = vectorPos + VECTOR_TYPE.size();
++depth;
}
}
rapidjson::Value actTypeValue(rapidjson::kObjectType);
addId(actTypeValue);
actTypeValue.AddMember("name",
rapidjson::Value().SetString(innerMostType.c_str(),
innerMostType.size(),
allocator),
allocator);
for (unsigned i = 0; i < depth; ++i) {
rapidjson::Value aux(rapidjson::kObjectType);
addId(aux);
aux.AddMember("name", "vector", allocator);
aux.AddMember("data-type", actTypeValue, allocator);
actTypeValue = aux;
}
return actTypeValue;
}
开发者ID:super-ast,项目名称:cpptranslate,代码行数:48,代码来源:SuperastCPP.cpp
示例18: determineStorageType
Value::EStorageType Value::determineStorageType(clang::QualType QT) {
const clang::Type* desugCanon = QT.getCanonicalType().getTypePtr();
if (desugCanon->isSignedIntegerOrEnumerationType())
return kSignedIntegerOrEnumerationType;
else if (desugCanon->isUnsignedIntegerOrEnumerationType())
return kUnsignedIntegerOrEnumerationType;
else if (desugCanon->isRealFloatingType()) {
const clang::BuiltinType* BT = desugCanon->getAs<clang::BuiltinType>();
if (BT->getKind() == clang::BuiltinType::Double)
return kDoubleType;
else if (BT->getKind() == clang::BuiltinType::Float)
return kFloatType;
else if (BT->getKind() == clang::BuiltinType::LongDouble)
return kLongDoubleType;
} else if (desugCanon->isPointerType() || desugCanon->isObjectType()
|| desugCanon->isReferenceType()) {
if (desugCanon->isRecordType() || desugCanon->isConstantArrayType()
|| desugCanon->isMemberPointerType())
return kManagedAllocation;
return kPointerType;
}
return kUnsupportedType;
}
开发者ID:gbitzes,项目名称:root,代码行数:23,代码来源:Value.cpp
示例19:
insieme::core::TypePtr VariableLengthArrayExtension::Visit(const clang::QualType& type, insieme::frontend::conversion::Converter& converter) {
// we iterate trough the dimensions of the array from left to right. There is no hint
// in the C standard how this should be handled and therefore the normal operator precedence is used.
if(const clang::VariableArrayType* arrType = llvm::dyn_cast<clang::VariableArrayType>(type.getTypePtr())) {
// check if we already converted this decl
if(::containsKey(arrayTypeMap, arrType)) return arrayTypeMap[arrType];
// only consider variable array types
// create a decl stmt e.g., decl uint v1 = i;
core::IRBuilder builder = converter.getIRBuilder();
auto index = converter.convertExpr(arrType->getSizeExpr());
// cast needed from rhs type to int<inf>?!
if(index->getType() != builder.getLangBasic().getUIntInf()) {
index = builder.numericCast(index, builder.getLangBasic().getUIntInf());
}
auto decl = builder.declarationStmt(builder.getLangBasic().getUIntInf(), index);
sizes.push_back(decl);
// convert the element type (in nested array case this is again a variable array type)
core::TypePtr elementType = converter.convertType(arrType->getElementType());
core::TypePtr arrayType = builder.arrayType(elementType, decl->getVariable());
// add type to map
arrayTypeMap[arrType] = arrayType;
return arrayType;
}
return nullptr;
}
开发者ID:zmanchun,项目名称:insieme,代码行数:28,代码来源:variable_length_array_extension.cpp
示例20:
ASTDumper::ASTDumper (clang::QualType type)
{
m_dump = type.getAsString();
}
开发者ID:carlokok,项目名称:lldb,代码行数:4,代码来源:ASTDumper.cpp
注:本文中的clang::QualType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论