r285983 - Delete a trivially true check for a variable 'S' being null.

Chandler Carruth via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 3 23:16:09 PDT 2016

Author: chandlerc
Date: Fri Nov  4 01:16:09 2016
New Revision: 285983

URL: http://llvm.org/viewvc/llvm-project?rev=285983&view=rev
Delete a trivially true check for a variable 'S' being null.

The exact same test guards entry into the loop in which this test
occurs, and there is nothing inside the loop that assigns to the
variable, so it has already been checked for null.

This was flagged by PVS-Studio as well, but the report is actually wrong
-- this is not a case where we dereference a variable prior to testing
it for null, this is a case where we have a redundant test for null
after we already performed the exact same test.


Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=285983&r1=285982&r2=285983&view=diff
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Nov  4 01:16:09 2016
@@ -1293,7 +1293,7 @@ bool Sema::CppLookupName(LookupResult &R
         // If we have a context, and it's not a context stashed in the
         // template parameter scope for an out-of-line definition, also
         // look into that context.
-        if (!(Found && S && S->isTemplateParamScope())) {
+        if (!(Found && S->isTemplateParamScope())) {
           assert(Ctx->isFileContext() &&
               "We should have been looking only at file context here already.");

More information about the cfe-commits mailing list