Skip to content

Commit e1cef4f

Browse files
authored
Merge pull request #41419 from beccadax/not-enough-bits
[NFC] 32-bit-safe ImportDiagnosticTarget
2 parents 0e4ddbd + f440c2d commit e1cef4f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

include/swift/ClangImporter/ClangImporter.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ class DWARFImporterDelegate {
110110
virtual void anchor();
111111
};
112112

113+
// ⚠️ DANGER ⚠️
114+
// Putting more than four types in this `PointerUnion` will break the build for
115+
// 32-bit hosts. If we need five or more types in the future, we'll need to
116+
// design a proper larger-than-word-sized type.
113117
typedef llvm::PointerUnion<const clang::Decl *, const clang::MacroInfo *,
114-
const clang::ModuleMacro *, const clang::Type *,
115-
const clang::Token *>
118+
const clang::Type *, const clang::Token *>
116119
ImportDiagnosticTarget;
117120

118121
/// Class that imports Clang modules into Swift, mapping directly

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,9 +4221,6 @@ void ClangImporter::Implementation::diagnoseTargetDirectly(
42214221
} else if (const clang::MacroInfo *macro =
42224222
target.dyn_cast<const clang::MacroInfo *>()) {
42234223
Walker.VisitMacro(macro);
4224-
} else if (const clang::ModuleMacro *macro =
4225-
target.dyn_cast<const clang::ModuleMacro *>()) {
4226-
Walker.VisitMacro(macro->getMacroInfo());
42274224
}
42284225
}
42294226

@@ -4237,7 +4234,7 @@ ClangImporter::Implementation::importDiagnosticTargetFromLookupTableEntry(
42374234
return macro;
42384235
} else if (const clang::ModuleMacro *macro =
42394236
entry.dyn_cast<clang::ModuleMacro *>()) {
4240-
return macro;
4237+
return macro->getMacroInfo();
42414238
}
42424239
llvm_unreachable("SwiftLookupTable::Single entry must be a NamedDecl, "
42434240
"MacroInfo or ModuleMacro pointer");

0 commit comments

Comments
 (0)