[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 16 10:54:29 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:10546-10548
+  if (PointeeTy->isDependentType()) {
+    return true;
+  }
----------------



================
Comment at: clang/lib/Sema/SemaExpr.cpp:13824
                                         SourceLocation OpLoc) {
-  if (Op->isTypeDependent())
+  if (Op->isTypeDependent() && !Op->getType()->isPointerType())
     return S.Context.DependentTy;
----------------
One thing that makes me a bit uncomfortable is that the logic for these used to be far more understandable when it was just checking for a dependent type. Now we need to sprinkle "and not a pointer type" in places, but it's not particularly clear as to why for a naïve reader of the code.

I wonder if we want some sort of type predicate `isDeferrablyDependentType()` or something along those lines, or whether that's not really plausible? Basically, I'm hoping to find a way that, as a code reviewer, I can more easily spot places where `isTypeDependent()` should really be caring about type dependent pointers as a special case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112453/new/

https://reviews.llvm.org/D112453



More information about the cfe-commits mailing list