summaryrefslogtreecommitdiff
path: root/clang/include
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <ashaposhnikov@google.com>2023-05-09 18:14:39 +0000
committerAlexander Shaposhnikov <ashaposhnikov@google.com>2023-05-09 18:14:39 +0000
commit6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b (patch)
tree3384f767e0cbb5872c0ba83c5cccfe42fc411c4e /clang/include
parente305dcc6fdc7e0efc0de4091a49386923e3845b4 (diff)
downloadllvm-6db007a0654ed7a6ed5c3aa3b61a937c19a6bc6b.tar.gz
[Clang][Sema] Fix comparison of constraint expressions
This diff switches the approach to comparison of constraint expressions to the new one based on template args substitution. It continues the effort to fix our handling of out-of-line definitions of constrained templates. This is a recommit of 3a54022934. Differential revision: https://reviews.llvm.org/D146178
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/DeclTemplate.h6
-rw-r--r--clang/include/clang/Sema/Template.h18
2 files changed, 21 insertions, 3 deletions
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 3677335fa176..7cd505218f2b 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2309,9 +2309,15 @@ protected:
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
}
+ void setCommonPtr(Common *C) {
+ RedeclarableTemplateDecl::Common = C;
+ }
+
public:
+
friend class ASTDeclReader;
friend class ASTDeclWriter;
+ friend class TemplateDeclInstantiator;
/// Load any lazily-loaded specializations from the external source.
void LoadLazySpecializations() const;
diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h
index 48e8b78311e1..1de2cc6917b4 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -232,9 +232,21 @@ enum class TemplateSubstitutionKind : char {
/// Replaces the current 'innermost' level with the provided argument list.
/// This is useful for type deduction cases where we need to get the entire
/// list from the AST, but then add the deduced innermost list.
- void replaceInnermostTemplateArguments(ArgList Args) {
- assert(TemplateArgumentLists.size() > 0 && "Replacing in an empty list?");
- TemplateArgumentLists[0].Args = Args;
+ void replaceInnermostTemplateArguments(Decl *AssociatedDecl, ArgList Args) {
+ assert((!TemplateArgumentLists.empty() || NumRetainedOuterLevels) &&
+ "Replacing in an empty list?");
+
+ if (!TemplateArgumentLists.empty()) {
+ assert((TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ||
+ TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ==
+ AssociatedDecl) &&
+ "Trying to change incorrect declaration?");
+ TemplateArgumentLists[0].Args = Args;
+ } else {
+ --NumRetainedOuterLevels;
+ TemplateArgumentLists.push_back(
+ {{AssociatedDecl, /*Final=*/false}, Args});
+ }
}
/// Add an outermost level that we are not substituting. We have no