clang API Documentation
#include "clang/AST/Decl.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
Go to the source code of this file.
enum LVComputationKind |
Kinds of LV computation. The linkage side of the computation is always the same, but different things can change how visibility is computed.
static LinkageInfo computeLVForDecl | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 1216 of file Decl.cpp.
References clang::LinkageInfo::external(), clang::Decl::getDeclContext(), clang::Decl::getKind(), clang::CXXRecordDecl::getLambdaContextDecl(), clang::CXXRecordDecl::getLambdaManglingNumber(), getLVForClassMember(), getLVForClosure(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), getOutermostEnclosingLambda(), clang::DeclContext::getRedeclContext(), clang::LinkageInfo::internal(), clang::DeclContext::isFileContext(), clang::DeclContext::isFunctionOrMethod(), clang::CXXRecordDecl::isLambda(), clang::DeclContext::isRecord(), clang::LinkageInfo::none(), and Record.
Referenced by clang::LinkageComputer::getLVForDecl(), and clang::NamedDecl::isLinkageValid().
static LanguageLinkage getDeclLanguageLinkage | ( | const T & | D | ) | [static] |
Definition at line 1767 of file Decl.cpp.
References clang::CLanguageLinkage, Context, clang::CXXLanguageLinkage, clang::ASTContext::getLangOpts(), isFirstInExternCContext(), clang::DeclContext::isRecord(), and clang::NoLanguageLinkage.
Referenced by clang::VarDecl::getLanguageLinkage(), and clang::FunctionDecl::getLanguageLinkage().
static Optional<Visibility> getExplicitVisibility | ( | const NamedDecl * | D, |
LVComputationKind | kind | ||
) | [static] |
Definition at line 149 of file Decl.cpp.
References clang::NamedDecl::getExplicitVisibility(), and hasExplicitVisibilityAlready().
Referenced by getLVForClassMember(), getLVForLocalDecl(), and getLVForNamespaceScopeDecl().
static Optional<Visibility> getExplicitVisibilityAux | ( | const NamedDecl * | ND, |
NamedDecl::ExplicitVisibilityKind | kind, | ||
bool | IsMostRecent | ||
) | [static] |
Definition at line 1031 of file Decl.cpp.
References clang::CXXRecordDecl::getInstantiatedFromMemberClass(), clang::FunctionDecl::getInstantiatedFromMemberFunction(), clang::VarDecl::getInstantiatedFromStaticDataMember(), clang::NamedDecl::getMostRecentDecl(), and getVisibilityOf().
Referenced by clang::NamedDecl::getExplicitVisibility().
static LinkageInfo getLVForClassMember | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 833 of file Decl.cpp.
References clang::DefaultVisibility, clang::Decl::getDeclContext(), getExplicitVisibility(), clang::LinkageInfo::getLinkage(), clang::Type::getLinkage(), getLVForDecl(), getLVForTemplateParameterList(), getLVForType(), clang::ClassTemplateDecl::getTemplatedDecl(), clang::LinkageInfo::getVisibility(), hasDirectVisibilityAttribute(), hasExplicitVisibilityAlready(), clang::HiddenVisibility, isExplicitMemberSpecialization(), clang::isExternallyVisible(), clang::LinkageInfo::isVisibilityExplicit(), clang::LinkageInfo::mergeExternalVisibility(), clang::LinkageInfo::mergeMaybeWithVisibility(), mergeTemplateLV(), clang::LinkageInfo::mergeVisibility(), clang::LinkageInfo::none(), clang::LinkageInfo::uniqueExternal(), clang::UniqueExternalLinkage, useInlineVisibilityHidden(), and withExplicitVisibilityAlready().
Referenced by computeLVForDecl().
static LinkageInfo getLVForClosure | ( | const DeclContext * | DC, |
Decl * | ContextDecl, | ||
LVComputationKind | computation | ||
) | [static] |
Definition at line 1106 of file Decl.cpp.
References clang::LinkageInfo::external(), clang::Decl::getDeclContext(), getLVForDecl(), and clang::DeclContext::getRedeclContext().
Referenced by computeLVForDecl(), and getLVForLocalDecl().
static LinkageInfo getLVForDecl | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
getLVForDecl - Get the linkage and visibility for the given declaration.
Definition at line 1346 of file Decl.cpp.
Referenced by clang::NamedDecl::getLinkageAndVisibility(), clang::NamedDecl::getLinkageInternal(), getLVForClassMember(), getLVForClosure(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), and getLVForTemplateArgumentList().
static LinkageInfo getLVForLocalDecl | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 1122 of file Decl.cpp.
References Context, clang::Decl::getASTContext(), getExplicitVisibility(), clang::ASTContext::getLangOpts(), clang::LinkageInfo::getLinkage(), getLVForClosure(), getLVForDecl(), getOutermostFuncOrBlockContext(), clang::Redeclarable< decl_type >::getPreviousDecl(), clang::FunctionDecl::getTemplateSpecializationKind(), clang::LinkageInfo::getVisibility(), hasExplicitVisibilityAlready(), clang::HiddenVisibility, clang::LinkageInfo::internal(), clang::isExternallyVisible(), clang::FunctionDecl::isInlined(), clang::LinkageInfo::isVisibilityExplicit(), clang::LinkageInfo::mergeVisibility(), clang::LinkageInfo::none(), clang::SC_PrivateExtern, clang::SC_Static, clang::LinkageInfo::setLinkage(), clang::TSK_Undeclared, clang::LinkageInfo::uniqueExternal(), and clang::VisibleNoLinkage.
Referenced by computeLVForDecl().
static LinkageInfo getLVForNamespaceScopeDecl | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 572 of file Decl.cpp.
References Context, clang::DefaultVisibility, clang::ExternalLinkage, Func, clang::Decl::getAsFunction(), clang::Decl::getASTContext(), clang::Decl::getDeclContext(), getExplicitVisibility(), clang::LinkageInfo::getLinkage(), clang::Type::getLinkage(), getLVForDecl(), getLVForTemplateParameterList(), getLVForType(), clang::DeclContext::getParent(), clang::Redeclarable< decl_type >::getPreviousDecl(), clang::DeclContext::getRedeclContext(), hasExplicitVisibilityAlready(), clang::HiddenVisibility, clang::LinkageInfo::internal(), clang::InternalLinkage, clang::isExternalFormalLinkage(), clang::DeclContext::isFileContext(), isFirstInExternCContext(), clang::Decl::isInAnonymousNamespace(), isSingleLineLanguageLinkage(), clang::LinkageInfo::isVisibilityExplicit(), LVForType, LVForValue, clang::LinkageInfo::merge(), clang::LinkageInfo::mergeMaybeWithVisibility(), mergeTemplateLV(), clang::LinkageInfo::mergeVisibility(), clang::LinkageInfo::none(), clang::SC_Extern, clang::SC_None, clang::SC_PrivateExtern, clang::SC_Static, clang::LinkageInfo::uniqueExternal(), clang::UniqueExternalLinkage, and useInlineVisibilityHidden().
Referenced by computeLVForDecl().
static LinkageInfo getLVForTemplateArgumentList | ( | ArrayRef< TemplateArgument > | Args, |
LVComputationKind | computation | ||
) | [static] |
Get the most restrictive linkage for the types and declarations in the given template argument list.
Note that we don't take an LVComputationKind because we always want to honor the visibility of template arguments in the same way.
Definition at line 310 of file Decl.cpp.
References clang::TemplateArgument::Declaration, clang::TemplateArgument::Expression, getLVForDecl(), getLVForType(), clang::TemplateArgument::Integral, clang::LinkageInfo::merge(), clang::TemplateArgument::Null, clang::TemplateArgument::NullPtr, clang::TemplateArgument::Pack, clang::TemplateArgument::Template, clang::TemplateArgument::TemplateExpansion, clang::TemplateArgument::Type, and usesTypeVisibility().
Referenced by getLVForTemplateArgumentList(), and mergeTemplateLV().
static LinkageInfo getLVForTemplateArgumentList | ( | const TemplateArgumentList & | TArgs, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 354 of file Decl.cpp.
References clang::TemplateArgumentList::asArray(), and getLVForTemplateArgumentList().
static LinkageInfo getLVForTemplateParameterList | ( | const TemplateParameterList * | Params, |
LVComputationKind | computation | ||
) | [static] |
Get the most restrictive linkage for the types in the given template parameter list. For visibility purposes, template parameters are part of the signature of a template.
Definition at line 236 of file Decl.cpp.
References clang::TemplateTemplateParmDecl::getExpansionTemplateParameters(), clang::Type::getLinkageAndVisibility(), getLVForType(), clang::TemplateTemplateParmDecl::getNumExpansionTemplateParameters(), clang::TemplateDecl::getTemplateParameters(), clang::Type::isDependentType(), clang::TemplateTemplateParmDecl::isExpandedParameterPack(), clang::LinkageInfo::merge(), P, and clang::ast_matchers::type.
Referenced by getLVForClassMember(), getLVForNamespaceScopeDecl(), and mergeTemplateLV().
static LinkageInfo getLVForType | ( | const Type & | T, |
LVComputationKind | computation | ||
) | [static] |
Definition at line 226 of file Decl.cpp.
References clang::DefaultVisibility, clang::Type::getLinkage(), clang::Type::getLinkageAndVisibility(), and LVForLinkageOnly.
Referenced by getLVForClassMember(), getLVForNamespaceScopeDecl(), getLVForTemplateArgumentList(), and getLVForTemplateParameterList().
static unsigned getNumModuleIdentifiers | ( | Module * | Mod | ) | [static] |
Retrieve the number of module identifiers needed to name the given module.
Definition at line 3932 of file Decl.cpp.
References clang::Module::Parent.
Referenced by clang::ImportDecl::getIdentifierLocs().
static const CXXRecordDecl* getOutermostEnclosingLambda | ( | const CXXRecordDecl * | Record | ) | [inline, static] |
Definition at line 1204 of file Decl.cpp.
References clang::DeclContext::getParent(), clang::CXXRecordDecl::isLambda(), and Record.
Referenced by computeLVForDecl().
static const Decl* getOutermostFuncOrBlockContext | ( | const Decl * | D | ) | [static] |
Definition at line 294 of file Decl.cpp.
References clang::Decl::getDeclContext(), clang::DeclContext::getDeclKind(), and clang::DeclContext::getParent().
Referenced by getLVForLocalDecl().
static SourceLocation getTemplateOrInnerLocStart | ( | const DeclT * | decl | ) | [static] |
Definition at line 1551 of file Decl.cpp.
Referenced by clang::DeclaratorDecl::getOuterLocStart(), and clang::TagDecl::getOuterLocStart().
static Visibility getVisibilityFromAttr | ( | const T * | attr | ) | [static] |
Given a visibility attribute, return the explicit visibility associated with it.
Definition at line 186 of file Decl.cpp.
References clang::DefaultVisibility, clang::HiddenVisibility, and clang::ProtectedVisibility.
Referenced by getVisibilityOf().
static Optional<Visibility> getVisibilityOf | ( | const NamedDecl * | D, |
NamedDecl::ExplicitVisibilityKind | kind | ||
) | [static] |
Return the explicit visibility of the given declaration.
Definition at line 199 of file Decl.cpp.
References clang::DefaultVisibility, clang::Decl::getASTContext(), clang::Decl::getAttr(), clang::ASTContext::getTargetInfo(), clang::TargetInfo::getTriple(), getVisibilityFromAttr(), clang::Decl::specific_attrs(), and clang::NamedDecl::VisibilityForType.
Referenced by getExplicitVisibilityAux().
static bool hasDirectVisibilityAttribute | ( | const NamedDecl * | D, |
LVComputationKind | computation | ||
) | [static] |
Does the given declaration have a direct visibility attribute that would match the given rules?
Definition at line 399 of file Decl.cpp.
References clang::Decl::hasAttr(), LVForExplicitType, LVForExplicitValue, LVForLinkageOnly, LVForType, and LVForValue.
Referenced by getLVForClassMember(), and shouldConsiderTemplateVisibility().
static bool hasExplicitVisibilityAlready | ( | LVComputationKind | computation | ) | [static] |
Does this computation kind permit us to consider additional visibility settings from attributes and the like?
Definition at line 131 of file Decl.cpp.
References IgnoreExplicitVisibilityBit.
Referenced by getExplicitVisibility(), getLVForClassMember(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), mergeTemplateLV(), and shouldConsiderTemplateVisibility().
static bool isDeclExternC | ( | const T & | D | ) | [static] |
Definition at line 1795 of file Decl.cpp.
References clang::CLanguageLinkage, and clang::DeclContext::isRecord().
Referenced by clang::VarDecl::isExternC(), and clang::FunctionDecl::isExternC().
static std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value, bool>::type isExplicitMemberSpecialization | ( | const T * | D | ) | [static] |
Does the given declaration have member specialization information, and if so, is it an explicit specialization?
Definition at line 168 of file Decl.cpp.
Referenced by getLVForClassMember().
static bool isExplicitMemberSpecialization | ( | const RedeclarableTemplateDecl * | D | ) | [static] |
For templates, this question is easier: a member template can't be explicitly instantiated, so there's a single bit indicating whether or not this is an explicit member specialization.
Definition at line 179 of file Decl.cpp.
References clang::RedeclarableTemplateDecl::isMemberSpecialization().
static bool isFieldOrIndirectField | ( | Decl::Kind | K | ) | [static] |
Definition at line 3592 of file Decl.cpp.
References clang::FieldDecl::classofKind(), and clang::IndirectFieldDecl::classofKind().
static bool isFirstInExternCContext | ( | T * | D | ) | [static] |
Definition at line 560 of file Decl.cpp.
Referenced by getDeclLanguageLinkage(), and getLVForNamespaceScopeDecl().
static bool isNamed | ( | const NamedDecl * | ND, |
const char(&) | Str[Len] | ||
) | [static] |
Definition at line 2356 of file Decl.cpp.
References clang::NamedDecl::getIdentifier(), and clang::IdentifierInfo::isStr().
Referenced by clang::FunctionDecl::isMain(), and clang::FunctionDecl::isReplaceableGlobalAllocationFunction().
static bool isSingleLineLanguageLinkage | ( | const Decl & | D | ) | [static] |
Definition at line 565 of file Decl.cpp.
References clang::Decl::getDeclContext().
Referenced by getLVForNamespaceScopeDecl(), and clang::VarDecl::isThisDeclarationADefinition().
static void mergeTemplateLV | ( | LinkageInfo & | LV, |
const FunctionDecl * | fn, | ||
const FunctionTemplateSpecializationInfo * | specInfo, | ||
LVComputationKind | computation | ||
) | [static] |
Merge in template-related linkage and visibility for the given function template specialization.
We don't need a computation kind here because we can assume LVForValue.
[out] | LV | the computation to use for the parent |
Definition at line 379 of file Decl.cpp.
References getLVForTemplateArgumentList(), getLVForTemplateParameterList(), clang::FunctionTemplateSpecializationInfo::getTemplate(), clang::TemplateDecl::getTemplateParameters(), clang::LinkageInfo::mergeMaybeWithVisibility(), shouldConsiderTemplateVisibility(), and clang::FunctionTemplateSpecializationInfo::TemplateArguments.
Referenced by getLVForClassMember(), and getLVForNamespaceScopeDecl().
static void mergeTemplateLV | ( | LinkageInfo & | LV, |
const ClassTemplateSpecializationDecl * | spec, | ||
LVComputationKind | computation | ||
) | [static] |
Merge in template-related linkage and visibility for the given class template specialization.
Definition at line 456 of file Decl.cpp.
References getLVForTemplateArgumentList(), getLVForTemplateParameterList(), clang::ClassTemplateSpecializationDecl::getSpecializedTemplate(), clang::ClassTemplateSpecializationDecl::getTemplateArgs(), clang::TemplateDecl::getTemplateParameters(), hasExplicitVisibilityAlready(), clang::LinkageInfo::mergeExternalVisibility(), clang::LinkageInfo::mergeMaybeWithVisibility(), clang::LinkageInfo::mergeVisibility(), and shouldConsiderTemplateVisibility().
static void mergeTemplateLV | ( | LinkageInfo & | LV, |
const VarTemplateSpecializationDecl * | spec, | ||
LVComputationKind | computation | ||
) | [static] |
Merge in template-related linkage and visibility for the given variable template specialization. As usual, follow class template specialization logic up to initialization.
Definition at line 508 of file Decl.cpp.
References getLVForTemplateArgumentList(), getLVForTemplateParameterList(), clang::VarTemplateSpecializationDecl::getSpecializedTemplate(), clang::VarTemplateSpecializationDecl::getTemplateArgs(), clang::TemplateDecl::getTemplateParameters(), hasExplicitVisibilityAlready(), clang::LinkageInfo::mergeExternalVisibility(), clang::LinkageInfo::mergeMaybeWithVisibility(), clang::LinkageInfo::mergeVisibility(), and shouldConsiderTemplateVisibility().
static bool RedeclForcesDefC99 | ( | const FunctionDecl * | Redecl | ) | [static] |
Definition at line 2693 of file Decl.cpp.
References clang::Decl::getLexicalDeclContext(), clang::FunctionDecl::getStorageClass(), clang::Decl::isImplicit(), clang::FunctionDecl::isInlineSpecified(), clang::DeclContext::isTranslationUnit(), and clang::SC_Extern.
Referenced by clang::FunctionDecl::doesDeclarationForceExternallyVisibleDefinition(), and clang::FunctionDecl::isInlineDefinitionExternallyVisible().
static bool redeclForcesDefMSVC | ( | const FunctionDecl * | Redecl | ) | [static] |
Definition at line 2681 of file Decl.cpp.
References clang::Redeclarable< decl_type >::getPreviousDecl(), clang::FunctionDecl::getStorageClass(), and clang::SC_Extern.
Referenced by clang::FunctionDecl::doesDeclarationForceExternallyVisibleDefinition().
static bool shouldConsiderTemplateVisibility | ( | const FunctionDecl * | fn, |
const FunctionTemplateSpecializationInfo * | specInfo | ||
) | [static] |
Definition at line 359 of file Decl.cpp.
References clang::Decl::hasAttr(), and clang::FunctionTemplateSpecializationInfo::isExplicitInstantiationOrSpecialization().
Referenced by mergeTemplateLV().
static bool shouldConsiderTemplateVisibility | ( | const ClassTemplateSpecializationDecl * | spec, |
LVComputationKind | computation | ||
) | [static] |
Should we consider visibility associated with the template arguments and parameters of the given class template specialization?
Definition at line 420 of file Decl.cpp.
References hasDirectVisibilityAttribute(), hasExplicitVisibilityAlready(), clang::ClassTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization(), and clang::ClassTemplateSpecializationDecl::isExplicitSpecialization().
static bool shouldConsiderTemplateVisibility | ( | const VarTemplateSpecializationDecl * | spec, |
LVComputationKind | computation | ||
) | [static] |
Should we consider visibility associated with the template arguments and parameters of the given variable template specialization? As usual, follow class template specialization logic up to initialization.
Definition at line 484 of file Decl.cpp.
References hasDirectVisibilityAttribute(), hasExplicitVisibilityAlready(), clang::VarTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization(), and clang::VarTemplateSpecializationDecl::isExplicitSpecialization().
static bool useInlineVisibilityHidden | ( | const NamedDecl * | D | ) | [static] |
Definition at line 532 of file Decl.cpp.
References clang::Decl::getASTContext(), clang::ASTContext::getLangOpts(), clang::FunctionDecl::getMemberSpecializationInfo(), clang::FunctionDecl::getTemplateSpecializationInfo(), clang::Decl::hasAttr(), clang::FunctionDecl::hasBody(), clang::FunctionDecl::isInlined(), clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, and clang::TSK_Undeclared.
Referenced by getLVForClassMember(), and getLVForNamespaceScopeDecl().
static bool usesTypeVisibility | ( | const NamedDecl * | D | ) | [static] |
Is the given declaration a "type" or a "value" for the purposes of visibility computation?
Definition at line 158 of file Decl.cpp.
Referenced by clang::NamedDecl::getLinkageAndVisibility(), and getLVForTemplateArgumentList().
static LVComputationKind withExplicitVisibilityAlready | ( | LVComputationKind | oldKind | ) | [static] |
Given an LVComputationKind, return one of the same type/value sort that records that it already has explicit visibility.
Definition at line 138 of file Decl.cpp.
References IgnoreExplicitVisibilityBit, LVForExplicitType, LVForExplicitValue, LVForType, and LVForValue.
Referenced by getLVForClassMember().
const unsigned IgnoreAllVisibilityBit = 4 |
const unsigned IgnoreExplicitVisibilityBit = 2 |
Definition at line 97 of file Decl.cpp.
Referenced by hasExplicitVisibilityAlready(), and withExplicitVisibilityAlready().