diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Expr.cpp | 1 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 15 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 28 | ||||
-rw-r--r-- | lib/Checker/CheckerHelpers.cpp | 5 | ||||
-rw-r--r-- | lib/Checker/GRExprEngine.cpp | 16 | ||||
-rw-r--r-- | lib/Checker/IdempotentOperationChecker.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 7 | ||||
-rw-r--r-- | lib/Frontend/StmtXML.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 |
10 files changed, 1 insertions, 80 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index c4666facd2..7b1828cfee 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -447,7 +447,6 @@ const char *UnaryOperator::getOpcodeStr(Opcode Op) { case Real: return "__real"; case Imag: return "__imag"; case Extension: return "__extension__"; - case OffsetOf: return "__builtin_offsetof"; } } diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 30234f5a78..3ef2a62e2d 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1573,19 +1573,6 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *E) { } 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 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case UnaryOperator::Real: case UnaryOperator::Imag: return CheckICE(Exp->getSubExpr(), Ctx); - case UnaryOperator::OffsetOf: - break; } // OffsetOf falls through here. diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 6ff4711ea0..be7fdb5656 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -77,9 +77,6 @@ namespace { 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 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) { 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) << ", "; diff --git a/lib/Checker/CheckerHelpers.cpp b/lib/Checker/CheckerHelpers.cpp index e3cb36b00c..ece69435ca 100644 --- a/lib/Checker/CheckerHelpers.cpp +++ b/lib/Checker/CheckerHelpers.cpp @@ -67,11 +67,6 @@ bool clang::containsStaticLocal(const Stmt *S) { // 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; diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 1f6c266e3a..98d2bf1b08 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -2910,22 +2910,6 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, 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: { diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp index 9866c6096e..74f4a62ccc 100644 --- a/lib/Checker/IdempotentOperationChecker.cpp +++ b/lib/Checker/IdempotentOperationChecker.cpp @@ -540,10 +540,9 @@ bool IdempotentOperationChecker::CanVary(const Expr *Ex, ASTContext &Ctx) { } 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); diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 89947df940..6898956eeb 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -254,7 +254,6 @@ public: Value *VisitUnaryExtension(const UnaryOperator *E) { return Visit(E->getSubExpr()); } - Value *VisitUnaryOffsetOf(const UnaryOperator *E); // C++ Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) { @@ -1412,12 +1411,6 @@ Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) { 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 //===----------------------------------------------------------------------===// diff --git a/lib/Frontend/StmtXML.cpp b/lib/Frontend/StmtXML.cpp index 21dc0ba0a1..c810bca6c6 100644 --- a/lib/Frontend/StmtXML.cpp +++ b/lib/Frontend/StmtXML.cpp @@ -261,7 +261,6 @@ const char *StmtXML::getOpcodeStr(UnaryOperator::Opcode Op) { case UnaryOperator::Real: return "__real"; case UnaryOperator::Imag: return "__imag"; case UnaryOperator::Extension: return "__extension__"; - case UnaryOperator::OffsetOf: return "__builtin_offsetof"; } } diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 14c0d87ffb..f6d37d432d 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2352,7 +2352,6 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { // 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: diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f87d39fd8f..f7b450d2c9 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6689,10 +6689,6 @@ Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, 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: |