aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
diff options
context:
space:
mode:
authorZixu Wang <zixu_wang@apple.com>2022-03-25 11:43:44 -0700
committerZixu Wang <zixu_wang@apple.com>2022-03-29 10:06:08 -0700
commit15bf0e567375c977cf7d7b48465eb1561e890b54 (patch)
tree15278bfbd9173bd90a16b3c6723412ce7613d55b /clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
parentef6f7c4a60836b052a0c6d995280d19eafa31b39 (diff)
downloadllvm-15bf0e567375c977cf7d7b48465eb1561e890b54.zip
llvm-15bf0e567375c977cf7d7b48465eb1561e890b54.tar.gz
llvm-15bf0e567375c977cf7d7b48465eb1561e890b54.tar.bz2
[clang][extract-api] Use correct language info from inputs
The current way of getting the `clang::Language` from `LangOptions` does not handle Objective-C correctly because `clang::Language::ObjC` does not correspond to any `LangStandard`. This patch passes the correct `Language` from the frontend input information. Differential Revision: https://reviews.llvm.org/D122495
Diffstat (limited to 'clang/lib/ExtractAPI/ExtractAPIConsumer.cpp')
-rw-r--r--clang/lib/ExtractAPI/ExtractAPIConsumer.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index 0636e6d..dc3e067 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -41,9 +41,8 @@ namespace {
/// information.
class ExtractAPIVisitor : public RecursiveASTVisitor<ExtractAPIVisitor> {
public:
- explicit ExtractAPIVisitor(ASTContext &Context)
- : Context(Context),
- API(Context.getTargetInfo().getTriple(), Context.getLangOpts()) {}
+ ExtractAPIVisitor(ASTContext &Context, Language Lang)
+ : Context(Context), API(Context.getTargetInfo().getTriple(), Lang) {}
const APISet &getAPI() const { return API; }
@@ -309,9 +308,9 @@ private:
class ExtractAPIConsumer : public ASTConsumer {
public:
- ExtractAPIConsumer(ASTContext &Context, StringRef ProductName,
+ ExtractAPIConsumer(ASTContext &Context, StringRef ProductName, Language Lang,
std::unique_ptr<raw_pwrite_stream> OS)
- : Visitor(Context), ProductName(ProductName), OS(std::move(OS)) {}
+ : Visitor(Context, Lang), ProductName(ProductName), OS(std::move(OS)) {}
void HandleTranslationUnit(ASTContext &Context) override {
// Use ExtractAPIVisitor to traverse symbol declarations in the context.
@@ -339,6 +338,7 @@ ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return nullptr;
return std::make_unique<ExtractAPIConsumer>(
CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
+ CI.getFrontendOpts().Inputs.back().getKind().getLanguage(),
std::move(OS));
}