Fix unused function warning to handle used attributes and redeclarations. Update test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96444 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 863a1cb..222adcb 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -194,6 +194,24 @@
   return getTranslationUnitDecl()->getASTContext();
 }
 
+bool Decl::isUsed() const { 
+  if (Used)
+    return true;
+  
+  // Check for used attribute.
+  if (hasAttr<UsedAttr>())
+    return true;
+  
+  // Check redeclarations for used attribute.
+  for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
+    if (I->hasAttr<UsedAttr>() || I->Used)
+      return true;
+  }
+  
+  return false; 
+}
+
+
 unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
   switch (DeclKind) {
     case Function: