[clang] 3f1e95a - [clang][Interp] consider "MS constexpr" functions as well
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 12:49:24 PST 2024
Author: Timm Bäder
Date: 2024-02-06T21:49:13+01:00
New Revision: 3f1e95a9d4cc1fdb933390247d0bd4391cf93f60
URL: https://github.com/llvm/llvm-project/commit/3f1e95a9d4cc1fdb933390247d0bd4391cf93f60
DIFF: https://github.com/llvm/llvm-project/commit/3f1e95a9d4cc1fdb933390247d0bd4391cf93f60.diff
LOG: [clang][Interp] consider "MS constexpr" functions as well
This implements the minimum amout of support for this feature
to get the test/AST/ms-constexpr.cpp test working. More has to
be added to get SemaCXX tests to work.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeEmitter.cpp
clang/test/AST/ms-constexpr.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 409ce21506caae..8bbfa928bd6457 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -14,6 +14,7 @@
#include "Opcode.h"
#include "Program.h"
#include "clang/AST/ASTLambda.h"
+#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/Basic/Builtins.h"
#include <type_traits>
@@ -116,7 +117,8 @@ Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
if (const auto *MD = dyn_cast<CXXMethodDecl>(FuncDecl))
IsEligibleForCompilation = MD->isLambdaStaticInvoker();
if (!IsEligibleForCompilation)
- IsEligibleForCompilation = FuncDecl->isConstexpr();
+ IsEligibleForCompilation =
+ FuncDecl->isConstexpr() || FuncDecl->hasAttr<MSConstexprAttr>();
// Compile the function body.
if (!IsEligibleForCompilation || !visitFunc(FuncDecl)) {
diff --git a/clang/test/AST/ms-constexpr.cpp b/clang/test/AST/ms-constexpr.cpp
index e85af8494f3344..673af1234f4430 100644
--- a/clang/test/AST/ms-constexpr.cpp
+++ b/clang/test/AST/ms-constexpr.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump -verify %s | FileCheck %s
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump -verify %s -fexperimental-new-constant-interpreter | FileCheck %s
// expected-no-diagnostics
// CHECK: used f1 'bool ()'
More information about the cfe-commits
mailing list