================
@@ -1741,6 +1742,61 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr(
setDependence(computeDependence(this));
}
+static const ValueDecl *getAddrSpaceOfEntity(const Expr *E) {
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
+ return dyn_cast<ValueDecl>(DRE->getDecl());
+ if (const auto *ME = dyn_cast<MemberExpr>(E))
+ return ME->getMemberDecl();
+ return nullptr;
+}
+
+static std::optional<LangAS> getCUDADeclAddressSpace(const ASTContext &Ctx,
+ const ValueDecl *D) {
+ if (!Ctx.getLangOpts().CUDA)
+ return std::nullopt;
+
+ if (D->hasAttr<CUDAConstantAttr>())
+ return LangAS::cuda_constant;
+ if (D->hasAttr<CUDASharedAttr>())
+ return LangAS::cuda_shared;
+
+ const auto *VD = dyn_cast<VarDecl>(D);
+ if (!VD)
+ return std::nullopt;
----------------
AaronBallman wrote:
What about a case like:
```
int array[3];
auto __attribute__((address_space(12))) [a, b, c] = array;
static_assert(__addrspaceof(a) != 0);
```
https://github.com/llvm/llvm-project/pull/210242
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits