Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/Decl.cpp
Show First 20 Lines • Show All 594 Lines • ▼ Show 20 Lines | case Decl::ModuleOwnershipKind::ModulePrivate: | ||||
return false; | return false; | ||||
case Decl::ModuleOwnershipKind::Visible: | case Decl::ModuleOwnershipKind::Visible: | ||||
case Decl::ModuleOwnershipKind::VisibleWhenImported: | case Decl::ModuleOwnershipKind::VisibleWhenImported: | ||||
return isInModulePurview(D); | return isInModulePurview(D); | ||||
} | } | ||||
llvm_unreachable("unexpected module ownership kind"); | llvm_unreachable("unexpected module ownership kind"); | ||||
} | } | ||||
static bool isDeclaredInModuleInterfaceOrPartition(const NamedDecl *D) { | |||||
if (auto *M = D->getOwningModule()) | |||||
return M->isInterfaceOrPartition(); | |||||
return false; | |||||
} | |||||
static LinkageInfo getInternalLinkageFor(const NamedDecl *D) { | static LinkageInfo getInternalLinkageFor(const NamedDecl *D) { | ||||
return LinkageInfo::internal(); | return LinkageInfo::internal(); | ||||
} | } | ||||
static LinkageInfo getExternalLinkageFor(const NamedDecl *D) { | static LinkageInfo getExternalLinkageFor(const NamedDecl *D) { | ||||
return LinkageInfo::external(); | return LinkageInfo::external(); | ||||
} | } | ||||
Show All 26 Lines | if (getStorageClass(D->getCanonicalDecl()) == SC_Static) { | ||||
// that is explicitly declared static; or | // that is explicitly declared static; or | ||||
// (This bullet corresponds to C99 6.2.2p3.) | // (This bullet corresponds to C99 6.2.2p3.) | ||||
return getInternalLinkageFor(D); | return getInternalLinkageFor(D); | ||||
} | } | ||||
if (const auto *Var = dyn_cast<VarDecl>(D)) { | if (const auto *Var = dyn_cast<VarDecl>(D)) { | ||||
// - a non-template variable of non-volatile const-qualified type, unless | // - a non-template variable of non-volatile const-qualified type, unless | ||||
// - it is explicitly declared extern, or | // - it is explicitly declared extern, or | ||||
// - it is inline or exported, or | // - it is declared in the purview of a module interface unit | ||||
// (outside the private-module-fragment, if any) or module partition, or | |||||
// - it is inline, or | |||||
// - it was previously declared and the prior declaration did not have | // - it was previously declared and the prior declaration did not have | ||||
// internal linkage | // internal linkage | ||||
// (There is no equivalent in C99.) | // (There is no equivalent in C99.) | ||||
if (Context.getLangOpts().CPlusPlus && | if (Context.getLangOpts().CPlusPlus && Var->getType().isConstQualified() && | ||||
Var->getType().isConstQualified() && | !Var->getType().isVolatileQualified() && !Var->isInline() && | ||||
!Var->getType().isVolatileQualified() && | !isDeclaredInModuleInterfaceOrPartition(Var) && | ||||
!Var->isInline() && | |||||
!isExportedFromModuleInterfaceUnit(Var) && | |||||
!isa<VarTemplateSpecializationDecl>(Var) && | !isa<VarTemplateSpecializationDecl>(Var) && | ||||
!Var->getDescribedVarTemplate()) { | !Var->getDescribedVarTemplate()) { | ||||
const VarDecl *PrevVar = Var->getPreviousDecl(); | const VarDecl *PrevVar = Var->getPreviousDecl(); | ||||
if (PrevVar) | if (PrevVar) | ||||
return getLVForDecl(PrevVar, computation); | return getLVForDecl(PrevVar, computation); | ||||
if (Var->getStorageClass() != SC_Extern && | if (Var->getStorageClass() != SC_Extern && | ||||
Var->getStorageClass() != SC_PrivateExtern && | Var->getStorageClass() != SC_PrivateExtern && | ||||
▲ Show 20 Lines • Show All 4,770 Lines • Show Last 20 Lines |