[PATCH] D136936: [clang][Interp] Handle undefined functions better
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 1 07:24:03 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:30
if (!FuncDecl->isDefined(FuncDecl) ||
- (!FuncDecl->hasBody() && FuncDecl->willHaveBody()))
- return nullptr;
+ (FuncDecl->hasBody() && FuncDecl->willHaveBody()))
+ HasBody = false;
----------------
`hasBody()` returns `true` if any body in the redeclaration chain already has a body, so I'm surprised to see this change -- I don't know if we reset `willHaveBody()` when we give the function a body, but the logic here seems wrong to me.
================
Comment at: clang/lib/AST/Interp/Program.cpp:210
Function *Program::getFunction(const FunctionDecl *F) {
- F = F->getDefinition();
+ F = F->getCanonicalDecl();
+ assert(F);
----------------
Same question here about canonical decl.
================
Comment at: clang/lib/AST/Interp/Program.h:97
Function *createFunction(const FunctionDecl *Def, Ts &&... Args) {
+ Def = Def->getCanonicalDecl();
auto *Func = new Function(*this, Def, std::forward<Ts>(Args)...);
----------------
Are you trying to get the `FunctionDecl` which represents the function definition, or do you really mean you want the first declaration in the redecl chain?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136936/new/
https://reviews.llvm.org/D136936
More information about the cfe-commits
mailing list