@@ -166,7 +166,7 @@ static bool isIdenticalExpr(const ASTContext &Ctx, const Expr *Expr1,
166166 // are identical.
167167 if (!IgnoreSideEffects && Expr1->HasSideEffects (Ctx))
168168 return false ;
169- // Is expression is based on macro then don't warn even if
169+ // If either expression comes from a macro then don't warn even if
170170 // the expressions are identical.
171171 if ((Expr1->getExprLoc ().isMacroID ()) || (Expr2->getExprLoc ().isMacroID ()))
172172 return false ;
@@ -199,41 +199,39 @@ static bool isIdenticalExpr(const ASTContext &Ctx, const Expr *Expr1,
199199 case Stmt::ParenExprClass:
200200 return true ;
201201 case Stmt::BinaryOperatorClass: {
202- const BinaryOperator *BinOp1 = dyn_cast <BinaryOperator>(Expr1);
203- const BinaryOperator *BinOp2 = dyn_cast <BinaryOperator>(Expr2);
202+ const BinaryOperator *BinOp1 = cast <BinaryOperator>(Expr1);
203+ const BinaryOperator *BinOp2 = cast <BinaryOperator>(Expr2);
204204 return BinOp1->getOpcode () == BinOp2->getOpcode ();
205205 }
206206 case Stmt::CharacterLiteralClass: {
207- const CharacterLiteral *CharLit1 = dyn_cast <CharacterLiteral>(Expr1);
208- const CharacterLiteral *CharLit2 = dyn_cast <CharacterLiteral>(Expr2);
207+ const CharacterLiteral *CharLit1 = cast <CharacterLiteral>(Expr1);
208+ const CharacterLiteral *CharLit2 = cast <CharacterLiteral>(Expr2);
209209 return CharLit1->getValue () == CharLit2->getValue ();
210210 }
211211 case Stmt::DeclRefExprClass: {
212- const DeclRefExpr *DeclRef1 = dyn_cast <DeclRefExpr>(Expr1);
213- const DeclRefExpr *DeclRef2 = dyn_cast <DeclRefExpr>(Expr2);
212+ const DeclRefExpr *DeclRef1 = cast <DeclRefExpr>(Expr1);
213+ const DeclRefExpr *DeclRef2 = cast <DeclRefExpr>(Expr2);
214214 return DeclRef1->getDecl () == DeclRef2->getDecl ();
215215 }
216216 case Stmt::IntegerLiteralClass: {
217- const IntegerLiteral *IntLit1 = dyn_cast <IntegerLiteral>(Expr1);
218- const IntegerLiteral *IntLit2 = dyn_cast <IntegerLiteral>(Expr2);
217+ const IntegerLiteral *IntLit1 = cast <IntegerLiteral>(Expr1);
218+ const IntegerLiteral *IntLit2 = cast <IntegerLiteral>(Expr2);
219219 return IntLit1->getValue () == IntLit2->getValue ();
220220 }
221221 case Stmt::FloatingLiteralClass: {
222- const FloatingLiteral *FloatLit1 = dyn_cast <FloatingLiteral>(Expr1);
223- const FloatingLiteral *FloatLit2 = dyn_cast <FloatingLiteral>(Expr2);
222+ const FloatingLiteral *FloatLit1 = cast <FloatingLiteral>(Expr1);
223+ const FloatingLiteral *FloatLit2 = cast <FloatingLiteral>(Expr2);
224224 return FloatLit1->getValue ().bitwiseIsEqual (FloatLit2->getValue ());
225225 }
226226 case Stmt::MemberExprClass: {
227- const MemberExpr *MemberExpr1 = dyn_cast <MemberExpr>(Expr1);
228- const MemberExpr *MemberExpr2 = dyn_cast <MemberExpr>(Expr2);
227+ const MemberExpr *MemberExpr1 = cast <MemberExpr>(Expr1);
228+ const MemberExpr *MemberExpr2 = cast <MemberExpr>(Expr2);
229229 return MemberExpr1->getMemberDecl () == MemberExpr2->getMemberDecl ();
230230 }
231231 case Stmt::UnaryOperatorClass: {
232- const UnaryOperator *UnaryOp1 = dyn_cast<UnaryOperator>(Expr1);
233- const UnaryOperator *UnaryOp2 = dyn_cast<UnaryOperator>(Expr2);
234- if (UnaryOp1->getOpcode () != UnaryOp2->getOpcode ())
235- return false ;
236- return IgnoreSideEffects || !UnaryOp1->isIncrementDecrementOp ();
232+ const UnaryOperator *UnaryOp1 = cast<UnaryOperator>(Expr1);
233+ const UnaryOperator *UnaryOp2 = cast<UnaryOperator>(Expr2);
234+ return UnaryOp1->getOpcode () == UnaryOp2->getOpcode ();
237235 }
238236 }
239237}
0 commit comments