From c232cb8542b5d057058595dc556c52884d8ff153 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sat, 24 Nov 2012 23:17:09 +0000 Subject: [PATCH] Revert r168519, "Merge used flags so that we don't have to iterate on isUsed. With this change" It brought bunch of (possibly false) warnings. llvm/unittests/VMCore/PassManagerTest.cpp:60:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleNDNM::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:86:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleNDM2::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:106:21: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char ModuleDNM::ID=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:217:16: warning: variable 'initcount' is not needed and will not be emitted [-Wunneeded-internal-declaration] int LPass::initcount=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:218:16: warning: variable 'fincount' is not needed and will not be emitted [-Wunneeded-internal-declaration] int LPass::fincount=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:259:16: warning: variable 'inited' is not needed and will not be emitted [-Wunneeded-internal-declaration] int BPass::inited=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:260:16: warning: variable 'fin' is not needed and will not be emitted [-Wunneeded-internal-declaration] int BPass::fin=0; ^ llvm/unittests/VMCore/PassManagerTest.cpp:283:24: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration] char OnTheFlyTest::ID=0; ^ 8 warnings generated. llvm-svn: 168549 --- clang/lib/AST/DeclBase.cpp | 7 +++++++ clang/lib/Sema/SemaDecl.cpp | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index b04c149..7b20e775 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -261,6 +261,13 @@ bool Decl::isUsed(bool CheckUsedAttr) const { if (CheckUsedAttr && hasAttr()) 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; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e482110..629fccc 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2388,10 +2388,6 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, if (Old->isPure()) New->setPure(); - // Merge "used" flag. - if (Old->isUsed(false)) - New->setUsed(); - // Merge attributes from the parameters. These can mismatch with K&R // declarations. if (New->getNumParams() == Old->getNumParams()) -- 2.7.4