https://github.com/hazohelet updated https://github.com/llvm/llvm-project/pull/66954
>From 74b06739e7309798e53110307bfe0abb9bd5b649 Mon Sep 17 00:00:00 2001 From: Takuya Shimizu <shimizu2...@gmail.com> Date: Thu, 21 Sep 2023 06:27:55 +0900 Subject: [PATCH 1/2] [clang][Sema] Fix crash introduced in b2cd9db Old iterator is invalidaed upon SmallVector elements additions. Stores index instead of iterator to avoid this. Fixes https://github.com/llvm/llvm-project/issues/66938 --- clang/lib/Sema/SemaConcept.cpp | 7 +++++-- clang/test/SemaTemplate/concepts.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index dacdd07c8069950..80788f04e2241c5 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -185,7 +185,7 @@ calculateConstraintSatisfaction(Sema &S, const Expr *ConstraintExpr, ConstraintExpr = ConstraintExpr->IgnoreParenImpCasts(); if (LogicalBinOp BO = ConstraintExpr) { - auto EffectiveDetailEnd = Satisfaction.Details.end(); + size_t EffectiveDetailEndIndex = Satisfaction.Details.size(); ExprResult LHSRes = calculateConstraintSatisfaction( S, BO.getLHS(), Satisfaction, Evaluator); @@ -228,9 +228,12 @@ calculateConstraintSatisfaction(Sema &S, const Expr *ConstraintExpr, // The following code removes the irrelevant diagnostic information. // FIXME: We should probably delay the addition of diagnostic information // until we know the entire expression is false. - if (BO.isOr() && IsRHSSatisfied) + if (BO.isOr() && IsRHSSatisfied) { + auto EffectiveDetailEnd = + Satisfaction.Details.begin() + EffectiveDetailEndIndex; Satisfaction.Details.erase(EffectiveDetailEnd, Satisfaction.Details.end()); + } return BO.recreateBinOp(S, LHSRes, RHSRes); } diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 68050e0f09e248a..e98ebcc9203a430 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1048,3 +1048,19 @@ namespace GH66612 { // expected-note@-1{{because 'int' does not satisfy 'Container'}} // expected-note@#66612GH_END{{because 'end' would be invalid: reference to overloaded function could not be resolved; did you mean to call it?}} } + +namespace GH66938 { +template <class> +concept True = true; + +template <class> +concept False = false; + +template <class T> +void cand(T t) + requires False<T> || False<T> || False<T> || False<T> || False<T> || + False<T> || False<T> || False<T> || False<T> || True<T> +{} + +void test() { cand(42); } +} >From f60bddd47003aa2c7791ac99e50aa718995e4b37 Mon Sep 17 00:00:00 2001 From: Takuya Shimizu <shimizu2...@gmail.com> Date: Thu, 21 Sep 2023 06:41:06 +0900 Subject: [PATCH 2/2] Address comments from erichkeane --- clang/lib/Sema/SemaConcept.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 80788f04e2241c5..036548b68247bfa 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -229,8 +229,8 @@ calculateConstraintSatisfaction(Sema &S, const Expr *ConstraintExpr, // FIXME: We should probably delay the addition of diagnostic information // until we know the entire expression is false. if (BO.isOr() && IsRHSSatisfied) { - auto EffectiveDetailEnd = - Satisfaction.Details.begin() + EffectiveDetailEndIndex; + auto EffectiveDetailEnd = Satisfaction.Details.begin(); + std::advance(EffectiveDetailEnd, EffectiveDetailEndIndex); Satisfaction.Details.erase(EffectiveDetailEnd, Satisfaction.Details.end()); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits