[PATCH] D146234: [clang] Fix crash when handling nested immediate invocations

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 12:36:06 PDT 2023


Fznamznon added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:17897
+        if (SemaRef.FailedImmediateInvocations.contains(E))
+          CurrentII->setInt(1);
+      } else {
----------------
shafik wrote:
> It is not obvious to me why this is correct, can you please explain.
The visitor which this function is a part of traverses all subexpressions of a given ImmediateInvocationCandidate, it is saved to `CurrentII` member. Each ImmediateIvocationCandidate is a pair of integer and a pointer to ConstantExpr. The non-zero integer indicates that we should not try to evaluate particular immediate invocation. So, this patch, once found out that current expression contains a subexpression from another evaluation context whose evaluation failed before, marks that we shouldn't evaluate it to avoid double diagnosing. Otherwise, if some subexpression was found in the same context that current ImmediateInvocationCandidate belongs to, mark that we should not evaluate it instead, again to avoid double diagnosing. Hope that helps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146234



More information about the cfe-commits mailing list