Skip to content

Commit 882ef91

Browse files
committed
[Macros] Separate iteration over attributes from adding those attributes elsewhere
This is an intrusive linked list, so such operations can introduce unfortunate behavior like... infinite looping.
1 parent 133c936 commit 882ef91

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Sema/TypeCheckMacros.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,9 @@ bool swift::expandAttributes(CustomAttr *attr, MacroDecl *macro, Decl *member) {
10731073
TypeChecker::typeCheckDecl(decl);
10741074

10751075
// Add the new attributes to the semantic attribute list.
1076-
for (auto *attr : decl->getAttrs()) {
1076+
SmallVector<DeclAttribute *, 2> attrs(decl->getAttrs().begin(),
1077+
decl->getAttrs().end());
1078+
for (auto *attr : attrs) {
10771079
addedAttributes = true;
10781080
member->getAttrs().add(attr);
10791081
}

0 commit comments

Comments
 (0)