================
@@ -125,3 +126,155 @@ 
CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args)
       Args.ReturnStmtOnAllocFailure;
   llvm::copy(Args.ParamMoves, const_cast<Stmt **>(getParamMoves().data()));
 }
+
+CXXExpansionStmtPattern::CXXExpansionStmtPattern(StmtClass SC, EmptyShell 
Empty)
+    : Stmt(SC, Empty) {}
+
+CXXExpansionStmtPattern::CXXExpansionStmtPattern(
+    StmtClass SC, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt 
*ExpansionVar,
+
+    SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation 
RParenLoc)
+    : Stmt(SC), ParentDecl(ESD), LParenLoc(LParenLoc), ColonLoc(ColonLoc),
+      RParenLoc(RParenLoc) {
+  setInit(Init);
+  setExpansionVarStmt(ExpansionVar);
+  setBody(nullptr);
+}
+
+CXXEnumeratingExpansionStmtPattern::CXXEnumeratingExpansionStmtPattern(
+    EmptyShell Empty)
+    : CXXExpansionStmtPattern(CXXEnumeratingExpansionStmtPatternClass, Empty) 
{}
+
+CXXEnumeratingExpansionStmtPattern::CXXEnumeratingExpansionStmtPattern(
+    CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar,
+    SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation 
RParenLoc)
+    : CXXExpansionStmtPattern(CXXEnumeratingExpansionStmtPatternClass, ESD,
+                              Init, ExpansionVar, LParenLoc, ColonLoc,
+                              RParenLoc) {}
+
+SourceLocation CXXExpansionStmtPattern::getBeginLoc() const {
+  return ParentDecl->getLocation();
+}
+
+VarDecl *CXXExpansionStmtPattern::getExpansionVariable() {
+  Decl *LV = cast<DeclStmt>(getExpansionVarStmt())->getSingleDecl();
+  assert(LV && "No expansion variable in CXXExpansionStmtPattern");
+  return cast<VarDecl>(LV);
+}
+
+bool CXXExpansionStmtPattern::hasDependentSize() const {
+  if (isa<CXXEnumeratingExpansionStmtPattern>(this))
+    return cast<CXXExpansionInitListSelectExpr>(
+               getExpansionVariable()->getInit())
+        ->getRangeExpr()
+        ->containsPackExpansion();
+
+  if (auto *Iterating = dyn_cast<CXXIteratingExpansionStmtPattern>(this)) {
+    const Expr *Begin = Iterating->getBeginVar()->getInit();
+    const Expr *End = Iterating->getBeginVar()->getInit();
+    return Begin->isTypeDependent() || Begin->isValueDependent() ||
----------------
erichkeane wrote:

>Not in the general case I believe (e.g. sizeof(T)` is not type-dependent 
>afaik, only value-dependent), but here yeah, you’re probably right, and I 
>think we only care about type-dependence here.

Right, you can be JUST value dependent, but you can't be JUST type dependent.

>Shouldn’t we check for type dependence specifically? Because as I understand 
>it it’s possible for this to be instantiation-dependent even if the type is 
>known (and potentially the value too), in which case we still want to 
>instantiate it? Maybe I’m just overthinking this and those are hypothetical 
>scenarios that we don’t care too much about though...

It depends on how much we CARE about the individual situations.  We often just 
do `instantiation dependent` and figure we'll lose a few early errors, at the 
guarantee of making sure we get it 'right'.

https://github.com/llvm/llvm-project/pull/169680
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to