Index: cfe/trunk/include/clang/Frontend/FrontendActions.h =================================================================== --- cfe/trunk/include/clang/Frontend/FrontendActions.h +++ cfe/trunk/include/clang/Frontend/FrontendActions.h @@ -139,6 +139,12 @@ StringRef InFile) override; }; +class GenerateInterfaceIfsExpV1Action : public GenerateInterfaceStubAction { +protected: + std::unique_ptr CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override; +}; + class GenerateModuleFromModuleMapAction : public GenerateModuleAction { private: bool BeginSourceFileAction(CompilerInstance &CI) override; Index: cfe/trunk/include/clang/Frontend/FrontendOptions.h =================================================================== --- cfe/trunk/include/clang/Frontend/FrontendOptions.h +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h @@ -92,6 +92,7 @@ /// Generate Interface Stub Files. GenerateInterfaceYAMLExpV1, GenerateInterfaceTBEExpV1, + GenerateInterfaceIfsExpV1, /// Only execute frontend initialization. InitOnly, Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -3638,12 +3638,14 @@ : "") .Case("experimental-yaml-elf-v1", "experimental-yaml-elf-v1") .Case("experimental-tapi-elf-v1", "experimental-tapi-elf-v1") + .Case("experimental-ifs-v1", "experimental-ifs-v1") .Default(""); if (StubFormat.empty()) D.Diag(diag::err_drv_invalid_value) << "Must specify a valid interface stub format type using " << "-interface-stub-version="; CmdArgs.push_back("-emit-interface-stubs"); Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp =================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -1737,11 +1737,14 @@ frontend::GenerateInterfaceYAMLExpV1) .Case("experimental-tapi-elf-v1", frontend::GenerateInterfaceTBEExpV1) + .Case("experimental-ifs-v1", + frontend::GenerateInterfaceIfsExpV1) .Default(llvm::None); if (!ProgramAction) Diags.Report(diag::err_drv_invalid_value) << "Must specify a valid interface stub format type using " << "-interface-stub-version="; Opts.ProgramAction = *ProgramAction; break; @@ -3185,6 +3188,7 @@ case frontend::GeneratePCH: case frontend::GenerateInterfaceYAMLExpV1: case frontend::GenerateInterfaceTBEExpV1: + case frontend::GenerateInterfaceIfsExpV1: case frontend::ParseSyntaxOnly: case frontend::ModuleFileInfo: case frontend::VerifyPCH: Index: cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp =================================================================== --- cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -354,9 +354,55 @@ OS.flush(); }; + auto writeIfsV1 = + [this](const llvm::Triple &T, const MangledSymbols &Symbols, + const ASTContext &context, StringRef Format, + raw_ostream &OS) -> void { + OS << "--- !" << Format << "\n"; + OS << "IfsVersion: 1.0\n"; + OS << "Triple: " << T.str() << "\n"; + OS << "ObjectFileFormat: " << "ELF" << "\n"; // TODO: For now, just ELF. + OS << "Symbols:\n"; + for (const auto &E : Symbols) { + const MangledSymbol &Symbol = E.second; + for (auto Name : Symbol.Names) { + OS << " " + << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus + ? "" + : (Symbol.ParentName + ".")) + << Name << ": { Type: "; + switch (Symbol.Type) { + default: + llvm_unreachable( + "clang -emit-iterface-stubs: Unexpected symbol type."); + case llvm::ELF::STT_NOTYPE: + OS << "NoType"; + break; + case llvm::ELF::STT_OBJECT: { + auto VD = cast(E.first)->getType(); + OS << "Object, Size: " + << context.getTypeSizeInChars(VD).getQuantity(); + break; + } + case llvm::ELF::STT_FUNC: + OS << "Func"; + break; + } + if (Symbol.Binding == llvm::ELF::STB_WEAK) + OS << ", Weak: true"; + OS << " }\n"; + } + } + OS << "...\n"; + OS.flush(); + }; + if (Format == "experimental-yaml-elf-v1") writeIfoYaml(Instance.getTarget().getTriple(), Symbols, context, Format, *OS); + else if (Format == "experimental-ifs-v1") + writeIfsV1(Instance.getTarget().getTriple(), Symbols, context, Format, + *OS); else writeIfoElfAbiYaml(Instance.getTarget().getTriple(), Symbols, context, Format, *OS); @@ -376,3 +422,10 @@ return std::make_unique( CI, InFile, "experimental-tapi-elf-v1"); } + +std::unique_ptr +GenerateInterfaceIfsExpV1Action::CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) { + return std::make_unique( + CI, InFile, "experimental-ifs-v1"); +} Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -68,6 +68,8 @@ return std::make_unique(); case GenerateInterfaceTBEExpV1: return std::make_unique(); + case GenerateInterfaceIfsExpV1: + return std::make_unique(); case InitOnly: return std::make_unique(); case ParseSyntaxOnly: return std::make_unique(); case ModuleFileInfo: return std::make_unique();