aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp')
-rw-r--r--clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index 970f885..cb597c4 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -354,9 +354,55 @@ public:
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<ValueDecl>(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 @@ GenerateInterfaceTBEExpV1Action::CreateASTConsumer(CompilerInstance &CI,
return std::make_unique<InterfaceStubFunctionsConsumer>(
CI, InFile, "experimental-tapi-elf-v1");
}
+
+std::unique_ptr<ASTConsumer>
+GenerateInterfaceIfsExpV1Action::CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
+ return std::make_unique<InterfaceStubFunctionsConsumer>(
+ CI, InFile, "experimental-ifs-v1");
+}