aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
diff options
context:
space:
mode:
authorDaniel Grumberg <dgrumberg@apple.com>2022-03-16 13:38:54 +0000
committerDaniel Grumberg <dgrumberg@apple.com>2022-03-23 16:34:08 +0000
commit5ef2ec7e4e129cb9a1d9e688fbf8590a85f01530 (patch)
tree9caca4ea73b2ec2d9c39edc9953511bf49d684b1 /clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
parent2da5c5781e5a833f52a47752d76423bbb7bcf1a1 (diff)
downloadllvm-5ef2ec7e4e129cb9a1d9e688fbf8590a85f01530.zip
llvm-5ef2ec7e4e129cb9a1d9e688fbf8590a85f01530.tar.gz
llvm-5ef2ec7e4e129cb9a1d9e688fbf8590a85f01530.tar.bz2
[clang][extract-api] Suppprt for the module name property in SymbolGraph
Adds `--product-name=` flag to the clang driver. This gets forwarded to cc1 only when we are performing a ExtractAPI Action. This is used to populate the `name` field of the module object in the generated SymbolGraph. Differential Revision: https://reviews.llvm.org/D122141
Diffstat (limited to 'clang/lib/ExtractAPI/ExtractAPIConsumer.cpp')
-rw-r--r--clang/lib/ExtractAPI/ExtractAPIConsumer.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index c469f56..754c3c1 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -183,8 +183,9 @@ private:
class ExtractAPIConsumer : public ASTConsumer {
public:
- ExtractAPIConsumer(ASTContext &Context, std::unique_ptr<raw_pwrite_stream> OS)
- : Visitor(Context), OS(std::move(OS)) {}
+ ExtractAPIConsumer(ASTContext &Context, StringRef ProductName,
+ std::unique_ptr<raw_pwrite_stream> OS)
+ : Visitor(Context), ProductName(ProductName), OS(std::move(OS)) {}
void HandleTranslationUnit(ASTContext &Context) override {
// Use ExtractAPIVisitor to traverse symbol declarations in the context.
@@ -193,12 +194,13 @@ public:
// Setup a SymbolGraphSerializer to write out collected API information in
// the Symbol Graph format.
// FIXME: Make the kind of APISerializer configurable.
- SymbolGraphSerializer SGSerializer(Visitor.getAPI());
+ SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
SGSerializer.serialize(*OS);
}
private:
ExtractAPIVisitor Visitor;
+ std::string ProductName;
std::unique_ptr<raw_pwrite_stream> OS;
};
@@ -209,8 +211,9 @@ ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::unique_ptr<raw_pwrite_stream> OS = CreateOutputFile(CI, InFile);
if (!OS)
return nullptr;
- return std::make_unique<ExtractAPIConsumer>(CI.getASTContext(),
- std::move(OS));
+ return std::make_unique<ExtractAPIConsumer>(
+ CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
+ std::move(OS));
}
std::unique_ptr<raw_pwrite_stream>