[cfe-commits] r41550 - in /cfe/trunk: Sema/SemaExpr.cpp include/clang/AST/Expr.h
Chris Lattner
sabre at nondot.org
Tue Aug 28 11:36:55 PDT 2007
Author: lattner
Date: Tue Aug 28 13:36:55 2007
New Revision: 41550
URL: http://llvm.org/viewvc/llvm-project?rev=41550&view=rev
Log:
add a sourcelocation to binary operator to keep track of the location of the operator.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41550&r1=41549&r2=41550&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Tue Aug 28 13:36:55 2007
@@ -1561,9 +1561,9 @@
if (ResultTy.isNull())
return true;
if (CompTy.isNull())
- return new BinaryOperator(lhs, rhs, Opc, ResultTy);
+ return new BinaryOperator(lhs, rhs, Opc, ResultTy, TokLoc);
else
- return new CompoundAssignOperator(lhs, rhs, Opc, ResultTy, CompTy);
+ return new CompoundAssignOperator(lhs, rhs, Opc, ResultTy, CompTy, TokLoc);
}
// Unary Operators. 'Tok' is the token for the operator.
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=41550&r1=41549&r2=41550&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 28 13:36:55 2007
@@ -722,15 +722,23 @@
OrAssign,
Comma // [C99 6.5.17] Comma operator.
};
+private:
+ enum { LHS, RHS, END_EXPR };
+ Expr* SubExprs[END_EXPR];
+ Opcode Opc;
+ SourceLocation OpLoc;
+public:
- BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy)
- : Expr(BinaryOperatorClass, ResTy), Opc(opc) {
+ BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
+ SourceLocation opLoc)
+ : Expr(BinaryOperatorClass, ResTy), Opc(opc), OpLoc(opLoc) {
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
assert(!isCompoundAssignmentOp() &&
"Use ArithAssignBinaryOperator for compound assignments");
}
+ SourceLocation getOperatorLoc() const { return OpLoc; }
Opcode getOpcode() const { return Opc; }
Expr *getLHS() const { return SubExprs[LHS]; }
Expr *getRHS() const { return SubExprs[RHS]; }
@@ -764,14 +772,10 @@
virtual child_iterator child_begin();
virtual child_iterator child_end();
-private:
- enum { LHS, RHS, END_EXPR };
- Expr* SubExprs[END_EXPR];
- Opcode Opc;
-
protected:
- BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, bool dead)
- : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc) {
+ BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
+ SourceLocation oploc, bool dead)
+ : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
}
@@ -787,8 +791,10 @@
QualType ComputationType;
public:
CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc,
- QualType ResType, QualType CompType)
- : BinaryOperator(lhs, rhs, opc, ResType, true), ComputationType(CompType) {
+ QualType ResType, QualType CompType,
+ SourceLocation OpLoc)
+ : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
+ ComputationType(CompType) {
assert(isCompoundAssignmentOp() &&
"Only should be used for compound assignments");
}
More information about the cfe-commits
mailing list