clang
3.9.0
|
#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/DeclOpenMP.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>
#include "clang/AST/DeclNodes.inc"
Go to the source code of this file.
Classes | |
class | clang::LinkageComputer |
Namespaces | |
clang | |
Dataflow Directional Tag Classes. | |
Macros | |
#define | DECL(Type, Base) |
#define | ABSTRACT_DECL(DECL) |
Enumerations | |
enum | LVComputationKind { LVForType = NamedDecl::VisibilityForType, LVForValue = NamedDecl::VisibilityForValue, LVForExplicitType = (LVForType | IgnoreExplicitVisibilityBit), LVForExplicitValue = (LVForValue | IgnoreExplicitVisibilityBit), LVForLinkageOnly } |
Kinds of LV computation. More... | |
Functions | |
static bool | hasExplicitVisibilityAlready (LVComputationKind computation) |
Does this computation kind permit us to consider additional visibility settings from attributes and the like? More... | |
static LVComputationKind | withExplicitVisibilityAlready (LVComputationKind oldKind) |
Given an LVComputationKind, return one of the same type/value sort that records that it already has explicit visibility. More... | |
static Optional< Visibility > | getExplicitVisibility (const NamedDecl *D, LVComputationKind kind) |
static bool | usesTypeVisibility (const NamedDecl *D) |
Is the given declaration a "type" or a "value" for the purposes of visibility computation? More... | |
template<class T > | |
static std::enable_if <!std::is_base_of < RedeclarableTemplateDecl, T > ::value, bool >::type | isExplicitMemberSpecialization (const T *D) |
Does the given declaration have member specialization information, and if so, is it an explicit specialization? More... | |
static bool | isExplicitMemberSpecialization (const RedeclarableTemplateDecl *D) |
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. More... | |
template<class T > | |
static Visibility | getVisibilityFromAttr (const T *attr) |
Given a visibility attribute, return the explicit visibility associated with it. More... | |
static Optional< Visibility > | getVisibilityOf (const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind) |
Return the explicit visibility of the given declaration. More... | |
static LinkageInfo | getLVForType (const Type &T, LVComputationKind computation) |
static LinkageInfo | getLVForTemplateParameterList (const TemplateParameterList *Params, LVComputationKind computation) |
Get the most restrictive linkage for the types in the given template parameter list. More... | |
static LinkageInfo | getLVForDecl (const NamedDecl *D, LVComputationKind computation) |
getLVForDecl - Get the linkage and visibility for the given declaration. More... | |
static const Decl * | getOutermostFuncOrBlockContext (const Decl *D) |
static LinkageInfo | getLVForTemplateArgumentList (ArrayRef< TemplateArgument > Args, LVComputationKind computation) |
Get the most restrictive linkage for the types and declarations in the given template argument list. More... | |
static LinkageInfo | getLVForTemplateArgumentList (const TemplateArgumentList &TArgs, LVComputationKind computation) |
static bool | shouldConsiderTemplateVisibility (const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo) |
static void | mergeTemplateLV (LinkageInfo &LV, const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo, LVComputationKind computation) |
Merge in template-related linkage and visibility for the given function template specialization. More... | |
static bool | hasDirectVisibilityAttribute (const NamedDecl *D, LVComputationKind computation) |
Does the given declaration have a direct visibility attribute that would match the given rules? More... | |
static bool | shouldConsiderTemplateVisibility (const ClassTemplateSpecializationDecl *spec, LVComputationKind computation) |
Should we consider visibility associated with the template arguments and parameters of the given class template specialization? More... | |
static void | mergeTemplateLV (LinkageInfo &LV, const ClassTemplateSpecializationDecl *spec, LVComputationKind computation) |
Merge in template-related linkage and visibility for the given class template specialization. More... | |
static bool | shouldConsiderTemplateVisibility (const VarTemplateSpecializationDecl *spec, LVComputationKind computation) |
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. More... | |
static void | mergeTemplateLV (LinkageInfo &LV, const VarTemplateSpecializationDecl *spec, LVComputationKind computation) |
Merge in template-related linkage and visibility for the given variable template specialization. More... | |
static bool | useInlineVisibilityHidden (const NamedDecl *D) |
template<typename T > | |
static bool | isFirstInExternCContext (T *D) |
static bool | isSingleLineLanguageLinkage (const Decl &D) |
static LinkageInfo | getLVForNamespaceScopeDecl (const NamedDecl *D, LVComputationKind computation) |
static LinkageInfo | getLVForClassMember (const NamedDecl *D, LVComputationKind computation) |
static LinkageInfo | computeLVForDecl (const NamedDecl *D, LVComputationKind computation) |
static Optional< Visibility > | getExplicitVisibilityAux (const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent) |
static LinkageInfo | getLVForClosure (const DeclContext *DC, Decl *ContextDecl, LVComputationKind computation) |
static LinkageInfo | getLVForLocalDecl (const NamedDecl *D, LVComputationKind computation) |
static const CXXRecordDecl * | getOutermostEnclosingLambda (const CXXRecordDecl *Record) |
template<typename T > | |
static bool | isRedeclarableImpl (Redeclarable< T > *) |
static bool | isRedeclarableImpl (...) |
static bool | isRedeclarable (Decl::Kind K) |
template<typename DeclT > | |
static SourceLocation | getTemplateOrInnerLocStart (const DeclT *decl) |
template<typename T > | |
static LanguageLinkage | getDeclLanguageLinkage (const T &D) |
template<typename T > | |
static bool | isDeclExternC (const T &D) |
template<std::size_t Len> | |
static bool | isNamed (const NamedDecl *ND, const char(&Str)[Len]) |
static bool | redeclForcesDefMSVC (const FunctionDecl *Redecl) |
static bool | RedeclForcesDefC99 (const FunctionDecl *Redecl) |
static unsigned | getNumModuleIdentifiers (Module *Mod) |
Retrieve the number of module identifiers needed to name the given module. More... | |
Variables | |
const unsigned | IgnoreExplicitVisibilityBit = 2 |
const unsigned | IgnoreAllVisibilityBit = 4 |
#define ABSTRACT_DECL | ( | DECL | ) |
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 |
Definition at line 1227 of file Decl.cpp.
References clang::LinkageInfo::external(), clang::CXXRecordDecl::getLambdaContextDecl(), clang::CXXRecordDecl::getLambdaManglingNumber(), getLVForClassMember(), getLVForClosure(), getLVForDecl(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), getOutermostEnclosingLambda(), clang::DeclContext::getRedeclContext(), clang::LinkageInfo::internal(), clang::LinkageInfo::none(), and clang::TypeAlias.
Referenced by clang::LinkageComputer::getLVForDecl(), and clang::NamedDecl::isLinkageValid().
|
static |
Definition at line 1852 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 |
Definition at line 156 of file Decl.cpp.
References clang::NamedDecl::getExplicitVisibility(), and hasExplicitVisibilityAlready().
Referenced by getLVForClassMember(), getLVForLocalDecl(), and getLVForNamespaceScopeDecl().
|
static |
Definition at line 1043 of file Decl.cpp.
References clang::CXXRecordDecl::getInstantiatedFromMemberClass(), clang::FunctionDecl::getInstantiatedFromMemberFunction(), clang::VarDecl::getInstantiatedFromStaticDataMember(), clang::NamedDecl::getMostRecentDecl(), getVisibilityOf(), and clang::None.
Referenced by clang::NamedDecl::getExplicitVisibility().
|
static |
Definition at line 848 of file Decl.cpp.
References clang::DefaultVisibility, 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::UniqueExternalLinkage, useInlineVisibilityHidden(), and withExplicitVisibilityAlready().
Referenced by computeLVForDecl().
|
static |
Definition at line 1117 of file Decl.cpp.
References clang::LinkageInfo::external(), and getLVForDecl().
Referenced by computeLVForDecl(), and getLVForLocalDecl().
|
static |
getLVForDecl - Get the linkage and visibility for the given declaration.
Definition at line 1393 of file Decl.cpp.
References clang::LinkageComputer::getLVForDecl().
Referenced by computeLVForDecl(), clang::NamedDecl::getLinkageAndVisibility(), clang::NamedDecl::getLinkageInternal(), getLVForClassMember(), getLVForClosure(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), and getLVForTemplateArgumentList().
|
static |
Definition at line 1133 of file Decl.cpp.
References Context, getExplicitVisibility(), clang::ASTContext::getLangOpts(), clang::LinkageInfo::getLinkage(), getLVForClosure(), getLVForDecl(), getOutermostFuncOrBlockContext(), clang::Redeclarable< decl_type >::getPreviousDecl(), clang::LinkageInfo::getVisibility(), hasExplicitVisibilityAlready(), clang::HiddenVisibility, clang::LinkageInfo::internal(), clang::isExternallyVisible(), clang::isTemplateInstantiation(), clang::LinkageInfo::isVisibilityExplicit(), clang::LinkageInfo::mergeVisibility(), clang::LinkageInfo::none(), clang::SC_PrivateExtern, clang::SC_Static, clang::LinkageInfo::setLinkage(), clang::LinkageInfo::uniqueExternal(), and clang::VisibleNoLinkage.
Referenced by computeLVForDecl().
|
static |
Definition at line 578 of file Decl.cpp.
References Context, clang::DefaultVisibility, clang::ExternalLinkage, getExplicitVisibility(), clang::LinkageInfo::getLinkage(), clang::Type::getLinkage(), getLVForDecl(), getLVForTemplateParameterList(), getLVForType(), clang::Redeclarable< decl_type >::getPreviousDecl(), hasExplicitVisibilityAlready(), clang::HiddenVisibility, clang::InternalLinkage, clang::isExternalFormalLinkage(), isFirstInExternCContext(), isSingleLineLanguageLinkage(), clang::LinkageInfo::isVisibilityExplicit(), LVForType, LVForValue, clang::LinkageInfo::merge(), clang::LinkageInfo::mergeMaybeWithVisibility(), mergeTemplateLV(), clang::LinkageInfo::mergeVisibility(), clang::SC_Extern, clang::SC_None, clang::SC_PrivateExtern, clang::SC_Static, clang::UniqueExternalLinkage, and useInlineVisibilityHidden().
Referenced by computeLVForDecl().
|
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 316 of file Decl.cpp.
References getLVForDecl(), getLVForType(), clang::LinkageInfo::merge(), and usesTypeVisibility().
Referenced by getLVForTemplateArgumentList(), and mergeTemplateLV().
|
static |
Definition at line 360 of file Decl.cpp.
References clang::TemplateArgumentList::asArray(), and getLVForTemplateArgumentList().
|
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 243 of file Decl.cpp.
References clang::Type::getLinkageAndVisibility(), getLVForType(), clang::Type::isDependentType(), clang::LinkageInfo::merge(), P, and clang::ast_matchers::type.
Referenced by getLVForClassMember(), getLVForNamespaceScopeDecl(), and mergeTemplateLV().
|
static |
Definition at line 233 of file Decl.cpp.
References clang::DefaultVisibility, clang::Type::getLinkage(), clang::Type::getLinkageAndVisibility(), and LVForLinkageOnly.
Referenced by getLVForClassMember(), getLVForNamespaceScopeDecl(), getLVForTemplateArgumentList(), and getLVForTemplateParameterList().
Retrieve the number of module identifiers needed to name the given module.
Definition at line 4216 of file Decl.cpp.
References clang::Module::Parent, and clang::Result.
Referenced by clang::ImportDecl::getIdentifierLocs().
|
inlinestatic |
Definition at line 1215 of file Decl.cpp.
References clang::DeclContext::getParent(), and clang::CXXRecordDecl::isLambda().
Referenced by computeLVForDecl().
Definition at line 300 of file Decl.cpp.
References clang::DeclContext::getDeclKind(), and clang::DeclContext::getParent().
Referenced by getLVForLocalDecl().
|
static |
Definition at line 1636 of file Decl.cpp.
Referenced by clang::DeclaratorDecl::getOuterLocStart(), and clang::TagDecl::getOuterLocStart().
|
static |
Given a visibility attribute, return the explicit visibility associated with it.
Definition at line 193 of file Decl.cpp.
References clang::DefaultVisibility, clang::HiddenVisibility, and clang::ProtectedVisibility.
Referenced by getVisibilityOf().
|
static |
Return the explicit visibility of the given declaration.
Definition at line 206 of file Decl.cpp.
References clang::DefaultVisibility, getVisibilityFromAttr(), and clang::None.
Referenced by getExplicitVisibilityAux().
|
static |
Does the given declaration have a direct visibility attribute that would match the given rules?
Definition at line 405 of file Decl.cpp.
References LVForExplicitType, LVForExplicitValue, LVForLinkageOnly, LVForType, and LVForValue.
Referenced by getLVForClassMember(), and shouldConsiderTemplateVisibility().
|
static |
Does this computation kind permit us to consider additional visibility settings from attributes and the like?
Definition at line 138 of file Decl.cpp.
References IgnoreExplicitVisibilityBit.
Referenced by getExplicitVisibility(), getLVForClassMember(), getLVForLocalDecl(), getLVForNamespaceScopeDecl(), mergeTemplateLV(), and shouldConsiderTemplateVisibility().
|
static |
Definition at line 1880 of file Decl.cpp.
References clang::CLanguageLinkage, and clang::DeclContext::isRecord().
Referenced by clang::VarDecl::isExternC(), and clang::FunctionDecl::isExternC().
|
static |
Does the given declaration have member specialization information, and if so, is it an explicit specialization?
Definition at line 175 of file Decl.cpp.
Referenced by getLVForClassMember().
|
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 186 of file Decl.cpp.
References clang::RedeclarableTemplateDecl::isMemberSpecialization().
|
static |
Definition at line 566 of file Decl.cpp.
Referenced by getDeclLanguageLinkage(), and getLVForNamespaceScopeDecl().
|
static |
Definition at line 2515 of file Decl.cpp.
References clang::NamedDecl::getIdentifier(), and clang::IdentifierInfo::isStr().
Referenced by clang::FunctionDecl::isMain(), and clang::FunctionDecl::isReplaceableGlobalAllocationFunction().
|
static |
Definition at line 1503 of file Decl.cpp.
Referenced by clang::NamedDecl::declarationReplaces().
|
static |
Definition at line 571 of file Decl.cpp.
Referenced by getLVForNamespaceScopeDecl(), and clang::VarDecl::isThisDeclarationADefinition().
|
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 385 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 |
Merge in template-related linkage and visibility for the given class template specialization.
Definition at line 462 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 |
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 514 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 |
Definition at line 2829 of file Decl.cpp.
References clang::FunctionDecl::getStorageClass(), clang::FunctionDecl::isInlineSpecified(), clang::DeclContext::isTranslationUnit(), and clang::SC_Extern.
Referenced by clang::FunctionDecl::doesDeclarationForceExternallyVisibleDefinition(), and clang::FunctionDecl::isInlineDefinitionExternallyVisible().
|
static |
Definition at line 2817 of file Decl.cpp.
References clang::Redeclarable< decl_type >::getPreviousDecl(), clang::FunctionDecl::getStorageClass(), and clang::SC_Extern.
Referenced by clang::FunctionDecl::doesDeclarationForceExternallyVisibleDefinition().
|
static |
Definition at line 365 of file Decl.cpp.
References clang::FunctionTemplateSpecializationInfo::isExplicitInstantiationOrSpecialization().
Referenced by mergeTemplateLV().
|
static |
Should we consider visibility associated with the template arguments and parameters of the given class template specialization?
Definition at line 426 of file Decl.cpp.
References hasDirectVisibilityAttribute(), hasExplicitVisibilityAlready(), clang::ClassTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization(), and clang::ClassTemplateSpecializationDecl::isExplicitSpecialization().
|
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 490 of file Decl.cpp.
References hasDirectVisibilityAttribute(), hasExplicitVisibilityAlready(), clang::VarTemplateSpecializationDecl::isExplicitInstantiationOrSpecialization(), and clang::VarTemplateSpecializationDecl::isExplicitSpecialization().
Definition at line 538 of file Decl.cpp.
References clang::FunctionDecl::isInlined(), clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, and clang::TSK_Undeclared.
Referenced by getLVForClassMember(), and getLVForNamespaceScopeDecl().
Is the given declaration a "type" or a "value" for the purposes of visibility computation?
Definition at line 165 of file Decl.cpp.
Referenced by clang::NamedDecl::getLinkageAndVisibility(), and getLVForTemplateArgumentList().
|
static |
Given an LVComputationKind, return one of the same type/value sort that records that it already has explicit visibility.
Definition at line 145 of file Decl.cpp.
References IgnoreExplicitVisibilityBit, LVForExplicitType, LVForExplicitValue, LVForType, and LVForValue.
Referenced by getLVForClassMember().
const unsigned IgnoreExplicitVisibilityBit = 2 |
Definition at line 104 of file Decl.cpp.
Referenced by hasExplicitVisibilityAlready(), and withExplicitVisibilityAlready().