/// allocated for the trailing objects when needed.
BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc,
QualType ResTy, ExprValueKind VK, ExprObjectKind OK,
- SourceLocation opLoc, FPOptions FPFeatures)
- : Expr(BinaryOperatorClass, ResTy, VK, OK) {
- BinaryOperatorBits.Opc = opc;
- assert(!isCompoundAssignmentOp() &&
- "Use CompoundAssignOperator for compound assignments");
- BinaryOperatorBits.OpLoc = opLoc;
- SubExprs[LHS] = lhs;
- SubExprs[RHS] = rhs;
- BinaryOperatorBits.HasFPFeatures = FPFeatures.requiresTrailingStorage(Ctx);
- if (BinaryOperatorBits.HasFPFeatures)
- *getTrailingFPFeatures() = FPFeatures;
- setDependence(computeDependence(this));
- }
+ SourceLocation opLoc, FPOptions FPFeatures);
/// Construct an empty binary operator.
explicit BinaryOperator(EmptyShell Empty) : Expr(BinaryOperatorClass, Empty) {
// Get the FP features status of this operator. Only meaningful for
// operations on floating point types.
- FPOptions getFPFeatures(const ASTContext &C) const {
+ FPOptions getFPFeatures(const LangOptions &LO) const {
if (BinaryOperatorBits.HasFPFeatures)
return getStoredFPFeatures();
- return FPOptions::defaultWithoutTrailingStorage(C);
+ return FPOptions::defaultWithoutTrailingStorage(LO);
}
// Get the FP contractability status of this operator. Only meaningful for
// operations on floating point types.
- bool isFPContractableWithinStatement(const ASTContext &C) const {
- return getFPFeatures(C).allowFPContractWithinStatement();
+ bool isFPContractableWithinStatement(const LangOptions &LO) const {
+ return getFPFeatures(LO).allowFPContractWithinStatement();
}
// Get the FENV_ACCESS status of this operator. Only meaningful for
// operations on floating point types.
- bool isFEnvAccessOn(const ASTContext &C) const {
- return getFPFeatures(C).allowFEnvAccess();
+ bool isFEnvAccessOn(const LangOptions &LO) const {
+ return getFPFeatures(LO).allowFEnvAccess();
}
protected:
BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc,
QualType ResTy, ExprValueKind VK, ExprObjectKind OK,
- SourceLocation opLoc, FPOptions FPFeatures, bool dead2)
- : Expr(CompoundAssignOperatorClass, ResTy, VK, OK) {
- BinaryOperatorBits.Opc = opc;
- assert(isCompoundAssignmentOp() &&
- "Use CompoundAssignOperator for compound assignments");
- BinaryOperatorBits.OpLoc = opLoc;
- SubExprs[LHS] = lhs;
- SubExprs[RHS] = rhs;
- BinaryOperatorBits.HasFPFeatures = FPFeatures.requiresTrailingStorage(Ctx);
- if (BinaryOperatorBits.HasFPFeatures)
- *getTrailingFPFeatures() = FPFeatures;
- setDependence(computeDependence(this));
- }
+ SourceLocation opLoc, FPOptions FPFeatures, bool dead2);
/// Construct an empty BinaryOperator, SC is CompoundAssignOperator.
BinaryOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) {
namespace clang {
-class ASTContext;
-
/// Bitfields of LangOptions, split out from LangOptions in order to ensure that
/// this large collection of bitfields is a trivial class type.
class LangOptionsBase {
/// Return the default value of FPOptions that's used when trailing
/// storage isn't required.
- static FPOptions defaultWithoutTrailingStorage(const ASTContext &C);
+ static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO);
/// Does this FPOptions require trailing storage when stored in various
/// AST nodes, or can it be recreated using `defaultWithoutTrailingStorage`?
- bool requiresTrailingStorage(const ASTContext &C);
+ bool requiresTrailingStorage(const LangOptions &LO);
bool allowFPContractWithinStatement() const {
return fp_contract == LangOptions::FPC_On;
if (Err)
return std::move(Err);
- return BinaryOperator::Create(Importer.getToContext(), ToLHS, ToRHS,
- E->getOpcode(), ToType, E->getValueKind(),
- E->getObjectKind(), ToOperatorLoc,
- E->getFPFeatures(Importer.getFromContext()));
+ return BinaryOperator::Create(
+ Importer.getToContext(), ToLHS, ToRHS, E->getOpcode(), ToType,
+ E->getValueKind(), E->getObjectKind(), ToOperatorLoc,
+ E->getFPFeatures(Importer.getFromContext().getLangOpts()));
}
ExpectedStmt ASTNodeImporter::VisitConditionalOperator(ConditionalOperator *E) {
return CompoundAssignOperator::Create(
Importer.getToContext(), ToLHS, ToRHS, E->getOpcode(), ToType,
E->getValueKind(), E->getObjectKind(), ToOperatorLoc,
- E->getFPFeatures(Importer.getFromContext()),
+ E->getFPFeatures(Importer.getFromContext().getLangOpts()),
importChecked(Err, ToComputationLHSType),
importChecked(Err, ToComputationResultType));
}
return new (Mem) ParenListExpr(EmptyShell(), NumExprs);
}
+BinaryOperator::BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs,
+ Opcode opc, QualType ResTy, ExprValueKind VK,
+ ExprObjectKind OK, SourceLocation opLoc,
+ FPOptions FPFeatures)
+ : Expr(BinaryOperatorClass, ResTy, VK, OK) {
+ BinaryOperatorBits.Opc = opc;
+ assert(!isCompoundAssignmentOp() &&
+ "Use CompoundAssignOperator for compound assignments");
+ BinaryOperatorBits.OpLoc = opLoc;
+ SubExprs[LHS] = lhs;
+ SubExprs[RHS] = rhs;
+ BinaryOperatorBits.HasFPFeatures =
+ FPFeatures.requiresTrailingStorage(Ctx.getLangOpts());
+ if (BinaryOperatorBits.HasFPFeatures)
+ *getTrailingFPFeatures() = FPFeatures;
+ setDependence(computeDependence(this));
+}
+
+BinaryOperator::BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs,
+ Opcode opc, QualType ResTy, ExprValueKind VK,
+ ExprObjectKind OK, SourceLocation opLoc,
+ FPOptions FPFeatures, bool dead2)
+ : Expr(CompoundAssignOperatorClass, ResTy, VK, OK) {
+ BinaryOperatorBits.Opc = opc;
+ assert(isCompoundAssignmentOp() &&
+ "Use CompoundAssignOperator for compound assignments");
+ BinaryOperatorBits.OpLoc = opLoc;
+ SubExprs[LHS] = lhs;
+ SubExprs[RHS] = rhs;
+ BinaryOperatorBits.HasFPFeatures =
+ FPFeatures.requiresTrailingStorage(Ctx.getLangOpts());
+ if (BinaryOperatorBits.HasFPFeatures)
+ *getTrailingFPFeatures() = FPFeatures;
+ setDependence(computeDependence(this));
+}
+
BinaryOperator *BinaryOperator::CreateEmpty(const ASTContext &C,
bool HasFPFeatures) {
unsigned Extra = sizeOfTrailingObjects(HasFPFeatures);
ExprValueKind VK, ExprObjectKind OK,
SourceLocation opLoc,
FPOptions FPFeatures) {
- bool HasFPFeatures = FPFeatures.requiresTrailingStorage(C);
+ bool HasFPFeatures = FPFeatures.requiresTrailingStorage(C.getLangOpts());
unsigned Extra = sizeOfTrailingObjects(HasFPFeatures);
void *Mem =
C.Allocate(sizeof(BinaryOperator) + Extra, alignof(BinaryOperator));
const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc,
FPOptions FPFeatures, QualType CompLHSType, QualType CompResultType) {
- bool HasFPFeatures = FPFeatures.requiresTrailingStorage(C);
+ bool HasFPFeatures = FPFeatures.requiresTrailingStorage(C.getLangOpts());
unsigned Extra = sizeOfTrailingObjects(HasFPFeatures);
void *Mem = C.Allocate(sizeof(CompoundAssignOperator) + Extra,
alignof(CompoundAssignOperator));
//===----------------------------------------------------------------------===//
#include "clang/Basic/LangOptions.h"
-#include "clang/AST/ASTContext.h"
using namespace clang;
return VersionTuple(Ver / 100, (Ver % 100) / 10);
}
-FPOptions FPOptions::defaultWithoutTrailingStorage(const ASTContext &C) {
- FPOptions result(C.getLangOpts());
+FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
+ FPOptions result(LO);
return result;
}
-bool FPOptions::requiresTrailingStorage(const ASTContext &C) {
- return getAsOpaqueInt() != defaultWithoutTrailingStorage(C).getAsOpaqueInt();
+bool FPOptions::requiresTrailingStorage(const LangOptions &LO) {
+ return getAsOpaqueInt() != defaultWithoutTrailingStorage(LO).getAsOpaqueInt();
}
Result.RHS = Visit(E->getRHS());
Result.Ty = E->getType();
Result.Opcode = E->getOpcode();
- Result.FPFeatures = E->getFPFeatures(CGF.getContext());
+ Result.FPFeatures = E->getFPFeatures(CGF.getLangOpts());
Result.E = E;
return Result;
}
OpInfo.RHS = Visit(E->getRHS());
OpInfo.Ty = E->getComputationResultType();
OpInfo.Opcode = E->getOpcode();
- OpInfo.FPFeatures = E->getFPFeatures(CGF.getContext());
+ OpInfo.FPFeatures = E->getFPFeatures(CGF.getLangOpts());
OpInfo.E = E;
// Load/convert the LHS.
LValue LHSLV = EmitCheckedLValue(E->getLHS(), CodeGenFunction::TCK_Store);
return BinaryOperator::Create(Context, BO->getLHS(), RHS.get(), BO_Comma,
BO->getType(), BO->getValueKind(),
BO->getObjectKind(), BO->getOperatorLoc(),
- BO->getFPFeatures(getASTContext()));
+ BO->getFPFeatures(getLangOpts()));
}
}
return getDerived().RebuildBinaryOperator(
E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
- getSema().FPFeatures = E->getFPFeatures(getSema().getASTContext());
+ getSema().FPFeatures = E->getFPFeatures(getSema().getLangOpts());
return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
LHS.get(), RHS.get());
TreeTransform<Derived>::TransformCompoundAssignOperator(
CompoundAssignOperator *E) {
Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
- getSema().FPFeatures = E->getFPFeatures(getSema().getASTContext());
+ getSema().FPFeatures = E->getFPFeatures(getSema().getLangOpts());
return getDerived().TransformBinaryOperator(E);
}