Skip to content

Commit

Permalink
[NFC] Rename Sema.FPFeatures to CurFPFeatures and accessor to getCurF…
Browse files Browse the repository at this point in the history
…PFeatures
  • Loading branch information
Melanie Blower committed Apr 16, 2020
1 parent 5fedf7f commit 8812b0c
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class Sema final {
typedef OpaquePtr<QualType> TypeTy;

OpenCLOptions OpenCLFeatures;
FPOptions FPFeatures;
FPOptions CurFPFeatures;

const LangOptions &LangOpts;
Preprocessor &PP;
Expand Down Expand Up @@ -1354,8 +1354,8 @@ class Sema final {
/// statements.
class FPFeaturesStateRAII {
public:
FPFeaturesStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.FPFeatures) {}
~FPFeaturesStateRAII() { S.FPFeatures = OldFPFeaturesState; }
FPFeaturesStateRAII(Sema &S) : S(S), OldFPFeaturesState(S.CurFPFeatures) {}
~FPFeaturesStateRAII() { S.CurFPFeatures = OldFPFeaturesState; }

private:
Sema& S;
Expand All @@ -1378,7 +1378,7 @@ class Sema final {

const LangOptions &getLangOpts() const { return LangOpts; }
OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
FPOptions &getFPOptions() { return FPFeatures; }
FPOptions &getCurFPFeatures() { return CurFPFeatures; }

DiagnosticsEngine &getDiagnostics() const { return Diags; }
SourceManager &getSourceManager() const { return SourceMgr; }
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const unsigned Sema::MaximumAlignment;
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
: ExternalSource(nullptr), isMultiplexExternalSource(false),
FPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
CurFPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()),
SourceMgr(PP.getSourceManager()), CollectStats(false),
CodeCompleter(CodeCompleter), CurContext(nullptr),
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/Sema/SemaAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,32 +929,32 @@ void Sema::ActOnPragmaVisibility(const IdentifierInfo* VisType,
void Sema::ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC) {
switch (FPC) {
case LangOptions::FPC_On:
FPFeatures.setAllowFPContractWithinStatement();
CurFPFeatures.setAllowFPContractWithinStatement();
break;
case LangOptions::FPC_Fast:
FPFeatures.setAllowFPContractAcrossStatement();
CurFPFeatures.setAllowFPContractAcrossStatement();
break;
case LangOptions::FPC_Off:
FPFeatures.setDisallowFPContract();
CurFPFeatures.setDisallowFPContract();
break;
}
}

void Sema::setRoundingMode(llvm::RoundingMode FPR) {
FPFeatures.setRoundingMode(FPR);
CurFPFeatures.setRoundingMode(FPR);
}

void Sema::setExceptionMode(LangOptions::FPExceptionModeKind FPE) {
FPFeatures.setExceptionMode(FPE);
CurFPFeatures.setExceptionMode(FPE);
}

void Sema::ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC) {
switch (FPC) {
case LangOptions::FEA_On:
FPFeatures.setAllowFEnvAccess();
CurFPFeatures.setAllowFEnvAccess();
break;
case LangOptions::FEA_Off:
FPFeatures.setDisallowFEnvAccess();
CurFPFeatures.setDisallowFEnvAccess();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13698,7 +13698,7 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T,
Expr *Comparison = BinaryOperator::Create(
S.Context, IterationVarRefRVal.build(S, Loc),
IntegerLiteral::Create(S.Context, Upper, SizeType, Loc), BO_NE,
S.Context.BoolTy, VK_RValue, OK_Ordinary, Loc, S.FPFeatures);
S.Context.BoolTy, VK_RValue, OK_Ordinary, Loc, S.CurFPFeatures);

// Create the pre-increment of the iteration variable. We can determine
// whether the increment will overflow based on the value of the array
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13693,9 +13693,9 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
if (CompResultTy.isNull()) {
if (ConvertHalfVec)
return convertHalfVecBinOp(*this, LHS, RHS, Opc, ResultTy, VK, OK, false,
OpLoc, FPFeatures);
OpLoc, CurFPFeatures);
return BinaryOperator::Create(Context, LHS.get(), RHS.get(), Opc, ResultTy,
VK, OK, OpLoc, FPFeatures);
VK, OK, OpLoc, CurFPFeatures);
}

// Handle compound assignments.
Expand All @@ -13707,10 +13707,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,

if (ConvertHalfVec)
return convertHalfVecBinOp(*this, LHS, RHS, Opc, ResultTy, VK, OK, true,
OpLoc, FPFeatures);
OpLoc, CurFPFeatures);

return CompoundAssignOperator::Create(Context, LHS.get(), RHS.get(), Opc,
ResultTy, VK, OK, OpLoc, FPFeatures,
ResultTy, VK, OK, OpLoc, CurFPFeatures,
CompLHSTy, CompResultTy);
}

Expand Down
24 changes: 12 additions & 12 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12975,7 +12975,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
/*ADL*/ true, IsOverloaded(Fns), Fns.begin(), Fns.end());
return CXXOperatorCallExpr::Create(Context, Op, Fn, ArgsArray,
Context.DependentTy, VK_RValue, OpLoc,
FPFeatures);
CurFPFeatures);
}

// Build an empty overload set.
Expand Down Expand Up @@ -13048,8 +13048,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,

Args[0] = Input;
CallExpr *TheCall = CXXOperatorCallExpr::Create(
Context, Op, FnExpr.get(), ArgsArray, ResultTy, VK, OpLoc, FPFeatures,
Best->IsADLCandidate);
Context, Op, FnExpr.get(), ArgsArray, ResultTy, VK, OpLoc,
CurFPFeatures, Best->IsADLCandidate);

if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl))
return ExprError();
Expand Down Expand Up @@ -13220,10 +13220,10 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
if (Opc <= BO_Assign || Opc > BO_OrAssign)
return BinaryOperator::Create(Context, Args[0], Args[1], Opc,
Context.DependentTy, VK_RValue,
OK_Ordinary, OpLoc, FPFeatures);
OK_Ordinary, OpLoc, CurFPFeatures);
return CompoundAssignOperator::Create(
Context, Args[0], Args[1], Opc, Context.DependentTy, VK_LValue,
OK_Ordinary, OpLoc, FPFeatures, Context.DependentTy,
OK_Ordinary, OpLoc, CurFPFeatures, Context.DependentTy,
Context.DependentTy);
}

Expand All @@ -13237,7 +13237,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
/*ADL*/ PerformADL, IsOverloaded(Fns), Fns.begin(), Fns.end());
return CXXOperatorCallExpr::Create(Context, Op, Fn, Args,
Context.DependentTy, VK_RValue, OpLoc,
FPFeatures);
CurFPFeatures);
}

// Always do placeholder-like conversions on the RHS.
Expand Down Expand Up @@ -13406,7 +13406,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,

CXXOperatorCallExpr *TheCall = CXXOperatorCallExpr::Create(
Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
FPFeatures, Best->IsADLCandidate);
CurFPFeatures, Best->IsADLCandidate);

if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall,
FnDecl))
Expand Down Expand Up @@ -13674,7 +13674,7 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
Expr *SyntacticForm = BinaryOperator::Create(
Context, OrigLHS, OrigRHS, BO_Cmp, Result.get()->getType(),
Result.get()->getValueKind(), Result.get()->getObjectKind(), OpLoc,
FPFeatures);
CurFPFeatures);
Expr *SemanticForm[] = {LHS, RHS, Result.get()};
return PseudoObjectExpr::Create(Context, SyntacticForm, SemanticForm, 2);
}
Expand Down Expand Up @@ -13705,7 +13705,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,

return CXXOperatorCallExpr::Create(Context, OO_Subscript, Fn, Args,
Context.DependentTy, VK_RValue, RLoc,
FPFeatures);
CurFPFeatures);
}

// Handle placeholders on both operands.
Expand Down Expand Up @@ -13780,7 +13780,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,

CXXOperatorCallExpr *TheCall =
CXXOperatorCallExpr::Create(Context, OO_Subscript, FnExpr.get(),
Args, ResultTy, VK, RLoc, FPFeatures);
Args, ResultTy, VK, RLoc, CurFPFeatures);
if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
return ExprError();

Expand Down Expand Up @@ -14403,7 +14403,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,

CXXOperatorCallExpr *TheCall =
CXXOperatorCallExpr::Create(Context, OO_Call, NewFn.get(), MethodArgs,
ResultTy, VK, RParenLoc, FPFeatures);
ResultTy, VK, RParenLoc, CurFPFeatures);

if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
return true;
Expand Down Expand Up @@ -14520,7 +14520,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
ExprValueKind VK = Expr::getValueKindForType(ResultTy);
ResultTy = ResultTy.getNonLValueExprType(Context);
CXXOperatorCallExpr *TheCall = CXXOperatorCallExpr::Create(
Context, OO_Arrow, FnExpr.get(), Base, ResultTy, VK, OpLoc, FPFeatures);
Context, OO_Arrow, FnExpr.get(), Base, ResultTy, VK, OpLoc, CurFPFeatures);

if (CheckCallReturnType(Method->getReturnType(), OpLoc, TheCall, Method))
return ExprError();
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Sema/SemaPseudoObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ PseudoOpBuilder::buildAssignmentOperation(Scope *Sc, SourceLocation opcLoc,
result = semanticRHS;
syntactic = BinaryOperator::Create(
S.Context, syntacticLHS, capturedRHS, opcode, capturedRHS->getType(),
capturedRHS->getValueKind(), OK_Ordinary, opcLoc, S.FPFeatures);
capturedRHS->getValueKind(), OK_Ordinary, opcLoc, S.CurFPFeatures);

} else {
ExprResult opLHS = buildGet();
Expand All @@ -464,7 +464,7 @@ PseudoOpBuilder::buildAssignmentOperation(Scope *Sc, SourceLocation opcLoc,

syntactic = CompoundAssignOperator::Create(
S.Context, syntacticLHS, capturedRHS, opcode, result.get()->getType(),
result.get()->getValueKind(), OK_Ordinary, opcLoc, S.FPFeatures,
result.get()->getValueKind(), OK_Ordinary, opcLoc, S.CurFPFeatures,
opLHS.get()->getType(), result.get()->getType());
}

Expand Down Expand Up @@ -1583,7 +1583,7 @@ ExprResult Sema::checkPseudoObjectAssignment(Scope *S, SourceLocation opcLoc,
if (LHS->isTypeDependent() || RHS->isTypeDependent())
return BinaryOperator::Create(Context, LHS, RHS, opcode,
Context.DependentTy, VK_RValue, OK_Ordinary,
opcLoc, FPFeatures);
opcLoc, CurFPFeatures);

// Filter out non-overload placeholder types in the RHS.
if (RHS->getType()->isNonOverloadPlaceholderType()) {
Expand Down Expand Up @@ -1646,7 +1646,7 @@ Expr *Sema::recreateSyntacticForm(PseudoObjectExpr *E) {
return CompoundAssignOperator::Create(
Context, lhs, rhs, cop->getOpcode(), cop->getType(),
cop->getValueKind(), cop->getObjectKind(), cop->getOperatorLoc(),
FPFeatures, cop->getComputationLHSType(),
CurFPFeatures, cop->getComputationLHSType(),
cop->getComputationResultType());

} else if (BinaryOperator *bop = dyn_cast<BinaryOperator>(syntax)) {
Expand All @@ -1655,7 +1655,7 @@ Expr *Sema::recreateSyntacticForm(PseudoObjectExpr *E) {
return BinaryOperator::Create(Context, lhs, rhs, bop->getOpcode(),
bop->getType(), bop->getValueKind(),
bop->getObjectKind(), bop->getOperatorLoc(),
FPFeatures);
CurFPFeatures);

} else if (isa<CallExpr>(syntax)) {
return syntax;
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -10267,7 +10267,7 @@ TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
return getDerived().RebuildBinaryOperator(
E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
getSema().FPFeatures = E->getFPFeatures(getSema().getLangOpts());
getSema().CurFPFeatures = E->getFPFeatures(getSema().getLangOpts());

return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
LHS.get(), RHS.get());
Expand Down Expand Up @@ -10322,7 +10322,7 @@ ExprResult
TreeTransform<Derived>::TransformCompoundAssignOperator(
CompoundAssignOperator *E) {
Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
getSema().FPFeatures = E->getFPFeatures(getSema().getLangOpts());
getSema().CurFPFeatures = E->getFPFeatures(getSema().getLangOpts());
return getDerived().TransformBinaryOperator(E);
}

Expand Down Expand Up @@ -10797,7 +10797,7 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
return SemaRef.MaybeBindToTemporary(E);

Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
getSema().FPFeatures = E->getFPFeatures();
getSema().CurFPFeatures = E->getFPFeatures();

return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
E->getOperatorLoc(),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7773,7 +7773,7 @@ void ASTReader::InitializeSema(Sema &S) {
// FIXME: What happens if these are changed by a module import?
if (!FPPragmaOptions.empty()) {
assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS");
SemaObj->FPFeatures = FPOptions(FPPragmaOptions[0]);
SemaObj->CurFPFeatures = FPOptions(FPPragmaOptions[0]);
}

SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4727,7 +4727,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
WriteReferencedSelectorsPool(SemaRef);
WriteLateParsedTemplates(SemaRef);
WriteIdentifierTable(PP, SemaRef.IdResolver, isModule);
WriteFPPragmaOptions(SemaRef.getFPOptions());
WriteFPPragmaOptions(SemaRef.getCurFPFeatures());
WriteOpenCLExtensions(SemaRef);
WriteOpenCLExtensionTypes(SemaRef);
WriteCUDAPragmas(SemaRef);
Expand Down

0 comments on commit 8812b0c

Please sign in to comment.