[cxx-interop] Emit C++ declarations only when '-clang-header-expose-public-decl' is enabled

This fix also ensures that we only emit C++ functions for now
This commit is contained in:
Alex Lorenz
2022-03-20 20:22:02 -07:00
parent 2e3aa87737
commit 80bc75ab9b
14 changed files with 43 additions and 21 deletions

View File

@@ -124,13 +124,15 @@ class ModuleWriter {
std::vector<const Decl *> declsToWrite;
DelayedMemberSet delayedMembers;
DeclAndTypePrinter printer;
OutputLanguageMode outputLangMode;
public:
ModuleWriter(raw_ostream &os, raw_ostream &prologueOS,
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, access, outputLang),
outputLangMode(outputLang) {}
/// Returns true if we added the decl's module to the import set, false if
/// the decl is a local decl.
@@ -576,7 +578,11 @@ public:
const Decl *D = declsToWrite.back();
bool success = true;
if (isa<ValueDecl>(D)) {
if (outputLangMode == OutputLanguageMode::Cxx) {
if (auto FD = dyn_cast<FuncDecl>(D))
success = writeFunc(FD);
// FIXME: Warn on unsupported exported decl.
} else if (isa<ValueDecl>(D)) {
if (auto CD = dyn_cast<ClassDecl>(D))
success = writeClass(CD);
else if (auto PD = dyn_cast<ProtocolDecl>(D))