CXXLinkage {
38 autoLV =
D->getLinkageAndVisibility();
44 boolHasInlineAttribute =
false;
46(!
D->getASTContext().getLangOpts().CPlusPlus &&
47!
D->getASTContext().getTargetInfo().getCXXABI().isMicrosoft() &&
48!
D->hasAttr<DLLExportAttr>());
51 for(
const auto*RD :
D->redecls()) {
54HasInlineAttribute =
true;
55 if(!(NoCXXAttr || RD->hasAttr<GNUInlineAttr>()))
57 if(RD->doesThisDeclarationHaveABody() &&
58RD->isInlineDefinitionExternallyVisible())
62 if(!HasInlineAttribute)
71 Result|= SymbolFlags::WeakDefined;
73 Result|= SymbolFlags::ThreadLocalValue;
86std::string InstallAPIVisitor::getMangledName(
const NamedDecl*
D)
const{
88 if(MC->shouldMangleDeclName(
D)) {
89raw_svector_ostream NStream(Name);
90MC->mangleName(
D, NStream);
92Name +=
D->getNameAsString();
94 returngetBackendMangledName(Name);
97std::string InstallAPIVisitor::getBackendMangledName(Twine Name)
const{
99Mangler::getNameWithPrefix(FinalName, Name, DataLayout(Layout));
100 returnstd::string(FinalName);
103std::optional<HeaderType>
104InstallAPIVisitor::getAccessForDecl(
constNamedDecl *
D)
const{
105SourceLocation
Loc=
D->getLocation();
106 if(
Loc.isInvalid())
113 if(
ID.isInvalid())
121 if(!Header.has_value())
134 for(;
D!=
nullptr;
D=
D->getSuperClass())
135 if(
D->hasAttr<ObjCExceptionAttr>())
140voidInstallAPIVisitor::recordObjCInstanceVariables(
142 constllvm::iterator_range<
149 Linkage= RecordLinkage::Unknown;
151 else if(ContainerLinkage != RecordLinkage::Unknown)
153 for(
const auto*IV : Ivars) {
154 autoAccess = getAccessForDecl(IV);
157StringRef Name = IV->getName();
159 autoAC = IV->getCanonicalAccessControl();
162Ctx.
Verifier->verify(ObjCIVR, FA, SuperClass);
168 if(!
D->isThisDeclarationADefinition())
172 autoAccess = getAccessForDecl(
D);
176StringRef Name =
D->getObjCRuntimeNameAsString();
178 isExported(
D) ? RecordLinkage::Exported : RecordLinkage::Internal;
180 const boolIsEHType =
181(!
D->getASTContext().getLangOpts().ObjCRuntime.isFragile() &&
185Ctx.
Slice->addObjCInterface(Name,
Linkage, Avail,
D, *Access, IsEHType);
189StringRef SuperClassName;
190 if(
const auto*SuperClass =
D->getSuperClass())
191SuperClassName = SuperClass->getObjCRuntimeNameAsString();
193recordObjCInstanceVariables(
D->getASTContext(),
Class,
Class->getName(),
199StringRef CategoryName =
D->getName();
201 autoAccess = getAccessForDecl(
D);
206 constStringRef InterfaceName = InterfaceD->
getName();
209Ctx.
Slice->addObjCCategory(InterfaceName, CategoryName, Avail,
D, *Access)
211recordObjCInstanceVariables(
D->getASTContext(), CategoryRecord, InterfaceName,
218 if(isa<ParmVarDecl>(
D))
222 if(
D->getDeclContext()->isRecord())
226 if(!
D->isDefinedOutsideFunctionOrMethod())
230 if(
D->getASTContext().getTemplateOrSpecializationInfo(
D) &&
235 autoAccess = getAccessForDecl(
D);
240 isExported(
D) ? RecordLinkage::Exported : RecordLinkage::Internal;
241 const boolWeakDef =
D->hasAttr<WeakAttr>();
244 auto[GR, FA] = Ctx.
Slice->addGlobal(getMangledName(
D),
Linkage,
245GlobalRecord::Kind::Variable, Avail,
D,
246*Access,
getFlags(WeakDef, ThreadLocal));
254 if(M->getParent()->getDescribedClassTemplate() !=
nullptr)
258 for(
const DynTypedNode&
P:
D->getASTContext().getParents(*M)) {
264 if(isa<CXXConstructorDecl>(M) || isa<CXXDestructorDecl>(M))
269 switch(
D->getTemplatedKind()) {
275 if(
auto*TempInfo =
D->getTemplateSpecializationInfo()) {
276 if(!TempInfo->isExplicitInstantiationOrSpecialization())
285 autoAccess = getAccessForDecl(
D);
288 autoName = getMangledName(
D);
290 const boolExplicitInstantiation =
D->getTemplateSpecializationKind() ==
292 const boolWeakDef = ExplicitInstantiation ||
D->hasAttr<WeakAttr>();
295? RecordLinkage::Internal
296: RecordLinkage::Exported;
298Ctx.
Slice->addGlobal(Name,
Linkage, GlobalRecord::Kind::Function, Avail,
299 D, *Access,
getFlags(WeakDef), Inlined);
307 if(!
D->hasDefinition() || !
D->isDynamicClass())
310assert(
D->isExternallyVisible() &&
"Should be externally visible");
311assert(
D->isCompleteDefinition() &&
"Only works on complete definitions");
314 D->getASTContext().getCurrentKeyFunction(
D);
326 "Unexpected TemplateSpecializationKind for key function");
328}
else if(
D->isAbstract()) {
334 switch(
D->getTemplateSpecializationKind()) {
345llvm_unreachable(
"Invalid TemplateSpecializationKind!");
349assert((
D->hasDefinition() &&
D->isDynamicClass()) &&
"Record has no vtable");
350assert(
D->isExternallyVisible() &&
"Record should be externally visible");
352 returnCXXLinkage::PrivateLinkage;
355 D->getASTContext().getCurrentKeyFunction(
D);
363 returnCXXLinkage::LinkOnceODRLinkage;
364 returnCXXLinkage::ExternalLinkage;
366llvm_unreachable(
"No external vtable for implicit instantiations");
368 returnCXXLinkage::WeakODRLinkage;
371 "Unexpected TemplateSpecializationKind for key function");
375 switch(
D->getTemplateSpecializationKind()) {
379 returnCXXLinkage::LinkOnceODRLinkage;
382 returnCXXLinkage::WeakODRLinkage;
385llvm_unreachable(
"Invalid TemplateSpecializationKind!");
389 if(
D->hasAttr<WeakAttr>())
392 if(
D->isAbstract() &&
D->getASTContext().getCurrentKeyFunction(
D) ==
nullptr)
395 if(
D->isDynamicClass())
402 if(!
D->getASTContext().getLangOpts().RTTI)
405 if(!
D->hasDefinition())
408 if(!
D->isDynamicClass())
425InstallAPIVisitor::getMangledCXXRTTIName(
const CXXRecordDecl*
D)
const{
427raw_svector_ostream NameStream(Name);
428MC->mangleCXXRTTIName(
QualType(
D->getTypeForDecl(), 0), NameStream);
430 returngetBackendMangledName(Name);
433std::string InstallAPIVisitor::getMangledCXXRTTI(
constCXXRecordDecl *
D)
const{
435raw_svector_ostream NameStream(Name);
436MC->mangleCXXRTTI(QualType(
D->getTypeForDecl(), 0), NameStream);
438 returngetBackendMangledName(Name);
442InstallAPIVisitor::getMangledCXXVTableName(
constCXXRecordDecl *
D)
const{
444raw_svector_ostream NameStream(Name);
445MC->mangleCXXVTable(
D, NameStream);
447 returngetBackendMangledName(Name);
450std::string InstallAPIVisitor::getMangledCXXThunk(
451 constGlobalDecl &
D,
constThunkInfo &Thunk,
boolElideOverrideInfo)
const{
453raw_svector_ostream NameStream(Name);
454 const auto*Method = cast<CXXMethodDecl>(
D.getDecl());
455 if(
const auto*Dtor = dyn_cast<CXXDestructorDecl>(Method))
456MC->mangleCXXDtorThunk(Dtor,
D.getDtorType(), Thunk, ElideOverrideInfo,
459MC->mangleThunk(Method, Thunk, ElideOverrideInfo, NameStream);
461 returngetBackendMangledName(Name);
464std::string InstallAPIVisitor::getMangledCtorDtor(
constCXXMethodDecl *
D,
467raw_svector_ostream NameStream(Name);
469 if(
const auto*Ctor = dyn_cast<CXXConstructorDecl>(
D))
472 const auto*Dtor = cast<CXXDestructorDecl>(
D);
475MC->mangleName(GD, NameStream);
476 returngetBackendMangledName(Name);
479voidInstallAPIVisitor::emitVTableSymbols(
constCXXRecordDecl *
D,
480 constAvailabilityInfo &Avail,
482 boolEmittedVTable) {
484EmittedVTable =
true;
486 if(VTableLinkage == CXXLinkage::ExternalLinkage ||
487VTableLinkage == CXXLinkage::WeakODRLinkage) {
488 conststd::string Name = getMangledCXXVTableName(
D);
489 const boolWeakDef = VTableLinkage == CXXLinkage::WeakODRLinkage;
490 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
491GlobalRecord::Kind::Variable, Avail,
494 if(!
D->getDescribedClassTemplate() && !
D->isInvalidDecl()) {
495VTableContextBase *VTable =
D->getASTContext().getVTableContext();
496 autoAddThunk = [&](GlobalDecl GD) {
498VTable->getThunkInfo(GD);
502 for(
const auto&Thunk : *Thunks) {
503 conststd::string Name =
504getMangledCXXThunk(GD, Thunk,
true);
505 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
506GlobalRecord::Kind::Function,
507Avail, GD.getDecl(), Access);
512 for(
const auto*Method :
D->methods()) {
513 if(isa<CXXConstructorDecl>(Method) || !Method->isVirtual())
516 if(
autoDtor = dyn_cast<CXXDestructorDecl>(Method)) {
518 if(Dtor->isDefaulted())
533std::string Name = getMangledCXXRTTI(
D);
535Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
536GlobalRecord::Kind::Variable, Avail,
D, Access);
539Name = getMangledCXXRTTIName(
D);
540 auto[NamedGR, NamedFA] =
541Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
542GlobalRecord::Kind::Variable, Avail,
D, Access);
543Ctx.
Verifier->verify(NamedGR, NamedFA);
546 for(
const auto&It :
D->bases()) {
547 constCXXRecordDecl *
Base=
548cast<CXXRecordDecl>(It.getType()->castAs<RecordType>()->getDecl());
549 const autoBaseAccess = getAccessForDecl(
Base);
553emitVTableSymbols(
Base, BaseAvail, *BaseAccess,
true);
558 if(!
D->isCompleteDefinition())
562 if(
D->getDescribedClassTemplate() !=
nullptr)
566 if(isa<ClassTemplatePartialSpecializationDecl>(
D))
569 autoAccess = getAccessForDecl(
D);
576emitVTableSymbols(
D, Avail, *Access);
579 boolKeepInlineAsWeak =
false;
580 if(
auto*Templ = dyn_cast<ClassTemplateSpecializationDecl>(
D)) {
581ClassSK = Templ->getTemplateSpecializationKind();
583KeepInlineAsWeak =
true;
587 for(
const auto*M :
D->methods()) {
590 boolWeakDef =
false;
592 if(!KeepInlineAsWeak)
601 switch(M->getTemplateSpecializationKind()) {
616 if(!M->isUserProvided())
623 const autoAccess = getAccessForDecl(M);
628 if(
const auto*Ctor = dyn_cast<CXXConstructorDecl>(M)) {
630 if(Ctor->isDefaulted())
633std::string Name = getMangledCtorDtor(M,
Ctor_Base);
634 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
635GlobalRecord::Kind::Function, Avail,
639 if(!
D->isAbstract()) {
641 auto[GR, FA] = Ctx.
Slice->addGlobal(
642Name, RecordLinkage::Exported, GlobalRecord::Kind::Function, Avail,
650 if(
const auto*Dtor = dyn_cast<CXXDestructorDecl>(M)) {
652 if(Dtor->isDefaulted())
655std::string Name = getMangledCtorDtor(M,
Dtor_Base);
656 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
657GlobalRecord::Kind::Function, Avail,
662 auto[CompleteGR, CompleteFA] = Ctx.
Slice->addGlobal(
663Name, RecordLinkage::Exported, GlobalRecord::Kind::Function, Avail,
D,
665Ctx.
Verifier->verify(CompleteGR, CompleteFA);
667 if(Dtor->isVirtual()) {
669 auto[VirtualGR, VirtualFA] = Ctx.
Slice->addGlobal(
670Name, RecordLinkage::Exported, GlobalRecord::Kind::Function, Avail,
672Ctx.
Verifier->verify(VirtualGR, VirtualFA);
681 if(M->isPureVirtual())
684std::string Name = getMangledName(M);
685 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
686GlobalRecord::Kind::Function, Avail, M,
691 if(
auto*Templ = dyn_cast<ClassTemplateSpecializationDecl>(
D)) {
692 if(!Templ->isExplicitInstantiationOrSpecialization())
697 usingvar_range = iterator_range<var_iter>;
698 for(
const auto*Var : var_range(
D->decls())) {
705 if(Var->isStaticDataMember() && Var->hasInit())
712 conststd::string Name = getMangledName(Var);
713 const autoAccess = getAccessForDecl(Var);
717 const boolWeakDef = Var->hasAttr<WeakAttr>() || KeepInlineAsWeak;
719 auto[GR, FA] = Ctx.
Slice->addGlobal(Name, RecordLinkage::Exported,
720GlobalRecord::Kind::Variable, Avail,
D,
llvm::MachO::SymbolFlags SymbolFlags
llvm::MachO::ObjCCategoryRecord ObjCCategoryRecord
llvm::MachO::RecordLinkage RecordLinkage
llvm::MachO::Record Record
llvm::MachO::ObjCContainerRecord ObjCContainerRecord
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
bool hasErrorOccurred() const
A dynamically typed AST node container.
Represents a function declaration or definition.
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
clang::ObjCRuntime ObjCRuntime
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
ObjCCategoryDecl - Represents a category declaration.
Represents an ObjC class declaration.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
A (possibly-)qualified type.
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location,...
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
SmallVector< ThunkInfo, 1 > ThunkInfoVectorTy
Represents a variable declaration or definition.
@ TLS_None
Not a TLS variable.
void HandleTranslationUnit(ASTContext &ASTCtx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
bool VisitCXXRecordDecl(const CXXRecordDecl *D)
Collect global c++ declarations.
bool VisitFunctionDecl(const FunctionDecl *D)
Collect global functions.
bool VisitVarDecl(const VarDecl *D)
Collect global variables.
bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D)
Collect Objective-C Category/Extension declarations.
bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
Collect Objective-C Interface declarations.
Defines the Linkage enumeration and various utility functions.
The DirectoryScanner for collecting library files on the file system.
static bool isInlined(const FunctionDecl *D)
static CXXLinkage getVTableLinkage(const CXXRecordDecl *D)
@ Unknown
Unset or unknown type.
static bool hasObjCExceptionAttribute(const ObjCInterfaceDecl *D)
Check if the interface itself or any of its super classes have an exception attribute.
static bool hasVTable(const CXXRecordDecl *D)
static bool isRTTIWeakDef(const CXXRecordDecl *D)
static bool hasRTTI(const CXXRecordDecl *D)
static SymbolFlags getFlags(bool WeakDef, bool ThreadLocal=false)
static bool isExported(const NamedDecl *D)
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ Result
The result type of a method or function.
CXXDtorType
C++ destructor types.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ Class
The "class" keyword introduces the elaborated-type-specifier.
bool isExternallyVisible(Linkage L)
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
Diagnostic wrappers for TextAPI types for error reporting.
Storage of availability attributes for a declaration.
static AvailabilityInfo createFromDecl(const Decl *Decl)
std::optional< HeaderType > findAndRecordFile(const FileEntry *FE, const Preprocessor &PP)
Record visited files during frontend actions to determine whether to include their declarations for T...
std::shared_ptr< FrontendRecordsSlice > Slice
Active TargetSlice for symbol record collection.
std::unique_ptr< DylibVerifier > Verifier
Verifier when binary dylib is passed as input.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4