r193248 - A decl never becomes unused. Make that explicit in the API.
Rafael Espindola
rafael.espindola at gmail.com
Wed Oct 23 09:46:34 PDT 2013
Author: rafael
Date: Wed Oct 23 11:46:34 2013
New Revision: 193248
URL: http://llvm.org/viewvc/llvm-project?rev=193248&view=rev
Log:
A decl never becomes unused. Make that explicit in the API.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=193248&r1=193247&r2=193248&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Oct 23 11:46:34 2013
@@ -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.
///
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=193248&r1=193247&r2=193248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 23 11:46:34 2013
@@ -2801,7 +2801,8 @@ bool Sema::MergeCompatibleFunctionDecls(
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, Lo
}
// 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);
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=193248&r1=193247&r2=193248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Oct 23 11:46:34 2013
@@ -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());
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=193248&r1=193247&r2=193248&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Oct 23 11:46:34 2013
@@ -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,
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;
}
}
More information about the cfe-commits
mailing list