Add a hasExternalStorageAsWritten helper. No functionality change.

It is possible that some of the current uses of
"getStorageClassAsWritten() == SC_Extern" should use this but I don't know
enough about SC_PrivateExtern to change and test them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176606 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2013-03-07 01:42:44 +00:00
Родитель 58bd77f613
Коммит 377830097a
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -800,6 +800,13 @@ public:
getStorageClass() == SC_PrivateExtern;
}
/// hasExternalStorageAsWritten - Returns true if a variable was written
/// with extern or __private_extern__ storage.
bool hasExternalStorageAsWritten() const {
return getStorageClassAsWritten() == SC_Extern ||
getStorageClassAsWritten() == SC_PrivateExtern;
}
/// hasGlobalStorage - Returns true for all variables that do not
/// have local storage. This includs all global variables as well
/// as static variables declared within a function.

Просмотреть файл

@ -1049,8 +1049,7 @@ static LinkageInfo getLVForLocalDecl(const NamedDecl *D,
}
if (const VarDecl *Var = dyn_cast<VarDecl>(D)) {
if (Var->getStorageClassAsWritten() == SC_Extern ||
Var->getStorageClassAsWritten() == SC_PrivateExtern) {
if (Var->hasExternalStorageAsWritten()) {
if (Var->isInAnonymousNamespace() &&
!Var->getDeclContext()->isExternCContext())
return LinkageInfo::uniqueExternal();
@ -1601,8 +1600,7 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition(
if (hasExternalStorage())
return DeclarationOnly;
if (getStorageClassAsWritten() == SC_Extern ||
getStorageClassAsWritten() == SC_PrivateExtern) {
if (hasExternalStorageAsWritten()) {
for (const VarDecl *PrevVar = getPreviousDecl();
PrevVar; PrevVar = PrevVar->getPreviousDecl()) {
if (PrevVar->getLinkage() == InternalLinkage)