summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-13 18:42:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-13 18:42:17 +0000
commit35672e78523162ab292962ce5aec3f512ee5cf8a (patch)
tree3fc477ff544140ebd4fe96a5b0fa46005c823a99 /clang/lib/Sema/Sema.cpp
parent5cd66587988e8fc858ca1c32f7cb295966fd824d (diff)
downloadbcm5719-llvm-35672e78523162ab292962ce5aec3f512ee5cf8a.tar.gz
bcm5719-llvm-35672e78523162ab292962ce5aec3f512ee5cf8a.zip
Change Sema's UnusedStaticFuncs to UnusedFileScopedDecls to allow also keeping track of unused file scoped variables.
This is only preparation, currently only static function definitions are tracked, as before. llvm-svn: 111025
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 778bf8c98a2..f5c85ad99cd 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -262,12 +262,12 @@ void Sema::ActOnEndOfTranslationUnit() {
break;
}
- // Remove functions that turned out to be used.
- UnusedStaticFuncs.erase(std::remove_if(UnusedStaticFuncs.begin(),
- UnusedStaticFuncs.end(),
- std::bind2nd(std::mem_fun(&FunctionDecl::isUsed),
+ // Remove file scoped decls that turned out to be used.
+ UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(),
+ UnusedFileScopedDecls.end(),
+ std::bind2nd(std::mem_fun(&DeclaratorDecl::isUsed),
true)),
- UnusedStaticFuncs.end());
+ UnusedFileScopedDecls.end());
if (!CompleteTranslationUnit)
return;
@@ -330,14 +330,16 @@ void Sema::ActOnEndOfTranslationUnit() {
}
- // Output warning for unused functions.
- for (std::vector<FunctionDecl*>::iterator
- F = UnusedStaticFuncs.begin(),
- FEnd = UnusedStaticFuncs.end();
- F != FEnd;
- ++F)
- Diag((*F)->getLocation(), diag::warn_unused_function) << (*F)->getDeclName();
-
+ // Output warning for unused file scoped decls.
+ for (std::vector<const DeclaratorDecl*>::iterator
+ I = UnusedFileScopedDecls.begin(),
+ E = UnusedFileScopedDecls.end(); I != E; ++I) {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I))
+ Diag(FD->getLocation(), diag::warn_unused_function) << FD->getDeclName();
+ else
+ Diag((*I)->getLocation(), diag::warn_unused_variable)
+ << cast<VarDecl>(*I)->getDeclName();
+ }
}
OpenPOWER on IntegriCloud