[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 30 09:59:04 PST 2018
rjmccall added inline comments.
================
Comment at: include/clang/AST/DeclCXX.h:2189
+ C.addCVRUQualifiers(CVRU);
+ C.addQualifiers(getType().getQualifiers());
+ return C;
----------------
The address-space qualifier should get stored in the same way on the `FunctionProtoType` as the other method qualifiers (at least as far as the public interface of FPT goes). It's not the same thing as an ordinary type qualifier on the type, and trying to represent it that way will lead to a lot of problems downstream.
You'll probably also have to do some extra work in SemaType to make sure that the attribute gets applied in the right place.
You'll need to mess around with the representation of FPT to make this efficient, because we don't want to make every instance of FPT have to pay to store a full `Qualifiers`. I'd do it like this:
- Go ahead and add a full `Qualifiers` in `FunctionProtoType::ExtProtoInfo`; this is never stored permanently, so the cost is negligible.
- There are currently four bits for "qualifiers" in `FunctionTypeBits`. The only qualifiers that are actually important to store inline like this are `const` and `volatile`, but since we have four bits, let's store CVR here and use the fourth bit to indicate that there are more qualifiers stored in trailing storage.
- When there are non-CVR qualifiers present, `ASTContext::getFunctionTypeInternal` should allocate additional trailing storage for a `Qualifiers` object that can store the rest of the qualifiers.
- `getTypeQuals()` can check for the bit and load the qualifiers if present, or else just return the CVR qualifiers stored inline.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54862/new/
https://reviews.llvm.org/D54862
More information about the cfe-commits
mailing list