@@ -1255,6 +1255,7 @@ class swift::MemberLookupTable : public ASTAllocated<swift::MemberLookupTable> {
1255
1255
}
1256
1256
1257
1257
bool isLazilyCompleteForMacroExpansion (DeclName name) const {
1258
+ assert (!MacroDecl::isUniqueMacroName (name.getBaseName ()));
1258
1259
// If we've already expanded macros for a simple name, we must have expanded
1259
1260
// all macros that produce names with the same base identifier.
1260
1261
bool isBaseNameComplete = name.isCompoundName () &&
@@ -1264,6 +1265,7 @@ class swift::MemberLookupTable : public ASTAllocated<swift::MemberLookupTable> {
1264
1265
}
1265
1266
1266
1267
void markLazilyCompleteForMacroExpansion (DeclName name) {
1268
+ assert (!MacroDecl::isUniqueMacroName (name.getBaseName ()));
1267
1269
LazilyCompleteNamesForMacroExpansion.insert (name);
1268
1270
}
1269
1271
@@ -1521,6 +1523,17 @@ populateLookupTableEntryFromExtensions(ASTContext &ctx,
1521
1523
}
1522
1524
}
1523
1525
1526
+ // / Adjust the given name to make it a proper key for the lazy macro expansion
1527
+ // / cache, which maps all uniquely-generated names down to a single placeholder
1528
+ // / key.
1529
+ static DeclName adjustLazyMacroExpansionNameKey (
1530
+ ASTContext &ctx, DeclName name) {
1531
+ if (MacroDecl::isUniqueMacroName (name.getBaseName ()))
1532
+ return MacroDecl::getUniqueNamePlaceholder (ctx);
1533
+
1534
+ return name;
1535
+ }
1536
+
1524
1537
static void
1525
1538
populateLookupTableEntryFromMacroExpansions (ASTContext &ctx,
1526
1539
MemberLookupTable &table,
@@ -1756,9 +1769,11 @@ DirectLookupRequest::evaluate(Evaluator &evaluator,
1756
1769
Table.markLazilyComplete (baseName);
1757
1770
}
1758
1771
1759
- if (!Table.isLazilyCompleteForMacroExpansion (name)) {
1760
- populateLookupTableEntryFromMacroExpansions (ctx, Table, name, decl);
1761
- Table.markLazilyCompleteForMacroExpansion (name);
1772
+ DeclName macroExpansionKey = adjustLazyMacroExpansionNameKey (ctx, name);
1773
+ if (!Table.isLazilyCompleteForMacroExpansion (macroExpansionKey)) {
1774
+ populateLookupTableEntryFromMacroExpansions (
1775
+ ctx, Table, macroExpansionKey, decl);
1776
+ Table.markLazilyCompleteForMacroExpansion (macroExpansionKey);
1762
1777
}
1763
1778
1764
1779
// Look for a declaration with this name.
0 commit comments