mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-02 19:56:05 +00:00
Add r168519 back, but with a fix to also merge the used flag in variables.
llvm-svn: 168564
This commit is contained in:
parent
48cf0dc360
commit
befe130dd2
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user