diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2020-04-16 11:45:02 +0200 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2020-04-16 11:46:35 +0200 |
commit | 3ee1ec0b9dd6ee2350f39ae8a418bf3ce28d06cf (patch) | |
tree | 2658c35a917e3e6401253d4affce167fd8aba70c /clang/lib | |
parent | c8d6fa5134ae66f3fb8e0b8caac5de4f737c8bef (diff) | |
download | llvm-3ee1ec0b9dd6ee2350f39ae8a418bf3ce28d06cf.zip llvm-3ee1ec0b9dd6ee2350f39ae8a418bf3ce28d06cf.tar.gz llvm-3ee1ec0b9dd6ee2350f39ae8a418bf3ce28d06cf.tar.bz2 |
LangOptions cannot depend on ASTContext, make it not use ASTContext directly
Fixes a layering violation introduced in 2ba4e3a4598b165245c581c506a813cd4a7dce33.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 10 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 40 | ||||
-rw-r--r-- | clang/lib/Basic/LangOptions.cpp | 9 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 4 |
6 files changed, 52 insertions, 17 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index e303701..5cdf1de 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -6703,10 +6703,10 @@ ExpectedStmt ASTNodeImporter::VisitBinaryOperator(BinaryOperator *E) { 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) { @@ -6817,7 +6817,7 @@ ASTNodeImporter::VisitCompoundAssignOperator(CompoundAssignOperator *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)); } diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index a5c634e..bc6fadc 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -4347,6 +4347,42 @@ ParenListExpr *ParenListExpr::CreateEmpty(const ASTContext &Ctx, 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); @@ -4360,7 +4396,7 @@ BinaryOperator *BinaryOperator::Create(const ASTContext &C, Expr *lhs, 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)); @@ -4380,7 +4416,7 @@ CompoundAssignOperator *CompoundAssignOperator::Create( 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)); diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp index 6e12bda..a74efdc 100644 --- a/clang/lib/Basic/LangOptions.cpp +++ b/clang/lib/Basic/LangOptions.cpp @@ -11,7 +11,6 @@ //===----------------------------------------------------------------------===// #include "clang/Basic/LangOptions.h" -#include "clang/AST/ASTContext.h" using namespace clang; @@ -49,11 +48,11 @@ VersionTuple LangOptions::getOpenCLVersionTuple() const { 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(); } diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 75be18e..97e9694 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2929,7 +2929,7 @@ BinOpInfo ScalarExprEmitter::EmitBinOps(const BinaryOperator *E) { 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; } @@ -2949,7 +2949,7 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue( 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); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1fe1515..0761f02 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -6994,7 +6994,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { return BinaryOperator::Create(Context, BO->getLHS(), RHS.get(), BO_Comma, BO->getType(), BO->getValueKind(), BO->getObjectKind(), BO->getOperatorLoc(), - BO->getFPFeatures(getASTContext())); + BO->getFPFeatures(getLangOpts())); } } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index de7892f..e79969e 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -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().getASTContext()); + getSema().FPFeatures = E->getFPFeatures(getSema().getLangOpts()); return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get()); @@ -10322,7 +10322,7 @@ ExprResult 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); } |