[PATCH] D137563: [clang][Interp] Check declarations for constexpr-ness in Load() instructions
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 14 13:03:36 PST 2022
shafik added inline comments.
================
Comment at: clang/lib/AST/Interp/Interp.cpp:101
+static bool CheckConstexpr(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+ if (!S.inConstantContext())
----------------
Is `CheckConstexpr` descriptive enough? Would something like `CheckLoadIsValid` be better?
================
Comment at: clang/lib/AST/Interp/Interp.cpp:110
+ if (auto *VarD = dyn_cast<VarDecl>(VD)) {
+ if (VarD->hasLocalStorage() || VarD->isConstexpr())
+ return true;
----------------
Is this sufficient? How about something like this:
```
int *p;
int constexpr f(int &x) {
*p=1;
return 10;
}
```
Maybe I am not understanding. I think more test case would be useful.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137563/new/
https://reviews.llvm.org/D137563
More information about the cfe-commits
mailing list