aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-06-05 06:38:48 +0200
committerGitHub <noreply@github.com>2025-06-05 06:38:48 +0200
commit478bdd8b9023612a4ef25d50973064e699a95d5b (patch)
tree0d78a4d7b9b59d8a0b7f4bc3a6554d5b60e7d168 /clang/lib/AST/ByteCode/Interp.cpp
parenteca616f376eccfeaccb01fcfc6c833e571b7f1e1 (diff)
downloadllvm-478bdd8b9023612a4ef25d50973064e699a95d5b.zip
llvm-478bdd8b9023612a4ef25d50973064e699a95d5b.tar.gz
llvm-478bdd8b9023612a4ef25d50973064e699a95d5b.tar.bz2
[clang][bytecode] Save Constexpr bit in Function (#142793)
Rename isConstexpr to isValid, the former was always a bad name. Save a constexpr bit in Function so we don't have to access the decl in CheckCallable.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Interp.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index db91e5e..5c8abff 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -857,23 +857,22 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
return false;
}
- // Bail out if the function declaration itself is invalid. We will
- // have produced a relevant diagnostic while parsing it, so just
- // note the problematic sub-expression.
- if (F->getDecl()->isInvalidDecl())
- return Invalid(S, OpPC);
-
if (S.checkingPotentialConstantExpression() && S.Current->getDepth() != 0)
return false;
- if (F->isConstexpr() && F->hasBody() &&
- (F->getDecl()->isConstexpr() || F->getDecl()->hasAttr<MSConstexprAttr>()))
+ if (F->isValid() && F->hasBody() && F->isConstexpr())
return true;
// Implicitly constexpr.
if (F->isLambdaStaticInvoker())
return true;
+ // Bail out if the function declaration itself is invalid. We will
+ // have produced a relevant diagnostic while parsing it, so just
+ // note the problematic sub-expression.
+ if (F->getDecl()->isInvalidDecl())
+ return Invalid(S, OpPC);
+
// Diagnose failed assertions specially.
if (S.Current->getLocation(OpPC).isMacroID() &&
F->getDecl()->getIdentifier()) {
@@ -923,7 +922,8 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
// for a constant expression. It might be defined at the point we're
// actually calling it.
bool IsExtern = DiagDecl->getStorageClass() == SC_Extern;
- if (!DiagDecl->isDefined() && !IsExtern && DiagDecl->isConstexpr() &&
+ bool IsDefined = F->isDefined();
+ if (!IsDefined && !IsExtern && DiagDecl->isConstexpr() &&
S.checkingPotentialConstantExpression())
return false;