Skip to content

[clang][Sema] Fix crash introduced in b2cd9db589335d5885c04df83003a623cf2f05ff #66954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
std::advance(EffectiveDetailEnd, EffectiveDetailEndIndex);
Satisfaction.Details.erase(EffectiveDetailEnd,
Satisfaction.Details.end());
}

return BO.recreateBinOp(S, LHSRes, RHSRes);
}
Expand Down
16 changes: 16 additions & 0 deletions clang/test/SemaTemplate/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
}