Hi Matt, I believe this change caused http://llvm.org/bugs/show_bug.cgi?id=11594
On Wed, Dec 14, 2011 at 8:02 PM, Matt Beaumont-Gay <[email protected]> wrote: > Author: matthewbg > Date: Wed Dec 14 10:02:15 2011 > New Revision: 146562 > > URL: http://llvm.org/viewvc/llvm-project?rev=146562&view=rev > Log: > r146430 lost some compile-time performance on > MultiSource/Benchmarks/MiBench/security-rijndael; this gets most of it back. > > Modified: > cfe/trunk/include/clang/Sema/Sema.h > cfe/trunk/lib/Sema/SemaChecking.cpp > > Modified: cfe/trunk/include/clang/Sema/Sema.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=146562&r1=146561&r2=146562&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Sema/Sema.h (original) > +++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 14 10:02:15 2011 > @@ -6190,7 +6190,8 @@ > > private: > void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, > - bool isSubscript=false, bool AllowOnePastEnd=true); > + const ArraySubscriptExpr *ASE=0, > + bool AllowOnePastEnd=true); > void CheckArrayAccess(const Expr *E); > bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall); > bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall); > > Modified: cfe/trunk/lib/Sema/SemaChecking.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=146562&r1=146561&r2=146562&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Dec 14 10:02:15 2011 > @@ -4274,20 +4274,21 @@ > } > > void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, > - bool isSubscript, bool AllowOnePastEnd) { > - const Type *EffectiveType = getElementType(BaseExpr); > - BaseExpr = BaseExpr->IgnoreParenCasts(); > + const ArraySubscriptExpr *ASE, > + bool AllowOnePastEnd) { > IndexExpr = IndexExpr->IgnoreParenCasts(); > + if (IndexExpr->isValueDependent()) > + return; > > + const Type *EffectiveType = getElementType(BaseExpr); > + BaseExpr = BaseExpr->IgnoreParenCasts(); > const ConstantArrayType *ArrayTy = > Context.getAsConstantArrayType(BaseExpr->getType()); > if (!ArrayTy) > return; > > - if (IndexExpr->isValueDependent()) > - return; > llvm::APSInt index; > - if (!IndexExpr->isIntegerConstantExpr(index, Context)) > + if (!IndexExpr->EvaluateAsInt(index, Context)) > return; > > const NamedDecl *ND = NULL; > @@ -4336,8 +4337,22 @@ > if (IsTailPaddedMemberArray(*this, size, ND)) > return; > > + // Suppress the warning if the subscript expression (as identified by the > + // ']' location) and the index expression are both from macro expansions > + // within a system header. > + if (ASE) { > + SourceLocation RBracketLoc = SourceMgr.getSpellingLoc( > + ASE->getRBracketLoc()); > + if (SourceMgr.isInSystemHeader(RBracketLoc)) { > + SourceLocation IndexLoc = SourceMgr.getSpellingLoc( > + IndexExpr->getLocStart()); > + if (SourceMgr.isFromSameFile(RBracketLoc, IndexLoc)) > + return; > + } > + } > + > unsigned DiagID = diag::warn_ptr_arith_exceeds_bounds; > - if (isSubscript) > + if (ASE) > DiagID = diag::warn_array_index_exceeds_bounds; > > DiagRuntimeBehavior(BaseExpr->getLocStart(), BaseExpr, > @@ -4347,7 +4362,7 @@ > << IndexExpr->getSourceRange()); > } else { > unsigned DiagID = diag::warn_array_index_precedes_bounds; > - if (!isSubscript) { > + if (!ASE) { > DiagID = diag::warn_ptr_arith_precedes_bounds; > if (index.isNegative()) index = -index; > } > @@ -4381,17 +4396,7 @@ > switch (expr->getStmtClass()) { > case Stmt::ArraySubscriptExprClass: { > const ArraySubscriptExpr *ASE = cast<ArraySubscriptExpr>(expr); > - // Suppress the warning if the subscript expression (as identified by > - // the ']' location) and the index expression are both from macro > - // expansions within a system header. > - SourceLocation RBracketLoc = SourceMgr.getSpellingLoc( > - ASE->getRBracketLoc()); > - SourceLocation IndexLoc = SourceMgr.getSpellingLoc( > - ASE->getIdx()->IgnoreParens()->getLocStart()); > - if (SourceMgr.isFromSameFile(RBracketLoc, IndexLoc) && > - SourceMgr.isInSystemHeader(RBracketLoc)) > - return; > - CheckArrayAccess(ASE->getBase(), ASE->getIdx(), true, > + CheckArrayAccess(ASE->getBase(), ASE->getIdx(), ASE, > AllowOnePastEnd > 0); > return; > } > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits -- Alexander Potapenko Software Engineer Google Moscow _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
