<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">There is `Expr::isCXX11ConstantExpr(const ASTContext &C, …)`, which returns e.g.:<div class=""><br class=""></div><div class="">```</div><div class=""><font face="Menlo" class="">constexpr int f(int i) {<br class="">  return i + 42;<br class="">}<br class=""><br class="">int g(int i) {<br class="">  return<br class="">      f(i); // </font><span style="font-family: Menlo;" class="">isCXX11ConstantExpr</span><font face="Menlo" class=""> = false<br class="">}<br class=""><br class="">int main() {<br class="">  int j =<br class="">      g(3); // </font><span style="font-family: Menlo;" class="">isCXX11ConstantExpr</span><font face="Menlo" class=""> = false<br class=""><br class="">  int k =<br class="">      f(g(3)); // </font><span style="font-family: Menlo;" class="">isCXX11ConstantExpr</span><font face="Menlo" class=""> = false (both CallExprs)<br class=""><br class="">  int l =<br class="">      f(3); // </font><span style="font-family: Menlo;" class="">isCXX11ConstantExpr</span><font face="Menlo" class=""> = true<br class="">}</font></div><div class="">```</div><div class=""><br class=""></div><div class="">It is defined in terms of `EvaluateAsRValue` FWIW.  Note that all the `EvaluateAs*` methods refer to evaluating at compile time, regardless of the `InConstantContext` argument, and (I think) all will return false whenever the expression cannot fully "fold" (i.e. if there will necessarily be run-time dependencies remaining in the expression, or there was an error during evaluation).</div><div class=""><br class=""></div><div class="">Hope that helps,</div><div class=""><br class=""></div><div class="">Dave</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 30, 2020, at 7:15 PM, Connor Davis via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello all,<br class=""><br class="">Is it possible to determine if a CallExpr will be evaluated<br class="">at compile time from clang-tidy? I notice some references to<br class="">InConstantContext in the EvaluateAs* functions in ExprConstant.cpp,<br class="">but I'm not sure if that is applicable/usable from clang-tidy.<br class=""><br class="">Thanks,<br class="">Connor Davis<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></div></blockquote></div><br class=""></div></body></html>