[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 Mar 30 22:27:32 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG30f96a8fb451: [clang][Interp] Properly identify not-yet-defined functions (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141591/new/
https://reviews.llvm.org/D141591
Files:
clang/lib/AST/Interp/ByteCodeEmitter.cpp
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
@@ -162,3 +162,21 @@
}
}
+
+struct F {
+ constexpr bool ok() const {
+ return okRecurse();
+ }
+ constexpr bool okRecurse() const {
+ return true;
+ }
+};
+
+struct BodylessMemberFunction {
+ constexpr int first() const {
+ return second();
+ }
+ constexpr int second() const {
+ return 1;
+ }
+};
Index: clang/lib/AST/Interp/Function.h
===================================================================
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -157,14 +157,15 @@
bool HasThisPointer, bool HasRVO);
/// Sets the code of a function.
- void setCode(unsigned NewFrameSize, std::vector<char> &&NewCode, SourceMap &&NewSrcMap,
- llvm::SmallVector<Scope, 2> &&NewScopes) {
+ void setCode(unsigned NewFrameSize, std::vector<char> &&NewCode,
+ SourceMap &&NewSrcMap, llvm::SmallVector<Scope, 2> &&NewScopes,
+ bool NewHasBody) {
FrameSize = NewFrameSize;
Code = std::move(NewCode);
SrcMap = std::move(NewSrcMap);
Scopes = std::move(NewScopes);
IsValid = true;
- HasBody = true;
+ HasBody = NewHasBody;
}
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
@@ -1465,7 +1465,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;
Index: clang/lib/AST/Interp/ByteCodeEmitter.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -92,7 +92,7 @@
// Set the function's code.
Func->setCode(NextLocalOffset, std::move(Code), std::move(SrcMap),
- std::move(Scopes));
+ std::move(Scopes), FuncDecl->hasBody());
Func->setIsFullyCompiled(true);
return Func;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141591.509903.patch
Type: text/x-patch
Size: 2411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230331/41c2362b/attachment.bin>
More information about the cfe-commits
mailing list