[cfe-commits] r41375 - in /cfe/trunk: Sema/Sema.h Sema/SemaExpr.cpp include/clang/AST/Expr.h
Chris Lattner
sabre at nondot.org
Fri Aug 24 14:16:53 PDT 2007
Author: lattner
Date: Fri Aug 24 16:16:53 2007
New Revision: 41375
URL: http://llvm.org/viewvc/llvm-project?rev=41375&view=rev
Log:
Implement sema support for __real/__imag nodes.
Modified:
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=41375&r1=41374&r2=41375&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Fri Aug 24 16:16:53 2007
@@ -420,6 +420,7 @@
QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
QualType CheckSizeOfAlignOfOperand(QualType type, SourceLocation loc,
bool isSizeof);
+ QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isImag);
/// type checking primary expressions.
QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc,
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41375&r1=41374&r2=41375&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Fri Aug 24 16:16:53 2007
@@ -271,6 +271,15 @@
return new SizeOfAlignOfTypeExpr(isSizeof, ArgTy, resultType, OpLoc, RPLoc);
}
+QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isImag) {
+ DefaultFunctionArrayConversion(V);
+
+ if (const ComplexType *CT = V->getType()->getAsComplexType())
+ return CT->getElementType();
+ return V->getType();
+}
+
+
Action::ExprResult Sema::ParsePostfixUnaryOp(SourceLocation OpLoc,
tok::TokenKind Kind,
@@ -1586,8 +1595,13 @@
case UnaryOperator::AlignOf:
resultType = CheckSizeOfAlignOfOperand(Input->getType(), OpLoc, false);
break;
+ case UnaryOperator::Real:
+ resultType = CheckRealImagOperand(Input, OpLoc, false);
+ break;
+ case UnaryOperator::Imag:
+ resultType = CheckRealImagOperand(Input, OpLoc, true);
+ break;
case UnaryOperator::Extension:
- // FIXME: does __extension__ cause any promotions? I would think not.
resultType = Input->getType();
break;
}
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=41375&r1=41374&r2=41375&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Aug 24 16:16:53 2007
@@ -297,6 +297,13 @@
/// UnaryOperator - This represents the unary-expression's (except sizeof of
/// types), the postinc/postdec operators from postfix-expression, and various
/// extensions.
+///
+/// Notes on various nodes:
+///
+/// Real/Imag - These return the real/imag part of a complex operand. If
+/// applied to a non-complex value, the former returns its operand and the
+/// later returns zero in the type of the operand.
+///
class UnaryOperator : public Expr {
public:
// Note that additions to this should also update the StmtVisitor class.
More information about the cfe-commits
mailing list