[all-commits] [llvm/llvm-project] 10d85d: [C++20] [Modules] Pop Expression Evaluation Contex...
Chuanqi Xu via All-commits
all-commits at lists.llvm.org
Thu Feb 2 18:28:07 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 10d85dc75468074d2aceb1a648125167128d6f25
https://github.com/llvm/llvm-project/commit/10d85dc75468074d2aceb1a648125167128d6f25
Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
Date: 2023-02-03 (Fri, 03 Feb 2023)
Changed paths:
M clang/lib/Parse/Parser.cpp
A clang/test/Modules/pr60275.cppm
Log Message:
-----------
[C++20] [Modules] Pop Expression Evaluation Context when we skip its body during parsing
Close https://github.com/llvm/llvm-project/issues/60275
The root cause of issue 60275 is the imbalance of
PushExpressionEvaluationContext() and PopExpressionEvaluationContext().
See
https://github.com/llvm/llvm-project/blob/f1c4f927f7c15b5efdc3589c050fd0513bf6b303/clang/lib/Parse/Parser.cpp#L1396-L1437
We will PushExpressionEvaluationContext() in ActOnStartOfFunctionDef()
in line 1396 and we should pop it in ActOnFinishFunctionBody later.
However if we skip the function body in line 1402, the expression
evaluation context will not be popped. Then here is the issue report. I
fix the issue by inserting codes to pop the expression evaluation
context explicitly if the function body is skipped. Maybe this looks
like an ad-hoc fix. But if we want to fix this in a pretty way, we
should refactor the current framework for pushing and popping expression
evaluation contexts. Currently there are 23
PushExpressionEvaluationContext() callsities and 21
PopExpressionEvaluationContext() callsites in the code. And it seems not
easy to balance them well and fast. So I suggest to land this fix first.
At least it can prevent the crash.
Reviewed By: cor3ntin
Differential Revision: https://reviews.llvm.org/D143053
More information about the All-commits
mailing list