Skip to content

[clang] Add CLANG_ENABLE_NEW_CONST_INTERP_BY_DEFAULT cmake option#199396

Open
tbaederr wants to merge 1 commit into
llvm:mainfrom
tbaederr:cmake-const-interp
Open

[clang] Add CLANG_ENABLE_NEW_CONST_INTERP_BY_DEFAULT cmake option#199396
tbaederr wants to merge 1 commit into
llvm:mainfrom
tbaederr:cmake-const-interp

Conversation

@tbaederr
Copy link
Copy Markdown
Contributor

To enable the new constant interpreter by default at configure time.

I don't expect any distributions to set this for now but it's useful for testing and I think we need it eventually.

To enable the new constant interpreter by default at configure time.

I don't expect any distributions to set this for now but it's useful for
testing and I think we need it eventually.
@tbaederr tbaederr requested review from AaronBallman and RKSimon May 24, 2026 05:36
@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 24, 2026
@tbaederr
Copy link
Copy Markdown
Contributor Author

I was a bit split on the naming here, the cmake option misses the "experimental" bit, which is quite imporant.

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

To enable the new constant interpreter by default at configure time.

I don't expect any distributions to set this for now but it's useful for testing and I think we need it eventually.


Full diff: https://github.com/llvm/llvm-project/pull/199396.diff

4 Files Affected:

  • (modified) clang/CMakeLists.txt (+3)
  • (modified) clang/include/clang/Basic/LangOptions.def (+1-1)
  • (modified) clang/include/clang/Config/config.h.cmake (+4)
  • (modified) clang/lib/Basic/LangOptions.cpp (+1)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 40506fc8a1546..e0ad8de149bbc 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -489,6 +489,9 @@ option(CLANG_ENABLE_STATIC_ANALYZER
 
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
+option(CLANG_ENABLE_NEW_CONST_INTERP_BY_DEFAULT
+  "Enable the experimental new constant interpreter by default." OFF)
+
 if (DEFINED CLANG_ENABLE_ARCMT)
   set(CLANG_ENABLE_OBJC_REWRITER ${CLANG_ENABLE_ARCMT})
   message(DEPRECATION "'CLANG_ENABLE_ARCMT' is deprecated as ARCMigrate has been removed from Clang. Please use 'CLANG_ENABLE_OBJC_REWRITER' instead to enable or disable the Objective-C rewriter.")
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index 3bbb40ba09f05..0e8acc6e67924 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -385,7 +385,7 @@ LANGOPT(ConstexprCallDepth, 32, 512, Benign,
         "maximum constexpr call depth")
 LANGOPT(ConstexprStepLimit, 32, 1048576, Benign,
         "maximum constexpr evaluation steps")
-LANGOPT(EnableNewConstInterp, 1, 0, Benign,
+LANGOPT(EnableNewConstInterp, 1, CLANG_ENABLE_NEW_CONST_INTERP_BY_DEFAULT, Benign,
         "enable the experimental new constant interpreter")
 LANGOPT(BracketDepth, 32, 256, Benign,
         "maximum bracket nesting depth")
diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake
index 05e4deb671a7e..758fd0e1165c7 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -91,4 +91,8 @@
 /* Policy to use for xcselect */
 #cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY}
 
+
+/* Enable the experimental new constant interpreter by default */
+#cmakedefine01 CLANG_ENABLE_NEW_CONST_INTERP_BY_DEFAULT
+
 #endif
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 40cdc646780e3..7e75bf1221eb7 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/LangStandard.h"
+#include "clang/Config/config.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant