-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstallAPI] Break up headers and add common header for TextAPI types (…
…#84960) Before it gets too unwieldy, add a common header for all MachO types that are used across InstallAPI. Also, break up the types in `InstallAPI/Frontend`. This both avoids circular dependencies and is logically easier to maintain as more functionality gets added.
- Loading branch information
1 parent
4521970
commit a38b7a4
Showing
8 changed files
with
159 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
//===- InstallAPI/FrontendRecords.h ------------------------------*- C++-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H | ||
#define LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H | ||
|
||
#include "clang/AST/Availability.h" | ||
#include "clang/AST/DeclObjC.h" | ||
#include "clang/InstallAPI/MachO.h" | ||
|
||
namespace clang { | ||
namespace installapi { | ||
|
||
/// Frontend information captured about records. | ||
struct FrontendAttrs { | ||
const AvailabilityInfo Avail; | ||
const Decl *D; | ||
const HeaderType Access; | ||
}; | ||
|
||
// Represents a collection of frontend records for a library that are tied to a | ||
// darwin target triple. | ||
class FrontendRecordsSlice : public llvm::MachO::RecordsSlice { | ||
public: | ||
FrontendRecordsSlice(const llvm::Triple &T) | ||
: llvm::MachO::RecordsSlice({T}) {} | ||
|
||
/// Add non-ObjC global record with attributes from AST. | ||
/// | ||
/// \param Name The name of symbol. | ||
/// \param Linkage The linkage of symbol. | ||
/// \param GV The kind of global. | ||
/// \param Avail The availability information tied to the active target | ||
/// triple. | ||
/// \param D The pointer to the declaration from traversing AST. | ||
/// \param Access The intended access level of symbol. | ||
/// \param Flags The flags that describe attributes of the symbol. | ||
/// \param Inlined Whether declaration is inlined, only applicable to | ||
/// functions. | ||
/// \return The non-owning pointer to added record in slice. | ||
GlobalRecord *addGlobal(StringRef Name, RecordLinkage Linkage, | ||
GlobalRecord::Kind GV, | ||
const clang::AvailabilityInfo Avail, const Decl *D, | ||
const HeaderType Access, | ||
SymbolFlags Flags = SymbolFlags::None, | ||
bool Inlined = false); | ||
|
||
/// Add ObjC Class record with attributes from AST. | ||
/// | ||
/// \param Name The name of class, not symbol. | ||
/// \param Linkage The linkage of symbol. | ||
/// \param Avail The availability information tied to the active target | ||
/// triple. | ||
/// \param D The pointer to the declaration from traversing AST. | ||
/// \param Access The intended access level of symbol. | ||
/// \param IsEHType Whether declaration has an exception attribute. | ||
/// \return The non-owning pointer to added record in slice. | ||
ObjCInterfaceRecord *addObjCInterface(StringRef Name, RecordLinkage Linkage, | ||
const clang::AvailabilityInfo Avail, | ||
const Decl *D, HeaderType Access, | ||
bool IsEHType); | ||
|
||
/// Add ObjC Category record with attributes from AST. | ||
/// | ||
/// \param ClassToExtend The name of class that is extended by category, not | ||
/// symbol. | ||
/// \param CategoryName The name of category, not symbol. | ||
/// \param Avail The availability information tied | ||
/// to the active target triple. | ||
/// \param D The pointer to the declaration from traversing AST. | ||
/// \param Access The intended access level of symbol. | ||
/// \return The non-owning pointer to added record in slice. | ||
ObjCCategoryRecord *addObjCCategory(StringRef ClassToExtend, | ||
StringRef CategoryName, | ||
const clang::AvailabilityInfo Avail, | ||
const Decl *D, HeaderType Access); | ||
|
||
/// Add ObjC IVar record with attributes from AST. | ||
/// | ||
/// \param Container The owning pointer for instance variable. | ||
/// \param Name The name of ivar, not symbol. | ||
/// \param Linkage The linkage of symbol. | ||
/// \param Avail The availability information tied to the active target | ||
/// triple. | ||
/// \param D The pointer to the declaration from traversing AST. | ||
/// \param Access The intended access level of symbol. | ||
/// \param AC The access control tied to the ivar declaration. | ||
/// \return The non-owning pointer to added record in slice. | ||
ObjCIVarRecord *addObjCIVar(ObjCContainerRecord *Container, | ||
StringRef IvarName, RecordLinkage Linkage, | ||
const clang::AvailabilityInfo Avail, | ||
const Decl *D, HeaderType Access, | ||
const clang::ObjCIvarDecl::AccessControl AC); | ||
|
||
private: | ||
/// Mapping of records stored in slice to their frontend attributes. | ||
llvm::DenseMap<Record *, FrontendAttrs> FrontendRecords; | ||
}; | ||
|
||
} // namespace installapi | ||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_INSTALLAPI_FRONTENDRECORDS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//===- InstallAPI/MachO.h ---------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Imports and forward declarations for llvm::MachO types. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_INSTALLAPI_MACHO_H | ||
#define LLVM_CLANG_INSTALLAPI_MACHO_H | ||
|
||
#include "llvm/TextAPI/Architecture.h" | ||
#include "llvm/TextAPI/InterfaceFile.h" | ||
#include "llvm/TextAPI/PackedVersion.h" | ||
#include "llvm/TextAPI/Platform.h" | ||
#include "llvm/TextAPI/RecordVisitor.h" | ||
#include "llvm/TextAPI/Target.h" | ||
#include "llvm/TextAPI/TextAPIWriter.h" | ||
#include "llvm/TextAPI/Utils.h" | ||
|
||
using SymbolFlags = llvm::MachO::SymbolFlags; | ||
using RecordLinkage = llvm::MachO::RecordLinkage; | ||
using Record = llvm::MachO::Record; | ||
using GlobalRecord = llvm::MachO::GlobalRecord; | ||
using ObjCContainerRecord = llvm::MachO::ObjCContainerRecord; | ||
using ObjCInterfaceRecord = llvm::MachO::ObjCInterfaceRecord; | ||
using ObjCCategoryRecord = llvm::MachO::ObjCCategoryRecord; | ||
using ObjCIVarRecord = llvm::MachO::ObjCIVarRecord; | ||
using Records = llvm::MachO::Records; | ||
using BinaryAttrs = llvm::MachO::RecordsSlice::BinaryAttrs; | ||
using SymbolSet = llvm::MachO::SymbolSet; | ||
using FileType = llvm::MachO::FileType; | ||
using PackedVersion = llvm::MachO::PackedVersion; | ||
using Target = llvm::MachO::Target; | ||
|
||
#endif // LLVM_CLANG_INSTALLAPI_MACHO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters