Migrate DeclStmt over to using a DeclGroup instead of a pointer to a ScopedDecl*.
This also removes the ugly hack needed in CFG.cpp for subclassing DeclStmt to create a DeclStmt with one Decl*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57275 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 68b36ba..f75758e 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -42,7 +42,28 @@
return true;
ScopedDecl *SD = cast<ScopedDecl>(static_cast<Decl *>(decl));
- return new DeclStmt(SD, StartLoc, EndLoc);
+
+
+ // This is a temporary hack until we are always passing around
+ // DeclGroupRefs.
+ llvm::SmallVector<Decl*, 10> decls;
+ while (SD) {
+ ScopedDecl* d = SD;
+ SD = SD->getNextDeclarator();
+ d->setNextDeclarator(0);
+ decls.push_back(d);
+ }
+
+ assert (!decls.empty());
+
+ if (decls.size() == 1) {
+ DeclGroupOwningRef DG(*decls.begin());
+ return new DeclStmt(DG, StartLoc, EndLoc);
+ }
+ else {
+ DeclGroupOwningRef DG(DeclGroup::Create(Context, decls.size(), &decls[0]));
+ return new DeclStmt(DG, StartLoc, EndLoc);
+ }
}
Action::StmtResult