summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-07 20:29:57 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-07 20:29:57 +0000
commitfd27fed58462229be261321c377146c045ad66ab (patch)
tree3e86335d41d0e31a7b51ac987cccc156b0d64383 /clang
parent643a55708f129a68a21649358b27ba096322eb2d (diff)
downloadbcm5719-llvm-fd27fed58462229be261321c377146c045ad66ab.tar.gz
bcm5719-llvm-fd27fed58462229be261321c377146c045ad66ab.zip
Return early from Sema::MarkDeclarationReferenced when we know there
isn't any extra work to perform. Also, don't check for unused parameters when the warnings will be suppressed anyway. Improves performance of -fsyntax-only on 403.gcc's combine.c by ~2.5%. <rdar://problem/7836787> llvm-svn: 100686
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/Sema.h4
-rw-r--r--clang/lib/Sema/SemaExpr.cpp9
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index c93acf69461..a6bcc4375e4 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -843,6 +843,10 @@ public:
/// ParmVarDecl pointers.
template<typename InputIterator>
void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) {
+ if (Diags.getDiagnosticLevel(diag::warn_unused_parameter) ==
+ Diagnostic::Ignored)
+ return;
+
for (; Param != ParamEnd; ++Param) {
if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
!(*Param)->template hasAttr<UnusedAttr>())
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7967a342a25..b78e8b5b67b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7311,9 +7311,14 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
// (e.g. (void)sizeof()) constitute a use for warning purposes (-Wunused-variables and
// -Wunused-parameters)
if (isa<ParmVarDecl>(D) ||
- (isa<VarDecl>(D) && D->getDeclContext()->isFunctionOrMethod()))
+ (isa<VarDecl>(D) && D->getDeclContext()->isFunctionOrMethod())) {
D->setUsed(true);
-
+ return;
+ }
+
+ if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D))
+ return;
+
// Do not mark anything as "used" within a dependent context; wait for
// an instantiation.
if (CurContext->isDependentContext())
OpenPOWER on IntegriCloud