[cfe-commits] r92162 - in /cfe/trunk/lib: AST/ASTContext.cpp AST/ExprConstant.cpp Analysis/GRExprEngine.cpp CodeGen/CGExprCXX.cpp CodeGen/CGExprScalar.cpp CodeGen/CGObjCMac.cpp Driver/Driver.cpp Sema/SemaCXXCast.cpp Sema/SemaCodeComplete.cpp Sema/SemaDeclCXX.cpp Sema/SemaExpr.cpp Sema/SemaStmt.cpp

Ted Kremenek kremenek at apple.com
Sat Dec 26 11:44:50 PST 2009


Hi Ben,

Thanks for doing this.  My only caution is that static analysis  
support for C++ is very much in the early stages.  While the dead  
stores checker in particular is designed to be a sound check, I  
wouldn't vouch that it has reached that state yet for C++.  In other  
words, carefully verify all results before making changes (which I'm  
sure you did in this case).

Ted

On Dec 25, 2009, at 7:43 AM, Benjamin Kramer  
<benny.kra at googlemail.com> wrote:

> Author: d0k
> Date: Fri Dec 25 09:43:36 2009
> New Revision: 92162
>
> URL: http://llvm.org/viewvc/llvm-project?rev=92162&view=rev
> Log:
> Remove some dead variables clang-analyzer found.
>
> Modified:
>    cfe/trunk/lib/AST/ASTContext.cpp
>    cfe/trunk/lib/AST/ExprConstant.cpp
>    cfe/trunk/lib/Analysis/GRExprEngine.cpp
>    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
>    cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>    cfe/trunk/lib/Driver/Driver.cpp
>    cfe/trunk/lib/Sema/SemaCXXCast.cpp
>    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>    cfe/trunk/lib/Sema/SemaExpr.cpp
>    cfe/trunk/lib/Sema/SemaStmt.cpp
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Dec 25 09:43:36 2009
> @@ -1065,9 +1065,7 @@
>
>   // Add in synthesized ivar count if laying out an implementation.
>   if (Impl) {
> -    unsigned FieldCount = D->ivar_size();
>     unsigned SynthCount = CountSynthesizedIvars(D);
> -    FieldCount += SynthCount;
>     // If there aren't any sythesized ivars then reuse the interface
>     // entry. Note we can't cache this because we simply free all
>     // entries later; however we shouldn't look up implementations
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Dec 25 09:43:36 2009
> @@ -1291,8 +1291,6 @@
> /// VisitSizeAlignOfExpr - Evaluate a sizeof or alignof with a  
> result as the
> /// expression's type.
> bool IntExprEvaluator::VisitSizeOfAlignOfExpr(const  
> SizeOfAlignOfExpr *E) {
> -  QualType DstTy = E->getType();
> -
>   // Handle alignof separately.
>   if (!E->isSizeOf()) {
>     if (E->isArgumentType())
>
> Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
> +++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Dec 25 09:43:36 2009
> @@ -2228,7 +2228,6 @@
>
>     if (InitEx) {
>       SVal InitVal = state->getSVal(InitEx);
> -      QualType T = VD->getType();
>
>       // Recover some path-sensitivity if a scalar value evaluated to
>       // UnknownVal.
> @@ -2261,7 +2260,6 @@
>
>     const LocationContext *LC = N->getLocationContext();
>     SVal InitVal = state->getSVal(InitEx);
> -    QualType T = VD->getType();
>
>     // Recover some path-sensitivity if a scalar value evaluated to
>     // UnknownVal.
>
> Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Dec 25 09:43:36 2009
> @@ -78,7 +78,6 @@
>   }
>
>   return CalculateCookiePadding(Ctx, E->getAllocatedType());
> -  QualType T = E->getAllocatedType();
> }
>
> static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Dec 25 09:43:36 2009
> @@ -1199,7 +1199,7 @@
> Value *ScalarExprEmitter::EmitCompoundAssign(const  
> CompoundAssignOperator *E,
>                       Value *(ScalarExprEmitter::*Func)(const  
> BinOpInfo &)) {
>   bool Ignore = TestAndClearIgnoreResultAssign();
> -  QualType LHSTy = E->getLHS()->getType(), RHSTy = E->getRHS()- 
> >getType();
> +  QualType LHSTy = E->getLHS()->getType();
>
>   BinOpInfo OpInfo;
>
>
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Dec 25 09:43:36 2009
> @@ -3351,7 +3351,6 @@
>     SkipScanIvars.push_back(SkScan);
>   }
>
> -  bool BytesSkipped = false;
>   if (!SkipIvars.empty()) {
>     unsigned int LastIndex = SkipIvars.size()-1;
>     int LastByteSkipped =
> @@ -3360,9 +3359,8 @@
>     int LastByteScanned =
>       IvarsInfo[LastIndex].ivar_bytepos +
>       IvarsInfo[LastIndex].ivar_size * WordSize;
> -    BytesSkipped = (LastByteSkipped > LastByteScanned);
>     // Compute number of bytes to skip at the tail end of the last  
> ivar scanned.
> -    if (BytesSkipped) {
> +    if (LastByteSkipped > LastByteScanned) {
>       unsigned int TotalWords = (LastByteSkipped + (WordSize -1)) /  
> WordSize;
>       SKIP_SCAN SkScan;
>       SkScan.skip = TotalWords - (LastByteScanned/WordSize);
> @@ -3393,8 +3391,6 @@
>     unsigned int skip_big  = SkipScanIvars[i].skip / 0xf;
>     unsigned int scan_big  = SkipScanIvars[i].scan / 0xf;
>
> -    if (skip_small > 0 || skip_big > 0)
> -      BytesSkipped = true;
>     // first skip big.
>     for (unsigned int ix = 0; ix < skip_big; ix++)
>       BitMap += (unsigned char)(0xf0);
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Fri Dec 25 09:43:36 2009
> @@ -776,10 +776,8 @@
>     UsePipes = false;
>
>   // -save-temps inhibits pipes.
> -  if (SaveTemps && UsePipes) {
> +  if (SaveTemps && UsePipes)
>     Diag(clang::diag::warn_drv_pipe_ignored_with_save_temps);
> -    UsePipes = true;
> -  }
>
>   Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o);
>
> @@ -914,14 +912,12 @@
>   // See if we should use an integrated preprocessor. We do so when  
> we have
>   // exactly one input, since this is the only use case we care about
>   // (irrelevant since we don't support combine yet).
> -  bool UseIntegratedCPP = false;
>   const ActionList *Inputs = &A->getInputs();
>   if (Inputs->size() == 1 && isa<PreprocessJobAction>(*Inputs->begin 
> ())) {
>     if (!C.getArgs().hasArg(options::OPT_no_integrated_cpp) &&
>         !C.getArgs().hasArg(options::OPT_traditional_cpp) &&
>         !C.getArgs().hasArg(options::OPT_save_temps) &&
>         T.hasIntegratedCPP()) {
> -      UseIntegratedCPP = true;
>       Inputs = &(*Inputs)[0]->getInputs();
>     }
>   }
>
> Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Fri Dec 25 09:43:36 2009
> @@ -975,8 +975,6 @@
>                                         const SourceRange &OpRange,
>                                         unsigned &msg,
>                                         CastExpr::CastKind &Kind) {
> -  QualType OrigDestType = DestType, OrigSrcType = SrcExpr->getType();
> -
>   DestType = Self.Context.getCanonicalType(DestType);
>   QualType SrcType = SrcExpr->getType();
>   if (const ReferenceType *DestTypeTmp = DestType- 
> >getAs<ReferenceType>()) {
>
> Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Dec 25 09:43:36 2009
> @@ -2453,7 +2453,6 @@
>   typedef CodeCompleteConsumer::Result Result;
>
>   Expr *RecExpr = static_cast<Expr *>(Receiver);
> -  QualType RecType = RecExpr->getType();
>
>   // If necessary, apply function/array conversion to the receiver.
>   // C99 6.7.5.3p[7,8].
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Dec 25 09:43:36 2009
> @@ -109,8 +109,6 @@
> bool
> Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
>                               SourceLocation EqualLoc) {
> -  QualType ParamType = Param->getType();
> -
>   if (RequireCompleteType(Param->getLocation(), Param->getType(),
>                           diag::err_typecheck_decl_incomplete_type)) {
>     Param->setInvalidDecl();
> @@ -158,7 +156,6 @@
>   UnparsedDefaultArgLocs.erase(Param);
>
>   ExprOwningPtr<Expr> DefaultArg(this, defarg.takeAs<Expr>());
> -  QualType ParamType = Param->getType();
>
>   // Default arguments are only permitted in C++
>   if (!getLangOptions().CPlusPlus) {
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 25 09:43:36 2009
> @@ -1435,7 +1435,6 @@
>   assert(D && "Cannot refer to a NULL declaration");
>   assert(!isa<FunctionTemplateDecl>(D) &&
>          "Cannot refer unambiguously to a function template");
> -  DeclarationName Name = D->getDeclName();
>
>   if (CheckDeclInExpr(*this, Loc, D))
>     return ExprError();
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=92162&r1=92161&r2=92162&view=diff
>
> === 
> === 
> === 
> =====================================================================
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Dec 25 09:43:36 2009
> @@ -978,7 +978,6 @@
>
>   if (!FnRetType->isDependentType() && !RetValExp->isTypeDependent 
> ()) {
>     // we have a non-void block with an expression, continue checking
> -    QualType RetValType = RetValExp->getType();
>
>     // C99 6.8.6.4p3(136): The return statement is not an  
> assignment. The
>     // overlap restriction of subclause 6.5.16.1 does not apply to  
> the case of
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list