[cfe-commits] r139520 - /cfe/trunk/lib/Sema/SemaExpr.cpp
Richard Trieu
rtrieu at google.com
Mon Sep 12 11:37:54 PDT 2011
Author: rtrieu
Date: Mon Sep 12 13:37:54 2011
New Revision: 139520
URL: http://llvm.org/viewvc/llvm-project?rev=139520&view=rev
Log:
Refactor CheckAdditionOperands() to use early return for pointer addition.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=139520&r1=139519&r2=139520&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep 12 13:37:54 2011
@@ -6010,32 +6010,33 @@
if (IExp->getType()->isAnyPointerType())
std::swap(PExp, IExp);
- if (PExp->getType()->isAnyPointerType()) {
- if (IExp->getType()->isIntegerType()) {
- if (!checkArithmeticOpPointerOperand(*this, Loc, PExp))
- return QualType();
+ if (!PExp->getType()->isAnyPointerType())
+ return InvalidOperands(Loc, LHS, RHS);
- // Diagnose bad cases where we step over interface counts.
- if (!checkArithmethicPointerOnNonFragileABI(*this, Loc, PExp))
- return QualType();
+ if (!IExp->getType()->isIntegerType())
+ return InvalidOperands(Loc, LHS, RHS);
- // Check array bounds for pointer arithemtic
- CheckArrayAccess(PExp, IExp);
+ if (!checkArithmeticOpPointerOperand(*this, Loc, PExp))
+ return QualType();
- if (CompLHSTy) {
- QualType LHSTy = Context.isPromotableBitField(LHS.get());
- if (LHSTy.isNull()) {
- LHSTy = LHS.get()->getType();
- if (LHSTy->isPromotableIntegerType())
- LHSTy = Context.getPromotedIntegerType(LHSTy);
- }
- *CompLHSTy = LHSTy;
- }
- return PExp->getType();
+ // Diagnose bad cases where we step over interface counts.
+ if (!checkArithmethicPointerOnNonFragileABI(*this, Loc, PExp))
+ return QualType();
+
+ // Check array bounds for pointer arithemtic
+ CheckArrayAccess(PExp, IExp);
+
+ if (CompLHSTy) {
+ QualType LHSTy = Context.isPromotableBitField(LHS.get());
+ if (LHSTy.isNull()) {
+ LHSTy = LHS.get()->getType();
+ if (LHSTy->isPromotableIntegerType())
+ LHSTy = Context.getPromotedIntegerType(LHSTy);
}
+ *CompLHSTy = LHSTy;
}
- return InvalidOperands(Loc, LHS, RHS);
+ return PExp->getType();
}
// C99 6.5.6
More information about the cfe-commits
mailing list