Avoid calculating linkage until the more obvious checks have run when

deciding whether to queue a decl for unused-declaration warnings.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117431 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2010-10-27 01:41:35 +00:00
Родитель d4aff0e2b7
Коммит 82b965992f
1 изменённых файлов: 18 добавлений и 15 удалений

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

@ -559,10 +559,6 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const {
if (D->getDeclContext()->isDependentContext())
return false;
// We warn for unused decls internal to the translation unit.
if (D->getLinkage() == ExternalLinkage)
return false;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return false;
@ -577,25 +573,32 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const {
return false;
}
if (FD->isThisDeclarationADefinition())
return !Context.DeclMustBeEmitted(FD);
return true;
}
if (FD->isThisDeclarationADefinition() &&
Context.DeclMustBeEmitted(FD))
return false;
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (!VD->isFileVarDecl() ||
VD->getType().isConstant(Context) ||
Context.DeclMustBeEmitted(VD))
return false;
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (VD->isStaticDataMember() &&
VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return false;
if ( VD->isFileVarDecl() &&
!VD->getType().isConstant(Context))
return !Context.DeclMustBeEmitted(VD);
} else {
return false;
}
return false;
}
// Only warn for unused decls internal to the translation unit.
if (D->getLinkage() == ExternalLinkage)
return false;
void Sema::MarkUnusedFileScopedDecl(const DeclaratorDecl *D) {
return true;
}
void Sema::MarkUnusedFileScopedDecl(const DeclaratorDecl *D) {
if (!D)
return;