[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 23 09:47:12 PDT 2023


Fznamznon added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:17979
+  if (Rec.ImmediateInvocationCandidates.size() > 1 ||
+      SemaRef.FailedImmediateInvocations.size()) {
 
----------------
cor3ntin wrote:
> Shouln't we clear `FailedImmediateInvocations` at the end of a full expression to avoid going there if there was an error in another expression
The idea sounds reasonable, but I'm not sure it can work with current algorithm of handling immediate invocations. Immediate invocations are handled when expression evaluation context is popped, so we need to remember previously failed immediate invocations until then, even though they could happen in two different full expressions. 

```
consteval foo() { ... }
void bar() {
  int a = foo(/* there might be a failed immediate invocation attached to initializer context */); // this is a full-expression
  int b = foo(); // this is another full-expression
} // This is where immediate invocations that appear in function context are processed
```


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