diff --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp index b7f0c08b2a7d4..f4c5523184630 100644 --- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp @@ -93,7 +93,7 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, const Stmt *LoopStmt, if (T.isVolatileQualified()) return true; - if (!T->isAnyPointerType() && !T->isReferenceType()) + if (!T->isPointerOrObjCObjectPointerType() && !T->isReferenceType()) break; T = T->getPointeeType(); diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp index 84957e0b8190c..7779b6725673c 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp @@ -45,7 +45,8 @@ void SuspiciousMemoryComparisonCheck::check( for (unsigned int ArgIndex = 0; ArgIndex < 2; ++ArgIndex) { const Expr *ArgExpr = CE->getArg(ArgIndex); QualType ArgType = ArgExpr->IgnoreImplicit()->getType(); - const Type *PointeeType = ArgType->getPointeeOrArrayElementType(); + const Type *PointeeType = + ArgType->getPointerOrObjCPointerOrArrayElementType(); assert(PointeeType != nullptr && "PointeeType should always be available."); QualType PointeeQualifiedType(PointeeType, 0); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp index 3eef2fd12cc8e..be1673d5c08c9 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -95,7 +95,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) { else if (TypePtr->isFloatingType()) { InitializationString = " = NAN"; AddMathInclude = true; - } else if (TypePtr->isAnyPointerType()) { + } else if (TypePtr->isPointerOrObjCObjectPointerType()) { if (getLangOpts().CPlusPlus11) InitializationString = " = nullptr"; else diff --git a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp index 5abe4f77d6598..36628d0fd84be 100644 --- a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp +++ b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp @@ -229,7 +229,7 @@ static bool isTypedefTypeMatching(const TypedefType *const Typedef, /// \returns type of the argument static const Type *argumentType(const CallExpr *const CE, const size_t Idx) { const QualType QT = CE->getArg(Idx)->IgnoreImpCasts()->getType(); - return QT.getTypePtr()->getPointeeOrArrayElementType(); + return QT.getTypePtr()->getPointerOrObjCPointerOrArrayElementType(); } void TypeMismatchCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 3f63eec2c51a8..dc740377c4db1 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -1218,7 +1218,7 @@ StyleKind IdentifierNamingCheck::findStyleKind( return SK_ConstexprVariable; if (!Type.isNull() && Type.isConstQualified()) { - if (Type.getTypePtr()->isAnyPointerType() && + if (Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_ConstantPointerParameter]) return SK_ConstantPointerParameter; @@ -1232,7 +1232,8 @@ StyleKind IdentifierNamingCheck::findStyleKind( if (Decl->isParameterPack() && NamingStyles[SK_ParameterPack]) return SK_ParameterPack; - if (!Type.isNull() && Type.getTypePtr()->isAnyPointerType() && + if (!Type.isNull() && + Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_PointerParameter]) return SK_PointerParameter; @@ -1508,7 +1509,8 @@ StyleKind IdentifierNamingCheck::findStyleKindForVar( if (Var->isStaticDataMember() && NamingStyles[SK_ClassConstant]) return SK_ClassConstant; - if (Var->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() && + if (Var->isFileVarDecl() && + Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_GlobalConstantPointer]) return SK_GlobalConstantPointer; @@ -1518,7 +1520,8 @@ StyleKind IdentifierNamingCheck::findStyleKindForVar( if (Var->isStaticLocal() && NamingStyles[SK_StaticConstant]) return SK_StaticConstant; - if (Var->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() && + if (Var->isLocalVarDecl() && + Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_LocalConstantPointer]) return SK_LocalConstantPointer; @@ -1535,7 +1538,8 @@ StyleKind IdentifierNamingCheck::findStyleKindForVar( if (Var->isStaticDataMember() && NamingStyles[SK_ClassMember]) return SK_ClassMember; - if (Var->isFileVarDecl() && Type.getTypePtr()->isAnyPointerType() && + if (Var->isFileVarDecl() && + Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_GlobalPointer]) return SK_GlobalPointer; @@ -1545,7 +1549,8 @@ StyleKind IdentifierNamingCheck::findStyleKindForVar( if (Var->isStaticLocal() && NamingStyles[SK_StaticVariable]) return SK_StaticVariable; - if (Var->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() && + if (Var->isLocalVarDecl() && + Type.getTypePtr()->isPointerOrObjCObjectPointerType() && NamingStyles[SK_LocalPointer]) return SK_LocalPointer; diff --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp index c5eaff88e0ed3..dc6b459e05bdf 100644 --- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp @@ -472,7 +472,8 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType, // Unless argument and param are both multilevel pointers, the types are not // convertible. - if (!(ParamType->isAnyPointerType() && ArgType->isAnyPointerType())) + if (!(ParamType->isPointerOrObjCObjectPointerType() && + ArgType->isPointerOrObjCObjectPointerType())) return false; return arePointerTypesCompatible(ArgType, ParamType, IsParamContinuouslyConst, diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp index 0fea7946a59f9..eec39d97a94a7 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp @@ -84,7 +84,7 @@ inline bool isPointerOrPointerToMember(const Type *T) { } std::optional getPointeeOrArrayElementQualType(QualType T) { - if (T->isAnyPointerType() || T->isMemberPointerType()) + if (T->isPointerOrObjCObjectPointerType() || T->isMemberPointerType()) return T->getPointeeType(); if (T->isArrayType()) diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index e6d16af2495fe..238b28eb97696 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -296,7 +296,7 @@ bool isDefaultLibrary(const Decl *D) { bool isDefaultLibrary(const Type *T) { if (!T) return false; - const Type *Underlying = T->getPointeeOrArrayElementType(); + const Type *Underlying = T->getPointerOrObjCPointerOrArrayElementType(); if (Underlying->isBuiltinType()) return true; if (auto *TD = dyn_cast(Underlying)) diff --git a/clang/include/clang/AST/CanonicalType.h b/clang/include/clang/AST/CanonicalType.h index 6699284d215bd..8c0b9aa39df94 100644 --- a/clang/include/clang/AST/CanonicalType.h +++ b/clang/include/clang/AST/CanonicalType.h @@ -286,7 +286,7 @@ class CanProxyBase { LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isDerivedType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isScalarType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAggregateType) - LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isAnyPointerType) + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isPointerOrObjCObjectPointerType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVoidPointerType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isFunctionPointerType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isMemberFunctionPointerType) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 78677df578c4b..0a505ebbfa1dc 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2536,7 +2536,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isPointerType() const; bool isPointerOrReferenceType() const; bool isSignableType() const; - bool isAnyPointerType() const; // Any C pointer or ObjC object pointer + bool isPointerOrObjCObjectPointerType() + const; // Any C pointer or ObjC object pointer bool isCountAttributedType() const; bool isBlockPointerType() const; bool isVoidPointerType() const; @@ -2862,13 +2863,23 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// This should never be used when type qualifiers are meaningful. const Type *getArrayElementTypeNoTypeQual() const; - /// If this is a pointer type, return the pointee type. + /// If this is a C or ObjC pointer type, return the pointee type. Notably, + /// this does not handle things like member pointers or block pointers. + /// /// If this is an array type, return the array element type. + /// /// This should never be used when type qualifiers are meaningful. - const Type *getPointeeOrArrayElementType() const; + const Type *getPointerOrObjCPointerOrArrayElementType() const; - /// If this is a pointer, ObjC object pointer, or block - /// pointer, this returns the respective pointee. + /// Return the 'pointee type' for any of the following kinds of types, + /// and an empty QualType otherwise. + /// + /// - PointerType + /// - ObjCObjectPointerType + /// - BlockPointerType + /// - ReferenceType + /// - MemberPointerType + /// - DecayedType QualType getPointeeType() const; /// Return the specified type with any "sugar" removed from the type, @@ -8196,7 +8207,7 @@ inline bool Type::isPointerOrReferenceType() const { return isPointerType() || isReferenceType(); } -inline bool Type::isAnyPointerType() const { +inline bool Type::isPointerOrObjCObjectPointerType() const { return isPointerType() || isObjCObjectPointerType(); } @@ -8656,8 +8667,8 @@ inline bool Type::isUndeducedType() const { inline bool Type::isOverloadableType() const { if (!isDependentType()) return isRecordType() || isEnumeralType(); - return !isArrayType() && !isFunctionType() && !isAnyPointerType() && - !isMemberPointerType(); + return !isArrayType() && !isFunctionType() && + !isPointerOrObjCObjectPointerType() && !isMemberPointerType(); } /// Determines whether this type is written as a typedef-name. @@ -8690,9 +8701,9 @@ inline const Type *Type::getBaseElementTypeUnsafe() const { return type; } -inline const Type *Type::getPointeeOrArrayElementType() const { +inline const Type *Type::getPointerOrObjCPointerOrArrayElementType() const { const Type *type = this; - if (type->isAnyPointerType()) + if (type->isPointerOrObjCObjectPointerType()) return type->getPointeeType().getTypePtr(); else if (type->isArrayType()) return type->getBaseElementTypeUnsafe(); diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 239fcba4e5e05..d9f505c5645f0 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -4156,7 +4156,7 @@ AST_MATCHER_P(QualType, asString, std::string, Name) { AST_MATCHER_P( QualType, pointsTo, internal::Matcher, InnerMatcher) { - return (!Node.isNull() && Node->isAnyPointerType() && + return (!Node.isNull() && Node->isPointerOrObjCObjectPointerType() && InnerMatcher.matches(Node->getPointeeType(), Finder, Builder)); } @@ -6605,7 +6605,7 @@ AST_MATCHER(QualType, isAnyCharacter) { /// varDecl(hasType(isAnyPointer())) /// matches "int *i" and "Foo *f", but not "int j". AST_MATCHER(QualType, isAnyPointer) { - return Node->isAnyPointerType(); + return Node->isPointerOrObjCObjectPointerType(); } /// Matches QualType nodes that are const-qualified, i.e., that diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h index f88bf70d72398..15e01bdbcd6ed 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -787,7 +787,7 @@ class SymbolicRegion : public SubRegion { // Because pointer arithmetic is represented by ElementRegion layers, // the base symbol here should not contain any arithmetic. assert(isa_and_nonnull(s)); - assert(s->getType()->isAnyPointerType() || + assert(s->getType()->isPointerOrObjCObjectPointerType() || s->getType()->isReferenceType() || s->getType()->isBlockPointerType()); assert(isa(sreg) || isa(sreg) || diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h index fcc9c02999b3b..d175b6d288609 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h @@ -264,7 +264,8 @@ class SMTConv { uint64_t FromBitWidth) { if ((FromTy->isIntegralOrEnumerationType() && ToTy->isIntegralOrEnumerationType()) || - (FromTy->isAnyPointerType() ^ ToTy->isAnyPointerType()) || + (FromTy->isPointerOrObjCObjectPointerType() ^ + ToTy->isPointerOrObjCObjectPointerType()) || (FromTy->isBlockPointerType() ^ ToTy->isBlockPointerType()) || (FromTy->isReferenceType() ^ ToTy->isReferenceType())) { @@ -365,7 +366,8 @@ class SMTConv { // If the two operands are pointers and the operation is a subtraction, // the result is of type ptrdiff_t, which is signed - if (LTy->isAnyPointerType() && RTy->isAnyPointerType() && Op == BO_Sub) { + if (LTy->isPointerOrObjCObjectPointerType() && + RTy->isPointerOrObjCObjectPointerType() && Op == BO_Sub) { *RetTy = Ctx.getPointerDiffType(); } } @@ -509,8 +511,9 @@ class SMTConv { Solver->mkFloat(Zero)); } - if (Ty->isIntegralOrEnumerationType() || Ty->isAnyPointerType() || - Ty->isBlockPointerType() || Ty->isReferenceType()) { + if (Ty->isIntegralOrEnumerationType() || + Ty->isPointerOrObjCObjectPointerType() || Ty->isBlockPointerType() || + Ty->isReferenceType()) { // Skip explicit comparison for boolean types bool isSigned = Ty->isSignedIntegerOrEnumerationType(); @@ -613,7 +616,8 @@ class SMTConv { return; } - if ((LTy->isAnyPointerType() || RTy->isAnyPointerType()) || + if ((LTy->isPointerOrObjCObjectPointerType() || + RTy->isPointerOrObjCObjectPointerType()) || (LTy->isBlockPointerType() || RTy->isBlockPointerType()) || (LTy->isReferenceType() || RTy->isReferenceType())) { // TODO: Refactor to Sema::FindCompositePointerType(), and @@ -624,7 +628,8 @@ class SMTConv { // Cast the non-pointer type to the pointer type. // TODO: Be more strict about this. - if ((LTy->isAnyPointerType() ^ RTy->isAnyPointerType()) || + if ((LTy->isPointerOrObjCObjectPointerType() ^ + RTy->isPointerOrObjCObjectPointerType()) || (LTy->isBlockPointerType() ^ RTy->isBlockPointerType()) || (LTy->isReferenceType() ^ RTy->isReferenceType())) { if (LTy->isNullPtrType() || LTy->isBlockPointerType() || diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 54430d426a82a..93e6b08644807 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -356,8 +356,7 @@ class SValBuilder { /// space. /// \param type pointer type. loc::ConcreteInt makeNullWithType(QualType type) { - // We cannot use the `isAnyPointerType()`. - assert((type->isPointerType() || type->isObjCObjectPointerType() || + assert((type->isPointerOrObjCObjectPointerType() || type->isBlockPointerType() || type->isNullPtrType() || type->isReferenceType()) && "makeNullWithType must use pointer type"); diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index aeb57b28077c6..c6c6951ba3219 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -260,7 +260,7 @@ class Loc : public DefinedSVal { void dumpToStream(raw_ostream &Out) const; static bool isLocType(QualType T) { - return T->isAnyPointerType() || T->isBlockPointerType() || + return T->isPointerOrObjCObjectPointerType() || T->isBlockPointerType() || T->isReferenceType() || T->isNullPtrType(); } diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index c1bc7c762088f..47c130379d512 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -1042,7 +1042,7 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, } static bool TypeIsInnerPointer(QualType T) { - if (!T->isAnyPointerType()) + if (!T->isPointerOrObjCObjectPointerType()) return false; if (T->isObjCObjectPointerType() || T->isObjCBuiltinType() || T->isBlockPointerType() || T->isFunctionPointerType() || @@ -1366,7 +1366,7 @@ static bool IsVoidStarType(QualType Ty) { /// CF object types or of the "void *" variety. It returns true if we don't care about the type /// such as a non-pointer or pointers which have no ownership issues (such as "int *"). static bool AuditedType (QualType AT) { - if (!AT->isAnyPointerType() && !AT->isBlockPointerType()) + if (!AT->isPointerOrObjCObjectPointerType() && !AT->isBlockPointerType()) return true; // FIXME. There isn't much we can say about CF pointer type; or is there? if (ento::coreFoundation::isCFObjectRef(AT) || diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index be1dd29d46278..9d4743bd0a0aa 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2980,9 +2980,9 @@ bool ASTContext::isSentinelNullExpr(const Expr *E) { // nullptr_t is always treated as null. if (E->getType()->isNullPtrType()) return true; - if (E->getType()->isAnyPointerType() && - E->IgnoreParenCasts()->isNullPointerConstant(*this, - Expr::NPC_ValueDependentIsNull)) + if (E->getType()->isPointerOrObjCObjectPointerType() && + E->IgnoreParenCasts()->isNullPointerConstant( + *this, Expr::NPC_ValueDependentIsNull)) return true; // Unfortunately, __null has type 'int'. @@ -3518,7 +3518,7 @@ QualType ASTContext::getObjCGCQualType(QualType T, if (const auto *ptr = T->getAs()) { QualType Pointee = ptr->getPointeeType(); - if (Pointee->isAnyPointerType()) { + if (Pointee->isPointerOrObjCObjectPointerType()) { QualType ResultType = getObjCGCQualType(Pointee, GCAttr); return getPointerType(ResultType); } @@ -10101,7 +10101,7 @@ Qualifiers::GC ASTContext::getObjCGCAttrKind(QualType Ty) const { QualType CT = Ty->getCanonicalTypeInternal(); while (const auto *AT = dyn_cast(CT)) CT = AT->getElementType(); - assert(CT->isAnyPointerType() || CT->isBlockPointerType()); + assert(CT->isPointerOrObjCObjectPointerType() || CT->isBlockPointerType()); #endif } return GCAttrs; diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index dec4c7221bc77..654dd050a74ad 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1942,7 +1942,7 @@ Error ASTNodeImporter::ImportDeclParts( FunDecl->hasBody()) { auto getLeafPointeeType = [](const Type *T) { while (T->isPointerType() || T->isArrayType()) { - T = T->getPointeeOrArrayElementType(); + T = T->getPointerOrObjCPointerOrArrayElementType(); } return T; }; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index f6a4ed970cb23..b7de5a5b9e623 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1872,7 +1872,7 @@ bool CastExpr::CastConsistency() const { case CK_AnyPointerToBlockPointerCast: assert(getType()->isBlockPointerType()); - assert(getSubExpr()->getType()->isAnyPointerType() && + assert(getSubExpr()->getType()->isPointerOrObjCObjectPointerType() && !getSubExpr()->getType()->isBlockPointerType()); goto CheckNoBasePath; @@ -5199,7 +5199,7 @@ QualType ArraySectionExpr::getBaseOriginalType(const Expr *Base) { OriginalTy = PVD->getOriginalType().getNonReferenceType(); for (unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) { - if (OriginalTy->isAnyPointerType()) + if (OriginalTy->isPointerOrObjCObjectPointerType()) OriginalTy = OriginalTy->getPointeeType(); else if (OriginalTy->isArrayType()) OriginalTy = OriginalTy->castAsArrayTypeUnsafe()->getElementType(); diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 5bf5d6adf525a..dd7d09f783367 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -733,7 +733,7 @@ CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const { if (!ThisArg) return nullptr; - if (ThisArg->getType()->isAnyPointerType()) + if (ThisArg->getType()->isPointerOrObjCObjectPointerType()) return ThisArg->getType()->getPointeeType()->getAsCXXRecordDecl(); return ThisArg->getType()->getAsCXXRecordDecl(); diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 2e680d1569f60..c596a29b47948 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2361,7 +2361,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc, if (auto *FD = dyn_cast_or_null(BaseVD); FD && FD->isImmediateFunction()) { Info.FFDiag(Loc, diag::note_consteval_address_accessible) - << !Type->isAnyPointerType(); + << !Type->isPointerOrObjCObjectPointerType(); Info.Note(FD->getLocation(), diag::note_declared_at); return false; } diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index edeeaeaa9ae17..ce8ca88b7f425 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -2570,8 +2570,9 @@ void MicrosoftCXXNameMangler::mangleType(QualType T, SourceRange Range, return; } - bool IsPointer = T->isAnyPointerType() || T->isMemberPointerType() || - T->isReferenceType() || T->isBlockPointerType(); + bool IsPointer = T->isPointerOrObjCObjectPointerType() || + T->isMemberPointerType() || T->isReferenceType() || + T->isBlockPointerType(); switch (QMM) { case QMM_Drop: diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp index 13cd7e26dc16f..1903047784223 100644 --- a/clang/lib/Analysis/ThreadSafetyCommon.cpp +++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp @@ -383,7 +383,7 @@ static const ValueDecl *getValueDeclFromSExpr(const til::SExpr *E) { static bool hasAnyPointerType(const til::SExpr *E) { auto *VD = getValueDeclFromSExpr(E); - if (VD && VD->getType()->isAnyPointerType()) + if (VD && VD->getType()->isPointerOrObjCObjectPointerType()) return true; if (const auto *C = dyn_cast(E)) return C->castOpcode() == til::CAST_objToPtr; diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index bf2f730618650..9cce3c0961cbe 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -417,7 +417,8 @@ void ClassifyRefs::VisitOMPExecutableDirective(OMPExecutableDirective *ED) { } static bool isPointerToConst(const QualType &QT) { - return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified(); + return QT->isPointerOrObjCObjectPointerType() && + QT->getPointeeType().isConstQualified(); } static bool hasTrivialBody(CallExpr *CE) { diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 0fde4d8ee296b..3bdb0216ce28c 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2929,7 +2929,8 @@ static const NonNullAttr *getNonNullAttr(const Decl *FD, const ParmVarDecl *PVD, // In the former case, LLVM IR cannot represent the constraint. In // the latter case, we have no guarantee that the transparent union // is in fact passed as a pointer. - if (!ArgType->isAnyPointerType() && !ArgType->isBlockPointerType()) + if (!ArgType->isPointerOrObjCObjectPointerType() && + !ArgType->isBlockPointerType()) return nullptr; // First, check attribute on parameter itself. if (PVD) { diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6e5a21c8f01e7..bba936b3c7f3e 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -991,7 +991,8 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, CodeGenFunction::SanitizerScope SanScope(&CGF); - QualType EltTy{Base->getType()->getPointeeOrArrayElementType(), 0}; + QualType EltTy{Base->getType()->getPointerOrObjCPointerOrArrayElementType(), + 0}; if (llvm::Value *POS = CGF.LoadPassedObjectSize(Base, EltTy)) { IndexedType = Base->getType(); return POS; diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index 5679bd7158179..e924138df7b86 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -290,7 +290,7 @@ calculateElementType(const ASTContext &Context, const clang::Type *ResourceTy) { } void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) { - const Type *Ty = D->getType()->getPointeeOrArrayElementType(); + const Type *Ty = D->getType()->getPointerOrObjCPointerOrArrayElementType(); if (!Ty) return; const auto *RD = Ty->getAsCXXRecordDecl(); diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 1868b57cea903..12631dc70da9c 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -7067,7 +7067,7 @@ class MappableExprsHandler { // reference. References are ignored for mapping purposes. QualType Ty = I->getAssociatedDeclaration()->getType().getNonReferenceType(); - if (Ty->isAnyPointerType() && std::next(I) != CE) { + if (Ty->isPointerOrObjCObjectPointerType() && std::next(I) != CE) { // No need to generate individual map information for the pointer, it // can be associated with the combined storage if shared memory mode is // active or the base declaration is not global variable. @@ -7188,12 +7188,13 @@ class MappableExprsHandler { dyn_cast(I->getAssociatedExpression()); const auto *UO = dyn_cast(I->getAssociatedExpression()); const auto *BO = dyn_cast(I->getAssociatedExpression()); - bool IsPointer = - OAShE || - (OASE && ArraySectionExpr::getBaseOriginalType(OASE) - .getCanonicalType() - ->isAnyPointerType()) || - I->getAssociatedExpression()->getType()->isAnyPointerType(); + bool IsPointer = OAShE || + (OASE && ArraySectionExpr::getBaseOriginalType(OASE) + .getCanonicalType() + ->isPointerOrObjCObjectPointerType()) || + I->getAssociatedExpression() + ->getType() + ->isPointerOrObjCObjectPointerType(); bool IsMemberReference = isa(I->getAssociatedExpression()) && MapDecl && MapDecl->getType()->isLValueReferenceType(); @@ -7550,7 +7551,8 @@ class MappableExprsHandler { // For the case that having pointer as base, we need to remove one // level of indirection. if (&Component != &*Components.begin()) - ElementType = ElementType->getPointeeOrArrayElementType(); + ElementType = + ElementType->getPointerOrObjCPointerOrArrayElementType(); ElementTypeSize = Context.getTypeSizeInChars(ElementType).getQuantity(); CurStrides.push_back( @@ -7687,7 +7689,7 @@ class MappableExprsHandler { // 'private ptr' and 'map to' flag. Return the right flags if the captured // declaration is known as first-private in this handler. if (FirstPrivateDecls.count(Cap.getCapturedVar())) { - if (Cap.getCapturedVar()->getType()->isAnyPointerType()) + if (Cap.getCapturedVar()->getType()->isPointerOrObjCObjectPointerType()) return OpenMPOffloadMappingFlags::OMP_MAP_TO | OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ; return OpenMPOffloadMappingFlags::OMP_MAP_PRIVATE | @@ -8032,7 +8034,7 @@ class MappableExprsHandler { const ValueDecl *VD = cast_or_null(D); bool HasMapBasePtr = false; bool HasMapArraySec = false; - if (VD && VD->getType()->isAnyPointerType()) { + if (VD && VD->getType()->isPointerOrObjCObjectPointerType()) { for (const auto &M : Data.second) { HasMapBasePtr = any_of(M, [](const MapInfo &L) { return isa_and_present(L.VarRef); @@ -8533,9 +8535,10 @@ class MappableExprsHandler { assert(VDecl == VD && "We got information for the wrong declaration??"); assert(!Components.empty() && "Not expecting declaration with no component lists."); - if (VD && E && VD->getType()->isAnyPointerType() && isa(E)) + if (VD && E && VD->getType()->isPointerOrObjCObjectPointerType() && + isa(E)) HasMapBasePtr = true; - if (VD && E && VD->getType()->isAnyPointerType() && + if (VD && E && VD->getType()->isPointerOrObjCObjectPointerType() && (isa(E) || isa(E))) HasMapArraySec = true; DeclComponentLists.emplace_back(Components, C->getMapType(), @@ -8626,10 +8629,11 @@ class MappableExprsHandler { llvm::SmallVector Layout; if (!OverlappedData.empty()) { const Type *BaseType = VD->getType().getCanonicalType().getTypePtr(); - const Type *OrigType = BaseType->getPointeeOrArrayElementType(); + const Type *OrigType = + BaseType->getPointerOrObjCPointerOrArrayElementType(); while (BaseType != OrigType) { BaseType = OrigType->getCanonicalTypeInternal().getTypePtr(); - OrigType = BaseType->getPointeeOrArrayElementType(); + OrigType = BaseType->getPointerOrObjCPointerOrArrayElementType(); } if (const auto *CRD = BaseType->getAsCXXRecordDecl()) @@ -8752,7 +8756,7 @@ class MappableExprsHandler { CombinedInfo.DevicePtrDecls.push_back(nullptr); CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None); CombinedInfo.Pointers.push_back(CV); - if (!RI.getType()->isAnyPointerType()) { + if (!RI.getType()->isPointerOrObjCObjectPointerType()) { // We have to signal to the runtime captures passed by value that are // not pointers. CombinedInfo.Types.push_back( @@ -8784,7 +8788,8 @@ class MappableExprsHandler { CombinedInfo.BasePointers.push_back(CV); CombinedInfo.DevicePtrDecls.push_back(nullptr); CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None); - if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) { + if (I != FirstPrivateDecls.end() && + ElementType->isPointerOrObjCObjectPointerType()) { Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue( CV, ElementType, CGF.getContext().getDeclAlign(VD), AlignmentSource::Decl)); diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index dbb19f2a8d825..127d0d73f22d0 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -216,7 +216,7 @@ class CheckVarsEscapingDeclContext final if (((Attr->getCaptureKind() != OMPC_map) && !isOpenMPPrivate(Attr->getCaptureKind())) || ((Attr->getCaptureKind() == OMPC_map) && - !FD->getType()->isAnyPointerType())) + !FD->getType()->isPointerOrObjCObjectPointerType())) return; } if (!FD->getType()->isReferenceType()) { @@ -1962,7 +1962,9 @@ llvm::Function *CGOpenMPRuntimeGPU::createParallelDataSharingWrapper( CGFContext.getPointerType(ElemTy), CI->getLocation()); if (CI->capturesVariableByCopy() && - !CI->getCapturedVar()->getType()->isAnyPointerType()) { + !CI->getCapturedVar() + ->getType() + ->isPointerOrObjCObjectPointerType()) { Arg = castValueToType(CGF, Arg, ElemTy, CGFContext.getUIntPtrType(), CI->getLocation()); } diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 2b4ca65e169a6..04f16cfaceead 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -394,7 +394,7 @@ void CodeGenFunction::GenerateOpenMPCapturedVars( // If the field is not a pointer, we need to save the actual value // and load it as a void pointer. - if (!CurField->getType()->isAnyPointerType()) { + if (!CurField->getType()->isPointerOrObjCObjectPointerType()) { ASTContext &Ctx = getContext(); Address DstAddr = CreateMemTemp( Ctx.getUIntPtrType(), @@ -520,7 +520,8 @@ static llvm::Function *emitOutlinedFunctionPrologue( // deal with pointers. We can pass in the same way the VLA type sizes to the // outlined function. if (FO.UIntPtrCastRequired && - ((I->capturesVariableByCopy() && !ArgType->isAnyPointerType()) || + ((I->capturesVariableByCopy() && + !ArgType->isPointerOrObjCObjectPointerType()) || I->capturesVariableArrayType())) ArgType = Ctx.getUIntPtrType(); @@ -601,7 +602,8 @@ static llvm::Function *emitOutlinedFunctionPrologue( } // If we are capturing a pointer by copy we don't need to do anything, just // use the value that we get from the arguments. - if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) { + if (I->capturesVariableByCopy() && + FD->getType()->isPointerOrObjCObjectPointerType()) { const VarDecl *CurVD = I->getCapturedVar(); if (!FO.RegisterCastedArgsOnly) LocalAddrs.insert({Args[Cnt], {CurVD, LocalAddr}}); @@ -638,7 +640,7 @@ static llvm::Function *emitOutlinedFunctionPrologue( {Args[Cnt], {Var, ArgAddr.withAlignment(Ctx.getDeclAlign(Var))}}); } } else if (I->capturesVariableByCopy()) { - assert(!FD->getType()->isAnyPointerType() && + assert(!FD->getType()->isPointerOrObjCObjectPointerType() && "Not expecting a captured pointer."); const VarDecl *Var = I->getCapturedVar(); LocalAddrs.insert({Args[Cnt], diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 09191a4901f49..742c7b2bfc780 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -832,7 +832,8 @@ CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) { } bool CodeGenTypes::isPointerZeroInitializable(QualType T) { - assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type"); + assert((T->isPointerOrObjCObjectPointerType() || T->isBlockPointerType()) && + "Invalid type"); return isZeroInitializable(T); } diff --git a/clang/lib/CodeGen/Targets/SystemZ.cpp b/clang/lib/CodeGen/Targets/SystemZ.cpp index 23c96fa5cf98c..edf5a89684898 100644 --- a/clang/lib/CodeGen/Targets/SystemZ.cpp +++ b/clang/lib/CodeGen/Targets/SystemZ.cpp @@ -503,7 +503,7 @@ bool SystemZTargetCodeGenInfo::isVectorTypeBased(const Type *Ty, // Assume pointers are dereferenced. while (Ty->isPointerType() || Ty->isArrayType()) - Ty = Ty->getPointeeOrArrayElementType(); + Ty = Ty->getPointerOrObjCPointerOrArrayElementType(); // Vectors >= 16 bytes expose the ABI through alignment requirements. if (Ty->isVectorType() && Ctx.getTypeSize(Ty) / 8 >= 16) diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 66c03863293c2..9057a1247f0ed 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -513,7 +513,7 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForType( // ^---------------- ^ // pointer to const int // ``` - if (SQT.Ty->isAnyPointerType()) + if (SQT.Ty->isPointerOrObjCObjectPointerType()) return TypeFragments.appendSpace().append(std::move(QualsFragments)); return QualsFragments.appendSpace().append(std::move(TypeFragments)); diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 8df5465ad990d..819b096c431f4 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -2135,9 +2135,9 @@ void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S, CodeCompletionString *Completion = C->Completion; if (!Context.getPreferredType().isNull()) { if (C->Kind == CXCursor_MacroDefinition) { - Priority = getMacroUsagePriority(C->Completion->getTypedText(), - S.getLangOpts(), - Context.getPreferredType()->isAnyPointerType()); + Priority = getMacroUsagePriority( + C->Completion->getTypedText(), S.getLangOpts(), + Context.getPreferredType()->isPointerOrObjCObjectPointerType()); } else if (C->Type) { CanQualType Expected = S.Context.getCanonicalType( diff --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp index 4f79775bc5e91..c9c4717ca9d17 100644 --- a/clang/lib/Sema/SemaAPINotes.cpp +++ b/clang/lib/Sema/SemaAPINotes.cpp @@ -48,8 +48,8 @@ static bool isIndirectPointerType(QualType Type) { if (Pointee.isNull()) return false; - return Pointee->isAnyPointerType() || Pointee->isObjCObjectPointerType() || - Pointee->isMemberPointerType(); + return Pointee->isPointerOrObjCObjectPointerType() || + Pointee->isObjCObjectPointerType() || Pointee->isMemberPointerType(); } /// Apply nullability to the given declaration. diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp index db418d80e0e09..f8df8b36c62d1 100644 --- a/clang/lib/Sema/SemaARM.cpp +++ b/clang/lib/Sema/SemaARM.cpp @@ -37,7 +37,7 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, if (FirstArg.isInvalid()) return true; QualType FirstArgType = FirstArg.get()->getType(); - if (!FirstArgType->isAnyPointerType()) + if (!FirstArgType->isPointerOrObjCObjectPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); @@ -64,7 +64,7 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, if (FirstArg.isInvalid()) return true; QualType FirstArgType = FirstArg.get()->getType(); - if (!FirstArgType->isAnyPointerType()) + if (!FirstArgType->isPointerOrObjCObjectPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); @@ -86,7 +86,7 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, if (FirstArg.isInvalid()) return true; QualType FirstArgType = FirstArg.get()->getType(); - if (!FirstArgType->isAnyPointerType()) + if (!FirstArgType->isPointerOrObjCObjectPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) << "first" << FirstArgType << Arg0->getSourceRange(); @@ -108,7 +108,7 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, return true; QualType FirstArgType = FirstArg.get()->getType(); - if (!FirstArgType->isAnyPointerType()) + if (!FirstArgType->isPointerOrObjCObjectPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_must_be_pointer) << "first" << FirstArgType << Arg0->getSourceRange(); TheCall->setArg(0, FirstArg.get()); @@ -138,17 +138,17 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, }; // argument should be either a pointer or null - if (!ArgTypeA->isAnyPointerType() && !isNull(ArgA)) + if (!ArgTypeA->isPointerOrObjCObjectPointerType() && !isNull(ArgA)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) << "first" << ArgTypeA << ArgA->getSourceRange(); - if (!ArgTypeB->isAnyPointerType() && !isNull(ArgB)) + if (!ArgTypeB->isPointerOrObjCObjectPointerType() && !isNull(ArgB)) return Diag(TheCall->getBeginLoc(), diag::err_memtag_arg_null_or_pointer) << "second" << ArgTypeB << ArgB->getSourceRange(); // Ensure Pointee types are compatible - if (ArgTypeA->isAnyPointerType() && !isNull(ArgA) && - ArgTypeB->isAnyPointerType() && !isNull(ArgB)) { + if (ArgTypeA->isPointerOrObjCObjectPointerType() && !isNull(ArgA) && + ArgTypeB->isPointerOrObjCObjectPointerType() && !isNull(ArgB)) { QualType pointeeA = ArgTypeA->getPointeeType(); QualType pointeeB = ArgTypeB->getPointeeType(); if (!Context.typesAreCompatible( @@ -162,7 +162,8 @@ bool SemaARM::BuiltinARMMemoryTaggingCall(unsigned BuiltinID, } // at least one argument should be pointer type - if (!ArgTypeA->isAnyPointerType() && !ArgTypeB->isAnyPointerType()) + if (!ArgTypeA->isPointerOrObjCObjectPointerType() && + !ArgTypeB->isPointerOrObjCObjectPointerType()) return Diag(TheCall->getBeginLoc(), diag::err_memtag_any2arg_pointer) << ArgTypeA << ArgTypeB << ArgA->getSourceRange(); @@ -924,7 +925,8 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(unsigned BuiltinID, TheCall->setArg(IsLdrex ? 0 : 1, PointerArg); // In general, we allow ints, floats and pointers to be loaded and stored. - if (!ValType->isIntegerType() && !ValType->isAnyPointerType() && + if (!ValType->isIntegerType() && + !ValType->isPointerOrObjCObjectPointerType() && !ValType->isBlockPointerType() && !ValType->isFloatingType()) { Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intfltptr) << PointerArg->getType() << 0 << PointerArg->getSourceRange(); diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index f98857f852b5a..479337df148ff 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -596,12 +596,16 @@ static CastAwayConstnessKind unwrapCastAwayConstnessLevel(ASTContext &Context, QualType &T1, QualType &T2) { enum { None, Ptr, MemPtr, BlockPtr, Array }; auto Classify = [](QualType T) { - if (T->isAnyPointerType()) return Ptr; - if (T->isMemberPointerType()) return MemPtr; - if (T->isBlockPointerType()) return BlockPtr; + if (T->isPointerOrObjCObjectPointerType()) + return Ptr; + if (T->isMemberPointerType()) + return MemPtr; + if (T->isBlockPointerType()) + return BlockPtr; // We somewhat-arbitrarily don't look through VLA types here. This is at // least consistent with the behavior of UnwrapSimilarTypes. - if (T->isConstantArrayType() || T->isIncompleteArrayType()) return Array; + if (T->isConstantArrayType() || T->isIncompleteArrayType()) + return Array; return None; }; @@ -682,10 +686,11 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, return CastAwayConstnessKind::CACK_None; if (!DestType->isReferenceType()) { - assert((SrcType->isAnyPointerType() || SrcType->isMemberPointerType() || - SrcType->isBlockPointerType()) && + assert((SrcType->isPointerOrObjCObjectPointerType() || + SrcType->isMemberPointerType() || SrcType->isBlockPointerType()) && "Source type is not pointer or pointer to member."); - assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() || + assert((DestType->isPointerOrObjCObjectPointerType() || + DestType->isMemberPointerType() || DestType->isBlockPointerType()) && "Destination type is not pointer or pointer to member."); } @@ -2450,17 +2455,16 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, Kind = CK_NoOp; TryCastResult Result = TC_NotApplicable; if (SrcType->isIntegralOrEnumerationType() || - SrcType->isAnyPointerType() || - SrcType->isMemberPointerType() || - SrcType->isBlockPointerType()) { + SrcType->isPointerOrObjCObjectPointerType() || + SrcType->isMemberPointerType() || SrcType->isBlockPointerType()) { Result = TC_Success; } return Result; } - bool destIsPtr = DestType->isAnyPointerType() || + bool destIsPtr = DestType->isPointerOrObjCObjectPointerType() || DestType->isBlockPointerType(); - bool srcIsPtr = SrcType->isAnyPointerType() || + bool srcIsPtr = SrcType->isPointerOrObjCObjectPointerType() || SrcType->isBlockPointerType(); if (!destIsPtr && !srcIsPtr) { // Except for std::nullptr_t->integer and lvalue->reference, which are @@ -2902,8 +2906,10 @@ static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr, QualType SrcType = SrcExpr.get()->getType(); if (DestType.getUnqualifiedType()->isVoidType()) return; - if ((SrcType->isAnyPointerType() || SrcType->isBlockPointerType()) - && (DestType->isAnyPointerType() || DestType->isBlockPointerType())) + if ((SrcType->isPointerOrObjCObjectPointerType() || + SrcType->isBlockPointerType()) && + (DestType->isPointerOrObjCObjectPointerType() || + DestType->isBlockPointerType())) return; if (SrcType->isIntegerType() && DestType->isIntegerType() && (SrcType->isBooleanType() == DestType->isBooleanType()) && @@ -3318,7 +3324,8 @@ static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr, return; QualType SrcType = SrcExpr.get()->getType(); - if (!((SrcType->isAnyPointerType() && DestType->isAnyPointerType()) || + if (!((SrcType->isPointerOrObjCObjectPointerType() && + DestType->isPointerOrObjCObjectPointerType()) || DestType->isLValueReferenceType())) return; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 881907ac311a3..4e78ea98a7200 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2571,7 +2571,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, bool ReturnsPointer = BuiltinID == Builtin::BIaddressof || BuiltinID == Builtin::BI__addressof; if (!(Param->isReferenceType() && - (ReturnsPointer ? Result->isAnyPointerType() + (ReturnsPointer ? Result->isPointerOrObjCObjectPointerType() : Result->isReferenceType()) && Context.hasSameUnqualifiedType(Param->getPointeeType(), Result->getPointeeType()))) { @@ -4281,7 +4281,8 @@ ExprResult Sema::BuiltinAtomicOverloaded(ExprResult TheCallResult) { } QualType ValType = pointerType->getPointeeType(); - if (!ValType->isIntegerType() && !ValType->isAnyPointerType() && + if (!ValType->isIntegerType() && + !ValType->isPointerOrObjCObjectPointerType() && !ValType->isBlockPointerType()) { Diag(DRE->getBeginLoc(), diag::err_atomic_builtin_must_be_pointer_intptr) << FirstArg->getType() << 0 << FirstArg->getSourceRange(); @@ -4658,7 +4659,8 @@ ExprResult Sema::BuiltinNontemporalOverloaded(ExprResult TheCallResult) { // Strip any qualifiers off ValType. ValType = ValType.getUnqualifiedType(); - if (!ValType->isIntegerType() && !ValType->isAnyPointerType() && + if (!ValType->isIntegerType() && + !ValType->isPointerOrObjCObjectPointerType() && !ValType->isBlockPointerType() && !ValType->isFloatingType() && !ValType->isVectorType()) { Diag(DRE->getBeginLoc(), @@ -10950,7 +10952,7 @@ static void DiagnoseNullConversion(Sema &S, Expr *E, QualType T, return; // Return if target type is a safe conversion. - if (T->isAnyPointerType() || T->isBlockPointerType() || + if (T->isPointerOrObjCObjectPointerType() || T->isBlockPointerType() || T->isMemberPointerType() || !T->isScalarType() || T->isNullPtrType()) return; @@ -13422,7 +13424,7 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, return; const Type *EffectiveType = - BaseExpr->getType()->getPointeeOrArrayElementType(); + BaseExpr->getType()->getPointerOrObjCPointerOrArrayElementType(); BaseExpr = BaseExpr->IgnoreParenCasts(); const ConstantArrayType *ArrayTy = Context.getAsConstantArrayType(BaseExpr->getType()); diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 1f398bb004fa3..f42a7d2d20e3f 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5012,9 +5012,10 @@ void SemaCodeCompletion::CodeCompleteExpression( bool PreferredTypeIsPointer = false; if (!Data.PreferredType.isNull()) { - PreferredTypeIsPointer = Data.PreferredType->isAnyPointerType() || - Data.PreferredType->isMemberPointerType() || - Data.PreferredType->isBlockPointerType(); + PreferredTypeIsPointer = + Data.PreferredType->isPointerOrObjCObjectPointerType() || + Data.PreferredType->isMemberPointerType() || + Data.PreferredType->isBlockPointerType(); if (Data.PreferredType->isEnumeralType()) { EnumDecl *Enum = Data.PreferredType->castAs()->getDecl(); if (auto *Def = Enum->getDefinition()) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5b7275c316f74..0ec4575d73a35 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9541,7 +9541,7 @@ static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) { // Look into an array argument to check if it has a forbidden type. if (PT->isArrayType()) { - const Type *UnderlyingTy = PT->getPointeeOrArrayElementType(); + const Type *UnderlyingTy = PT->getPointerOrObjCPointerOrArrayElementType(); // Call ourself to check an underlying type of an array. Since the // getPointeeOrArrayElementType returns an innermost type which is not an // array, this recursive call only happens once. @@ -9644,7 +9644,7 @@ static void checkIsValidOpenCLKernelParameter( // an ArrayType of a RecordType. assert((PT->isArrayType() || PT->isRecordType()) && "Unexpected type."); const RecordType *RecTy = - PT->getPointeeOrArrayElementType()->getAs(); + PT->getPointerOrObjCPointerOrArrayElementType()->getAs(); const RecordDecl *OrigRecDecl = RecTy->getDecl(); VisitStack.push_back(RecTy->getDecl()); @@ -9672,7 +9672,8 @@ static void checkIsValidOpenCLKernelParameter( // walk around RecordDecl::fields(). assert((FieldTy->isArrayType() || FieldTy->isRecordType()) && "Unexpected type."); - const Type *FieldRecTy = FieldTy->getPointeeOrArrayElementType(); + const Type *FieldRecTy = + FieldTy->getPointerOrObjCPointerOrArrayElementType(); RD = FieldRecTy->castAs()->getDecl(); } else { @@ -12265,7 +12266,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, // restricted prior to C++17. if (auto *RT = T->getAs()) T = RT->getPointeeType(); - else if (T->isAnyPointerType()) + else if (T->isPointerOrObjCObjectPointerType()) T = T->getPointeeType(); else if (auto *MPT = T->getAs()) T = MPT->getPointeeType(); @@ -12499,7 +12500,7 @@ void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) { // Set an implicit return of 'zero' if the function can return some integral, // enumeration, pointer or nullptr type. if (FT->getReturnType()->isIntegralOrEnumerationType() || - FT->getReturnType()->isAnyPointerType() || + FT->getReturnType()->isPointerOrObjCObjectPointerType() || FT->getReturnType()->isNullPtrType()) // DllMain is exempt because a return value of zero means it failed. if (FD->getName() != "DllMain") @@ -16099,7 +16100,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, auto findBeginLoc = [&]() { // If the return type has `const` qualifier, we want to insert // `static` before `const` (and not before the typename). - if ((FD->getReturnType()->isAnyPointerType() && + if ((FD->getReturnType()->isPointerOrObjCObjectPointerType() && FD->getReturnType()->getPointeeType().isConstQualified()) || FD->getReturnType().isConstQualified()) { // But only do this if we can determine where the `const` is. diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index c1663f2d15c88..30fe6eba42035 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -206,7 +206,7 @@ static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const ParsedAttr &AL) { const auto *VD = cast(D); QualType QT = VD->getType(); - if (QT->isAnyPointerType()) + if (QT->isPointerOrObjCObjectPointerType()) return true; if (const auto *RT = QT->getAs()) { @@ -1267,13 +1267,13 @@ bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) { RecordDecl *UD = UT->getDecl(); for (const auto *I : UD->fields()) { QualType QT = I->getType(); - if (QT->isAnyPointerType() || QT->isBlockPointerType()) + if (QT->isPointerOrObjCObjectPointerType() || QT->isBlockPointerType()) return true; } } } - return T->isAnyPointerType() || T->isBlockPointerType(); + return T->isPointerOrObjCObjectPointerType() || T->isBlockPointerType(); } static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, @@ -1545,7 +1545,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { switch (K) { case OwnershipAttr::Takes: case OwnershipAttr::Holds: - if (!T->isAnyPointerType() && !T->isBlockPointerType()) + if (!T->isPointerOrObjCObjectPointerType() && !T->isBlockPointerType()) Err = 0; break; case OwnershipAttr::Returns: @@ -1763,7 +1763,8 @@ static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { QualType ResultType = getFunctionOrMethodResultType(D); - if (ResultType->isAnyPointerType() || ResultType->isBlockPointerType()) { + if (ResultType->isPointerOrObjCObjectPointerType() || + ResultType->isBlockPointerType()) { D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL)); return; } @@ -4129,7 +4130,7 @@ void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) { else llvm_unreachable("Unknown decl type for align_value"); - if (!T->isDependentType() && !T->isAnyPointerType() && + if (!T->isDependentType() && !T->isPointerOrObjCObjectPointerType() && !T->isReferenceType() && !T->isMemberPointerType()) { Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only) << &TmpAttr << T << D->getSourceRange(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ae40895980d90..65009ff80c4b4 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -662,7 +662,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { // expressions of certain types in C++. if (getLangOpts().CPlusPlus) { if (T == Context.OverloadTy || T->isRecordType() || - (T->isDependentType() && !T->isAnyPointerType() && + (T->isDependentType() && !T->isPointerOrObjCObjectPointerType() && !T->isMemberPointerType())) return E; } @@ -7974,9 +7974,10 @@ static bool checkCondition(Sema &S, const Expr *Cond, /// true otherwise. static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy) { - if ((!PointerTy->isAnyPointerType() && !PointerTy->isBlockPointerType()) || + if ((!PointerTy->isPointerOrObjCObjectPointerType() && + !PointerTy->isBlockPointerType()) || !NullExpr.get()->isNullPointerConstant(S.Context, - Expr::NPC_ValueDependentIsNull)) + Expr::NPC_ValueDependentIsNull)) return true; NullExpr = S.ImpCastExprToType(NullExpr.get(), PointerTy, CK_NullToPointer); @@ -8725,7 +8726,7 @@ static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx) { - if (!ResTy->isAnyPointerType()) + if (!ResTy->isPointerOrObjCObjectPointerType()) return ResTy; auto GetNullability = [](QualType Ty) { @@ -10508,7 +10509,7 @@ static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, // The rest of the operations only make sense with a null pointer // if the other expression is a pointer. - if (LHSNull == RHSNull || NonNullType->isAnyPointerType() || + if (LHSNull == RHSNull || NonNullType->isPointerOrObjCObjectPointerType() || NonNullType->canDecayToPointerType()) return; @@ -10709,8 +10710,8 @@ static void diagnoseSubtractionOnNullPointer(Sema &S, SourceLocation Loc, /// Diagnose invalid arithmetic on two function pointers. static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS) { - assert(LHS->getType()->isAnyPointerType()); - assert(RHS->getType()->isAnyPointerType()); + assert(LHS->getType()->isPointerOrObjCObjectPointerType()); + assert(RHS->getType()->isPointerOrObjCObjectPointerType()); S.Diag(Loc, S.getLangOpts().CPlusPlus ? diag::err_typecheck_pointer_arith_function_type : diag::ext_gnu_ptr_func_arith) @@ -10725,7 +10726,7 @@ static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, /// Diagnose invalid arithmetic on a function pointer. static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer) { - assert(Pointer->getType()->isAnyPointerType()); + assert(Pointer->getType()->isPointerOrObjCObjectPointerType()); S.Diag(Loc, S.getLangOpts().CPlusPlus ? diag::err_typecheck_pointer_arith_function_type : diag::ext_gnu_ptr_func_arith) @@ -10743,7 +10744,7 @@ static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, if (const AtomicType *ResAtomicType = ResType->getAs()) ResType = ResAtomicType->getValueType(); - assert(ResType->isAnyPointerType()); + assert(ResType->isPointerOrObjCObjectPointerType()); QualType PointeeTy = ResType->getPointeeType(); return S.RequireCompleteSizedType( Loc, PointeeTy, @@ -10765,7 +10766,8 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, if (const AtomicType *ResAtomicType = ResType->getAs()) ResType = ResAtomicType->getValueType(); - if (!ResType->isAnyPointerType()) return true; + if (!ResType->isPointerOrObjCObjectPointerType()) + return true; QualType PointeeTy = ResType->getPointeeType(); if (PointeeTy->isVoidType()) { @@ -10793,8 +10795,8 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, /// \returns True when the operand is valid to use (even if as an extension). static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr) { - bool isLHSPointer = LHSExpr->getType()->isAnyPointerType(); - bool isRHSPointer = RHSExpr->getType()->isAnyPointerType(); + bool isLHSPointer = LHSExpr->getType()->isPointerOrObjCObjectPointerType(); + bool isRHSPointer = RHSExpr->getType()->isPointerOrObjCObjectPointerType(); if (!isLHSPointer && !isRHSPointer) return true; QualType LHSPointeeTy, RHSPointeeTy; @@ -10892,7 +10894,7 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, const QualType StringType = StringRefExpr->getType(); // Return if not a PointerType. - if (!StringType->isAnyPointerType()) + if (!StringType->isPointerOrObjCObjectPointerType()) return; // Return if not a CharacterType. @@ -10928,8 +10930,8 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, /// Emit error when two pointers are incompatible. static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr) { - assert(LHSExpr->getType()->isAnyPointerType()); - assert(RHSExpr->getType()->isAnyPointerType()); + assert(LHSExpr->getType()->isPointerOrObjCObjectPointerType()); + assert(RHSExpr->getType()->isPointerOrObjCObjectPointerType()); S.Diag(Loc, diag::err_typecheck_sub_ptr_compatible) << LHSExpr->getType() << RHSExpr->getType() << LHSExpr->getSourceRange() << RHSExpr->getSourceRange(); @@ -11007,7 +11009,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, return InvalidOperands(Loc, LHS, RHS); } } - assert(PExp->getType()->isAnyPointerType()); + assert(PExp->getType()->isPointerOrObjCObjectPointerType()); if (!IExp->getType()->isIntegerType()) return InvalidOperands(Loc, LHS, RHS); @@ -11108,7 +11110,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, } // Either ptr - int or ptr - ptr. - if (LHS.get()->getType()->isAnyPointerType()) { + if (LHS.get()->getType()->isPointerOrObjCObjectPointerType()) { QualType lpointee = LHS.get()->getType()->getPointeeType(); // Diagnose bad cases where we step over interface counts. @@ -11594,8 +11596,10 @@ static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, QualType T = S.FindCompositePointerType(Loc, LHS, RHS); if (T.isNull()) { - if ((LHSType->isAnyPointerType() || LHSType->isMemberPointerType()) && - (RHSType->isAnyPointerType() || RHSType->isMemberPointerType())) + if ((LHSType->isPointerOrObjCObjectPointerType() || + LHSType->isMemberPointerType()) && + (RHSType->isPointerOrObjCObjectPointerType() || + RHSType->isMemberPointerType())) diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/true); else S.InvalidOperands(Loc, LHS, RHS); @@ -12165,13 +12169,13 @@ static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, } void Sema::CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE) { - if (!NullE.get()->getType()->isAnyPointerType()) + if (!NullE.get()->getType()->isPointerOrObjCObjectPointerType()) return; int NullValue = PP.isMacroDefined("NULL") ? 0 : 1; - if (!E.get()->getType()->isAnyPointerType() && + if (!E.get()->getType()->isPointerOrObjCObjectPointerType() && E.get()->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) == - Expr::NPCK_ZeroExpression) { + Expr::NPCK_ZeroExpression) { if (const auto *CL = dyn_cast(E.get())) { if (CL->getValue() == 0) Diag(E.get()->getExprLoc(), diag::warn_pointer_compare) @@ -12605,8 +12609,10 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, return computeResultTy(); } } - if ((LHSType->isAnyPointerType() && RHSType->isIntegerType()) || - (LHSType->isIntegerType() && RHSType->isAnyPointerType())) { + if ((LHSType->isPointerOrObjCObjectPointerType() && + RHSType->isIntegerType()) || + (LHSType->isIntegerType() && + RHSType->isPointerOrObjCObjectPointerType())) { unsigned DiagID = 0; bool isError = false; if (LangOpts.DebuggerSupport) { @@ -17063,8 +17069,10 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, return Type->isSpecificBuiltinType(BuiltinType::Char_S) || Type->isSpecificBuiltinType(BuiltinType::Char_U); }; - FDiag << (isPlainChar(FirstType->getPointeeOrArrayElementType()) || - isPlainChar(SecondType->getPointeeOrArrayElementType())); + FDiag << (isPlainChar( + FirstType->getPointerOrObjCPointerOrArrayElementType()) || + isPlainChar( + SecondType->getPointerOrObjCPointerOrArrayElementType())); } // If we can fix the conversion, suggest the FixIts. diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1e39d69e8b230..f025c2dede44d 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -5293,7 +5293,7 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return false; return T->isIncompleteArrayType(); case UTT_IsPointer: - return T->isAnyPointerType(); + return T->isPointerOrObjCObjectPointerType(); case UTT_IsLvalueReference: return T->isLValueReferenceType(); case UTT_IsRvalueReference: @@ -7276,10 +7276,10 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, // where at least one is a pointer or pointer to member type or // std::nullptr_t is: - bool T1IsPointerLike = T1->isAnyPointerType() || T1->isMemberPointerType() || - T1->isNullPtrType(); - bool T2IsPointerLike = T2->isAnyPointerType() || T2->isMemberPointerType() || - T2->isNullPtrType(); + bool T1IsPointerLike = T1->isPointerOrObjCObjectPointerType() || + T1->isMemberPointerType() || T1->isNullPtrType(); + bool T2IsPointerLike = T2->isPointerOrObjCObjectPointerType() || + T2->isMemberPointerType() || T2->isNullPtrType(); if (!T1IsPointerLike && !T2IsPointerLike) return QualType(); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 0dd5f468cf60b..f7755869c7f5b 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -7878,8 +7878,10 @@ ExprResult InitializationSequence::Perform(Sema &S, if (MTETy->isIncompleteArrayType() && !CurInit.get()->getType()->isIncompleteArrayType() && S.Context.hasSameType( - MTETy->getPointeeOrArrayElementType(), - CurInit.get()->getType()->getPointeeOrArrayElementType())) + MTETy->getPointerOrObjCPointerOrArrayElementType(), + CurInit.get() + ->getType() + ->getPointerOrObjCPointerOrArrayElementType())) MTETy = CurInit.get()->getType(); // Materialize the temporary into memory. diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index e1171d4284c76..a2c1fbe0d0620 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -5481,7 +5481,8 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) { QualType ValType = cast(ND)->getType(); if (ValType.isNull()) continue; - if (ValType->isAnyPointerType() || ValType->isReferenceType()) + if (ValType->isPointerOrObjCObjectPointerType() || + ValType->isReferenceType()) ValType = ValType->getPointeeType(); if (const FunctionProtoType *FPT = ValType->getAs()) if (FPT->getNumParams() == NumArgs) diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp index 9ded913638fb3..47db0d9a08916 100644 --- a/clang/lib/Sema/SemaOpenACC.cpp +++ b/clang/lib/Sema/SemaOpenACC.cpp @@ -2635,7 +2635,7 @@ ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, QualType OriginalBaseTy = ArraySectionExpr::getBaseOriginalType(Base); QualType ResultTy; if (!Base->isTypeDependent()) { - if (OriginalBaseTy->isAnyPointerType()) { + if (OriginalBaseTy->isPointerOrObjCObjectPointerType()) { ResultTy = OriginalBaseTy->getPointeeType(); } else if (OriginalBaseTy->isArrayType()) { ResultTy = OriginalBaseTy->getAsArrayTypeUnsafe()->getElementType(); diff --git a/clang/lib/Sema/SemaOpenCL.cpp b/clang/lib/Sema/SemaOpenCL.cpp index 9f746fffd34d0..a636f860cc0d4 100644 --- a/clang/lib/Sema/SemaOpenCL.cpp +++ b/clang/lib/Sema/SemaOpenCL.cpp @@ -324,7 +324,9 @@ bool SemaOpenCL::checkBuiltinEnqueueKernel(CallExpr *TheCall) { // Fifth argument is always passed as a pointer to clk_event_t. if (!Arg4->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) && - !Arg4->getType()->getPointeeOrArrayElementType()->isClkEventT()) { + !Arg4->getType() + ->getPointerOrObjCPointerOrArrayElementType() + ->isClkEventT()) { Diag(TheCall->getArg(4)->getBeginLoc(), diag::err_opencl_builtin_expected_type) << TheCall->getDirectCallee() diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index b83b2b12f4a23..971f04d356a06 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -2090,7 +2090,7 @@ getVariableCategoryFromDecl(const LangOptions &LO, const ValueDecl *VD) { return OMPC_DEFAULTMAP_scalar; return OMPC_DEFAULTMAP_aggregate; } - if (VD->getType().getNonReferenceType()->isAnyPointerType()) + if (VD->getType().getNonReferenceType()->isPointerOrObjCObjectPointerType()) return OMPC_DEFAULTMAP_pointer; if (VD->getType().getNonReferenceType()->isScalarType()) return OMPC_DEFAULTMAP_scalar; @@ -2222,7 +2222,7 @@ bool SemaOpenMP::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, // (except for reduction variables). // Defaultmap scalar is mutual exclusive to defaultmap pointer IsByRef = (DSAStack->isForceCaptureByReferenceInTargetExecutable() && - !Ty->isAnyPointerType()) || + !Ty->isPointerOrObjCObjectPointerType()) || !Ty->isScalarType() || DSAStack->isDefaultmapCapturedByRef( Level, getVariableCategoryFromDecl(getLangOpts(), D)) || @@ -8879,7 +8879,7 @@ std::pair OpenMPIterationSpaceChecker::buildMinMaxValues( return std::make_pair(nullptr, nullptr); // Convert to the ptrdiff_t, if original type is pointer. - if (VarType->isAnyPointerType() && + if (VarType->isPointerOrObjCObjectPointerType() && !SemaRef.Context.hasSameType( Diff.get()->getType(), SemaRef.Context.getUnsignedPointerDiffType())) { @@ -17344,8 +17344,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPPrivateClause(ArrayRef VarList, OpenMPDirectiveKind CurrDir = DSAStack->getCurrentDirective(); // Variably modified types are not supported for tasks. - if (!Type->isAnyPointerType() && Type->isVariablyModifiedType() && - isOpenMPTaskingDirective(CurrDir)) { + if (!Type->isPointerOrObjCObjectPointerType() && + Type->isVariablyModifiedType() && isOpenMPTaskingDirective(CurrDir)) { Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) << getOpenMPClauseName(OMPC_private) << Type << getOpenMPDirectiveName(CurrDir); @@ -17619,7 +17619,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPFirstprivateClause(ArrayRef VarList, } // Variably modified types are not supported for tasks. - if (!Type->isAnyPointerType() && Type->isVariablyModifiedType() && + if (!Type->isPointerOrObjCObjectPointerType() && + Type->isVariablyModifiedType() && isOpenMPTaskingDirective(DSAStack->getCurrentDirective())) { Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) << getOpenMPClauseName(OMPC_firstprivate) << Type @@ -19744,7 +19745,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPCopyprivateClause(ArrayRef VarList, } // Variably modified types are not supported. - if (!Type->isAnyPointerType() && Type->isVariablyModifiedType()) { + if (!Type->isPointerOrObjCObjectPointerType() && + Type->isVariablyModifiedType()) { Diag(ELoc, diag::err_omp_variably_modified_type_not_supported) << getOpenMPClauseName(OMPC_copyprivate) << Type << getOpenMPDirectiveName(DSAStack->getCurrentDirective()); @@ -20490,7 +20492,8 @@ class MapBaseChecker final : public StmtVisitor { bool VisitArraySubscriptExpr(ArraySubscriptExpr *AE) { Expr *E = AE->getBase()->IgnoreParenImpCasts(); - if (!E->getType()->isAnyPointerType() && !E->getType()->isArrayType()) { + if (!E->getType()->isPointerOrObjCObjectPointerType() && + !E->getType()->isArrayType()) { if (!NoDiagnose) { SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name) << 0 << AE->getSourceRange(); @@ -20540,7 +20543,7 @@ class MapBaseChecker final : public StmtVisitor { if (CurType->isReferenceType()) CurType = CurType->getPointeeType(); - bool IsPointer = CurType->isAnyPointerType(); + bool IsPointer = CurType->isPointerOrObjCObjectPointerType(); if (!IsPointer && !CurType->isArrayType()) { SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name) @@ -20814,7 +20817,7 @@ static bool checkMapConflicts( SI->getAssociatedExpression())) { Type = OASE->getBase()->getType()->getPointeeType(); } - if (Type.isNull() || Type->isAnyPointerType() || + if (Type.isNull() || Type->isPointerOrObjCObjectPointerType() || checkArrayExpressionDoesNotReferToWholeSize( SemaRef, SI->getAssociatedExpression(), Type)) break; @@ -20866,7 +20869,7 @@ static bool checkMapConflicts( // storage in the device data environment, all of the original storage // must have corresponding storage in the device data environment. // - if (DerivedType->isAnyPointerType()) { + if (DerivedType->isPointerOrObjCObjectPointerType()) { if (CI == CE || SI == SE) { SemaRef.Diag( DerivedLoc, @@ -20910,7 +20913,7 @@ static bool checkMapConflicts( if (It != Begin && It->getAssociatedDeclaration() ->getType() .getCanonicalType() - ->isAnyPointerType()) { + ->isPointerOrObjCObjectPointerType()) { IsEnclosedByDataEnvironmentExpr = false; EnclosingExpr = nullptr; return false; @@ -23776,7 +23779,7 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr( // Perform default conversions. QualType OriginalTy = ArraySectionExpr::getBaseOriginalType(Base); QualType ResultTy; - if (OriginalTy->isAnyPointerType()) { + if (OriginalTy->isPointerOrObjCObjectPointerType()) { ResultTy = OriginalTy->getPointeeType(); } else if (OriginalTy->isArrayType()) { ResultTy = OriginalTy->getAsArrayTypeUnsafe()->getElementType(); @@ -23843,7 +23846,7 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr( diag::err_omp_section_incomplete_type, Base)) return ExprError(); - if (LowerBound && !OriginalTy->isAnyPointerType()) { + if (LowerBound && !OriginalTy->isPointerOrObjCObjectPointerType()) { Expr::EvalResult Result; if (LowerBound->EvaluateAsInt(Result, Context)) { // OpenMP 5.0, [2.1.5 Array Sections] @@ -24010,7 +24013,8 @@ ExprResult SemaOpenMP::ActOnOMPIteratorExpr(Scope *S, DeclTy->containsUnexpandedParameterPack() || DeclTy->isInstantiationDependentType(); if (!IsDeclTyDependent) { - if (!DeclTy->isIntegralType(Context) && !DeclTy->isAnyPointerType()) { + if (!DeclTy->isIntegralType(Context) && + !DeclTy->isPointerOrObjCObjectPointerType()) { // OpenMP 5.0, 2.1.6 Iterators, Restrictions, C/C++ // The iterator-type must be an integral or pointer type. Diag(StartLoc, diag::err_omp_iterator_not_integral_or_pointer) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 34c287926b1d7..791f7d1d2ef9e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -301,7 +301,8 @@ isPointerConversionToVoidPointer(ASTContext& Context) const { if (First == ICK_Array_To_Pointer) FromType = Context.getArrayDecayedType(FromType); - if (Second == ICK_Pointer_Conversion && FromType->isAnyPointerType()) + if (Second == ICK_Pointer_Conversion && + FromType->isPointerOrObjCObjectPointerType()) if (const PointerType* ToPtrType = ToType->getAs()) return ToPtrType->getPointeeType()->isVoidType(); @@ -2371,7 +2372,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, FromType = ToType.getUnqualifiedType(); } else if (ToType->isBooleanType() && (FromType->isArithmeticType() || - FromType->isAnyPointerType() || + FromType->isPointerOrObjCObjectPointerType() || FromType->isBlockPointerType() || FromType->isMemberPointerType())) { // Boolean conversions (C++ 4.12). @@ -3439,7 +3440,8 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, Kind = CK_BitCast; - if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() && + if (Diagnose && !IsCStyleOrFunctionalCast && + !FromType->isPointerOrObjCObjectPointerType() && From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) == Expr::NPCK_ZeroExpression) { if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy)) @@ -8631,8 +8633,8 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty, // Skip over restrict if no restrict found anywhere in the types, or if // the type cannot be restrict-qualified. if ((CVR & Qualifiers::Restrict) && - (!hasRestrict || - (!(PointeeTy->isAnyPointerType() || PointeeTy->isReferenceType())))) + (!hasRestrict || (!(PointeeTy->isPointerOrObjCObjectPointerType() || + PointeeTy->isReferenceType())))) continue; // Build qualified pointee type. @@ -9034,7 +9036,7 @@ class BuiltinOperatorOverloadBuilder { // Add restrict version only if there are conversions to a restrict type // and our candidate type is a non-restrict-qualified pointer. - if (HasRestrict && CandidateTy->isAnyPointerType() && + if (HasRestrict && CandidateTy->isPointerOrObjCObjectPointerType() && !CandidateTy.isRestrictQualified()) { ParamTypes[0] = S.Context.getLValueReferenceType( @@ -9050,7 +9052,6 @@ class BuiltinOperatorOverloadBuilder { S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet); } } - } /// Helper to add an overload candidate for a binary builtin with types \p L diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp index 163f7129a7b42..2d82a13f80bcb 100644 --- a/clang/lib/Sema/SemaRISCV.cpp +++ b/clang/lib/Sema/SemaRISCV.cpp @@ -1339,7 +1339,8 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI, QualType ValType = PtrType->getPointeeType(); ValType = ValType.getUnqualifiedType(); - if (!ValType->isIntegerType() && !ValType->isAnyPointerType() && + if (!ValType->isIntegerType() && + !ValType->isPointerOrObjCObjectPointerType() && !ValType->isBlockPointerType() && !ValType->isFloatingType() && !ValType->isVectorType() && !ValType->isRVVSizelessBuiltinType()) { Diag(DRE->getBeginLoc(), diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index ce53990fdcb18..e09b26baf12f4 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -114,8 +114,8 @@ void SemaSYCL::deepTypeCheckForDevice(SourceLocation UsedAt, // In case pointer/array/reference type is met get pointee type, then // proceed with that type. - while (NextTy->isAnyPointerType() || NextTy->isArrayType() || - NextTy->isReferenceType()) { + while (NextTy->isPointerOrObjCObjectPointerType() || + NextTy->isArrayType() || NextTy->isReferenceType()) { if (NextTy->isArrayType()) NextTy = QualType{NextTy->getArrayElementTypeNoTypeQual(), 0}; else diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 1c1f6e30ab7b8..d786689d6d853 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -3795,7 +3795,7 @@ CheckOriginalCallArgDeduction(Sema &S, TemplateDeductionInfo &Info, // function types (recursively). bool ObjCLifetimeConversion = false; QualType ResultTy; - if ((A->isAnyPointerType() || A->isMemberPointerType()) && + if ((A->isPointerOrObjCObjectPointerType() || A->isMemberPointerType()) && (S.IsQualificationConversion(A, DeducedA, false, ObjCLifetimeConversion) || S.IsFunctionConversion(A, DeducedA, ResultTy))) diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 2ccf5a8e1d6f3..a7b386acbc2a5 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1595,7 +1595,7 @@ QualType Sema::BuildQualifiedType(QualType T, SourceLocation Loc, unsigned DiagID = 0; QualType ProblemTy; - if (T->isAnyPointerType() || T->isReferenceType() || + if (T->isPointerOrObjCObjectPointerType() || T->isReferenceType() || T->isMemberPointerType()) { QualType EltTy; if (T->isObjCObjectPointerType()) @@ -7365,10 +7365,10 @@ static bool CheckNullabilityTypeSpecifier( const Type *pointeeType = nullptr; if (Desugared->isArrayType()) pointeeType = Desugared->getArrayElementTypeNoTypeQual(); - else if (Desugared->isAnyPointerType()) + else if (Desugared->isPointerOrObjCObjectPointerType()) pointeeType = Desugared->getPointeeType().getTypePtr(); - if (pointeeType && (pointeeType->isAnyPointerType() || + if (pointeeType && (pointeeType->isPointerOrObjCObjectPointerType() || pointeeType->isObjCObjectPointerType() || pointeeType->isMemberPointerType())) { S.Diag(NullabilityLoc, diag::err_nullability_cs_multilevel) @@ -9807,7 +9807,7 @@ QualType Sema::BuiltinAddPointer(QualType BaseType, SourceLocation Loc) { QualType Sema::BuiltinRemovePointer(QualType BaseType, SourceLocation Loc) { // We don't want block pointers or ObjectiveC's id type. - if (!BaseType->isAnyPointerType() || BaseType->isObjCIdType()) + if (!BaseType->isPointerOrObjCObjectPointerType() || BaseType->isObjCIdType()) return BaseType; return BaseType->getPointeeType(); diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 1a14f38e34f0e..73eeac8789ba7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -2649,7 +2649,7 @@ void CStringChecker::evalSprintfCommon(CheckerContext &C, const CallEvent &Call, for (const auto &[ArgIdx, ArgExpr] : VariadicArguments) { // We consider only string buffers if (const QualType type = ArgExpr->getType(); - !type->isAnyPointerType() || + !type->isPointerOrObjCObjectPointerType() || !type->getPointeeType()->isAnyCharacterType()) continue; SourceArgExpr Source = {{ArgExpr, unsigned(ArgIdx)}}; diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp index c8fe5c2ccf384..e90ff3f80e411 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp @@ -30,7 +30,8 @@ static bool AreTypesCompatible(QualType Derived, QualType Ancestor, // Right now don't compare the compatibility of pointers. That involves // looking at subtyping relationships. FIXME: Future patch. - if (Derived->isAnyPointerType() && Ancestor->isAnyPointerType()) + if (Derived->isPointerOrObjCObjectPointerType() && + Ancestor->isPointerOrObjCObjectPointerType()) return true; return C.typesAreCompatible(Derived, Ancestor); diff --git a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp index 079bc61a87d96..171fb601ea80d 100644 --- a/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp @@ -274,7 +274,7 @@ class FuchsiaHandleSymbolVisitor final : public SymbolVisitor { static SmallVector getFuchsiaHandleSymbols(QualType QT, SVal Arg, ProgramStateRef State) { int PtrToHandleLevel = 0; - while (QT->isAnyPointerType() || QT->isReferenceType()) { + while (QT->isPointerOrObjCObjectPointerType() || QT->isReferenceType()) { ++PtrToHandleLevel; QT = QT->getPointeeType(); } diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp index 04472bb3895a7..a3d27e13f4d70 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -311,7 +311,7 @@ static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val, } static bool isValidPointerType(QualType T) { - return T->isAnyPointerType() || T->isBlockPointerType(); + return T->isPointerOrObjCObjectPointerType() || T->isBlockPointerType(); } const SymbolicRegion * diff --git a/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp index e2f8bd541c967..25c6eadb91264 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp @@ -155,7 +155,7 @@ class TrustNonnullChecker : public CheckerisAnyPointerType()) + if (!ExprRetType->isPointerOrObjCObjectPointerType()) return false; if (getNullabilityAnnotation(ExprRetType) == Nullability::Nonnull) diff --git a/clang/lib/StaticAnalyzer/Checkers/TrustReturnsNonnullChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TrustReturnsNonnullChecker.cpp index d80559c6a9152..0a0a22e2fdbca 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TrustReturnsNonnullChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TrustReturnsNonnullChecker.cpp @@ -42,7 +42,7 @@ class TrustReturnsNonnullChecker : public Checker { bool isNonNullPtr(const CallEvent &Call) const { QualType ExprRetType = Call.getResultType(); const Decl *CallDeclaration = Call.getDecl(); - if (!ExprRetType->isAnyPointerType() || !CallDeclaration) + if (!ExprRetType->isPointerOrObjCObjectPointerType() || !CallDeclaration) return false; return CallDeclaration->hasAttr(); diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h index e35778e6480c5..fae816bf7240f 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h +++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h @@ -328,7 +328,7 @@ inline bool isPrimitiveType(const QualType &T) { } inline bool isDereferencableType(const QualType &T) { - return T->isAnyPointerType() || T->isReferenceType(); + return T->isPointerOrObjCObjectPointerType() || T->isReferenceType(); } // Template method definitions. diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index a9b4dbb39b5bd..41e7ff797c91d 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -767,7 +767,7 @@ bool NoStoreFuncVisitor::prettyPrintRegionName(const RegionVector &FieldChain, return false; const auto *DR = cast(R); - Sep = DR->getValueType()->isAnyPointerType() ? "->" : "."; + Sep = DR->getValueType()->isPointerOrObjCObjectPointerType() ? "->" : "."; DR->getDecl()->getDeclName().print(os, PP); } @@ -3337,7 +3337,7 @@ UndefOrNullArgVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC, assert(ParamDecl && "Formal parameter has no decl?"); QualType T = ParamDecl->getType(); - if (!(T->isAnyPointerType() || T->isReferenceType())) { + if (!(T->isPointerOrObjCObjectPointerType() || T->isReferenceType())) { // Function can only change the value passed in by address. continue; } diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index bb4a39f68280c..db0dc968ae24f 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -87,7 +87,7 @@ static bool isCallback(QualType T) { // Check if a callback is passed inside a struct (for both, struct passed by // reference and by value). Dig just one level into the struct for now. - if (T->isAnyPointerType() || T->isReferenceType()) + if (T->isPointerOrObjCObjectPointerType() || T->isReferenceType()) T = T->getPointeeType(); if (const RecordType *RT = T->getAsStructureType()) { @@ -212,7 +212,7 @@ static bool isPointerToConst(QualType Ty) { return false; if (!PointeeTy.isConstQualified()) return false; - if (PointeeTy->isAnyPointerType()) + if (PointeeTy->isPointerOrObjCObjectPointerType()) return false; return true; } diff --git a/clang/lib/StaticAnalyzer/Core/DynamicType.cpp b/clang/lib/StaticAnalyzer/Core/DynamicType.cpp index 06052cb99fd18..54831176afcaa 100644 --- a/clang/lib/StaticAnalyzer/Core/DynamicType.cpp +++ b/clang/lib/StaticAnalyzer/Core/DynamicType.cpp @@ -117,7 +117,8 @@ ProgramStateRef setDynamicTypeAndCastInfo(ProgramStateRef State, return State; if (CastSucceeds) { - assert((CastToTy->isAnyPointerType() || CastToTy->isReferenceType()) && + assert((CastToTy->isPointerOrObjCObjectPointerType() || + CastToTy->isReferenceType()) && "DynamicTypeInfo should always be a pointer."); State = State->set(MR, CastToTy); } @@ -206,7 +207,7 @@ static raw_ostream &printJson(const DynamicTypeInfo &DTI, raw_ostream &Out, Out << "null"; } else { QualType ToPrint = DTI.getType(); - if (ToPrint->isAnyPointerType()) + if (ToPrint->isPointerOrObjCObjectPointerType()) ToPrint = ToPrint->getPointeeType(); Out << '\"' << ToPrint << "\", \"sub_classable\": " diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 7a900780384a9..56f1d88173df2 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -1101,7 +1101,7 @@ void ExprEngine::VisitIncrementDecrementOperator(const UnaryOperator* U, SVal RHS; SVal Result; - if (U->getType()->isAnyPointerType()) + if (U->getType()->isPointerOrObjCObjectPointerType()) RHS = svalBuilder.makeArrayIndex(1); else if (U->getType()->isIntegralOrEnumerationType()) RHS = svalBuilder.makeIntVal(1, U->getType()); diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp index afb0273d23bd4..67c277c2b673e 100644 --- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -1179,7 +1179,7 @@ SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state, // hierarchy to provide typed regions for all non-void pointers would be // better. For instance, we cannot extend this towards LocAsInteger // operations, where result type of the expression is integer. - if (resultTy->isAnyPointerType()) + if (resultTy->isPointerOrObjCObjectPointerType()) elementType = resultTy->getPointeeType(); } diff --git a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp index 10588a383da0b..4bf4d69f5f910 100644 --- a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp +++ b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp @@ -220,7 +220,7 @@ std::optional tooling::buildAccess(const Expr &RawExpression, const Expr *E = RawExpression.IgnoreImplicitAsWritten(); - if (E->getType()->isAnyPointerType() || + if (E->getType()->isPointerOrObjCObjectPointerType() || treatLikePointer(E->getType(), Classification, Context)) { // Strip off operator-> calls. They can only occur inside an actual arrow // member access, so we treat them as equivalent to an actual object diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp index c39a71b5983fc..db512494e67c8 100644 --- a/clang/lib/Tooling/Transformer/Stencil.cpp +++ b/clang/lib/Tooling/Transformer/Stencil.cpp @@ -166,7 +166,7 @@ class UnaryOperationStencil : public StencilInterface { Source = tooling::buildDereference(*E, *Match.Context); break; case UnaryNodeOperator::MaybeDeref: - if (E->getType()->isAnyPointerType() || + if (E->getType()->isPointerOrObjCObjectPointerType() || tooling::isKnownPointerLikeType(E->getType(), *Match.Context)) { // Strip off any operator->. This can only occur inside an actual arrow // member access, so we treat it as equivalent to an actual object @@ -186,7 +186,7 @@ class UnaryOperationStencil : public StencilInterface { Source = tooling::buildAddressOf(*E, *Match.Context); break; case UnaryNodeOperator::MaybeAddressOf: - if (E->getType()->isAnyPointerType() || + if (E->getType()->isPointerOrObjCObjectPointerType() || tooling::isKnownPointerLikeType(E->getType(), *Match.Context)) { // Strip off any operator->. This can only occur inside an actual arrow // member access, so we treat it as equivalent to an actual object diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 47051f2e68090..a49b3eea4ec82 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -4048,7 +4048,7 @@ TypeSystemClang::GetMinimumLanguage(lldb::opaque_compiler_type_t type) { // If the type is a reference, then resolve it to what it refers to first: clang::QualType qual_type(GetCanonicalQualType(type).getNonReferenceType()); - if (qual_type->isAnyPointerType()) { + if (qual_type->isPointerOrObjCObjectPointerType()) { if (qual_type->isObjCObjectPointerType()) return lldb::eLanguageTypeObjC; if (qual_type->getPointeeCXXRecordDecl())