Skip to content

Commit

Permalink
Revert ExtractAPI from https://reviews.llvm.org/D146656
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-grumberg committed Mar 27, 2023
1 parent 767aee1 commit 158a431
Show file tree
Hide file tree
Showing 10 changed files with 696 additions and 832 deletions.
604 changes: 12 additions & 592 deletions clang/include/clang/ExtractAPI/ExtractAPIVisitor.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clang/lib/ExtractAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_clang_library(clangExtractAPI
APIIgnoresList.cpp
AvailabilityInfo.cpp
ExtractAPIConsumer.cpp
ExtractAPIVisitor.cpp
DeclarationFragments.cpp
Serialization/SerializerBase.cpp
Serialization/SymbolGraphSerializer.cpp
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/ExtractAPI/DeclarationFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//

#include "clang/ExtractAPI/DeclarationFragments.h"
#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
#include "TypedefUnderlyingTypeResolver.h"
#include "clang/Index/USRGeneration.h"
#include "llvm/ADT/StringSwitch.h"

Expand Down
30 changes: 2 additions & 28 deletions clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
///
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTConcept.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Basic/DiagnosticFrontend.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
Expand All @@ -35,7 +33,6 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
Expand Down Expand Up @@ -222,42 +219,19 @@ struct LocationFileChecker {
llvm::DenseSet<const FileEntry *> ExternalFileEntries;
};

struct BatchExtractAPIVisitor : ExtractAPIVisitor<BatchExtractAPIVisitor> {
bool shouldDeclBeIncluded(const Decl *D) const {
bool ShouldBeIncluded = true;
// Check that we have the definition for redeclarable types.
if (auto *TD = llvm::dyn_cast<TagDecl>(D))
ShouldBeIncluded = TD->isThisDeclarationADefinition();
else if (auto *Interface = llvm::dyn_cast<ObjCInterfaceDecl>(D))
ShouldBeIncluded = Interface->isThisDeclarationADefinition();
else if (auto *Protocol = llvm::dyn_cast<ObjCProtocolDecl>(D))
ShouldBeIncluded = Protocol->isThisDeclarationADefinition();

ShouldBeIncluded = ShouldBeIncluded && LCF(D->getLocation());
return ShouldBeIncluded;
}

BatchExtractAPIVisitor(LocationFileChecker &LCF, ASTContext &Context,
APISet &API)
: ExtractAPIVisitor<BatchExtractAPIVisitor>(Context, API), LCF(LCF) {}

private:
LocationFileChecker &LCF;
};

class ExtractAPIConsumer : public ASTConsumer {
public:
ExtractAPIConsumer(ASTContext &Context,
std::unique_ptr<LocationFileChecker> LCF, APISet &API)
: Visitor(*LCF, Context, API), LCF(std::move(LCF)) {}
: Visitor(Context, *LCF, API), LCF(std::move(LCF)) {}

void HandleTranslationUnit(ASTContext &Context) override {
// Use ExtractAPIVisitor to traverse symbol declarations in the context.
Visitor.TraverseDecl(Context.getTranslationUnitDecl());
}

private:
BatchExtractAPIVisitor Visitor;
ExtractAPIVisitor Visitor;
std::unique_ptr<LocationFileChecker> LCF;
};

Expand Down

0 comments on commit 158a431

Please sign in to comment.