summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-13 20:13:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-13 20:13:06 +0000
commit98703d3883309f1a5eacf05299e0b850668334d5 (patch)
tree11284b550f11e59c2d2268d93bbb1dfc32fbe11d /clang/lib/Sema/Sema.cpp
parentf288803a95d5d156030fc727b2c05f2d14e4ee89 (diff)
downloadbcm5719-llvm-98703d3883309f1a5eacf05299e0b850668334d5.tar.gz
bcm5719-llvm-98703d3883309f1a5eacf05299e0b850668334d5.zip
Revert 111026 & 111027, build breakage.
llvm-svn: 111036
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp62
1 files changed, 9 insertions, 53 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index df9bb07cf94..f5c85ad99cd 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -235,42 +235,6 @@ void Sema::DeleteExpr(ExprTy *E) {
void Sema::DeleteStmt(StmtTy *S) {
}
-/// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector.
-static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
- if (D->isUsed())
- return true;
-
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- // UnusedFileScopedDecls stores the first declaration.
- // The declaration may have become definition so check again.
- const FunctionDecl *DeclToCheck;
- if (FD->hasBody(DeclToCheck))
- return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
-
- // Later redecls may add new information resulting in not having to warn,
- // so check again.
- DeclToCheck = FD->getMostRecentDeclaration();
- if (DeclToCheck != FD)
- return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
- }
-
- if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
- // UnusedFileScopedDecls stores the first declaration.
- // The declaration may have become definition so check again.
- const VarDecl *DeclToCheck = VD->getDefinition();
- if (DeclToCheck)
- return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
-
- // Later redecls may add new information resulting in not having to warn,
- // so check again.
- DeclToCheck = VD->getMostRecentDeclaration();
- if (DeclToCheck != VD)
- return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
- }
-
- return false;
-}
-
/// ActOnEndOfTranslationUnit - This is called at the very end of the
/// translation unit when EOF is reached and all but the top-level scope is
/// popped.
@@ -299,10 +263,10 @@ void Sema::ActOnEndOfTranslationUnit() {
}
// Remove file scoped decls that turned out to be used.
- UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(),
- UnusedFileScopedDecls.end(),
- std::bind1st(std::ptr_fun(ShouldRemoveFromUnused),
- this)),
+ UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(),
+ UnusedFileScopedDecls.end(),
+ std::bind2nd(std::mem_fun(&DeclaratorDecl::isUsed),
+ true)),
UnusedFileScopedDecls.end());
if (!CompleteTranslationUnit)
@@ -370,19 +334,11 @@ void Sema::ActOnEndOfTranslationUnit() {
for (std::vector<const DeclaratorDecl*>::iterator
I = UnusedFileScopedDecls.begin(),
E = UnusedFileScopedDecls.end(); I != E; ++I) {
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
- const FunctionDecl *DiagD;
- if (!FD->hasBody(DiagD))
- DiagD = FD;
- Diag(DiagD->getLocation(), diag::warn_unused_function)
- << DiagD->getDeclName();
- } else {
- const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
- if (!DiagD)
- DiagD = cast<VarDecl>(*I);
- Diag(DiagD->getLocation(), diag::warn_unused_variable)
- << DiagD->getDeclName();
- }
+ 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