]> granicus.if.org Git - clang/commitdiff
A decl never becomes unused. Make that explicit in the API.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 23 Oct 2013 16:46:34 +0000 (16:46 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 23 Oct 2013 16:46:34 +0000 (16:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193248 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Serialization/ASTReaderDecl.cpp

index 716b8853273059d8bfe4a91d7ec3abebd524c2a8..f8c69f99297d0cbd07ab8ef5cc99d1850ea353f9 100644 (file)
@@ -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.
   ///
index bc7be6d4593ea4bfb253891a3e628d39e26642cb..ba7892840608f79fe549f2109574409fd56a0de1 100644 (file)
@@ -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);
index 3989c56ccd8d63b5bad4cba2496db83b749028b4..f5c4c72cb349155e0f2e0a16827b8cbdeb4551d2 100644 (file)
@@ -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());
   }
 
index 0c885bc5792146a7a0b8752c5e1034b9bed5f67c..d3937fcff05df89686513e6581b368966bf88f58 100644 (file)
@@ -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;
     }
     }