aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 5833a64..a099e97 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -396,6 +396,16 @@ SourceLocation CXXPseudoDestructorExpr::getEndLoc() const {
return End;
}
+static bool UnresolvedLookupExprIsVariableOrConceptParameterPack(
+ UnresolvedSetIterator Begin, UnresolvedSetIterator End) {
+ if (std::distance(Begin, End) != 1)
+ return false;
+ NamedDecl *ND = *Begin;
+ if (const auto *TTP = llvm::dyn_cast<TemplateTemplateParmDecl>(ND))
+ return TTP->isParameterPack();
+ return false;
+}
+
// UnresolvedLookupExpr
UnresolvedLookupExpr::UnresolvedLookupExpr(
const ASTContext &Context, CXXRecordDecl *NamingClass,
@@ -404,9 +414,11 @@ UnresolvedLookupExpr::UnresolvedLookupExpr(
const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin,
UnresolvedSetIterator End, bool KnownDependent,
bool KnownInstantiationDependent)
- : OverloadExpr(UnresolvedLookupExprClass, Context, QualifierLoc,
- TemplateKWLoc, NameInfo, TemplateArgs, Begin, End,
- KnownDependent, KnownInstantiationDependent, false),
+ : OverloadExpr(
+ UnresolvedLookupExprClass, Context, QualifierLoc, TemplateKWLoc,
+ NameInfo, TemplateArgs, Begin, End, KnownDependent,
+ KnownInstantiationDependent,
+ UnresolvedLookupExprIsVariableOrConceptParameterPack(Begin, End)),
NamingClass(NamingClass) {
UnresolvedLookupExprBits.RequiresADL = RequiresADL;
}
@@ -1714,8 +1726,8 @@ SizeOfPackExpr *SizeOfPackExpr::CreateDeserialized(ASTContext &Context,
return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs);
}
-NonTypeTemplateParmDecl *SubstNonTypeTemplateParmExpr::getParameter() const {
- return cast<NonTypeTemplateParmDecl>(
+NamedDecl *SubstNonTypeTemplateParmExpr::getParameter() const {
+ return cast<NamedDecl>(
getReplacedTemplateParameterList(getAssociatedDecl())->asArray()[Index]);
}
@@ -1758,9 +1770,12 @@ QualType SubstNonTypeTemplateParmExpr::getParameterType(
const ASTContext &Context) const {
// Note that, for a class type NTTP, we will have an lvalue of type 'const
// T', so we can't just compute this from the type and value category.
+
+ QualType Type = getType();
+
if (isReferenceParameter())
- return Context.getLValueReferenceType(getType());
- return getType().getUnqualifiedType();
+ return Context.getLValueReferenceType(Type);
+ return Type.getUnqualifiedType();
}
SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
@@ -1997,9 +2012,10 @@ CXXFoldExpr::CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee,
NumExpansions(NumExpansions) {
CXXFoldExprBits.Opcode = Opcode;
// We rely on asserted invariant to distinguish left and right folds.
- assert(((LHS && LHS->containsUnexpandedParameterPack()) !=
- (RHS && RHS->containsUnexpandedParameterPack())) &&
- "Exactly one of LHS or RHS should contain an unexpanded pack");
+ if (LHS && RHS)
+ assert(LHS->containsUnexpandedParameterPack() !=
+ RHS->containsUnexpandedParameterPack() &&
+ "Exactly one of LHS or RHS should contain an unexpanded pack");
SubExprs[SubExpr::Callee] = Callee;
SubExprs[SubExpr::LHS] = LHS;
SubExprs[SubExpr::RHS] = RHS;