[PATCH] D141591: [clang][Interp] Properly identify not-yet-defined functions
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 12 03:37:37 PST 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Since we now handle functions without a body as well, we can't just use
getHasBody() anymore. Funtions that haven't been defined yet are those
that don't have a body *and* aren't valid.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141591
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Function.h
clang/test/AST/Interp/functions.cpp
Index: clang/test/AST/Interp/functions.cpp
===================================================================
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -154,3 +154,12 @@
}
}
+
+struct F {
+ constexpr bool ok() const {
+ return okRecurse();
+ }
+ constexpr bool okRecurse() const {
+ return true;
+ }
+};
Index: clang/lib/AST/Interp/Function.h
===================================================================
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,7 +157,7 @@
SrcMap = std::move(NewSrcMap);
Scopes = std::move(NewScopes);
IsValid = true;
- HasBody = true;
+ HasBody = NewCode.size() > 0;
}
void setIsFullyCompiled(bool FC) { IsFullyCompiled = FC; }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1484,7 +1484,7 @@
assert(FD);
const Function *Func = P.getFunction(FD);
bool IsBeingCompiled = Func && !Func->isFullyCompiled();
- bool WasNotDefined = Func && !Func->hasBody();
+ bool WasNotDefined = Func && !Func->isConstexpr() && !Func->hasBody();
if (IsBeingCompiled)
return Func;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141591.488584.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230112/daf63b14/attachment-0001.bin>
More information about the cfe-commits
mailing list