Add r168519 back, but with a fix to also merge the used flag in variables.

llvm-svn: 168564
This commit is contained in:
Rafael Espindola 2012-11-25 14:07:59 +00:00
parent 48cf0dc360
commit befe130dd2
2 changed files with 8 additions and 7 deletions

View File

@ -261,13 +261,6 @@ bool Decl::isUsed(bool CheckUsedAttr) const {
if (CheckUsedAttr && hasAttr<UsedAttr>()) if (CheckUsedAttr && hasAttr<UsedAttr>())
return true; return true;
// Check redeclarations. We merge attributes, so we don't need to check
// attributes in all redeclarations.
for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
if (I->Used)
return true;
}
return false; return false;
} }

View File

@ -2388,6 +2388,10 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
if (Old->isPure()) if (Old->isPure())
New->setPure(); New->setPure();
// Merge "used" flag.
if (Old->isUsed(false))
New->setUsed();
// Merge attributes from the parameters. These can mismatch with K&R // Merge attributes from the parameters. These can mismatch with K&R
// declarations. // declarations.
if (New->getNumParams() == Old->getNumParams()) if (New->getNumParams() == Old->getNumParams())
@ -2613,6 +2617,10 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
New->getDeclContext() == Old->getDeclContext()) New->getDeclContext() == Old->getDeclContext())
New->setStorageClass(Old->getStorageClass()); New->setStorageClass(Old->getStorageClass());
// Merge "used" flag.
if (Old->isUsed(false))
New->setUsed();
// Keep a chain of previous declarations. // Keep a chain of previous declarations.
New->setPreviousDeclaration(Old); New->setPreviousDeclaration(Old);