r176157 - Change Type::getLinkageAndVisibility to return a LinkageInfo.
Rafael Espindola
rafael.espindola at gmail.com
Tue Feb 26 18:27:20 PST 2013
Author: rafael
Date: Tue Feb 26 20:27:19 2013
New Revision: 176157
URL: http://llvm.org/viewvc/llvm-project?rev=176157&view=rev
Log:
Change Type::getLinkageAndVisibility to return a LinkageInfo.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/Type.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=176157&r1=176156&r2=176157&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Feb 26 20:27:19 2013
@@ -1775,13 +1775,17 @@ public:
Linkage getLinkage() const;
/// \brief Determine the visibility of this type.
- Visibility getVisibility() const;
+ Visibility getVisibility() const {
+ return getLinkageAndVisibility().visibility();
+ }
/// \brief Return true if the visibility was explicitly set is the code.
- bool isVisibilityExplicit() const;
+ bool isVisibilityExplicit() const {
+ return getLinkageAndVisibility().visibilityExplicit();
+ }
/// \brief Determine the linkage and visibility of this type.
- std::pair<Linkage,Visibility> getLinkageAndVisibility() const;
+ LinkageInfo getLinkageAndVisibility() const;
/// \brief Note that the linkage is no longer known.
void ClearLinkageCache();
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=176157&r1=176156&r2=176157&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Feb 26 20:27:19 2013
@@ -211,11 +211,6 @@ static Optional<Visibility> getVisibilit
return None;
}
-static LinkageInfo getLVForType(QualType T) {
- std::pair<Linkage,Visibility> P = T->getLinkageAndVisibility();
- return LinkageInfo(P.first, P.second, T->isVisibilityExplicit());
-}
-
/// \brief 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.
@@ -239,7 +234,7 @@ getLVForTemplateParameterList(const Temp
// Handle the non-pack case first.
if (!NTTP->isExpandedParameterPack()) {
if (!NTTP->getType()->isDependentType()) {
- LV.merge(getLVForType(NTTP->getType()));
+ LV.merge(NTTP->getType()->getLinkageAndVisibility());
}
continue;
}
@@ -248,7 +243,7 @@ getLVForTemplateParameterList(const Temp
for (unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
QualType type = NTTP->getExpansionType(i);
if (!type->isDependentType())
- LV.merge(getLVForType(type));
+ LV.merge(type->getLinkageAndVisibility());
}
continue;
}
@@ -296,7 +291,7 @@ getLVForTemplateArgumentList(ArrayRef<Te
continue;
case TemplateArgument::Type:
- LV.merge(getLVForType(arg.getAsType()));
+ LV.merge(arg.getAsType()->getLinkageAndVisibility());
continue;
case TemplateArgument::Declaration:
@@ -307,7 +302,7 @@ getLVForTemplateArgumentList(ArrayRef<Te
continue;
case TemplateArgument::NullPtr:
- LV.merge(getLVForType(arg.getNullPtrType()));
+ LV.merge(arg.getNullPtrType()->getLinkageAndVisibility());
continue;
case TemplateArgument::Template:
@@ -627,7 +622,7 @@ static LinkageInfo getLVForNamespaceScop
// because of this, but unique-external linkage suits us.
if (Context.getLangOpts().CPlusPlus &&
!Var->getDeclContext()->isExternCContext()) {
- LinkageInfo TypeLV = getLVForType(Var->getType());
+ LinkageInfo TypeLV = Var->getType()->getLinkageAndVisibility();
if (TypeLV.linkage() != ExternalLinkage)
return LinkageInfo::uniqueExternal();
if (!LV.visibilityExplicit())
@@ -819,7 +814,7 @@ static LinkageInfo getLVForClassMember(c
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
// Modify the variable's linkage by its type, but ignore the
// type's visibility unless it's a definition.
- LinkageInfo typeLV = getLVForType(VD->getType());
+ LinkageInfo typeLV = VD->getType()->getLinkageAndVisibility();
LV.mergeMaybeWithVisibility(typeLV,
!LV.visibilityExplicit() && !classLV.visibilityExplicit());
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=176157&r1=176156&r2=176157&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Feb 26 20:27:19 2013
@@ -2170,25 +2170,16 @@ Linkage Type::getLinkage() const {
return TypeBits.getLinkage();
}
-/// \brief Determine the linkage of this type.
-Visibility Type::getVisibility() const {
- Cache::ensure(this);
- return TypeBits.getVisibility();
-}
-
-bool Type::isVisibilityExplicit() const {
- Cache::ensure(this);
- return TypeBits.isVisibilityExplicit();
-}
-
bool Type::hasUnnamedOrLocalType() const {
Cache::ensure(this);
return TypeBits.hasLocalOrUnnamedType();
}
-std::pair<Linkage,Visibility> Type::getLinkageAndVisibility() const {
+LinkageInfo Type::getLinkageAndVisibility() const {
Cache::ensure(this);
- return std::make_pair(TypeBits.getLinkage(), TypeBits.getVisibility());
+ LinkageInfo LV(TypeBits.getLinkage(), TypeBits.getVisibility(),
+ TypeBits.isVisibilityExplicit());
+ return LV;
}
void Type::ClearLinkageCache() {
More information about the cfe-commits
mailing list