Zap unused UnaryOperator::OffsetOf.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110996 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 1c6ae84..9db9211 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -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); }
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 2c1a70a..ee0bca5 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 8078451..2c8d3e4 100644
--- a/include/clang/AST/StmtVisitor.h
+++ b/include/clang/AST/StmtVisitor.h
@@ -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. :)
diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def
index f63761a..9ca676c 100644
--- a/include/clang/Frontend/StmtXML.def
+++ b/include/clang/Frontend/StmtXML.def
@@ -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
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index c4666fa..7b1828c 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -447,7 +447,6 @@
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 30234f5..3ef2a62 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -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.
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 6ff4711..be7fdb5 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -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) << ", ";
diff --git a/lib/Checker/CheckerHelpers.cpp b/lib/Checker/CheckerHelpers.cpp
index e3cb36b..ece6943 100644
--- a/lib/Checker/CheckerHelpers.cpp
+++ b/lib/Checker/CheckerHelpers.cpp
@@ -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;
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 1f6c266..98d2bf1 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -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: {
diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp
index 9866c60..74f4a62 100644
--- a/lib/Checker/IdempotentOperationChecker.cpp
+++ b/lib/Checker/IdempotentOperationChecker.cpp
@@ -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);
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 89947df..6898956 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -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
//===----------------------------------------------------------------------===//
diff --git a/lib/Frontend/StmtXML.cpp b/lib/Frontend/StmtXML.cpp
index 21dc0ba..c810bca 100644
--- a/lib/Frontend/StmtXML.cpp
+++ b/lib/Frontend/StmtXML.cpp
@@ -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";
}
}
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 14c0d87..f6d37d4 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -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:
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f87d39f..f7b450d 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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: