================
@@ -19,11 +19,37 @@
#include "CIRGenCleanup.h"
#include "CIRGenFunction.h"
+#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/CIR/MissingFeatures.h"
using namespace clang;
using namespace clang::CIRGen;
+namespace {
+/// Return true if the expression tree contains an AbstractConditionalOperator
+/// (ternary ?:), which is the only construct whose CIR codegen calls
+/// ConditionalEvaluation::beginEvaluation() and thus causes cleanups to be
+/// deferred via pushFullExprCleanup. Logical &&/|| do NOT call
+/// beginEvaluation(); their branch-local cleanups are handled by LexicalScope.
+class ConditionalEvaluationFinder
----------------
bcardosolopes wrote:
An alternative solution would be to create the CleanupScopeOp lazily, something
like:
1. enterFullExprCleanupScope — just save the current insertion point (the
"marker"), no AST walk
2. Normal codegen proceeds, ops emitted into the parent block
3. If pushFullExprCleanup is called while isInConditionalBranch(), create the
CleanupScopeOp at the saved marker position and splice all ops between the
marker and current position into the scope's body region.
Reads like surgery, and not 100% sure it works with all cases but could be an
alternative.
https://github.com/llvm/llvm-project/pull/191479
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits