[PATCH] D65744: [PR42707][OpenCL] Fix addr space deduction for auto

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 14:41:20 PDT 2019


rjmccall added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:5998
+    QualType Type = Var->getType();
+    if (Type->isSamplerT() || Type->isVoidType())
+      return;
----------------
Anastasia wrote:
> I don't seem to need a check for dependent or auto types because the substitution happens using type info rather than getting type from the declaration. Not sure if I should explain it here or add the checks just in case?
If you have adequate test-case coverage (both inside and out of templates) then I don't think you need further explanation.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:6721
 
+  if (getLangOpts().OpenCL) {
+
----------------
Since you're moving this code anyway, can this be split into its own function?  I'm not sure if it's actually important that some of these failures return immediately and some of them fall through to later checks.


================
Comment at: clang/lib/Sema/SemaType.cpp:7460
+      // the initializing expression type during the type deduction.
+      (T->isUndeducedAutoType() && IsPointee) ||
       // OpenCL spec v2.0 s6.9.b:
----------------
Anastasia wrote:
> rjmccall wrote:
> > Okay, I understand why you're doing this now, and it makes sense.  I would like to propose changing the entire way `deduceOpenCLImplicitAddrSpace` works.  Why don't we do it more like how ObjC ARC infers its implicit ownership qualifiers:
> > 
> > - In SemaType, we add the default address space to non-qualified, non-dependent, non-undeduced-`auto` pointees when parsing a pointer or reference type.
> > - In SemaType, we add the default address space to non-qualified pointees when building a pointer or reference type.
> > - We add the default address space at the top level when when building a variable.
> > 
> > Then all of this context-specific logic where we're looking at different declarator chunks and trying to infer the relationship of the current chunk to the overall type being parsed can just go away or get pushed into a more appropriate position.
> Ok, it mainly works, however I still need a bit of parsing horribleness when deducing addr space of declarations with parenthesis  in `GetFullTypeForDeclarator`. This is the case for block pointers or pointers/references to arrays. It is incorrect to add address spaces on ParenType while building a pointer or references so I have to detect this as special case.
You can't add an address space outside a `ParenType`?  That seems odd; what problems are you seeing exactly?

If it's really just specific to `ParenType`, you could simply drill through them and then rebuild the `ParenType`s.


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

https://reviews.llvm.org/D65744





More information about the cfe-commits mailing list