[cfe-commits] r139856 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaExprCXX.cpp
Richard Trieu
rtrieu at google.com
Thu Sep 15 14:56:48 PDT 2011
Author: rtrieu
Date: Thu Sep 15 16:56:47 2011
New Revision: 139856
URL: http://llvm.org/viewvc/llvm-project?rev=139856&view=rev
Log:
Finish the lex->LHS and rex->RHS cleanup in Sema.
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=139856&r1=139855&r2=139856&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 15 16:56:47 2011
@@ -5614,7 +5614,7 @@
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS,
ExprResult &RHS);
QualType CheckPointerToMemberOperands( // C++ 5.5
- ExprResult &lex, ExprResult &rex, ExprValueKind &VK,
+ ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
SourceLocation OpLoc, bool isIndirect);
QualType CheckMultiplyDivideOperands( // C99 6.5.5
ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
@@ -6059,7 +6059,7 @@
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc);
- void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
+ void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS);
void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=139856&r1=139855&r2=139856&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 15 16:56:47 2011
@@ -2504,11 +2504,11 @@
/// Check for comparisons of floating point operands using != and ==.
/// Issue a warning if these are no self-comparisons, as they are not likely
/// to do what the programmer intended.
-void Sema::CheckFloatComparison(SourceLocation loc, Expr* lex, Expr *rex) {
+void Sema::CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr *RHS) {
bool EmitWarning = true;
- Expr* LeftExprSansParen = lex->IgnoreParenImpCasts();
- Expr* RightExprSansParen = rex->IgnoreParenImpCasts();
+ Expr* LeftExprSansParen = LHS->IgnoreParenImpCasts();
+ Expr* RightExprSansParen = RHS->IgnoreParenImpCasts();
// Special case: check for x == x (which is OK).
// Do not emit warnings for such cases.
@@ -2547,8 +2547,8 @@
// Emit the diagnostic.
if (EmitWarning)
- Diag(loc, diag::warn_floatingpoint_eq)
- << lex->getSourceRange() << rex->getSourceRange();
+ Diag(Loc, diag::warn_floatingpoint_eq)
+ << LHS->getSourceRange() << RHS->getSourceRange();
}
//===--- CHECK: Integer mixed-sign comparisons (-Wsign-compare) --------===//
@@ -3013,10 +3013,7 @@
/// \brief Implements -Wsign-compare.
///
-/// \param lex the left-hand expression
-/// \param rex the right-hand expression
-/// \param OpLoc the location of the joining operator
-/// \param BinOpc binary opcode or 0
+/// \param E the binary operator to check for warnings
void AnalyzeComparison(Sema &S, BinaryOperator *E) {
// The type the comparison is being performed in.
QualType T = E->getLHS()->getType();
@@ -3033,20 +3030,20 @@
|| E->isValueDependent() || E->isIntegerConstantExpr(S.Context))
return AnalyzeImpConvsInComparison(S, E);
- Expr *lex = E->getLHS()->IgnoreParenImpCasts();
- Expr *rex = E->getRHS()->IgnoreParenImpCasts();
+ Expr *LHS = E->getLHS()->IgnoreParenImpCasts();
+ Expr *RHS = E->getRHS()->IgnoreParenImpCasts();
// Check to see if one of the (unmodified) operands is of different
// signedness.
Expr *signedOperand, *unsignedOperand;
- if (lex->getType()->hasSignedIntegerRepresentation()) {
- assert(!rex->getType()->hasSignedIntegerRepresentation() &&
+ if (LHS->getType()->hasSignedIntegerRepresentation()) {
+ assert(!RHS->getType()->hasSignedIntegerRepresentation() &&
"unsigned comparison between two signed integer expressions?");
- signedOperand = lex;
- unsignedOperand = rex;
- } else if (rex->getType()->hasSignedIntegerRepresentation()) {
- signedOperand = rex;
- unsignedOperand = lex;
+ signedOperand = LHS;
+ unsignedOperand = RHS;
+ } else if (RHS->getType()->hasSignedIntegerRepresentation()) {
+ signedOperand = RHS;
+ unsignedOperand = LHS;
} else {
CheckTrivialUnsignedComparison(S, E);
return AnalyzeImpConvsInComparison(S, E);
@@ -3057,8 +3054,8 @@
// Go ahead and analyze implicit conversions in the operands. Note
// that we skip the implicit conversions on both sides.
- AnalyzeImplicitConversions(S, lex, E->getOperatorLoc());
- AnalyzeImplicitConversions(S, rex, E->getOperatorLoc());
+ AnalyzeImplicitConversions(S, LHS, E->getOperatorLoc());
+ AnalyzeImplicitConversions(S, RHS, E->getOperatorLoc());
// If the signed range is non-negative, -Wsign-compare won't fire,
// but we should still check for comparisons which are always true
@@ -3083,8 +3080,8 @@
}
S.Diag(E->getOperatorLoc(), diag::warn_mixed_sign_comparison)
- << lex->getType() << rex->getType()
- << lex->getSourceRange() << rex->getSourceRange();
+ << LHS->getType() << RHS->getType()
+ << LHS->getSourceRange() << RHS->getSourceRange();
}
/// Analyzes an attempt to assign the given value to a bitfield.
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=139856&r1=139855&r2=139856&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Sep 15 16:56:47 2011
@@ -3269,34 +3269,34 @@
RParen, Context.BoolTy));
}
-QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex,
+QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS,
ExprValueKind &VK,
SourceLocation Loc,
bool isIndirect) {
- assert(!lex.get()->getType()->isPlaceholderType() &&
- !rex.get()->getType()->isPlaceholderType() &&
+ assert(!LHS.get()->getType()->isPlaceholderType() &&
+ !RHS.get()->getType()->isPlaceholderType() &&
"placeholders should have been weeded out by now");
// The LHS undergoes lvalue conversions if this is ->*.
if (isIndirect) {
- lex = DefaultLvalueConversion(lex.take());
- if (lex.isInvalid()) return QualType();
+ LHS = DefaultLvalueConversion(LHS.take());
+ if (LHS.isInvalid()) return QualType();
}
// The RHS always undergoes lvalue conversions.
- rex = DefaultLvalueConversion(rex.take());
- if (rex.isInvalid()) return QualType();
+ RHS = DefaultLvalueConversion(RHS.take());
+ if (RHS.isInvalid()) return QualType();
const char *OpSpelling = isIndirect ? "->*" : ".*";
// C++ 5.5p2
// The binary operator .* [p3: ->*] binds its second operand, which shall
// be of type "pointer to member of T" (where T is a completely-defined
// class type) [...]
- QualType RType = rex.get()->getType();
- const MemberPointerType *MemPtr = RType->getAs<MemberPointerType>();
+ QualType RHSType = RHS.get()->getType();
+ const MemberPointerType *MemPtr = RHSType->getAs<MemberPointerType>();
if (!MemPtr) {
Diag(Loc, diag::err_bad_memptr_rhs)
- << OpSpelling << RType << rex.get()->getSourceRange();
+ << OpSpelling << RHSType << RHS.get()->getSourceRange();
return QualType();
}
@@ -3312,21 +3312,21 @@
// [...] to its first operand, which shall be of class T or of a class of
// which T is an unambiguous and accessible base class. [p3: a pointer to
// such a class]
- QualType LType = lex.get()->getType();
+ QualType LHSType = LHS.get()->getType();
if (isIndirect) {
- if (const PointerType *Ptr = LType->getAs<PointerType>())
- LType = Ptr->getPointeeType();
+ if (const PointerType *Ptr = LHSType->getAs<PointerType>())
+ LHSType = Ptr->getPointeeType();
else {
Diag(Loc, diag::err_bad_memptr_lhs)
- << OpSpelling << 1 << LType
+ << OpSpelling << 1 << LHSType
<< FixItHint::CreateReplacement(SourceRange(Loc), ".*");
return QualType();
}
}
- if (!Context.hasSameUnqualifiedType(Class, LType)) {
+ if (!Context.hasSameUnqualifiedType(Class, LHSType)) {
// If we want to check the hierarchy, we need a complete type.
- if (RequireCompleteType(Loc, LType, PDiag(diag::err_bad_memptr_lhs)
+ if (RequireCompleteType(Loc, LHSType, PDiag(diag::err_bad_memptr_lhs)
<< OpSpelling << (int)isIndirect)) {
return QualType();
}
@@ -3334,23 +3334,24 @@
/*DetectVirtual=*/false);
// FIXME: Would it be useful to print full ambiguity paths, or is that
// overkill?
- if (!IsDerivedFrom(LType, Class, Paths) ||
+ if (!IsDerivedFrom(LHSType, Class, Paths) ||
Paths.isAmbiguous(Context.getCanonicalType(Class))) {
Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
- << (int)isIndirect << lex.get()->getType();
+ << (int)isIndirect << LHS.get()->getType();
return QualType();
}
// Cast LHS to type of use.
QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
ExprValueKind VK =
- isIndirect ? VK_RValue : CastCategory(lex.get());
+ isIndirect ? VK_RValue : CastCategory(LHS.get());
CXXCastPath BasePath;
BuildBasePathArray(Paths, BasePath);
- lex = ImpCastExprToType(lex.take(), UseType, CK_DerivedToBase, VK, &BasePath);
+ LHS = ImpCastExprToType(LHS.take(), UseType, CK_DerivedToBase, VK,
+ &BasePath);
}
- if (isa<CXXScalarValueInitExpr>(rex.get()->IgnoreParens())) {
+ if (isa<CXXScalarValueInitExpr>(RHS.get()->IgnoreParens())) {
// Diagnose use of pointer-to-member type which when used as
// the functional cast in a pointer-to-member expression.
Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
@@ -3363,7 +3364,7 @@
// The cv qualifiers are the union of those in the pointer and the left side,
// in accordance with 5.5p5 and 5.2.5.
QualType Result = MemPtr->getPointeeType();
- Result = Context.getCVRQualifiedType(Result, LType.getCVRQualifiers());
+ Result = Context.getCVRQualifiedType(Result, LHSType.getCVRQualifiers());
// C++0x [expr.mptr.oper]p6:
// In a .* expression whose object expression is an rvalue, the program is
@@ -3378,15 +3379,15 @@
break;
case RQ_LValue:
- if (!isIndirect && !lex.get()->Classify(Context).isLValue())
+ if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
- << RType << 1 << lex.get()->getSourceRange();
+ << RHSType << 1 << LHS.get()->getSourceRange();
break;
case RQ_RValue:
- if (isIndirect || !lex.get()->Classify(Context).isRValue())
+ if (isIndirect || !LHS.get()->Classify(Context).isRValue())
Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
- << RType << 0 << lex.get()->getSourceRange();
+ << RHSType << 0 << LHS.get()->getSourceRange();
break;
}
}
@@ -3404,7 +3405,7 @@
} else if (isIndirect) {
VK = VK_LValue;
} else {
- VK = lex.get()->getValueKind();
+ VK = LHS.get()->getValueKind();
}
return Result;
More information about the cfe-commits
mailing list