[cfe-commits] r100686 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp

Douglas Gregor dgregor at apple.com
Wed Apr 7 13:29:57 PDT 2010


Author: dgregor
Date: Wed Apr  7 15:29:57 2010
New Revision: 100686

URL: http://llvm.org/viewvc/llvm-project?rev=100686&view=rev
Log:
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>


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=100686&r1=100685&r2=100686&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Apr  7 15:29:57 2010
@@ -843,6 +843,10 @@
   /// 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>())

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=100686&r1=100685&r2=100686&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr  7 15:29:57 2010
@@ -7311,9 +7311,14 @@
   // (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())





More information about the cfe-commits mailing list