[PrintAsClang] NFC, refactor primitive type mapping logic out from DeclAndTypePrinter

This will allow us to use type mappings in the C ABI function printer.
This commit is contained in:
Alex Lorenz
2022-03-18 14:38:46 -07:00
parent 80bc75ab9b
commit 86f9162606
6 changed files with 191 additions and 114 deletions

View File

@@ -15,6 +15,7 @@
#include "CxxSynthesis.h"
#include "DeclAndTypePrinter.h"
#include "OutputLanguageMode.h"
#include "PrimitiveTypeMapping.h"
#include "swift/AST/ExistentialLayout.h"
#include "swift/AST/Module.h"
@@ -123,6 +124,7 @@ class ModuleWriter {
llvm::DenseMap<const TypeDecl *, std::pair<EmissionState, bool>> seenTypes;
std::vector<const Decl *> declsToWrite;
DelayedMemberSet delayedMembers;
PrimitiveTypeMapping typeMapping;
DeclAndTypePrinter printer;
OutputLanguageMode outputLangMode;
@@ -131,7 +133,8 @@ public:
llvm::SmallPtrSetImpl<ImportModuleTy> &imports, ModuleDecl &mod,
AccessLevel access, OutputLanguageMode outputLang)
: os(os), imports(imports), M(mod),
printer(M, os, prologueOS, delayedMembers, access, outputLang),
printer(M, os, prologueOS, delayedMembers, typeMapping, access,
outputLang),
outputLangMode(outputLang) {}
/// Returns true if we added the decl's module to the import set, false if