aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2010-08-13 01:36:11 +0000
committerEli Friedman <eli.friedman@gmail.com>2010-08-13 01:36:11 +0000
commitde7e66256b1bdfcf6526994825a8c8fced52a31c (patch)
tree4bad43ec14bf772db58bd501a5ca473a2a8c2f51
parent1e3a97c98a9ad099410fa5172ce8783baf0da0fd (diff)
Zap unused UnaryOperator::OffsetOf.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110996 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h11
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h2
-rw-r--r--include/clang/AST/StmtVisitor.h3
-rw-r--r--include/clang/Frontend/StmtXML.def1
-rw-r--r--lib/AST/Expr.cpp1
-rw-r--r--lib/AST/ExprConstant.cpp15
-rw-r--r--lib/AST/StmtPrinter.cpp28
-rw-r--r--lib/Checker/CheckerHelpers.cpp5
-rw-r--r--lib/Checker/GRExprEngine.cpp16
-rw-r--r--lib/Checker/IdempotentOperationChecker.cpp3
-rw-r--r--lib/CodeGen/CGExprScalar.cpp7
-rw-r--r--lib/Frontend/StmtXML.cpp1
-rw-r--r--lib/Sema/SemaChecking.cpp1
-rw-r--r--lib/Sema/SemaExpr.cpp4
14 files changed, 5 insertions, 93 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 1c6ae84900..9db92111e6 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1028,10 +1028,6 @@ public:
/// 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 @@ public:
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 @@ public:
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 @@ public:
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); }
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 2c1a70a99d..ee0bca518f 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -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() \
diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h
index 8078451fa3..2c8d3e4654 100644
--- a/include/clang/AST/StmtVisitor.h
+++ b/include/clang/AST/StmtVisitor.h
@@ -98,7 +98,6 @@ public:
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 @@ public:
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. :)
diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def
index f63761a908..9ca676c2c8 100644
--- a/include/clang/Frontend/StmtXML.def
+++ b/include/clang/Frontend/StmtXML.def
@@ -254,7 +254,6 @@ NODE_XML(UnaryOperator, "UnaryOperator") // op(expr) or (expr)op
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
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: