diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-07 20:29:57 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-07 20:29:57 +0000 |
commit | fc2ca56874e1c8186ac30c0c3af13dc5e806cf74 (patch) | |
tree | b93fda17aafc4405faf414b943bd33d2cc82a98f /lib | |
parent | b205ac9fcd22b87b41697172d1983c5ae9dabaaf (diff) |
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>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/Sema.h | 4 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index c93acf6946..a6bcc4375e 100644 --- a/lib/Sema/Sema.h +++ b/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/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 7967a342a2..b78e8b5b67 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/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()) |