[clang] [clang][CodeComplete] Recurse into the subexpression of deref operator in getApproximateType (PR #93404)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun May 26 23:28:22 PDT 2024
================
@@ -5680,8 +5680,16 @@ QualType getApproximateType(const Expr *E) {
}
}
if (const auto *UO = llvm::dyn_cast<UnaryOperator>(E)) {
- if (UO->getOpcode() == UnaryOperatorKind::UO_Deref)
- return UO->getSubExpr()->getType()->getPointeeType();
+ if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
+ // We recurse into the subexpression because it could be of dependent
+ // type.
+ QualType SubType = getApproximateType(UO->getSubExpr());
+ if (auto Pointee = SubType->getPointeeType(); !Pointee.isNull())
+ return Pointee;
+ // Our caller expects a non-null result, even though the SubType is
+ // supposed to have a pointee.
+ return SubType;
----------------
HighCommander4 wrote:
Perhaps falling through to the `return Unresolved` would be better? That's a dependent representation of the pointee type, so it seems less misleading than returning the pointer type. (And it's also what other branches in this function do.)
https://github.com/llvm/llvm-project/pull/93404
More information about the cfe-commits
mailing list