[cfe-commits] r110996 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/RecursiveASTVisitor.h include/clang/AST/StmtVisitor.h include/clang/Frontend/StmtXML.def lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/AST/StmtPrinter.cpp lib/Checker/CheckerHelpers.cpp lib/Checker/GRExprEngine.cpp lib/Checker/IdempotentOperationChecker.cpp lib/CodeGen/CGExprScalar.cpp lib/Frontend/StmtXML.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaExpr.cpp
Douglas Gregor
dgregor at apple.com
Thu Aug 12 19:29:27 PDT 2010
On Aug 12, 2010, at 6:36 PM, Eli Friedman wrote:
> Author: efriedma
> Date: Thu Aug 12 20:36:11 2010
> New Revision: 110996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=110996&view=rev
> Log:
> Zap unused UnaryOperator::OffsetOf.
Woo-hoo! Thanks for finishing this, Eli!
- Doug
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/StmtVisitor.h
> cfe/trunk/include/clang/Frontend/StmtXML.def
> cfe/trunk/lib/AST/Expr.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/AST/StmtPrinter.cpp
> cfe/trunk/lib/Checker/CheckerHelpers.cpp
> cfe/trunk/lib/Checker/GRExprEngine.cpp
> cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/Frontend/StmtXML.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Thu Aug 12 20:36:11 2010
> @@ -1028,10 +1028,6 @@
> /// applied to a non-complex value, the former returns its operand and the
> /// later returns zero in the type of the operand.
> ///
> -/// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose
> -/// subexpression is a compound literal with the various MemberExpr and
> -/// ArraySubscriptExpr's applied to it. (This is only used in C)
> -///
> class UnaryOperator : public Expr {
> public:
> // Note that additions to this should also update the StmtVisitor class.
> @@ -1042,8 +1038,7 @@
> Plus, Minus, // [C99 6.5.3.3] Unary arithmetic operators.
> Not, LNot, // [C99 6.5.3.3] Unary arithmetic operators.
> Real, Imag, // "__real expr"/"__imag expr" Extension.
> - Extension, // __extension__ marker.
> - OffsetOf // __builtin_offsetof
> + Extension // __extension__ marker.
> };
> private:
> Stmt *Val;
> @@ -1053,8 +1048,7 @@
>
> UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l)
> : Expr(UnaryOperatorClass, type,
> - opc != OffsetOf && (input->isTypeDependent() ||
> - type->isDependentType()),
> + input->isTypeDependent() || type->isDependentType(),
> input->isValueDependent()),
> Val(input), Opc(opc), Loc(l) {}
>
> @@ -1086,7 +1080,6 @@
> bool isPostfix() const { return isPostfix(Opc); }
> bool isIncrementOp() const {return Opc==PreInc || Opc==PostInc; }
> bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
> - bool isOffsetOfOp() const { return Opc == OffsetOf; }
> static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; }
> bool isArithmeticOp() const { return isArithmeticOp(Opc); }
>
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Aug 12 20:36:11 2010
> @@ -42,7 +42,7 @@
> OPERATOR(Plus) OPERATOR(Minus) \
> OPERATOR(Not) OPERATOR(LNot) \
> OPERATOR(Real) OPERATOR(Imag) \
> - OPERATOR(Extension) OPERATOR(OffsetOf)
> + OPERATOR(Extension)
>
> // All binary operators (excluding compound assign operators).
> #define BINOP_LIST() \
>
> Modified: cfe/trunk/include/clang/AST/StmtVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/StmtVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/StmtVisitor.h Thu Aug 12 20:36:11 2010
> @@ -98,7 +98,6 @@
> case UnaryOperator::Real: DISPATCH(UnaryReal, UnaryOperator);
> case UnaryOperator::Imag: DISPATCH(UnaryImag, UnaryOperator);
> case UnaryOperator::Extension: DISPATCH(UnaryExtension, UnaryOperator);
> - case UnaryOperator::OffsetOf: DISPATCH(UnaryOffsetOf, UnaryOperator);
> }
> }
>
> @@ -163,7 +162,7 @@
> UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus)
> UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot)
> UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag)
> - UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(OffsetOf)
> + UNARYOP_FALLBACK(Extension)
> #undef UNARYOP_FALLBACK
>
> // Base case, ignore it. :)
>
> Modified: cfe/trunk/include/clang/Frontend/StmtXML.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/StmtXML.def?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/StmtXML.def (original)
> +++ cfe/trunk/include/clang/Frontend/StmtXML.def Thu Aug 12 20:36:11 2010
> @@ -254,7 +254,6 @@
> ENUM_XML(UnaryOperator::Real, "__real")
> ENUM_XML(UnaryOperator::Imag, "__imag")
> ENUM_XML(UnaryOperator::Extension, "__extension__")
> - ENUM_XML(UnaryOperator::OffsetOf, "__builtin_offsetof")
> END_ENUM_XML
> SUB_NODE_XML(Expr) // expr
> END_NODE_XML
>
> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Thu Aug 12 20:36:11 2010
> @@ -447,7 +447,6 @@
> case Real: return "__real";
> case Imag: return "__imag";
> case Extension: return "__extension__";
> - case OffsetOf: return "__builtin_offsetof";
> }
> }
>
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Aug 12 20:36:11 2010
> @@ -1573,19 +1573,6 @@
> }
>
> bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
> - // Special case unary operators that do not need their subexpression
> - // evaluated. offsetof/sizeof/alignof are all special.
> - if (E->isOffsetOfOp()) {
> - // The AST for offsetof is defined in such a way that we can just
> - // directly Evaluate it as an l-value.
> - LValue LV;
> - if (!EvaluateLValue(E->getSubExpr(), LV, Info))
> - return false;
> - if (LV.getLValueBase())
> - return false;
> - return Success(LV.getLValueOffset().getQuantity(), E);
> - }
> -
> if (E->getOpcode() == UnaryOperator::LNot) {
> // LNot's operand isn't necessarily an integer, so we handle it specially.
> bool bres;
> @@ -2495,8 +2482,6 @@
> case UnaryOperator::Real:
> case UnaryOperator::Imag:
> return CheckICE(Exp->getSubExpr(), Ctx);
> - case UnaryOperator::OffsetOf:
> - break;
> }
>
> // OffsetOf falls through here.
>
> Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Aug 12 20:36:11 2010
> @@ -77,9 +77,6 @@
> return OS;
> }
>
> - bool PrintOffsetOfDesignator(Expr *E);
> - void VisitUnaryOffsetOf(UnaryOperator *Node);
> -
> void Visit(Stmt* S) {
> if (Helper && Helper->handledStmt(S,OS))
> return;
> @@ -679,31 +676,6 @@
> OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
> }
>
> -bool StmtPrinter::PrintOffsetOfDesignator(Expr *E) {
> - if (isa<UnaryOperator>(E)) {
> - // Base case, print the type and comma.
> - OS << E->getType().getAsString(Policy) << ", ";
> - return true;
> - } else if (ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
> - PrintOffsetOfDesignator(ASE->getLHS());
> - OS << "[";
> - PrintExpr(ASE->getRHS());
> - OS << "]";
> - return false;
> - } else {
> - MemberExpr *ME = cast<MemberExpr>(E);
> - bool IsFirst = PrintOffsetOfDesignator(ME->getBase());
> - OS << (IsFirst ? "" : ".") << ME->getMemberDecl();
> - return false;
> - }
> -}
> -
> -void StmtPrinter::VisitUnaryOffsetOf(UnaryOperator *Node) {
> - OS << "__builtin_offsetof(";
> - PrintOffsetOfDesignator(Node->getSubExpr());
> - OS << ")";
> -}
> -
> void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
> OS << "__builtin_offsetof(";
> OS << Node->getTypeSourceInfo()->getType().getAsString(Policy) << ", ";
>
> Modified: cfe/trunk/lib/Checker/CheckerHelpers.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CheckerHelpers.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Checker/CheckerHelpers.cpp (original)
> +++ cfe/trunk/lib/Checker/CheckerHelpers.cpp Thu Aug 12 20:36:11 2010
> @@ -67,11 +67,6 @@
>
> // Recursively find any substatements containing __builtin_offsetof
> bool clang::containsBuiltinOffsetOf(const Stmt *S) {
> - const UnaryOperator *UO = dyn_cast<UnaryOperator>(S);
> -
> - if (UO && UO->getOpcode() == UnaryOperator::OffsetOf)
> - return true;
> -
> if (isa<OffsetOfExpr>(S))
> return true;
>
>
> Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
> +++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Aug 12 20:36:11 2010
> @@ -2910,22 +2910,6 @@
>
> return;
> }
> -
> - case UnaryOperator::OffsetOf: {
> - Expr::EvalResult Res;
> - if (U->Evaluate(Res, getContext()) && Res.Val.isInt()) {
> - const APSInt &IV = Res.Val.getInt();
> - assert(IV.getBitWidth() == getContext().getTypeSize(U->getType()));
> - assert(U->getType()->isIntegerType());
> - assert(IV.isSigned() == U->getType()->isSignedIntegerType());
> - SVal X = ValMgr.makeIntVal(IV);
> - MakeNode(Dst, U, Pred, GetState(Pred)->BindExpr(U, X));
> - return;
> - }
> - // FIXME: Handle the case where __builtin_offsetof is not a constant.
> - Dst.Add(Pred);
> - return;
> - }
>
> case UnaryOperator::Plus: assert(!asLValue); // FALL-THROUGH.
> case UnaryOperator::Extension: {
>
> Modified: cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp (original)
> +++ cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp Thu Aug 12 20:36:11 2010
> @@ -540,10 +540,9 @@
> }
> case Stmt::UnaryOperatorClass: {
> const UnaryOperator *U = cast<const UnaryOperator>(Ex);
> - // Handle two trivial cases first
> + // Handle trivial case first
> switch (U->getOpcode()) {
> case UnaryOperator::Extension:
> - case UnaryOperator::OffsetOf:
> return false;
> default:
> return CanVary(U->getSubExpr(), Ctx);
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Aug 12 20:36:11 2010
> @@ -254,7 +254,6 @@
> Value *VisitUnaryExtension(const UnaryOperator *E) {
> return Visit(E->getSubExpr());
> }
> - Value *VisitUnaryOffsetOf(const UnaryOperator *E);
>
> // C++
> Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
> @@ -1412,12 +1411,6 @@
> return llvm::Constant::getNullValue(ConvertType(E->getType()));
> }
>
> -Value *ScalarExprEmitter::VisitUnaryOffsetOf(const UnaryOperator *E) {
> - Value* ResultAsPtr = EmitLValue(E->getSubExpr()).getAddress();
> - const llvm::Type* ResultType = ConvertType(E->getType());
> - return Builder.CreatePtrToInt(ResultAsPtr, ResultType, "offsetof");
> -}
> -
> //===----------------------------------------------------------------------===//
> // Binary Operators
> //===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/lib/Frontend/StmtXML.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/StmtXML.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/StmtXML.cpp (original)
> +++ cfe/trunk/lib/Frontend/StmtXML.cpp Thu Aug 12 20:36:11 2010
> @@ -261,7 +261,6 @@
> case UnaryOperator::Real: return "__real";
> case UnaryOperator::Imag: return "__imag";
> case UnaryOperator::Extension: return "__extension__";
> - case UnaryOperator::OffsetOf: return "__builtin_offsetof";
> }
> }
>
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Aug 12 20:36:11 2010
> @@ -2352,7 +2352,6 @@
> // Operations with opaque sources are black-listed.
> case UnaryOperator::Deref:
> case UnaryOperator::AddrOf: // should be impossible
> - case UnaryOperator::OffsetOf:
> return IntRange::forType(C, E->getType());
>
> default:
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=110996&r1=110995&r2=110996&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Aug 12 20:36:11 2010
> @@ -6689,10 +6689,6 @@
> Expr *Input = (Expr *)InputArg.get();
> QualType resultType;
> switch (Opc) {
> - case UnaryOperator::OffsetOf:
> - assert(false && "Invalid unary operator");
> - break;
> -
> case UnaryOperator::PreInc:
> case UnaryOperator::PreDec:
> case UnaryOperator::PostInc:
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list