From: Rafael Espindola Date: Wed, 23 Oct 2013 16:46:34 +0000 (+0000) Subject: A decl never becomes unused. Make that explicit in the API. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7bd89af8aa96a779c0031baf1a21e960a51d0f0;p=clang A decl never becomes unused. Make that explicit in the API. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193248 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 716b885327..f8c69f9929 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -508,7 +508,7 @@ public: /// \brief Set whether the declaration is used, in the sense of odr-use. /// /// This should only be used immediately after creating a declaration. - void setIsUsed(bool U) { Used = U; } + void setIsUsed() { Used = true; } /// \brief Mark the declaration used, in the sense of odr-use. /// diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index bc7be6d459..ba78928406 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2801,7 +2801,8 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, New->setPure(); // Merge "used" flag. - New->setIsUsed(Old->getMostRecentDecl()->isUsed(false)); + if (Old->getMostRecentDecl()->isUsed(false)) + New->setIsUsed(); // Merge attributes from the parameters. These can mismatch with K&R // declarations. @@ -3114,7 +3115,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { } // Merge "used" flag. - New->setIsUsed(Old->getMostRecentDecl()->isUsed(false)); + if (Old->getMostRecentDecl()->isUsed(false)) + New->setIsUsed(); // Keep a chain of previous declarations. New->setPreviousDecl(Old); diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 3989c56ccd..f5c4c72cb3 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3378,7 +3378,8 @@ void Sema::BuildVariableInstantiation( NewVar->setAccess(OldVar->getAccess()); if (!OldVar->isStaticDataMember()) { - NewVar->setIsUsed(OldVar->isUsed(false)); + if (OldVar->isUsed(false)) + NewVar->setIsUsed(); NewVar->setReferenced(OldVar->isReferenced()); } diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 0c885bc579..d3937fcff0 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -386,7 +386,7 @@ void ASTDeclReader::VisitDecl(Decl *D) { D->setAttrsImpl(Attrs, Reader.getContext()); } D->setImplicit(Record[Idx++]); - D->setIsUsed(Record[Idx++]); + D->Used = Record[Idx++]; D->setReferenced(Record[Idx++]); D->setTopLevelDeclInObjCContainer(Record[Idx++]); D->setAccess((AccessSpecifier)Record[Idx++]); @@ -2989,7 +2989,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, case UPD_DECL_MARKED_USED: { // FIXME: This doesn't send the right notifications if there are // ASTMutationListeners other than an ASTWriter. - D->setIsUsed(true); + D->Used = true; break; } }