aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-02-17 02:17:21 +0000
committerTanya Lattner <tonic@nondot.org>2010-02-17 02:17:21 +0000
commit12ead498c4bc279472b21d446bfccec0f654779e (patch)
tree60fe0b4d67fdd486719f1ad573faad0805307e1c /lib/AST/DeclBase.cpp
parentc3f2d2bb839593eed8861bce14228df0faf7b6c0 (diff)
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
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 863a1cbd03..222adcb28e 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -194,6 +194,24 @@ ASTContext &Decl::getASTContext() const {
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: