[PATCH] D148614: [clang][Interp] Add frame depth checking

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 10:32:02 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.cpp:345-352
+  if ((S.Current->getDepth() + 1) > S.getLangOpts().ConstexprCallDepth) {
+    S.FFDiag(S.Current->getSource(OpPC),
+             diag::note_constexpr_depth_limit_exceeded)
+        << S.getLangOpts().ConstexprCallDepth;
+    return false;
+  }
+
----------------
`-fconstexpr-depth` sets the number of *recursive* constexpr calls, but this looks like it's measuring the depth of the call stack regardless of whether there's recursion or not. Can you add a test where you set this value to something low and make nested calls that exceed that depth?

(Also, there's `-fconstexpr-steps` https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps we'll need to support at some point, in case you weren't aware of the option.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148614/new/

https://reviews.llvm.org/D148614



More information about the cfe-commits mailing list