aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaConcept.cpp
diff options
context:
space:
mode:
authorYounan Zhang <zyn7109@gmail.com>2024-07-17 19:17:01 +0800
committerGitHub <noreply@github.com>2024-07-17 19:17:01 +0800
commit440fffad7e7231fab766c6e00e47a39ad5a9b95e (patch)
treecaa0b409282ed263e93645b0526afe57065a687f /clang/lib/Sema/SemaConcept.cpp
parent8156be684da4c37b6191dab26d2eb5c2777be17d (diff)
downloadllvm-440fffad7e7231fab766c6e00e47a39ad5a9b95e.zip
llvm-440fffad7e7231fab766c6e00e47a39ad5a9b95e.tar.gz
llvm-440fffad7e7231fab766c6e00e47a39ad5a9b95e.tar.bz2
[Clang][Concepts] Avoid substituting into constraints for invalid TemplateDecls (#75697)
Fixes https://github.com/llvm/llvm-project/issues/73885. Substituting into constraints for invalid TemplateDecls might still yield dependent expressions and end up crashing later in evaluation.
Diffstat (limited to 'clang/lib/Sema/SemaConcept.cpp')
-rw-r--r--clang/lib/Sema/SemaConcept.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 84c5753..9e16b67 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -625,6 +625,12 @@ bool Sema::CheckConstraintSatisfaction(
*this, nullptr, ConstraintExprs, ConvertedConstraints,
TemplateArgsLists, TemplateIDRange, OutSatisfaction);
}
+ // Invalid templates could make their way here. Substituting them could result
+ // in dependent expressions.
+ if (Template->isInvalidDecl()) {
+ OutSatisfaction.IsSatisfied = false;
+ return true;
+ }
// A list of the template argument list flattened in a predictible manner for
// the purposes of caching. The ConstraintSatisfaction type is in AST so it