[clang] [Clang] FunctionEffects: Correctly navigate through array types in FunctionEffectsRef::get(). (PR #121525)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 13 12:24:15 PST 2025
================
@@ -8836,13 +8836,22 @@ void FixedPointValueToString(SmallVectorImpl<char> &Str, llvm::APSInt Val,
unsigned Scale);
inline FunctionEffectsRef FunctionEffectsRef::get(QualType QT) {
+ const Type *TypePtr = QT.getTypePtr();
while (true) {
- QualType Pointee = QT->getPointeeType();
- if (Pointee.isNull())
+ // Note that getPointeeType() seems to successfully navigate some constructs
+ // for which isAnyPointerType() returns false (e.g.
+ // pointer-to-member-function).
+ QualType Pointee = TypePtr->getPointeeType();
+ if (Pointee.isNull()) {
+ if (TypePtr->isArrayType()) {
+ TypePtr = TypePtr->getBaseElementTypeUnsafe();
+ continue;
+ }
break;
- QT = Pointee;
+ }
+ TypePtr = Pointee.getTypePtr();
}
- if (const auto *FPT = QT->getAs<FunctionProtoType>())
+ if (const auto *FPT = TypePtr->getAs<FunctionProtoType>())
----------------
Sirraide wrote:
Update: We’re going to rename some of these functions and while I’m at it, I’ll add a new helper that you’ll be able to use for this situation.
https://github.com/llvm/llvm-project/pull/121525
More information about the cfe-commits
mailing list