Skip to content

[InstallAPI] Collect C++ Decls #84403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions clang/include/clang/InstallAPI/Visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/ADT/Twine.h"

namespace clang {
struct AvailabilityInfo;
namespace installapi {

/// ASTVisitor for collecting declarations that represent global symbols.
Expand All @@ -33,6 +34,7 @@ class InstallAPIVisitor final : public ASTConsumer,
MC(ItaniumMangleContext::create(ASTCtx, ASTCtx.getDiagnostics())),
Layout(ASTCtx.getTargetInfo().getDataLayoutString()) {}
void HandleTranslationUnit(ASTContext &ASTCtx) override;
bool shouldVisitTemplateInstantiations() const { return true; }

/// Collect global variables.
bool VisitVarDecl(const VarDecl *D);
Expand All @@ -51,16 +53,28 @@ class InstallAPIVisitor final : public ASTConsumer,
/// is therefore itself not collected.
bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D);

/// Collect global c++ declarations.
bool VisitCXXRecordDecl(const CXXRecordDecl *D);

private:
std::string getMangledName(const NamedDecl *D) const;
std::string getBackendMangledName(llvm::Twine Name) const;
std::string getMangledCXXVTableName(const CXXRecordDecl *D) const;
std::string getMangledCXXThunk(const GlobalDecl &D,
const ThunkInfo &Thunk) const;
std::string getMangledCXXRTTI(const CXXRecordDecl *D) const;
std::string getMangledCXXRTTIName(const CXXRecordDecl *D) const;
std::string getMangledCtorDtor(const CXXMethodDecl *D, int Type) const;

std::optional<HeaderType> getAccessForDecl(const NamedDecl *D) const;
void recordObjCInstanceVariables(
const ASTContext &ASTCtx, llvm::MachO::ObjCContainerRecord *Record,
StringRef SuperClass,
const llvm::iterator_range<
DeclContext::specific_decl_iterator<ObjCIvarDecl>>
Ivars);
void emitVTableSymbols(const CXXRecordDecl *D, const AvailabilityInfo &Avail,
const HeaderType Access, bool EmittedVTable = false);

InstallAPIContext &Ctx;
SourceManager &SrcMgr;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/InstallAPI/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ std::unique_ptr<MemoryBuffer> createInputBuffer(InstallAPIContext &Ctx) {
else
OS << "#import ";
if (H.useIncludeName())
OS << "<" << H.getIncludeName() << ">";
OS << "<" << H.getIncludeName() << ">\n";
else
OS << "\"" << H.getPath() << "\"";
OS << "\"" << H.getPath() << "\"\n";

Ctx.addKnownHeader(H);
}
Expand Down
Loading