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.

llvm-svn: 176606
This commit is contained in:
Rafael Espindola 2013-03-07 01:42:44 +00:00
parent 1e4272085d
commit 8f326a5a39
2 changed files with 10 additions and 5 deletions

View File

@ -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.

View File

@ -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)